huang
2025-12-01 dad0263459b30dbfa75f06dff062a0c85183517b
mes-web/src/views/device/DeviceEditDialog.vue
@@ -354,7 +354,7 @@
const deviceTypesLoading = ref(false)
// 设备逻辑参数(根据设备类型动态显示)
const deviceLogicParams = reactive({})
const deviceLogicParams = ref({})
const S7_PLC_TYPES = ['S1200', 'S1500']
const MODBUS_PLC_TYPES = ['MODBUS']
@@ -683,15 +683,11 @@
}
// 加载设备逻辑参数
const loadDeviceLogicParams = (deviceLogic, deviceType) => {
  // 清空现有参数
  Object.keys(deviceLogicParams).forEach(key => {
    delete deviceLogicParams[key]
  })
  // 根据设备类型加载对应的参数
const loadDeviceLogicParams = (deviceLogic) => {
  if (deviceLogic && Object.keys(deviceLogic).length > 0) {
    Object.assign(deviceLogicParams, deviceLogic)
    deviceLogicParams.value = { ...deviceLogic }
  } else {
    deviceLogicParams.value = {}
  }
}
@@ -701,9 +697,7 @@
  deviceFormRef.value?.clearValidate()
  
  // 重置设备逻辑参数
  Object.keys(deviceLogicParams).forEach(key => {
    delete deviceLogicParams[key]
  })
  deviceLogicParams.value = {}
}
const addConfigParam = () => {
@@ -778,8 +772,10 @@
  }
    // 保存设备逻辑参数(直接使用deviceLogicParams,由各个配置组件管理)
    if (deviceLogicParams && Object.keys(deviceLogicParams).length > 0) {
      extraObj.deviceLogic = { ...deviceLogicParams }
    if (deviceLogicParams.value && Object.keys(deviceLogicParams.value).length > 0) {
      extraObj.deviceLogic = { ...deviceLogicParams.value }
    } else {
      delete extraObj.deviceLogic
    }
    // 构建 configJson:将 configParams 数组转换为 JSON 字符串