huang
2025-11-26 792236ef78c2cdd3a989fb40a7f2e2487c4e17b6
mes-web/src/views/device/components/DeviceLogicConfig/LoadVehicleConfig.vue
@@ -30,15 +30,16 @@
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="玻璃间隔(ms)">
        <el-form-item label="玻璃间隔(秒)">
          <el-input-number
            v-model="config.glassIntervalMs"
            :min="100"
            :max="10000"
            :step="100"
            v-model="glassIntervalSeconds"
            :min="0.1"
            :max="10"
            :step="0.1"
            :precision="1"
            style="width: 100%;"
          />
          <span class="form-tip">玻璃上料间隔时间(毫秒)</span>
          <span class="form-tip">玻璃上料间隔时间(秒)</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
@@ -75,7 +76,7 @@
            :min="1"
            :max="1000"
            :step="1"
            style="width: 48%;"
            style="width: 40%;"
            placeholder="最小"
          />
          <span style="margin: 0 2%;">~</span>
@@ -84,7 +85,7 @@
            :min="1"
            :max="1000"
            :step="1"
            style="width: 48%;"
            style="width: 40%;"
            placeholder="最大"
          />
          <span class="form-tip">运动距离范围(格子)</span>
@@ -94,42 +95,44 @@
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="空闲监控间隔(ms)">
        <el-form-item label="空闲监控间隔(秒)">
          <el-input-number
            v-model="config.idleMonitorIntervalMs"
            :min="500"
            :max="10000"
            :step="100"
            v-model="idleMonitorIntervalSeconds"
            :min="0.5"
            :max="10"
            :step="0.1"
            :precision="1"
            style="width: 100%;"
          />
          <span class="form-tip">空闲状态监控间隔,默认2000ms</span>
          <span class="form-tip">空闲状态监控间隔,默认2秒</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="任务监控间隔(ms)">
        <el-form-item label="任务监控间隔(秒)">
          <el-input-number
            v-model="config.taskMonitorIntervalMs"
            :min="500"
            :max="10000"
            :step="100"
            v-model="taskMonitorIntervalSeconds"
            :min="0.5"
            :max="10"
            :step="0.1"
            :precision="1"
            style="width: 100%;"
          />
          <span class="form-tip">任务执行监控间隔,默认1000ms</span>
          <span class="form-tip">任务执行监控间隔,默认1秒</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="MES确认超时(ms)">
        <el-form-item label="MES确认超时(秒)">
          <el-input-number
            v-model="config.mesConfirmTimeoutMs"
            :min="5000"
            :max="300000"
            :step="1000"
            v-model="mesConfirmTimeoutSeconds"
            :min="5"
            :max="300"
            :step="1"
            style="width: 100%;"
          />
          <span class="form-tip">等待MES确认的超时时间,默认30000ms</span>
          <span class="form-tip">等待MES确认的超时时间,默认30秒</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
@@ -191,27 +194,6 @@
      </div>
      <span class="form-tip">将MES编号(如900/901)映射为实际位置值(格子)</span>
    </el-form-item>
    <el-form-item label="出片任务格子范围">
      <el-input-number
        v-model="config.outboundSlotRanges[0]"
        :min="1"
        :max="1000"
        :step="1"
        style="width: 48%;"
        placeholder="最小格子编号"
      />
      <span style="margin: 0 2%;">~</span>
      <el-input-number
        v-model="config.outboundSlotRanges[1]"
        :min="1"
        :max="1000"
        :step="1"
        style="width: 48%;"
        placeholder="最大格子编号"
      />
      <span class="form-tip">出片任务的startSlot范围,例如[1, 101]表示格子1~101都是出片任务</span>
    </el-form-item>
  </div>
</template>
@@ -241,12 +223,17 @@
  mesConfirmTimeoutMs: 30000,
  autoFeed: true,
  maxRetryCount: 5,
  positionMapping: {},
  outboundSlotRanges: [1, 101]
  positionMapping: {}
})
// 位置映射的键数组
const mappingKeys = ref([])
// 时间字段(秒)- 用于前端显示和输入
const glassIntervalSeconds = ref(1.0)
const idleMonitorIntervalSeconds = ref(2.0)
const taskMonitorIntervalSeconds = ref(1.0)
const mesConfirmTimeoutSeconds = ref(30)
// 监听props变化
watch(() => props.modelValue, (newVal) => {
@@ -264,16 +251,51 @@
      mesConfirmTimeoutMs: newVal.mesConfirmTimeoutMs ?? 30000,
      autoFeed: newVal.autoFeed ?? true,
      maxRetryCount: newVal.maxRetryCount ?? 5,
      positionMapping: newVal.positionMapping || {},
      outboundSlotRanges: newVal.outboundSlotRanges || [1, 101]
      positionMapping: newVal.positionMapping || {}
    }
    // 将毫秒转换为秒用于显示
    glassIntervalSeconds.value = (config.value.glassIntervalMs ?? 1000) / 1000
    idleMonitorIntervalSeconds.value = (config.value.idleMonitorIntervalMs ?? 2000) / 1000
    taskMonitorIntervalSeconds.value = (config.value.taskMonitorIntervalMs ?? 1000) / 1000
    mesConfirmTimeoutSeconds.value = (config.value.mesConfirmTimeoutMs ?? 30000) / 1000
    mappingKeys.value = Object.keys(config.value.positionMapping)
  }
}, { immediate: true, deep: true })
// 监听config变化,同步到父组件
watch(config, (newVal) => {
  emit('update:modelValue', { ...newVal })
// 监听秒字段变化,转换为毫秒并更新config
watch(glassIntervalSeconds, (val) => {
  config.value.glassIntervalMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
watch(idleMonitorIntervalSeconds, (val) => {
  config.value.idleMonitorIntervalMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
watch(taskMonitorIntervalSeconds, (val) => {
  config.value.taskMonitorIntervalMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
watch(mesConfirmTimeoutSeconds, (val) => {
  config.value.mesConfirmTimeoutMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
// 监听config其他字段变化,同步到父组件
watch(() => [
  config.value.vehicleCapacity,
  config.value.vehicleSpeed,
  config.value.defaultGlassLength,
  config.value.homePosition,
  config.value.minRange,
  config.value.maxRange,
  config.value.autoFeed,
  config.value.maxRetryCount,
  config.value.positionMapping
], () => {
  emit('update:modelValue', { ...config.value })
}, { deep: true })
// 位置映射相关方法