From 78992e90cb531f42322b4b75e715a0f96c582128 Mon Sep 17 00:00:00 2001 From: zhongwenkai <3478244299@qq.com> Date: Tue, 30 Jun 2026 17:31:48 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E4=B8=8A=E4=B8=8B=E6=A8=A1-?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=AE=BE=E5=A4=87=E4=BB=A5=E5=8F=8A=E6=A8=A1?= =?UTF-8?q?=E5=85=B7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/moldRepair/userSelect.vue | 7 +- .../pages/moldoperate/deviceSelect.vue | 12 +- .../pages/moldoperate/dismount.vue | 30 ++-- .../pages/moldoperate/history.vue | 2 +- .../pages/moldoperate/index.vue | 151 ++++++++++++++---- 5 files changed, 154 insertions(+), 48 deletions(-) diff --git a/src/pages_function/pages/moldRepair/userSelect.vue b/src/pages_function/pages/moldRepair/userSelect.vue index 0a920ac..f58c6c0 100644 --- a/src/pages_function/pages/moldRepair/userSelect.vue +++ b/src/pages_function/pages/moldRepair/userSelect.vue @@ -67,7 +67,9 @@ const fromSource = ref('moldRepair') // moldRepair | sparepartInbound | sparepa let searchTimer = null const pageTitle = computed(() => { - if (field.value === 'operator') return '选择经办人' + if (field.value === 'operator') { + return fromSource.value === 'moldoperate' ? '选择操作人' : '选择经办人' + } return field.value === 'confirmBy' ? t('moldRepair.confirmBy') : t('moldRepair.acceptedBy') }) @@ -131,7 +133,8 @@ function handleConfirm() { materialOutbound: '_materialOutboundUserSelectResult', productInbound: '_productInboundUserSelectResult', productOutbound: '_productOutboundUserSelectResult', - productCheck: '_productCheckUserSelectResult' + productCheck: '_productCheckUserSelectResult', + moldoperate: '_moldoperateUserSelectResult' } const key = keyMap[fromSource.value] || '_moldRepairUserSelectResult' getApp().globalData[key] = { diff --git a/src/pages_function/pages/moldoperate/deviceSelect.vue b/src/pages_function/pages/moldoperate/deviceSelect.vue index 22e7673..499322d 100644 --- a/src/pages_function/pages/moldoperate/deviceSelect.vue +++ b/src/pages_function/pages/moldoperate/deviceSelect.vue @@ -17,8 +17,8 @@ v-for="device in filteredList" :key="device.id" class="device-card" - :class="{ active: selectedId === device.id }" - @click="selectedId = device.id" + :class="{ active: selectedId === device.id, disabled: fromType === 'up' && hasMoldOnDevice(device) }" + @click="handleDeviceClick(device)" > {{ textValue(device.deviceName) }} @@ -154,6 +154,14 @@ function getCurrentMold(device) { } // 判断设备是否有在机模具 +function handleDeviceClick(device) { + if (fromType.value === 'up' && hasMoldOnDevice(device)) { + uni.showToast({ title: '该设备已有在机模具,不能选择上模', icon: 'none' }) + return + } + selectedId.value = device.id +} + function hasMoldOnDevice(device) { if (!device) return false const deviceName = device.deviceName diff --git a/src/pages_function/pages/moldoperate/dismount.vue b/src/pages_function/pages/moldoperate/dismount.vue index 5a3761b..b00243b 100644 --- a/src/pages_function/pages/moldoperate/dismount.vue +++ b/src/pages_function/pages/moldoperate/dismount.vue @@ -68,7 +68,7 @@ {{ t('moldOperate.moldName') }} - {{ textValue(selectedMold.moldName) }} + {{ textValue(selectedMold.moldName) }} {{ t('moldOperate.moldCode') }} @@ -82,12 +82,6 @@ - - - - - {{ t('moldOperate.changeTarget') }} - @@ -111,8 +105,9 @@ *{{ t('moldOperate.operator') }} - - {{ currentUserName }} + + {{ selectedOperator?.label || currentUserName || '请选择操作人' }} + @@ -496,6 +491,13 @@ function autoSetOperator() { } } +function goSelectOperator() { + const currentId = selectedOperator.value?.value || currentUserId.value || '' + uni.navigateTo({ + url: `/pages_function/pages/moldRepair/userSelect?field=operator&from=moldoperate&selectedId=${currentId}` + }) +} + function goToHistory() { uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=down' }) } @@ -535,6 +537,7 @@ async function handleConfirm() { // 添加操作人和备注 if (selectedOperator.value) { payload.operatorId = selectedOperator.value.value + payload.operatorName = selectedOperator.value.label } if (remarkText.value.trim()) { payload.remark = remarkText.value.trim() @@ -568,6 +571,15 @@ onReady(() => { onShow(async () => { autoSetOperator() await Promise.allSettled([loadDevices(), loadLineTree()]) + // 从 globalData 读取用户选择页回传的操作人 + const userResult = getApp().globalData?._moldoperateUserSelectResult + if (userResult) { + selectedOperator.value = { + value: userResult.user.id, + label: userResult.user.nickname || userResult.user.userName || userResult.user.name || '' + } + getApp().globalData._moldoperateUserSelectResult = null + } // 从 globalData 读取设备选择页回传的设备 const device = getApp().globalData._deviceSelectResult if (device) { diff --git a/src/pages_function/pages/moldoperate/history.vue b/src/pages_function/pages/moldoperate/history.vue index a3fac77..47c22ad 100644 --- a/src/pages_function/pages/moldoperate/history.vue +++ b/src/pages_function/pages/moldoperate/history.vue @@ -72,7 +72,7 @@ {{ t('moldOperate.operator') }} - {{ item.creatorName || item.operator || '-' }} + {{ item.operatorName || item.creatorName || item.operator || '-' }} {{ t('moldOperate.remark') }} diff --git a/src/pages_function/pages/moldoperate/index.vue b/src/pages_function/pages/moldoperate/index.vue index c428b44..4ce1871 100644 --- a/src/pages_function/pages/moldoperate/index.vue +++ b/src/pages_function/pages/moldoperate/index.vue @@ -31,7 +31,7 @@ - {{ t('moldOperate.selectedDevice') }} + 设备信息 @@ -51,7 +51,8 @@ {{ t('moldOperate.currentMold') }} - {{ currentMoldDisplay }} + {{ currentMoldDisplay }} + @@ -63,45 +64,57 @@ + + + + + + 选择模具 + + + - {{ t('moldOperate.selectMountMold') }} + 模具信息 - - - + {{ t('moldOperate.clickSelectMold') }} + + + + + + {{ t('moldOperate.changeMountTarget') }} @@ -115,8 +128,9 @@ *{{ t('moldOperate.operator') }} - - {{ currentUserName }} + + {{ selectedOperator?.label || currentUserName || '请选择操作人' }} + @@ -264,8 +278,56 @@ const tempSelectedDeviceId = ref(null) const remarkText = ref('') const selectedOperator = ref(null) const scanCodeInput = ref('') // 扫码/输入设备码 +const moldScanCodeInput = ref('') // 扫码/输入模具码 + +// 红外扫码确认时,通过 API 搜索模具(与模具台账搜索一致) +async function onMoldScanInputConfirm() { + const code = moldScanCodeInput.value.trim() + if (!code) return + try { + const res = await getMoldBrandPage({ + pageNo: 1, + pageSize: 10, + code: code, + name: code + }) + const root = (res && res.data !== undefined) ? res.data : res + function findList(obj, depth = 0) { + if (!obj || typeof obj !== 'object' || depth > 3) return [] + if (Array.isArray(obj)) return obj + for (const key of ['list', 'rows', 'records', 'items', 'data']) { + if (Array.isArray(obj[key])) return obj[key] + } + for (const val of Object.values(obj)) { + const found = findList(val, depth + 1) + if (found.length) return found + } + return [] + } + const list = findList(root) + if (list.length > 0) { + const matched = list[0] + if (Number(matched.status) === 0) { + uni.showToast({ title: '该模具已在机,不能重复上模', icon: 'none' }) + return + } + selectedMountMolds.value = [{ + id: matched.id, + name: matched.name || matched.moldName, + code: matched.code || matched.moldCode, + productName: matched.productName || '-', + status: matched.status + }] + moldScanCodeInput.value = '' + } else { + uni.showToast({ title: '未找到该模具', icon: 'none' }) + } + } catch (e) { + console.error('mold scan search error', e) + uni.showToast({ title: '搜索失败,请重试', icon: 'none' }) + } +} -// 聚焦阻止键盘弹出 const focusNoKeyboardRef = ref(null) const keywordInputSelector = '#mold-scan-input input, input#mold-scan-input' @@ -387,6 +449,10 @@ function validFormMount() { async function handleConfirmMount() { if (!validFormMount()) return + if (currentMoldList.value.length > 0) { + uni.showToast({ title: '该设备已有在机模具,请先下模再上模', icon: 'none', duration: 2000 }) + return + } try { const moldIds = selectedMountMolds.value.map((m) => m.id) const payload = { @@ -399,6 +465,7 @@ async function handleConfirmMount() { // 添加操作人和备注 if (selectedOperator.value) { payload.operatorId = selectedOperator.value.value + payload.operatorName = selectedOperator.value.label } if (remarkText.value.trim()) { payload.remark = remarkText.value.trim() @@ -481,6 +548,13 @@ function onScanInputConfirm() { } } +function goSelectOperator() { + const currentId = selectedOperator.value?.value || currentUserId.value || '' + uni.navigateTo({ + url: `/pages_function/pages/moldRepair/userSelect?field=operator&from=moldoperate&selectedId=${currentId}` + }) +} + function handleCancel() { selectedDevice.value = {} selectedMountMolds.value = [] @@ -502,6 +576,15 @@ onReady(() => { onShow(async () => { autoSetOperator() await Promise.allSettled([loadDevices(), loadLineTree()]) + // 从 globalData 读取用户选择页回传的操作人 + const userResult = getApp().globalData?._moldoperateUserSelectResult + if (userResult) { + selectedOperator.value = { + value: userResult.user.id, + label: userResult.user.nickname || userResult.user.userName || userResult.user.name || '' + } + getApp().globalData._moldoperateUserSelectResult = null + } // 从 globalData 读取设备选择页回传的设备 const device = getApp().globalData._deviceSelectResult if (device) {