feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段
This commit is contained in:
@@ -111,7 +111,7 @@ const list = ref([])
|
||||
const filter = reactive({ dockCode: '', name: '', dockType: '', status: '' })
|
||||
const dlg = reactive({
|
||||
show: false, isAdd: true, id: 0,
|
||||
dockCode: '', name: '', dockType: 'line', stationNo: 1, status: 'ENABLED'
|
||||
dockCode: '', name: '', dockType: 'line', status: 'ENABLED'
|
||||
})
|
||||
|
||||
const TYPE_LABEL = { line: '产线', store: '库房', other: '其他' }
|
||||
@@ -121,6 +121,45 @@ function tagType(t) { return t === 'line' ? 'success' : (t === 'store' ? 'warnin
|
||||
// (DOCK21 仅作后端映射;PLC 侧对应点位于 PLC 监控页同样只显示「库房接驳台」)
|
||||
function dockCodeLabel(code) { return String(code || '') === 'DOCK21' ? '库房接驳台' : code || '—' }
|
||||
|
||||
// 接驳台编码格式校验(运行期禁用正则:仅大写字母与数字,长度 2~16)。
|
||||
function isDockCodeAlnum(code) {
|
||||
const s = String(code || '').trim().toUpperCase()
|
||||
if (s.length < 2 || s.length > 16) return false
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
const c = s.charCodeAt(i)
|
||||
const isUpper = c >= 65 && c <= 90 // A-Z
|
||||
const isDigit = c >= 48 && c <= 57 // 0-9
|
||||
if (!isUpper && !isDigit) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
// 接驳台编码规范(产线类必须为 DOCK 开头 + 数字,如 DOCK05;对应硬件工位,由末位编号派生)。
|
||||
function isDockCodeStandard(code) {
|
||||
const s = String(code || '').trim().toUpperCase()
|
||||
if (s.length < 5 || s.slice(0, 4) !== 'DOCK') return false
|
||||
for (let i = 4; i < s.length; i++) {
|
||||
const c = s.charCodeAt(i)
|
||||
if (c < 48 || c > 57) return false // 末段必须全为数字
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 接驳台↔工位为硬件级对应关系:stationNo 由 dockCode 末位编号派生(DOCKnn → 工位 (nn+1)/2),不可人工编辑。
|
||||
// 运行期不使用正则,用 charCodeAt 取末位连续数字。
|
||||
function trailingNum(s) {
|
||||
s = s || ''
|
||||
let i = s.length
|
||||
while (i > 0 && s.charCodeAt(i - 1) >= 48 && s.charCodeAt(i - 1) <= 57) i--
|
||||
if (i === s.length) return 0
|
||||
return parseInt(s.slice(i), 10)
|
||||
}
|
||||
const lineStationNo = computed(() => {
|
||||
const n = trailingNum(dlg.dockCode)
|
||||
if (!n) return 0
|
||||
const s = Math.floor((n + 1) / 2)
|
||||
return s >= 1 && s <= 12 ? s : 0
|
||||
})
|
||||
|
||||
async function loadDocks() {
|
||||
const params = {}
|
||||
if (filter.dockCode.trim()) params.dockCode = filter.dockCode.trim()
|
||||
@@ -145,7 +184,6 @@ function openAdd() {
|
||||
dlg.dockCode = ''
|
||||
dlg.name = ''
|
||||
dlg.dockType = 'line'
|
||||
dlg.stationNo = 1
|
||||
dlg.status = 'ENABLED'
|
||||
dlg.show = true
|
||||
}
|
||||
@@ -155,26 +193,25 @@ function openEdit(row) {
|
||||
dlg.dockCode = row.dockCode
|
||||
dlg.name = row.name
|
||||
dlg.dockType = row.dockType
|
||||
dlg.stationNo = row.stationNo || 1
|
||||
dlg.status = row.status
|
||||
dlg.show = true
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!/^[A-Z0-9]{2,16}$/.test(String(dlg.dockCode || '').trim().toUpperCase())) {
|
||||
const code = String(dlg.dockCode || '').trim().toUpperCase()
|
||||
if (!isDockCodeAlnum(code)) {
|
||||
return ElMessage.warning('接驳台编码必填,仅支持大写字母与数字(2~16 位),如 DOCK05')
|
||||
}
|
||||
if (!String(dlg.name || '').trim()) return ElMessage.warning('接驳台名称必填')
|
||||
if (dlg.dockType === 'line' && !(dlg.stationNo >= 1 && dlg.stationNo <= 12)) {
|
||||
return ElMessage.warning('产线类接驳台必须绑定工位(工位号 1~12)')
|
||||
if (dlg.dockType === 'line' && !isDockCodeStandard(code)) {
|
||||
return ElMessage.warning('接驳台编码不规范(必须为 DOCK 开头+数字),请修正')
|
||||
}
|
||||
if (!String(dlg.name || '').trim()) return ElMessage.warning('接驳台名称必填')
|
||||
try {
|
||||
await request.post('/docks', {
|
||||
id: dlg.id,
|
||||
dockCode: String(dlg.dockCode).trim().toUpperCase(),
|
||||
dockCode: code,
|
||||
name: String(dlg.name).trim(),
|
||||
dockType: dlg.dockType,
|
||||
stationNo: dlg.dockType === 'line' ? dlg.stationNo : 0,
|
||||
status: dlg.status
|
||||
})
|
||||
ElMessage.success(dlg.isAdd ? '新增成功' : '已保存')
|
||||
@@ -436,8 +473,8 @@ onMounted(() => { refreshAll(); loadDocks() })
|
||||
</el-form-item>
|
||||
<el-form-item label="绑定工位" required>
|
||||
<template v-if="dlg.dockType === 'line'">
|
||||
<el-input-number v-model="dlg.stationNo" :min="1" :max="12" controls-position="right" style="width:140px" />
|
||||
<div style="color:#909399;font-size:12px;margin-top:4px">产线类接驳台必须绑定工位(1~12)</div>
|
||||
<span style="color:#303133">工位 {{ lineStationNo || '—' }}</span>
|
||||
<div style="color:#909399;font-size:12px;margin-top:4px">由接驳台编码派生(DOCKnn → 工位),硬件级对应关系,不可编辑</div>
|
||||
</template>
|
||||
<span v-else style="color:#909399">非产线类型不绑定工位</span>
|
||||
</el-form-item>
|
||||
|
||||
Reference in New Issue
Block a user