huang
2025-11-25 19f59c243e8df97c8b9fd9dba4e758be8235d68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
  <div class="workstation-scanner-config">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="扫码间隔(ms)">
          <el-input-number
            v-model="config.scanIntervalMs"
            :min="1000"
            :max="60000"
            :step="1000"
            style="width: 100%;"
          />
          <span class="form-tip">定时扫描MES写区的时间间隔,默认10000ms(10秒)</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="产线编号">
          <el-input-number
            v-model="config.workLine"
            :min="1"
            :max="100"
            :step="1"
            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>
  </div>
</template>
 
<script setup>
import { ref, watch } from 'vue'
 
const props = defineProps({
  modelValue: {
    type: Object,
    default: () => ({})
  }
})
 
const emit = defineEmits(['update:modelValue'])
 
// 配置数据
const config = ref({
  scanIntervalMs: 10000,
  workLine: null,
  autoAck: true
})
 
// 监听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
    }
  }
}, { immediate: true, deep: true })
 
// 监听config变化,同步到父组件
watch(config, (newVal) => {
  emit('update:modelValue', { ...newVal })
}, { deep: true })
</script>
 
<style scoped>
.form-tip {
  margin-left: 10px;
  font-size: 12px;
  color: #909399;
}
</style>