|
|
|
|
@ -31,7 +31,7 @@
|
|
|
|
|
<view class="section-card">
|
|
|
|
|
<view class="section-title-bar">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">{{ t('moldOperate.selectedDevice') }}</text>
|
|
|
|
|
<text class="section-title">设备信息</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="card-body-grid">
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
@ -51,7 +51,8 @@
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.currentMold') }}</text>
|
|
|
|
|
<text class="grid-value highlight">{{ currentMoldDisplay }}</text>
|
|
|
|
|
<text class="grid-value">{{ currentMoldDisplay }}</text>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
@ -63,45 +64,57 @@
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="action-row mold-scan-row">
|
|
|
|
|
<view class="scan-input-row">
|
|
|
|
|
<input
|
|
|
|
|
v-model="moldScanCodeInput"
|
|
|
|
|
class="scan-input"
|
|
|
|
|
placeholder="红外扫码或输入模具码"
|
|
|
|
|
confirm-type="done"
|
|
|
|
|
@blur="onMoldScanInputConfirm"
|
|
|
|
|
@confirm="onMoldScanInputConfirm"
|
|
|
|
|
/>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="action-btn select-btn" @click="openMountMoldPicker">
|
|
|
|
|
<text class="btn-text">选择模具</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 选择待上模模具 -->
|
|
|
|
|
<view class="section-card">
|
|
|
|
|
<view class="section-title-bar">
|
|
|
|
|
<view class="section-bar-line"></view>
|
|
|
|
|
<text class="section-title">{{ t('moldOperate.selectMountMold') }}</text>
|
|
|
|
|
<text class="section-title">模具信息</text>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<template v-if="selectedMountMolds.length > 0">
|
|
|
|
|
<view v-for="(mold, index) in selectedMountMolds" :key="mold.id || index" class="card-body-grid">
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.moldName') }}</text>
|
|
|
|
|
<text class="grid-value highlight">{{ textValue(mold.name || mold.moldName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.moldCode') }}</text>
|
|
|
|
|
<text class="grid-value">{{ textValue(mold.code || mold.moldCode) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="card-body-grid">
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.moldName') }}</text>
|
|
|
|
|
<text class="grid-value">{{ textValue(selectedMountMolds[0]?.name || selectedMountMolds[0]?.moldName) }}</text>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.product') }}</text>
|
|
|
|
|
<text class="grid-value">{{ textValue(mold.productName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.status') }}</text>
|
|
|
|
|
<view :class="['status-tag', getMoldStatusClass(mold.status)]">{{ getMoldStatusText(mold.status) }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.moldCode') }}</text>
|
|
|
|
|
<text class="grid-value">{{ textValue(selectedMountMolds[0]?.code || selectedMountMolds[0]?.moldCode) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 更换上模对象按钮 -->
|
|
|
|
|
<view class="change-target-btn" @click="openMountMoldPicker">
|
|
|
|
|
<text class="change-icon">⇄</text>
|
|
|
|
|
<text class="change-text">{{ t('moldOperate.changeMountTarget') }}</text>
|
|
|
|
|
<view class="grid-row">
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.product') }}</text>
|
|
|
|
|
<text class="grid-value">{{ textValue(selectedMountMolds[0]?.productName) }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="grid-cell">
|
|
|
|
|
<text class="grid-label">{{ t('moldOperate.status') }}</text>
|
|
|
|
|
<view :class="['status-tag', getMoldStatusClass(selectedMountMolds[0]?.status)]">{{ getMoldStatusText(selectedMountMolds[0]?.status) }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<view v-else class="empty-mold-hint" @click="openMountMoldPicker">
|
|
|
|
|
<text class="empty-mold-text">+ {{ t('moldOperate.clickSelectMold') }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 更换上模对象按钮 -->
|
|
|
|
|
<view class="change-target-btn" @click="openMountMoldPicker" v-if="selectedMountMolds.length > 0">
|
|
|
|
|
<text class="change-icon">⇄</text>
|
|
|
|
|
<text class="change-text">{{ t('moldOperate.changeMountTarget') }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
@ -115,8 +128,9 @@
|
|
|
|
|
<view class="form-row">
|
|
|
|
|
<view class="form-cell">
|
|
|
|
|
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
|
|
|
|
|
<view class="dropdown-input readonly-input">
|
|
|
|
|
<text class="dropdown-value">{{ currentUserName }}</text>
|
|
|
|
|
<view class="dropdown-input select-field" @click="goSelectOperator">
|
|
|
|
|
<text :class="['dropdown-value', selectedOperator ? '' : 'placeholder']">{{ selectedOperator?.label || currentUserName || '请选择操作人' }}</text>
|
|
|
|
|
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
@ -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) {
|
|
|
|
|
|