<template>
  <!-- 新增设备 -->
  <Dialog v-model="dialogFormVisible" title="编辑" width="600" class="equipment-form-dialog">
    <el-form :model="form" label-width="110" ref="ruleFormRef">
      <el-form-item label="库位号" prop="locationNo">
        <el-input v-model="form.locationNo" :disabled="true" />
      </el-form-item>
      <el-form-item label="所属线库号" prop="laneName">
        <el-input v-model="form.laneName" :disabled="true" />
      </el-form-item>
      <el-form-item label="所属区域号" prop="areaName">
        <el-input v-model="form.areaName" :disabled="true" />
      </el-form-item>
      <el-form-item label="状态" prop="locationUseStatus">
        <el-select v-model="form.locationUseStatus">
          <el-option label="空闲" :value="0" />
          <el-option label="占用" :value="1" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否禁用" prop="locationEnable">
        <el-select v-model="form.locationEnable">
          <el-option label="启用" :value="0" />
          <el-option label="禁用" :value="1" />
        </el-select>
      </el-form-item>
      <el-form-item label="物料信息" prop="skuInfo">
        <el-input v-model="form.skuInfo" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="submitForm"> 确定 </el-button>
      </div>
    </template>
  </Dialog>
</template>

<script setup>
import { reactive, ref } from 'vue'
import * as BinLocationAPi from '@/api/map/binLocation'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'

const message = useMessage() // 消息弹窗
const props = defineProps({
  positionMapId: {
    type: String,
    default: () => ''
  }
})

const ruleFormRef = ref()
const dialogFormVisible = ref(false) //列表的

//新增
const form = ref({
  id: '',
  locationNo: '', //线库名称
  laneName: '',
  areaName: '',
  locationUseStatus: '',
  locationEnable: '',
  skuInfo: ''
})

const open = (id) => {
  dialogFormVisible.value = true
  getDetail(id)
}

const getDetail = async (id) => {
  form.value = await BinLocationAPi.getHouseLocation(id)
}

const emit = defineEmits(['submitSuccess'])
const submitForm = async () => {
  await BinLocationAPi.updateHouseLocation(form.value)
  dialogFormVisible.value = false
  emit('submitSuccess')
  message.success('修改成功')
}

defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<style lang="scss">
.equipment-form-dialog {
  padding: 0px;

  .el-dialog__footer {
    padding: 0px 20px 20px 0;
    border-top: none !important;
  }
}
</style>
