| | |
| | | </div> |
| | | |
| | | <el-form :model="form" label-width="120px" :rules="rules" ref="formRef"> |
| | | <el-form-item label="玻璃ID列表" prop="glassIds" required> |
| | | <el-form-item label="玻璃ID列表" prop="glassIds"> |
| | | <el-input |
| | | v-model="glassIdsInput" |
| | | type="textarea" |
| | | :rows="4" |
| | | placeholder="请输入玻璃条码,支持多行或逗号分隔,每行一个或逗号分隔" |
| | | placeholder="可选:如果输入玻璃ID,将使用输入的ID进行测试(代替卧转立扫码);如果不输入,将从数据库读取最近扫码的玻璃ID进行测试" |
| | | show-word-limit |
| | | :maxlength="5000" |
| | | /> |
| | | <div class="form-tip"> |
| | | 已输入 {{ glassIds.length }} 个玻璃ID |
| | | <span v-if="glassIds.length > 0">已输入 {{ glassIds.length }} 个玻璃ID(测试模式:使用输入的ID)</span> |
| | | <span v-else>未输入玻璃ID(正常模式:将从数据库读取最近扫码的玻璃ID)</span> |
| | | </div> |
| | | </el-form-item> |
| | | |
| | | <el-divider content-position="left">执行配置</el-divider> |
| | | |
| | | <el-form-item label="单片间隔 (秒)"> |
| | | <el-input-number |
| | | v-model="form.glassIntervalSeconds" |
| | | :min="0" |
| | | :max="60" |
| | | :step="0.1" |
| | | :precision="1" |
| | | placeholder="每个玻璃ID之间的间隔时间" |
| | | /> |
| | | <div class="form-tip">多个玻璃ID时,每个玻璃ID传递之间的间隔时间(秒),用于模拟玻璃每片运动的时间。0表示一次性全部传递</div> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="执行间隔 (ms)"> |
| | | <el-input-number |
| | |
| | | }) |
| | | |
| | | const emit = defineEmits(['task-started']) |
| | | |
| | | //配置默认值 |
| | | const form = reactive({ |
| | | glassIntervalSeconds: 10, // 单片间隔,默认10秒 |
| | | executionInterval: 1000, |
| | | timeoutMinutes: 30, |
| | | retryCount: 3 |
| | |
| | | glassIds: [ |
| | | { |
| | | validator: (rule, value, callback) => { |
| | | // 如果输入了玻璃ID,则进行验证;如果没有输入,则允许(将从数据库读取) |
| | | if (glassIds.value.length === 0) { |
| | | callback(new Error('请至少输入一个玻璃ID')) |
| | | // 允许为空,将从数据库读取最近扫码的玻璃ID |
| | | callback() |
| | | } else if (glassIds.value.length > 100) { |
| | | callback(new Error('玻璃ID数量不能超过100个')) |
| | | } else { |
| | |
| | | .filter((item) => item.length > 0) |
| | | }) |
| | | |
| | | const normalizeType = (type) => (type || '').trim().toUpperCase() |
| | | |
| | | const fetchLoadDevice = async () => { |
| | | loadDeviceId.value = null |
| | | loadDeviceName.value = '' |
| | |
| | | : Array.isArray(rawList?.data) |
| | | ? rawList.data |
| | | : [] |
| | | const targetDevice = |
| | | deviceList.find((item) => (item.deviceType || '').toUpperCase() === 'LOAD_VEHICLE') || |
| | | deviceList[0] |
| | | const scannerDevice = deviceList.find((item) => { |
| | | const type = normalizeType(item.deviceType) |
| | | return type.includes('SCANNER') || type.includes('扫码') |
| | | }) |
| | | const loadVehicleDevice = deviceList.find((item) => { |
| | | const type = normalizeType(item.deviceType) |
| | | return type.includes('LOAD_VEHICLE') || type.includes('大车') |
| | | }) |
| | | const targetDevice = scannerDevice || loadVehicleDevice || deviceList[0] |
| | | if (targetDevice && targetDevice.id) { |
| | | loadDeviceId.value = targetDevice.id |
| | | loadDeviceName.value = targetDevice.deviceName || targetDevice.deviceCode || `ID: ${targetDevice.id}` |
| | |
| | | return |
| | | } |
| | | |
| | | if (glassIds.value.length === 0) { |
| | | ElMessage.warning('请至少输入一个玻璃ID') |
| | | return |
| | | } |
| | | |
| | | try { |
| | | loading.value = true |
| | | |
| | | // 构建任务参数 |
| | | // 如果输入了玻璃ID,使用输入的;如果没有输入,glassIds为空数组,后端会从数据库读取 |
| | | // 将秒转换为毫秒传给后端 |
| | | const glassIntervalMs = form.glassIntervalSeconds != null && form.glassIntervalSeconds !== undefined |
| | | ? Math.round(form.glassIntervalSeconds * 1000) |
| | | : 1000 |
| | | const parameters = { |
| | | glassIds: glassIds.value, |
| | | glassIds: glassIds.value.length > 0 ? glassIds.value : [], |
| | | glassIntervalMs: glassIntervalMs, |
| | | executionInterval: form.executionInterval || 1000 |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | if (!loadDeviceId.value) { |
| | | ElMessage.warning('未找到上大车设备,无法清空PLC') |
| | | ElMessage.warning('未找到对应设备,无法清空PLC') |
| | | return |
| | | } |
| | | try { |
| | | clearLoading.value = true |
| | | const response = await deviceInteractionApi.executeOperation({ |
| | | deviceId: loadDeviceId.value, |
| | | operation: 'clearGlass', |
| | | operation: 'clearPlc', |
| | | params: {} |
| | | }) |
| | | if (response?.code !== 200) { |