huang
2025-11-26 792236ef78c2cdd3a989fb40a7f2e2487c4e17b6
mes-web/src/views/device/components/DeviceLogicConfig/WorkstationTransferConfig.vue
@@ -2,27 +2,27 @@
  <div class="workstation-transfer-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">定时查询最近扫码玻璃的时间间隔,默认10000ms(10秒)</span>
          <span class="form-tip">定时查询最近扫码玻璃的时间间隔,默认10秒</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.transferDelayMs"
            :min="5000"
            :max="120000"
            :step="1000"
            v-model="transferDelaySeconds"
            :min="5"
            :max="120"
            :step="1"
            style="width: 100%;"
          />
          <span class="form-tip">30秒内无新玻璃扫码则判定为最后一片,默认30000ms(30秒)</span>
          <span class="form-tip">30秒内无新玻璃扫码则判定为最后一片,默认30秒</span>
        </el-form-item>
      </el-col>
    </el-row>
@@ -41,15 +41,15 @@
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="监控间隔(ms)">
        <el-form-item label="监控间隔(秒)">
          <el-input-number
            v-model="config.monitorIntervalMs"
            :min="1000"
            :max="60000"
            :step="1000"
            v-model="monitorIntervalSeconds"
            :min="1"
            :max="60"
            :step="1"
            style="width: 100%;"
          />
          <span class="form-tip">批次处理监控间隔,默认使用scanIntervalMs</span>
          <span class="form-tip">批次处理监控间隔,默认使用扫码间隔</span>
        </el-form-item>
      </el-col>
    </el-row>
@@ -80,15 +80,6 @@
        </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发送的玻璃信息</span>
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>
@@ -111,9 +102,13 @@
  vehicleCapacity: 6000,
  monitorIntervalMs: 10000,
  workLine: null,
  inPosition: null,
  autoAck: true
  inPosition: null
})
// 时间字段(秒)- 用于前端显示和输入
const scanIntervalSeconds = ref(10)
const transferDelaySeconds = ref(30)
const monitorIntervalSeconds = ref(10)
// 监听props变化
watch(() => props.modelValue, (newVal) => {
@@ -124,15 +119,43 @@
      vehicleCapacity: newVal.vehicleCapacity ?? 6000,
      monitorIntervalMs: newVal.monitorIntervalMs ?? newVal.scanIntervalMs ?? 10000,
      workLine: newVal.workLine ?? null,
      inPosition: newVal.inPosition ?? null,
      autoAck: newVal.autoAck ?? true
      inPosition: newVal.inPosition ?? null
    }
    // 将毫秒转换为秒用于显示
    scanIntervalSeconds.value = (config.value.scanIntervalMs ?? 10000) / 1000
    transferDelaySeconds.value = (config.value.transferDelayMs ?? 30000) / 1000
    monitorIntervalSeconds.value = (config.value.monitorIntervalMs ?? 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)
  // 如果monitorIntervalMs未设置,则使用scanIntervalMs
  if (!props.modelValue?.monitorIntervalMs) {
    config.value.monitorIntervalMs = config.value.scanIntervalMs
    monitorIntervalSeconds.value = val
  }
  emit('update:modelValue', { ...config.value })
})
watch(transferDelaySeconds, (val) => {
  config.value.transferDelayMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
watch(monitorIntervalSeconds, (val) => {
  config.value.monitorIntervalMs = Math.round(val * 1000)
  emit('update:modelValue', { ...config.value })
})
// 监听config其他字段变化,同步到父组件
watch(() => [
  config.value.vehicleCapacity,
  config.value.workLine,
  config.value.inPosition
], () => {
  emit('update:modelValue', { ...config.value })
}, { deep: true })
</script>