huang
2025-11-26 792236ef78c2cdd3a989fb40a7f2e2487c4e17b6
mes-web/src/views/device/components/DeviceLogicConfig/WorkstationScannerConfig.vue
@@ -2,15 +2,15 @@
  <div class="workstation-scanner-config">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="扫码间隔(ms)">
        <el-form-item label="扫码间隔(秒)">
          <el-input-number
            v-model="config.scanIntervalMs"
            :min="1000"
            :max="60000"
            :step="1000"
            v-model="scanIntervalSeconds"
            :min="1"
            :max="60"
            :step="1"
            style="width: 100%;"
          />
          <span class="form-tip">定时扫描MES写区的时间间隔,默认10000ms(10秒)</span>
          <span class="form-tip">定时扫描MES写区的时间间隔,默认10秒</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
@@ -23,15 +23,6 @@
            style="width: 100%;"
          />
          <span class="form-tip">产线编号,用于过滤玻璃信息</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="自动确认">
          <el-switch v-model="config.autoAck" />
          <span class="form-tip">是否自动确认MES发送的玻璃信息(回写mesSend=0)</span>
        </el-form-item>
      </el-col>
    </el-row>
@@ -53,24 +44,35 @@
// 配置数据
const config = ref({
  scanIntervalMs: 10000,
  workLine: null,
  autoAck: true
  workLine: null
})
// 时间字段(秒)- 用于前端显示和输入
const scanIntervalSeconds = ref(10)
// 监听props变化
watch(() => props.modelValue, (newVal) => {
  if (newVal && Object.keys(newVal).length > 0) {
    config.value = {
      scanIntervalMs: newVal.scanIntervalMs ?? 10000,
      workLine: newVal.workLine ?? null,
      autoAck: newVal.autoAck ?? true
      workLine: newVal.workLine ?? null
    }
    // 将毫秒转换为秒用于显示
    scanIntervalSeconds.value = (config.value.scanIntervalMs ?? 10000) / 1000
  }
}, { immediate: true, deep: true })
// 监听config变化,同步到父组件
watch(config, (newVal) => {
  emit('update:modelValue', { ...newVal })
// 监听秒字段变化,转换为毫秒并更新config
watch(scanIntervalSeconds, (val) => {
  config.value.scanIntervalMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
// 监听config其他字段变化,同步到父组件
watch(() => [
  config.value.workLine
], () => {
  emit('update:modelValue', { ...config.value })
}, { deep: true })
</script>