Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/locales/index.js
besure_bit
liutao 1 week ago
commit 4f3a7dc18d

@ -80,6 +80,22 @@ export function getBrandList(params = {}) {
})
}
export function createPressureNetRecord(data) {
return request({
url: '/admin-api/erp/mold-pressure-net-record/batch-create',
method: 'post',
data
})
}
export function getPressureNetRecordPage(params = {}) {
return request({
url: '/admin-api/erp/mold-pressure-net-record/page',
method: 'get',
params
})
}
export function getInTransitMoldAllList() {
return request({
url: '/admin-api/erp/mold/getInTransitMoldAllList',

@ -344,6 +344,7 @@ export default {
validatorOperateTypeRequired: 'Operation type is required',
validatorDeviceRequired: 'Device is required',
validatorMoldRequired: 'Select at least one mold for mounting',
validatorOperatorRequired: 'Please select operator',
validatorLowerMoldRequired: 'Select at least one mold for dismounting',
loadEditFailed: 'Failed to load edit data',
confirmDelete: 'Confirm delete this mold operate record?',
@ -374,7 +375,21 @@ export default {
changeTarget: 'Change Dismount Target',
confirmDismount: 'Confirm Dismount',
clickSelectDeviceFirst: 'Please select a device first',
noMoldOnDevice: 'No mold on this device'
noMoldOnDevice: 'No mold on this device',
historySuffix: ' History',
historyTitle: 'Mold Operate History',
searchPlaceholder: 'Search device/mold name',
operator: 'Operator',
placeholderOperator: 'Select operator',
filterAll: 'All',
filterToday: 'Today',
filterWeek: 'This Week',
historyEmpty: 'No history records',
totalPrefix: 'Total: ',
totalSuffix: '',
confirmDeleteHistory: 'Confirm delete this history record?',
operateTime: 'Operate Time',
operator: 'Operator'
},
moldInspectionItems: {
moduleName: 'Inspection Items',
@ -1156,11 +1171,120 @@ export default {
selectTemplateError: 'Please select inspection template',
noItems: 'Please select inspection template first',
noTemplate: 'No templates',
resultListTitle: 'Inspection Results',
editResult: 'Edit',
cancelEdit: 'Cancel Edit',
submit: 'Submit Inspection',
submitSuccess: 'Inspection submitted successfully',
submitFailed: 'Failed to submit inspection',
reInspect: 'Re-inspect'
},
moldMaintain: {
moduleName: 'Mold Maintenance',
addTitle: 'Add Maintenance',
detailTitle: 'Maintenance Detail',
searchPlaceholder: 'Enter maintenance No.',
empty: 'No maintenance records',
add: 'Add',
moldName: 'Mold Name',
moldCode: 'Mold Code',
product: 'Product',
status: 'Status',
taskType: 'Task Type',
taskTypeInspect: 'Inspection',
taskTypeMaintain: 'Maintenance',
planNo: 'Maintenance No.',
taskTime: 'Task Time',
template: 'Template',
operator: 'Operator',
jobResultOk: 'OK',
jobResultNg: 'NG',
progressTitle: 'Progress',
noResultData: 'No maintenance result data',
requiredText: 'Required',
inspectionMethod: 'Maintenance Method',
judgmentCriteria: 'Judgment Criteria',
textInput: 'Input Value',
inputPlaceholder: 'Enter value',
images: 'Images',
remark: 'Remark',
resultText: 'Result',
inspectionResultPass: 'Pass',
inspectionResultFail: 'Fail',
inspectionResultPending: 'Pending',
maxUploadCount: 'Max 3 images',
selectAllDecisionError: 'Please select all maintenance results',
currentMoldInfo: 'Mold Info',
moldGroupCode: 'Mold Group Code',
moldGroupName: 'Mold Group Name',
cavityCount: 'Cavity Count',
moldSize: 'Mold Size',
currentDevice: 'Current Device',
selectMold: 'Select Mold',
reSelectMold: 'Re-select Mold',
selectMoldError: 'Please select a mold',
searchMold: 'Enter mold name',
noMoldInfo: 'Please select a mold',
noMoldData: 'No molds available',
taskName: 'Task Name',
taskInfo: 'Task Info',
placeholderTaskName: 'Enter task name',
templateSelection: 'Template/Task Selection',
selectTemplate: 'Select Template',
selectTemplateError: 'Please select maintenance template',
noItems: 'Please select maintenance template first',
noTemplate: 'No templates',
resultListTitle: 'Inspection Results',
editResult: 'Edit',
cancelEdit: 'Cancel Edit',
submit: 'Submit Maintenance',
submitSuccess: 'Maintenance submitted successfully',
submitFailed: 'Failed to submit maintenance',
reInspect: 'Re-maintain'
},
moldPressureNet: {
moduleName: 'Replace Pressure Net',
recordTitle: 'Pressure Net Replacement',
recordDesc: 'Select mold group and sub-mold, then confirm replacement time',
history: 'History',
historyTitle: 'Pressure Net History',
moldGroup: 'Mold Group',
selectMoldGroup: 'Select Mold Group',
searchMoldGroup: 'Enter mold group name',
noMoldGroup: 'No mold groups',
moldGroupName: 'Mold Group Name',
moldGroupCode: 'Mold Group Code',
product: 'Product',
subMold: 'Sub-mold',
selectSubMold: 'Select Sub-mold',
reSelectMoldGroup: 'Re-select Mold Group',
reSelectSubMold: 'Re-select Sub-mold',
subMoldCode: 'Sub-mold Code',
subMoldName: 'Sub-mold Name',
searchSubMold: 'Search sub-mold name/code',
noSubMold: 'No sub-molds',
replaceInfo: 'Replacement Info',
replaceTime: 'Replacement Time',
pressureNetTime: 'Pressure Net Time',
selectReplaceTime: 'Select replacement time',
operator: 'Operator',
selectOperator: 'Select operator',
noOperator: 'No operators',
remark: 'Remark',
remarkPlaceholder: 'Enter replacement reason or remark',
confirmReplace: 'Confirm',
selectMoldGroupError: 'Please select a mold group',
selectSubMoldError: 'Please select a sub-mold',
selectedCount: '{count} sub-mold(s) selected',
selectReplaceTimeError: 'Please select replacement time',
submitSuccess: 'Saved successfully',
submitFailed: 'Save failed',
historyMoldIdPlaceholder: 'Enter sub-mold ID, blank for all',
searchBrandName: 'Mold Group Name',
selectDate: 'Select Date',
createTime: 'Create Time',
noHistory: 'No pressure net history'
},
moldRepair: {
moduleName: 'Mold Repair',
createTitle: 'Create Mold Repair',

@ -130,7 +130,12 @@ const literalMap = {
'模具点检': 'moldCheck.moduleName',
'点检详情': 'moldCheck.detailTitle',
'新增点检': 'moldCheck.addTitle',
'设备运维': 'work.equipmentMaintenance'
'设备运维': 'work.equipmentMaintenance',
'模具保养': 'moldMaintain.moduleName',
'保养详情': 'moldMaintain.detailTitle',
'新增保养': 'moldMaintain.addTitle',
'更换压网': 'moldPressureNet.moduleName',
'压网历史': 'moldPressureNet.historyTitle'
}
export function getCurrentLocale() {

@ -344,6 +344,7 @@ export default {
validatorOperateTypeRequired: '操作类型不能为空',
validatorDeviceRequired: '设备不能为空',
validatorMoldRequired: '请至少选择一个上模模具',
validatorOperatorRequired: '请选择操作人',
validatorLowerMoldRequired: '请至少选择一个下模模具',
loadEditFailed: '加载编辑数据失败',
confirmDelete: '确认删除该上下模记录吗?',
@ -374,7 +375,21 @@ export default {
changeTarget: '更换下模对象',
confirmDismount: '确认下模',
clickSelectDeviceFirst: '请先选择设备',
noMoldOnDevice: '该设备暂无在机模具'
noMoldOnDevice: '该设备暂无在机模具',
historySuffix: '历史',
historyTitle: '上下模历史',
searchPlaceholder: '搜索设备/模具名称',
operator: '操作人',
placeholderOperator: '请选择操作人',
filterAll: '全部',
filterToday: '今天',
filterWeek: '本周',
historyEmpty: '暂无历史记录',
totalPrefix: '共 ',
totalSuffix: ' 条',
confirmDeleteHistory: '确认删除该历史记录吗?',
operateTime: '操作时间',
operator: '操作人'
},
moldInspectionItems: {
moduleName: '点检项库',
@ -1159,11 +1174,120 @@ export default {
selectTemplateError: '请选择点检模板',
noItems: '请先选择点检模板',
noTemplate: '暂无模板',
resultListTitle: '检验结果',
editResult: '编辑',
cancelEdit: '取消编辑',
submit: '提交点检',
submitSuccess: '点检提交成功',
submitFailed: '点检提交失败',
reInspect: '再次点检'
},
moldMaintain: {
moduleName: '模具保养',
addTitle: '新增保养',
detailTitle: '保养详情',
searchPlaceholder: '请输入保养单号',
empty: '暂无保养记录',
add: '新增',
moldName: '模具名称',
moldCode: '模具编号',
product: '产品',
status: '状态',
taskType: '任务类型',
taskTypeInspect: '点检',
taskTypeMaintain: '保养',
planNo: '保养单号',
taskTime: '执行时间',
template: '配置模板',
operator: '操作员',
jobResultOk: '通过',
jobResultNg: '不通过',
progressTitle: '进度',
noResultData: '暂无保养结果数据',
requiredText: '必检',
inspectionMethod: '保养方式',
judgmentCriteria: '判定基准',
textInput: '输入值',
inputPlaceholder: '请输入',
images: '图片',
remark: '备注',
resultText: '结果',
inspectionResultPass: '通过',
inspectionResultFail: '不通过',
inspectionResultPending: '待判定',
maxUploadCount: '最多上传3张图片',
selectAllDecisionError: '请选择所有保养项的判定结果',
currentMoldInfo: '模具信息',
moldGroupCode: '模具组编码',
moldGroupName: '模具组名称',
cavityCount: '模穴数',
moldSize: '模具尺寸',
currentDevice: '当前设备',
selectMold: '选择模具',
reSelectMold: '重新选择模具',
selectMoldError: '请选择模具',
searchMold: '请输入模具名称',
noMoldInfo: '请选择模具',
noMoldData: '暂无可选模具',
taskName: '任务名称',
taskInfo: '任务信息',
placeholderTaskName: '请输入任务名称',
templateSelection: '模板/任务选择',
selectTemplate: '请选择模板',
selectTemplateError: '请选择保养模板',
noItems: '请先选择保养模板',
noTemplate: '暂无模板',
resultListTitle: '检验结果',
editResult: '编辑',
cancelEdit: '取消编辑',
submit: '提交保养',
submitSuccess: '保养提交成功',
submitFailed: '保养提交失败',
reInspect: '再次保养'
},
moldPressureNet: {
moduleName: '更换压网',
recordTitle: '压网更换记录',
recordDesc: '请选择模具组和子模,确认更换时间',
history: '历史数据',
historyTitle: '压网历史',
moldGroup: '模具组',
selectMoldGroup: '选择模具组',
searchMoldGroup: '请输入模具组名称',
noMoldGroup: '暂无模具组',
moldGroupName: '模具组名称',
moldGroupCode: '模具组编号',
product: '产品',
subMold: '子模',
selectSubMold: '选择子模',
reSelectMoldGroup: '重新选择模具组',
reSelectSubMold: '重新选择子模',
subMoldCode: '子模编码',
subMoldName: '子模名称',
searchSubMold: '搜索子模名称/编号',
noSubMold: '暂无子模',
replaceInfo: '更换信息',
replaceTime: '更换时间',
pressureNetTime: '压网时间',
selectReplaceTime: '请选择更换时间',
operator: '操作人',
selectOperator: '请选择操作人',
noOperator: '暂无操作人',
remark: '备注',
remarkPlaceholder: '请输入更换原因或备注',
confirmReplace: '确认更换',
selectMoldGroupError: '请选择模具组',
selectSubMoldError: '请选择子模',
selectedCount: '已选{count}个子模',
selectReplaceTimeError: '请选择更换时间',
submitSuccess: '压网更换保存成功',
submitFailed: '压网更换保存失败',
historyMoldIdPlaceholder: '输入子模ID筛选不填查全部',
searchBrandName: '模具组名称',
selectDate: '选择日期',
createTime: '创建时间',
noHistory: '暂无压网历史记录'
},
moldRepair: {
moduleName: '模具维修',
createTitle: '新增模具维修',

@ -22,7 +22,9 @@
"delay" : 0
},
/* */
"modules" : {},
"modules" : {
"Camera" : {}
},
/* */
"distribute" : {
/* android */

@ -610,6 +610,13 @@
"navigationStyle": "custom"
}
},
{
"path": "moldoperate/history",
"style": {
"navigationBarTitleText": "上下模历史",
"navigationStyle": "custom"
}
},
{
"path": "moldRepair/index",
"style": {
@ -742,9 +749,44 @@
"navigationBarTitleText": "新增点检",
"navigationStyle": "custom"
}
},
{
"path": "moldMaintain/index",
"style": {
"navigationBarTitleText": "模具保养",
"navigationStyle": "custom"
}
},
{
"path": "moldMaintain/detail",
"style": {
"navigationBarTitleText": "保养详情",
"navigationStyle": "custom"
}
},
{
"path": "moldMaintain/add",
"style": {
"navigationBarTitleText": "新增保养",
"navigationStyle": "custom"
}
},
{
"path": "moldPressureNet/index",
"style": {
"navigationBarTitleText": "更换压网",
"navigationStyle": "custom"
}
},
{
"path": "moldPressureNet/history",
"style": {
"navigationBarTitleText": "压网历史",
"navigationStyle": "custom"
}
}
]
}
],
"preloadRule": {}
}
}

@ -78,8 +78,15 @@
</view>
<!-- 点检项列表 -->
<view v-if="!inspectionItems.length" class="hint">{{ t('moldCheck.noItems') }}</view>
<view v-else class="inspection-list">
<view v-if="selectedTemplate" class="inspection-section">
<view class="inspection-toolbar">
<text class="inspection-toolbar-title">{{ t('moldCheck.resultListTitle') }}</text>
<view :class="['edit-toggle-btn', ticketResultEditable ? 'active' : '']" @click="toggleTicketResultEditable">
<uni-icons :type="ticketResultEditable ? 'closeempty' : 'compose'" size="18" :color="ticketResultEditable ? '#ef4444' : '#1f7cff'"></uni-icons>
<text>{{ ticketResultEditable ? t('moldCheck.cancelEdit') : t('moldCheck.editResult') }}</text>
</view>
</view>
<view class="inspection-list">
<view v-for="(item, index) in inspectionItems" :key="item.id || index" class="inspection-card">
<view class="inspection-header">
<view class="inspection-index">{{ index + 1 }}</view>
@ -103,6 +110,7 @@
:min="-999999999"
:max="999999999"
:step="1"
:disabled="!ticketResultEditable"
@change="onNumberInputChange(item, $event)"
/>
</view>
@ -114,6 +122,7 @@
class="form-textarea"
:placeholder="t('moldCheck.inputPlaceholder')"
maxlength="500"
:disabled="!ticketResultEditable"
/>
</view>
<view class="field-block">
@ -126,9 +135,9 @@
mode="aspectFill"
@click="previewImage(img, parseImages(item.images))"
/>
<view class="image-remove" @click="removeImage(item, imgIndex)">×</view>
<view v-if="ticketResultEditable" class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
<view v-if="parseImages(item.images).length < 3" class="image-upload" @click="chooseImages(item)">
<view v-if="ticketResultEditable && parseImages(item.images).length < 3" class="image-upload" @click="chooseImages(item)">
<text class="image-upload-icon">+</text>
</view>
</view>
@ -140,19 +149,20 @@
class="form-textarea"
:placeholder="t('moldCheck.inputPlaceholder')"
maxlength="500"
:disabled="!ticketResultEditable"
/>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldCheck.resultText') }}</text>
<view class="result-option-group">
<view
:class="['result-option', resultOptionClass(item, '1')]"
:class="['result-option', resultOptionClass(item, '1'), ticketResultEditable ? '' : 'result-option-disabled']"
@click="setDecision(item, '1')"
>
{{ t('moldCheck.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2')]"
:class="['result-option', resultOptionClass(item, '2'), ticketResultEditable ? '' : 'result-option-disabled']"
@click="setDecision(item, '2')"
>
{{ t('moldCheck.inspectionResultFail') }}
@ -164,6 +174,7 @@
</view>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
@ -247,7 +258,7 @@ import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
//
// Mold info, loaded from route params or picker.
const moldInfo = reactive({
id: '',
code: '',
@ -268,10 +279,12 @@ const templateFinished = ref(false)
const templatePageNo = ref(1)
const templatePageSize = ref(20)
const inspectionItems = ref([])
const ticketResultEditable = ref(false)
const ticketResultBackup = ref(null)
const submitLoading = ref(false)
const statusClass = ref('')
//
// Mold picker.
const showMoldPicker = ref(false)
const moldList = ref([])
const moldLoading = ref(false)
@ -300,7 +313,6 @@ onLoad(async (query) => {
moldInfo.statusLabel = getDictLabel(DICT_TYPE.ERP_MOLD_STATUS, moldInfo.status, moldInfo.status)
updateStatusClass()
} else {
// ID
await loadMoldInfo(moldId)
}
}
@ -327,18 +339,17 @@ async function loadMoldInfo(id) {
function updateStatusClass() {
const status = String(moldInfo.status)
if (status === '1' || moldInfo.statusLabel.includes('正常') || moldInfo.statusLabel.includes('使用')) {
if (status === '1') {
statusClass.value = 'status-success'
} else if (status === '2' || moldInfo.statusLabel.includes('维修') || moldInfo.statusLabel.includes('警')) {
} else if (status === '2') {
statusClass.value = 'status-warning'
} else if (status === '3' || moldInfo.statusLabel.includes('报废') || moldInfo.statusLabel.includes('停')) {
} else if (status === '3') {
statusClass.value = 'status-danger'
} else {
statusClass.value = 'status-default'
}
}
//
function openMoldPicker() {
showMoldPicker.value = true
if (!moldList.value.length) {
@ -390,7 +401,6 @@ function selectMold(mold) {
closeMoldPicker()
}
//
function openTemplatePicker() {
showTemplatePicker.value = true
if (!templateList.value.length) {
@ -434,6 +444,8 @@ async function loadMoreTemplates() {
function selectTemplate(template) {
selectedTemplate.value = template
ticketResultEditable.value = false
ticketResultBackup.value = null
loadInspectionItems(template.id)
closeTemplatePicker()
}
@ -476,7 +488,7 @@ function shouldShowInput(item) {
function isNumericValueType(value) {
const normalized = String(value ?? '')
const label = String(valueTypeText(value) || '').toLowerCase()
return normalized === '2' || /数值|数字|number|numeric|digit|decimal/.test(label)
return normalized === '2' || /鏁板€紎鏁板瓧|number|numeric|digit|decimal/.test(label)
}
function numberInputValue(item) {
@ -485,6 +497,7 @@ function numberInputValue(item) {
}
function onNumberInputChange(item, value) {
if (!ticketResultEditable.value) return
item.textInput = String(value)
}
@ -513,10 +526,12 @@ function resultOptionClass(item, value) {
}
function setDecision(item, value) {
if (!ticketResultEditable.value) return
item.inspectionResult = String(value)
}
async function chooseImages(item) {
if (!ticketResultEditable.value) return
try {
const currentCount = parseImages(item.images).length
const remain = Math.max(0, 3 - currentCount)
@ -546,6 +561,7 @@ async function chooseImages(item) {
}
function removeImage(item, index) {
if (!ticketResultEditable.value) return
const next = parseImages(item.images)
next.splice(index, 1)
item.images = next.join(',')
@ -572,6 +588,19 @@ function goBack() {
uni.navigateBack()
}
function toggleTicketResultEditable() {
if (ticketResultEditable.value) {
if (ticketResultBackup.value) {
inspectionItems.value = JSON.parse(JSON.stringify(ticketResultBackup.value))
ticketResultBackup.value = null
}
ticketResultEditable.value = false
return
}
ticketResultBackup.value = JSON.parse(JSON.stringify(inspectionItems.value))
ticketResultEditable.value = true
}
async function handleSubmit() {
if (submitLoading.value) return
@ -591,7 +620,7 @@ async function handleSubmit() {
}
const hasUnselected = inspectionItems.value.some((item) => String(item?.inspectionResult || '0') === '0')
if (inspectionItems.value.length && hasUnselected) {
if (ticketResultEditable.value && inspectionItems.value.length && hasUnselected) {
uni.showToast({ title: t('moldCheck.selectAllDecisionError'), icon: 'none' })
return
}
@ -665,6 +694,11 @@ async function handleSubmit() {
.template-select { display: flex; align-items: center; justify-content: space-between; height: 88rpx; padding: 0 24rpx; background: #f8fafc; border-radius: 14rpx; }
.template-text { font-size: 28rpx; color: #374151; }
.template-text.placeholder { color: #9ca3af; }
.inspection-section { display: flex; flex-direction: column; gap: 16rpx; }
.inspection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; padding: 0 4rpx; }
.inspection-toolbar-title { font-size: 30rpx; font-weight: 700; color: #1f2937; }
.edit-toggle-btn { height: 60rpx; padding: 0 18rpx; border-radius: 999rpx; border: 1rpx solid #bfdbfe; background: #eff6ff; color: #1f7cff; font-size: 24rpx; font-weight: 600; display: flex; align-items: center; gap: 8rpx; flex-shrink: 0; }
.edit-toggle-btn.active { border-color: #fecaca; background: #fef2f2; color: #ef4444; }
.inspection-list { display: flex; flex-direction: column; gap: 20rpx; }
.inspection-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.inspection-header { display: flex; align-items: center; gap: 16rpx; }
@ -681,6 +715,7 @@ async function handleSubmit() {
.result-option { min-width: 160rpx; height: 72rpx; padding: 0 24rpx; border-radius: 14rpx; border: 1rpx solid #d1d5db; color: #6b7280; font-size: 30rpx; display: flex; align-items: center; justify-content: center; background: #ffffff; }
.result-option-active { border-color: #60a5fa; background: #eff6ff; color: #1f7cff; }
.result-option-danger { border-color: #fca5a5; background: #fef2f2; color: #ef4444; }
.result-option-disabled { opacity: 0.55; }
.pending-tag { padding: 8rpx 14rpx; border-radius: 10rpx; background: #f3f4f6; color: #9ca3af; font-size: 24rpx; }
.form-textarea { width: 100%; min-height: 76rpx; max-height: 108rpx; background: #f8fafc; border-radius: 12rpx; padding: 10rpx 16rpx; font-size: 26rpx; color: #374151; box-sizing: border-box; }
.number-box-wrap { width: 100%; }
@ -696,10 +731,10 @@ async function handleSubmit() {
.image-upload { width: 140rpx; height: 140rpx; border-radius: 16rpx; border: 2rpx dashed #cbd5e1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-upload-icon { font-size: 60rpx; color: #94a3b8; line-height: 1; }
.hint { padding: 48rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 20rpx; padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom)); background: #f5f7fb; }
.action-btn { flex: 1; height: 88rpx; border-radius: 18rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #ffffff; color: #1f7cff; border: 1rpx solid #bfdbfe; }
.submit-btn { background: linear-gradient(135deg, #1f7cff, #3b82f6); color: #ffffff; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); }
.action-btn { flex: 1; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #eef2f7; color: #475569; }
.submit-btn { background: #1f4b79; color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
.picker-mask { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 100; display: flex; align-items: flex-end; }
.picker-popup { width: 100%; background: #ffffff; border-radius: 24rpx 24rpx 0 0; padding-bottom: env(safe-area-inset-bottom); }

@ -82,10 +82,10 @@
<view class="image-list">
<view v-for="(img, imgIndex) in parseImages(item.images)" :key="imgIndex" class="image-item">
<image
:src="img"
:src="encodeURI(img)"
class="result-image"
mode="aspectFill"
@click="previewImage(img, parseImages(item.images))"
@click="previewImage(encodeURI(img), parseImages(item.images).map(i => encodeURI(i)))"
/>
<view v-if="isEditableItem(item)" class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
@ -346,6 +346,7 @@ async function handleSave() {
try {
await batchUpdateMoldCheckResults(payload)
detailData.jobStatus = 1
uni.setStorageSync('moldCheckListNeedRefresh', '1')
uni.showToast({ title: t('functionCommon.saveSuccess'), icon: 'success' })
await fetchResults()
} catch (error) {
@ -416,9 +417,9 @@ function normalizeTextInput(value) {
.image-upload { width: 140rpx; height: 140rpx; border-radius: 16rpx; border: 2rpx dashed #cbd5e1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-upload-icon { font-size: 60rpx; color: #94a3b8; line-height: 1; }
.hint { padding: 48rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 20rpx; padding: 20rpx 24rpx calc(20rpx + env(safe-area-inset-bottom)); background: #f5f7fb; }
.action-btn { flex: 1; height: 88rpx; border-radius: 18rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #ffffff; color: #1f7cff; border: 1rpx solid #bfdbfe; }
.save-btn { background: linear-gradient(135deg, #1f7cff, #3b82f6); color: #ffffff; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); }
.action-btn { flex: 1; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #eef2f7; color: #475569; }
.save-btn { background: #1f4b79; color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
</style>
</style>

@ -10,7 +10,9 @@
type="text"
:placeholder="t('moldLedger.searchPlaceholder')"
placeholder-class="placeholder"
:focus="keywordFocus"
confirm-type="search"
@blur="keywordFocus = false"
@confirm="handleSearch"
/>
</view>
@ -19,9 +21,6 @@
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view>
<view class="reset-filter-btn" @click="resetFilters">{{ t('common.reset') }}</view>
<view class="scan-btn" @click="handleScan">
<uni-icons type="scan" size="22" color="#111827"></uni-icons>
</view>
</view>
<scroll-view
@ -95,8 +94,8 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { ref, computed, nextTick } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import CopyButton from '@/components/common/CopyButton.vue'
@ -116,6 +115,7 @@ const searchKeyword = ref('')
const selectedStatus = ref(undefined)
const scrollTop = ref(0)
const showGoTop = ref(false)
const keywordFocus = ref(false)
const statusOptions = computed(() => {
const options = []
@ -134,56 +134,24 @@ const selectedStatusLabel = computed(() => {
})
onLoad(async () => {
activateKeywordFocus()
await initAllDict()
await fetchList(true)
})
async function handleSearch() {
await fetchList(true)
}
onShow(() => {
activateKeywordFocus()
})
async function handleScan() {
try {
const res = await uni.scanCode({ scanType: ['qrCode', 'barCode'] })
const result = String(res?.result || '').trim()
if (!result) {
uni.showToast({ title: t('moldLedger.scanUnrecognized'), icon: 'none' })
return
}
const scan = parseMoldScanResult(result)
if (!scan.id) {
uni.showToast({ title: t('moldLedger.scanFormatError'), icon: 'none' })
return
}
searchKeyword.value = scan.id
await fetchList(true)
} catch (error) {
const message = String(error?.errMsg || '')
if (message.includes('cancel')) return
uni.showToast({ title: t('moldLedger.scanFailed'), icon: 'none' })
}
function activateKeywordFocus() {
keywordFocus.value = false
nextTick(() => {
keywordFocus.value = true
})
}
function parseMoldScanResult(result) {
const text = String(result || '').trim()
const directMatch = text.match(/^([A-Z_]+)-(\d+)$/i)
if (directMatch) {
return {
type: directMatch[1].toUpperCase(),
id: directMatch[1].toUpperCase() === 'MOLD' ? directMatch[2] : ''
}
}
try {
const parsed = JSON.parse(text)
const type = String(parsed?.type || parsed?.bizType || parsed?.codeType || '').toUpperCase()
const id = String(parsed?.id || parsed?.moldId || parsed?.deviceId || '').trim()
return {
type,
id: type === 'MOLD' && id ? id : ''
}
} catch {
return { type: '', id: '' }
}
async function handleSearch() {
await fetchList(true)
}
async function clearSearch() {
@ -194,6 +162,7 @@ async function clearSearch() {
async function resetFilters() {
searchKeyword.value = ''
selectedStatus.value = undefined
activateKeywordFocus()
await fetchList(true)
}
@ -236,7 +205,6 @@ async function fetchList(reset) {
pageSize: pageSize.value,
code: keyword || undefined,
name: keyword || undefined,
productName: keyword || undefined,
status: selectedStatus.value
})
const page = normalizePageData(res)
@ -363,7 +331,7 @@ function formatDateTime(value) {
.filter-bar {
display: grid;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx 64rpx;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx;
align-items: center;
gap: 14rpx;
padding: 18rpx 28rpx 20rpx;
@ -371,8 +339,7 @@ function formatDateTime(value) {
.keyword-box,
.status-box,
.reset-filter-btn,
.scan-btn {
.reset-filter-btn {
height: 66rpx;
background: #ffffff;
border: 1rpx solid #d9dde5;
@ -415,10 +382,6 @@ function formatDateTime(value) {
color: #4b5563;
}
.scan-btn {
justify-content: center;
}
.content-scroll {
width: 100%;
}

@ -0,0 +1,759 @@
<template>
<view class="page-container">
<NavBar :title="t('moldMaintain.addTitle')" />
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<!-- 模具信息 -->
<view class="section-card">
<view class="section-header">
<view class="section-icon">
<uni-icons type="info" size="24" color="#1f7cff"></uni-icons>
</view>
<text class="section-title">{{ t('moldMaintain.currentMoldInfo') }}</text>
</view>
<view class="form-field mold-select-field">
<text class="form-label">{{ t('moldMaintain.selectMold') }}<text class="required-star">*</text></text>
<view :class="['mold-select-area', moldInfo.id ? 'selected' : '']" @click="openMoldPicker">
<view class="mold-select-content">
<text :class="moldInfo.id ? 'mold-select-value' : 'mold-select-placeholder'">{{ moldInfo.id ? (moldInfo.name || moldInfo.code || '-') : t('moldMaintain.selectMold') }}</text>
<text v-if="moldInfo.id" class="mold-select-subtext">{{ moldInfo.code || t('moldMaintain.reSelectMold') }}</text>
</view>
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
</view>
</view>
<view v-if="moldInfo.id" class="mold-info-panel">
<view class="mold-info-grid">
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.moldGroupCode') }}</text>
<text class="mold-info-value">{{ moldInfo.code || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.moldGroupName') }}</text>
<text class="mold-info-value">{{ moldInfo.name || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.cavityCount') }}</text>
<text class="mold-info-value">{{ moldInfo.moldSize || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.product') }}</text>
<text class="mold-info-value">{{ moldInfo.productName || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.status') }}</text>
<text :class="['mold-info-value', 'status-tag', statusClass]">{{ moldInfo.statusLabel || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldMaintain.currentDevice') }}</text>
<text class="mold-info-value">{{ moldInfo.currentDevice || '-' }}</text>
</view>
</view>
</view>
</view>
<!-- 任务信息 -->
<view class="section-card">
<view class="section-header">
<view class="section-icon">
<uni-icons type="compose" size="24" color="#1f7cff"></uni-icons>
</view>
<text class="section-title">{{ t('moldMaintain.taskInfo') }}</text>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldMaintain.taskName') }}<text class="required-star">*</text></text>
<input
v-model="taskName"
class="form-input"
:placeholder="t('moldMaintain.placeholderTaskName')"
/>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldMaintain.templateSelection') }}<text class="required-star">*</text></text>
<view class="template-select" @click="openTemplatePicker">
<text :class="['template-text', selectedTemplate ? '' : 'placeholder']">{{ selectedTemplate?.planName || t('moldMaintain.selectTemplate') }}</text>
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
</view>
</view>
</view>
<!-- 点检项列表 -->
<view v-if="selectedTemplate" class="inspection-section">
<view class="inspection-toolbar">
<text class="inspection-toolbar-title">{{ t('moldMaintain.resultListTitle') }}</text>
<view :class="['edit-toggle-btn', ticketResultEditable ? 'active' : '']" @click="toggleTicketResultEditable">
<uni-icons :type="ticketResultEditable ? 'closeempty' : 'compose'" size="18" :color="ticketResultEditable ? '#ef4444' : '#1f7cff'"></uni-icons>
<text>{{ ticketResultEditable ? t('moldMaintain.cancelEdit') : t('moldMaintain.editResult') }}</text>
</view>
</view>
<view class="inspection-list">
<view v-for="(item, index) in inspectionItems" :key="item.id || index" class="inspection-card">
<view class="inspection-header">
<view class="inspection-index">{{ index + 1 }}</view>
<text class="inspection-title">{{ textValue(item.inspectionItemName || item.subjectName) }}</text>
<view v-if="isRequiredItem(item)" class="required-tag">{{ t('moldMaintain.requiredText') }}</view>
</view>
<view class="inspection-fields">
<view class="field-row">
<text class="field-label">{{ t('moldMaintain.inspectionMethod') }}</text>
<text class="field-value">{{ inspectionMethodText(item.inspectionMethod) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('moldMaintain.judgmentCriteria') }}</text>
<text class="field-value">{{ textValue(item.judgmentCriteria) }}</text>
</view>
<view v-if="shouldShowInput(item) && isNumericValueType(item.valueType)" class="field-row">
<text class="field-label">{{ t('moldMaintain.textInput') }}</text>
<view class="number-box-wrap number-box-wrap-inline">
<uni-number-box
:modelValue="numberInputValue(item)"
:min="-999999999"
:max="999999999"
:step="1"
:disabled="!ticketResultEditable"
@change="onNumberInputChange(item, $event)"
/>
</view>
</view>
<view v-else-if="shouldShowInput(item)" class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.textInput') }}</text>
<textarea
v-model="item.textInput"
class="form-textarea"
:placeholder="t('moldMaintain.inputPlaceholder')"
maxlength="500"
:disabled="!ticketResultEditable"
/>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.images') }}</text>
<view class="image-list">
<view v-for="(img, imgIndex) in parseImages(item.images)" :key="imgIndex" class="image-item">
<image
:src="img"
class="result-image"
mode="aspectFill"
@click="previewImage(img, parseImages(item.images))"
/>
<view v-if="ticketResultEditable" class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
<view v-if="ticketResultEditable && parseImages(item.images).length < 3" class="image-upload" @click="chooseImages(item)">
<text class="image-upload-icon">+</text>
</view>
</view>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.remark') }}</text>
<textarea
v-model="item.remark"
class="form-textarea"
:placeholder="t('moldMaintain.inputPlaceholder')"
maxlength="500"
:disabled="!ticketResultEditable"
/>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.resultText') }}</text>
<view class="result-option-group">
<view
:class="['result-option', resultOptionClass(item, '1'), ticketResultEditable ? '' : 'result-option-disabled']"
@click="setDecision(item, '1')"
>
{{ t('moldMaintain.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2'), ticketResultEditable ? '' : 'result-option-disabled']"
@click="setDecision(item, '2')"
>
{{ t('moldMaintain.inspectionResultFail') }}
</view>
<view v-if="String(item?.inspectionResult || '0') === '0'" class="pending-tag">{{ t('moldMaintain.inspectionResultPending') }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
<view class="action-btn back-btn" @click="goBack">{{ t('dashboard.back') }}</view>
<view :class="['action-btn', 'submit-btn', submitLoading ? 'action-btn-disabled' : '']" @click="handleSubmit">{{ t('moldMaintain.submit') }}</view>
</view>
<!-- 叿閫夋嫨寮圭獥 -->
<view v-if="showMoldPicker" class="picker-mask" @click="closeMoldPicker">
<view class="picker-popup" @click.stop>
<view class="picker-header">
<text class="picker-title">{{ t('moldMaintain.selectMold') }}</text>
<view class="picker-close" @click="closeMoldPicker">
<uni-icons type="close" size="24" color="#6b7280"></uni-icons>
</view>
</view>
<view class="picker-search">
<input v-model="moldSearchKeyword" class="picker-search-input" :placeholder="t('moldMaintain.searchMold')" confirm-type="search" @confirm="searchMold" />
</view>
<scroll-view scroll-y class="picker-content">
<view
v-for="mold in moldList"
:key="mold.id"
:class="['picker-item', moldInfo.id === String(mold.id) ? 'picker-item-active' : '']"
@click="selectMold(mold)"
>
<view class="picker-item-main">
<text class="picker-item-name">{{ mold.name || mold.code || '-' }}</text>
<text class="picker-item-code">{{ mold.code || '' }}</text>
</view>
<text v-if="mold.productName" class="picker-item-desc">{{ mold.productName }}</text>
</view>
<view v-if="moldLoading" class="picker-loading">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!moldList.length" class="picker-empty">{{ t('moldMaintain.noMoldData') }}</view>
<view v-else-if="moldFinished" class="picker-loading">{{ t('functionCommon.noMoreData') }}</view>
</scroll-view>
</view>
</view>
<!-- 模板选择弹窗 -->
<view v-if="showTemplatePicker" class="picker-mask" @click="closeTemplatePicker">
<view class="picker-popup" @click.stop>
<view class="picker-header">
<text class="picker-title">{{ t('moldMaintain.selectTemplate') }}</text>
<view class="picker-close" @click="closeTemplatePicker">
<uni-icons type="close" size="24" color="#6b7280"></uni-icons>
</view>
</view>
<scroll-view scroll-y class="picker-content" @scrolltolower="loadMoreTemplates">
<view
v-for="template in templateList"
:key="template.id"
:class="['picker-item', selectedTemplate?.id === template.id ? 'picker-item-active' : '']"
@click="selectTemplate(template)"
>
<view class="picker-item-main">
<text class="picker-item-name">{{ template.planName || '-' }}</text>
<text :class="['picker-item-type', String(template.planType) === '1' ? 'type-inspect' : 'type-maintain']">
{{ String(template.planType) === '1' ? t('moldMaintain.taskTypeInspect') : t('moldMaintain.taskTypeMaintain') }}
</text>
</view>
<text v-if="template.description" class="picker-item-desc">{{ template.description }}</text>
</view>
<view v-if="templateLoading" class="picker-loading">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!templateList.length" class="picker-empty">{{ t('moldMaintain.noTemplate') }}</view>
<view v-else-if="templateFinished" class="picker-loading">{{ t('functionCommon.noMoreData') }}</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { createMoldTicketDirect, getPlanMaintenancePage, getSubjectList, getMoldBrandDetail, uploadMoldCheckImage } from '@/api/mes/moldCheck'
import { getBrandList } from '@/api/mes/mold'
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
// Mold info, loaded from route params or picker.
const moldInfo = reactive({
id: '',
code: '',
name: '',
productName: '',
moldSize: '',
status: '',
statusLabel: '',
currentDevice: ''
})
const taskName = ref('')
const selectedTemplate = ref(null)
const templateList = ref([])
const showTemplatePicker = ref(false)
const templateLoading = ref(false)
const templateFinished = ref(false)
const templatePageNo = ref(1)
const templatePageSize = ref(20)
const inspectionItems = ref([])
const ticketResultEditable = ref(false)
const ticketResultBackup = ref(null)
const submitLoading = ref(false)
const statusClass = ref('')
// Mold picker.
const showMoldPicker = ref(false)
const moldList = ref([])
const moldLoading = ref(false)
const moldFinished = ref(true)
const moldSearchKeyword = ref('')
onLoad(async (query) => {
await initAllDict()
const moldId = String(query?.id || '')
if (moldId) {
// ID
const urlCode = query?.code ? decodeURIComponent(query.code) : ''
const urlName = query?.name ? decodeURIComponent(query.name) : ''
if (urlCode || urlName) {
//
moldInfo.id = moldId
moldInfo.code = urlCode
moldInfo.name = urlName
moldInfo.productName = query?.productName ? decodeURIComponent(query.productName) : ''
moldInfo.moldSize = query?.moldSize ? decodeURIComponent(query.moldSize) : ''
moldInfo.status = String(query?.status || '')
moldInfo.currentDevice = query?.currentDevice ? decodeURIComponent(query.currentDevice) : ''
moldInfo.statusLabel = getDictLabel(DICT_TYPE.ERP_MOLD_STATUS, moldInfo.status, moldInfo.status)
updateStatusClass()
} else {
await loadMoldInfo(moldId)
}
}
// ID
})
async function loadMoldInfo(id) {
try {
const res = await getMoldBrandDetail(id)
const data = res && res.data !== undefined ? res.data : res
moldInfo.id = String(data?.id || id)
moldInfo.code = String(data?.code || '')
moldInfo.name = String(data?.name || '')
moldInfo.productName = String(data?.productName || '')
moldInfo.moldSize = String(data?.moldSize || '')
moldInfo.status = String(data?.status || '')
moldInfo.currentDevice = String(data?.currentDevice || '')
moldInfo.statusLabel = getDictLabel(DICT_TYPE.ERP_MOLD_STATUS, moldInfo.status, moldInfo.status)
updateStatusClass()
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
}
}
function updateStatusClass() {
const status = String(moldInfo.status)
if (status === '1') {
statusClass.value = 'status-success'
} else if (status === '2') {
statusClass.value = 'status-warning'
} else if (status === '3') {
statusClass.value = 'status-danger'
} else {
statusClass.value = 'status-default'
}
}
function openMoldPicker() {
showMoldPicker.value = true
if (!moldList.value.length) {
loadMoldList(true)
}
}
function closeMoldPicker() {
showMoldPicker.value = false
}
async function loadMoldList(reset) {
if (moldLoading.value) return
if (reset) {
moldList.value = []
}
moldLoading.value = true
try {
const params = {}
if (moldSearchKeyword.value.trim()) {
params.name = moldSearchKeyword.value.trim()
}
const res = await getBrandList(params)
const root = res && res.data !== undefined ? res.data : res
const list = Array.isArray(root) ? root : (root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || [])
moldList.value = reset ? list : [...moldList.value, ...list]
moldFinished.value = true
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
moldLoading.value = false
}
}
function searchMold() {
loadMoldList(true)
}
function selectMold(mold) {
moldInfo.id = String(mold.id || '')
moldInfo.code = String(mold.code || '')
moldInfo.name = String(mold.name || '')
moldInfo.productName = String(mold.productName || '')
moldInfo.moldSize = String(mold.moldSize || '')
moldInfo.status = String(mold.status || '')
moldInfo.currentDevice = String(mold.currentDevice || '')
moldInfo.statusLabel = getDictLabel(DICT_TYPE.ERP_MOLD_STATUS, moldInfo.status, moldInfo.status)
updateStatusClass()
closeMoldPicker()
}
function openTemplatePicker() {
showTemplatePicker.value = true
if (!templateList.value.length) {
loadTemplates(true)
}
}
function closeTemplatePicker() {
showTemplatePicker.value = false
}
async function loadTemplates(reset) {
if (templateLoading.value) return
if (reset) {
templatePageNo.value = 1
templateFinished.value = false
}
templateLoading.value = true
try {
const res = await getPlanMaintenancePage({
pageNo: templatePageNo.value,
pageSize: templatePageSize.value
})
const root = res && res.data !== undefined ? res.data : res
const list = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || []
const total = root?.total ?? root?.data?.total ?? 0
templateList.value = reset ? list : [...templateList.value, ...list]
templateFinished.value = templateList.value.length >= total || list.length < templatePageSize.value
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
templateLoading.value = false
}
}
async function loadMoreTemplates() {
if (templateLoading.value || templateFinished.value) return
templatePageNo.value += 1
await loadTemplates(false)
}
function selectTemplate(template) {
selectedTemplate.value = template
ticketResultEditable.value = false
ticketResultBackup.value = null
loadInspectionItems(template.id)
closeTemplatePicker()
}
async function loadInspectionItems(planId) {
try {
inspectionItems.value = []
const res = await getSubjectList(planId)
const root = res && res.data !== undefined ? res.data : res
const items = Array.isArray(root) ? root : (root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || root?.data || [])
inspectionItems.value = Array.isArray(items) ? items.map((item, index) => ({
id: item.id,
subjectId: item.id,
inspectionItemName: item.subjectName ?? item.inspectionItemName ?? '',
inspectionMethod: item.inspectionMethod ?? '',
judgmentCriteria: item.judgmentCriteria ?? item.subjectStandard ?? '',
valueType: item.valueType ?? '',
textInput: item.textInput ?? '',
inspectionResult: String(item.inspectionResult ?? '0'),
images: item.images ?? '',
remark: item.remark ?? '',
required: item.required ?? item.isRequired ?? item.needCheck ?? item.mustCheck ?? false,
sort: index + 1
})) : []
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
}
}
function isRequiredItem(item) {
const value = item?.required ?? item?.isRequired ?? item?.needCheck ?? item?.mustCheck
return value === true || value === 1 || value === '1'
}
function shouldShowInput(item) {
const valueType = String(item?.valueType ?? '')
return valueType === '0' || valueType === '2' || !!String(item?.textInput || '').trim()
}
function isNumericValueType(value) {
const normalized = String(value ?? '')
const label = String(valueTypeText(value) || '').toLowerCase()
return normalized === '2' || /鏁板€紎鏁板瓧|number|numeric|digit|decimal/.test(label)
}
function numberInputValue(item) {
const value = Number(item?.textInput)
return Number.isFinite(value) ? value : 0
}
function onNumberInputChange(item, value) {
if (!ticketResultEditable.value) return
item.textInput = String(value)
}
function inspectionMethodText(value) {
return getDictLabel(DICT_TYPE.INSPECTION_METHOD, value, textValue(value))
}
function valueTypeText(value) {
return getDictLabel(DICT_TYPE.VALUE_TYPES, value, textValue(value))
}
function parseImages(value) {
if (!value) return []
if (Array.isArray(value)) return value.map((item) => String(item).trim()).filter(Boolean)
return String(value).split(',').map((item) => item.trim()).filter(Boolean)
}
function joinImages(value) {
return parseImages(value).join(',')
}
function resultOptionClass(item, value) {
const current = String(item?.inspectionResult || '')
if (current !== String(value)) return ''
return String(value) === '1' ? 'result-option-active' : 'result-option-danger'
}
function setDecision(item, value) {
if (!ticketResultEditable.value) return
item.inspectionResult = String(value)
}
async function chooseImages(item) {
if (!ticketResultEditable.value) return
try {
const currentCount = parseImages(item.images).length
const remain = Math.max(0, 3 - currentCount)
if (!remain) {
uni.showToast({ title: t('moldMaintain.maxUploadCount'), icon: 'none' })
return
}
const res = await uni.chooseImage({ count: remain, sizeType: ['compressed'] })
const files = Array.isArray(res?.tempFilePaths) ? res.tempFilePaths : []
if (!files.length) return
uni.showLoading({ title: t('functionCommon.uploading'), mask: true })
const uploaded = []
for (const filePath of files) {
const uploadRes = await uploadMoldCheckImage(filePath)
const url = String(uploadRes?.data?.fileUrl || uploadRes?.data?.url || uploadRes?.data || uploadRes?.url || '').trim()
if (url) uploaded.push(url)
}
item.images = joinImages([...parseImages(item.images), ...uploaded])
} catch (error) {
const message = String(error?.errMsg || '')
if (!message.includes('cancel')) {
uni.showToast({ title: t('functionCommon.uploadImageFailed'), icon: 'none' })
}
} finally {
uni.hideLoading()
}
}
function removeImage(item, index) {
if (!ticketResultEditable.value) return
const next = parseImages(item.images)
next.splice(index, 1)
item.images = next.join(',')
}
function previewImage(current, urls) {
uni.previewImage({ current, urls })
}
function normalizeTextInput(value) {
if (value === 0 || value === '0') return '0'
const text = String(value ?? '').trim()
return text || undefined
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function goBack() {
uni.navigateBack()
}
function toggleTicketResultEditable() {
if (ticketResultEditable.value) {
if (ticketResultBackup.value) {
inspectionItems.value = JSON.parse(JSON.stringify(ticketResultBackup.value))
ticketResultBackup.value = null
}
ticketResultEditable.value = false
return
}
ticketResultBackup.value = JSON.parse(JSON.stringify(inspectionItems.value))
ticketResultEditable.value = true
}
async function handleSubmit() {
if (submitLoading.value) return
if (!moldInfo.id) {
uni.showToast({ title: t('moldMaintain.selectMoldError'), icon: 'none' })
return
}
if (!taskName.value.trim()) {
uni.showToast({ title: t('moldMaintain.placeholderTaskName'), icon: 'none' })
return
}
if (!selectedTemplate.value) {
uni.showToast({ title: t('moldMaintain.selectTemplateError'), icon: 'none' })
return
}
const hasUnselected = inspectionItems.value.some((item) => String(item?.inspectionResult || '0') === '0')
if (ticketResultEditable.value && inspectionItems.value.length && hasUnselected) {
uni.showToast({ title: t('moldMaintain.selectAllDecisionError'), icon: 'none' })
return
}
submitLoading.value = true
try {
await createMoldTicketDirect({
name: taskName.value.trim(),
taskType: '2',
moldList: String(moldInfo.id),
projectForm: String(selectedTemplate.value.id),
ticketResultsList: inspectionItems.value.map((item) => ({
id: item.id,
subjectId: item.subjectId,
inspectionItemName: item.inspectionItemName,
inspectionMethod: item.inspectionMethod,
judgmentCriteria: item.judgmentCriteria,
valueType: item.valueType,
textInput: normalizeTextInput(item.textInput),
inspectionResult: String(item.inspectionResult || '0'),
images: joinImages(item.images),
remark: item.remark,
sort: item.sort
}))
})
uni.setStorageSync('moldMaintainListNeedRefresh', '1')
uni.showToast({ title: t('moldMaintain.submitSuccess'), icon: 'success' })
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (error) {
uni.showToast({ title: t('moldMaintain.submitFailed'), icon: 'none' })
} finally {
submitLoading.value = false
}
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f5f7fb; }
.detail-scroll { height: calc(100vh - 172rpx); }
.content-section { padding: 20rpx 24rpx 28rpx; }
.section-card { background: #ffffff; border-radius: 20rpx; padding: 24rpx; margin-bottom: 20rpx; border: 1rpx solid #eef2f7; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.04); }
.section-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 22rpx; padding-bottom: 18rpx; border-bottom: 1rpx solid #f1f5f9; }
.section-icon { width: 40rpx; height: 40rpx; border-radius: 10rpx; background: #eff6ff; display: flex; align-items: center; justify-content: center; }
.section-title { font-size: 32rpx; font-weight: 600; color: #1f2937; }
.mold-select-field { margin-bottom: 20rpx; }
.mold-select-area { display: flex; align-items: center; justify-content: space-between; min-height: 92rpx; padding: 16rpx 22rpx; background: #f8fafc; border: 1rpx solid #e5e7eb; border-radius: 14rpx; box-sizing: border-box; }
.mold-select-area.selected { background: #f9fbff; border-color: #bfdbfe; box-shadow: 0 4rpx 12rpx rgba(31, 124, 255, 0.08); }
.mold-select-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6rpx; }
.mold-select-placeholder { font-size: 28rpx; color: #9ca3af; }
.mold-select-value { font-size: 28rpx; font-weight: 600; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mold-select-subtext { font-size: 24rpx; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mold-info-panel { padding: 20rpx; background: #f8fafc; border: 1rpx solid #e8eef6; border-radius: 16rpx; }
.mold-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: #ffffff; border: 1rpx solid #eef2f7; border-radius: 14rpx; overflow: hidden; }
.mold-info-item { min-width: 0; display: flex; flex-direction: column; gap: 8rpx; padding: 18rpx 20rpx; border-right: 1rpx solid #f1f5f9; border-bottom: 1rpx solid #f1f5f9; }
.mold-info-item:nth-child(2n) { border-right: 0; }
.mold-info-item:nth-last-child(-n + 2) { border-bottom: 0; }
.mold-info-label { font-size: 23rpx; color: #8a94a6; }
.mold-info-value { font-size: 28rpx; color: #334155; line-height: 1.35; word-break: break-all; }
.status-tag { display: inline-flex; align-items: center; align-self: flex-start; padding: 6rpx 16rpx; border-radius: 999rpx; font-size: 24rpx; }
.status-success { color: #15803d; background: #dcfce7; }
.status-warning { color: #d97706; background: #fef3c7; }
.status-danger { color: #dc2626; background: #fee2e2; }
.status-default { color: #6b7280; background: #f3f4f6; }
.form-field { display: flex; flex-direction: column; gap: 12rpx; }
.form-field + .form-field { margin-top: 24rpx; }
.form-label { font-size: 26rpx; color: #4b5563; font-weight: 500; }
.required-star { color: #ef4444; font-size: 28rpx; margin-left: 4rpx; }
.form-input { width: 100%; height: 88rpx; padding: 0 24rpx; background: #f8fafc; border-radius: 14rpx; font-size: 28rpx; color: #374151; box-sizing: border-box; }
.template-select { display: flex; align-items: center; justify-content: space-between; height: 88rpx; padding: 0 24rpx; background: #f8fafc; border-radius: 14rpx; }
.template-text { font-size: 28rpx; color: #374151; }
.template-text.placeholder { color: #9ca3af; }
.inspection-section { display: flex; flex-direction: column; gap: 16rpx; }
.inspection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; padding: 0 4rpx; }
.inspection-toolbar-title { font-size: 30rpx; font-weight: 700; color: #1f2937; }
.edit-toggle-btn { height: 60rpx; padding: 0 18rpx; border-radius: 999rpx; border: 1rpx solid #bfdbfe; background: #eff6ff; color: #1f7cff; font-size: 24rpx; font-weight: 600; display: flex; align-items: center; gap: 8rpx; flex-shrink: 0; }
.edit-toggle-btn.active { border-color: #fecaca; background: #fef2f2; color: #ef4444; }
.inspection-list { display: flex; flex-direction: column; gap: 20rpx; }
.inspection-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.inspection-header { display: flex; align-items: center; gap: 16rpx; }
.inspection-index { width: 44rpx; height: 44rpx; border-radius: 50%; background: #1f7cff; color: #ffffff; font-size: 24rpx; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.inspection-title { flex: 1; min-width: 0; font-size: 30rpx; font-weight: 600; color: #1f2937; }
.required-tag { padding: 8rpx 16rpx; border-radius: 10rpx; background: #e8fff2; color: #22c55e; font-size: 24rpx; }
.inspection-fields { margin-top: 16rpx; display: flex; flex-direction: column; gap: 14rpx; }
.field-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20rpx; }
.field-label { width: 170rpx; font-size: 27rpx; color: #9ca3af; flex-shrink: 0; }
.field-value { flex: 1; text-align: right; font-size: 28rpx; color: #374151; line-height: 1.5; }
.field-block { display: flex; flex-direction: column; gap: 14rpx; }
.block-label { width: auto; }
.result-option-group { display: flex; align-items: center; gap: 16rpx; flex-wrap: wrap; }
.result-option { min-width: 160rpx; height: 72rpx; padding: 0 24rpx; border-radius: 14rpx; border: 1rpx solid #d1d5db; color: #6b7280; font-size: 30rpx; display: flex; align-items: center; justify-content: center; background: #ffffff; }
.result-option-active { border-color: #60a5fa; background: #eff6ff; color: #1f7cff; }
.result-option-danger { border-color: #fca5a5; background: #fef2f2; color: #ef4444; }
.result-option-disabled { opacity: 0.55; }
.pending-tag { padding: 8rpx 14rpx; border-radius: 10rpx; background: #f3f4f6; color: #9ca3af; font-size: 24rpx; }
.form-textarea { width: 100%; min-height: 76rpx; max-height: 108rpx; background: #f8fafc; border-radius: 12rpx; padding: 10rpx 16rpx; font-size: 26rpx; color: #374151; box-sizing: border-box; }
.number-box-wrap { width: 100%; }
.number-box-wrap-inline { width: 320rpx; }
.number-box-wrap :deep(.uni-numbox) { width: 100%; }
.number-box-wrap :deep(.uni-numbox__value) { flex: 1; height: 60rpx; font-size: 24rpx; }
.number-box-wrap :deep(.uni-numbox-btns) { min-width: 60rpx; justify-content: center; }
.number-box-wrap :deep(.uni-numbox--text) { font-size: 18px; }
.image-list { display: flex; flex-wrap: wrap; gap: 12rpx; }
.image-item { position: relative; }
.result-image { width: 140rpx; height: 140rpx; border-radius: 16rpx; background: #f3f4f6; }
.image-remove { position: absolute; top: -12rpx; right: -12rpx; width: 36rpx; height: 36rpx; border-radius: 18rpx; background: rgba(15, 23, 42, 0.72); color: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 24rpx; }
.image-upload { width: 140rpx; height: 140rpx; border-radius: 16rpx; border: 2rpx dashed #cbd5e1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-upload-icon { font-size: 60rpx; color: #94a3b8; line-height: 1; }
.hint { padding: 48rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); }
.action-btn { flex: 1; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #eef2f7; color: #475569; }
.submit-btn { background: #1f4b79; color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
.picker-mask { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 100; display: flex; align-items: flex-end; }
.picker-popup { width: 100%; background: #ffffff; border-radius: 24rpx 24rpx 0 0; padding-bottom: env(safe-area-inset-bottom); }
.picker-header { display: flex; align-items: center; justify-content: space-between; padding: 28rpx 32rpx; border-bottom: 1rpx solid #e5e7eb; }
.picker-title { font-size: 34rpx; font-weight: 600; color: #1f2937; }
.picker-close { width: 48rpx; height: 48rpx; display: flex; align-items: center; justify-content: center; }
.picker-search { padding: 16rpx 32rpx; }
.picker-search-input { width: 100%; height: 72rpx; padding: 0 20rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 26rpx; box-sizing: border-box; }
.picker-content { max-height: 60vh; }
.picker-item { padding: 24rpx 32rpx; border-bottom: 1rpx solid #f3f4f6; }
.picker-item-main { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
.picker-item-name { font-size: 28rpx; color: #374151; flex: 1; min-width: 0; }
.picker-item-code { font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.picker-item-type { padding: 6rpx 16rpx; border-radius: 8rpx; font-size: 22rpx; flex-shrink: 0; }
.type-inspect { color: #1d4ed8; background: #dbeafe; }
.type-maintain { color: #15803d; background: #dcfce7; }
.picker-item-desc { font-size: 24rpx; color: #9ca3af; margin-top: 8rpx; }
.picker-item-active { background: #eff6ff; }
.picker-item-active .picker-item-name { color: #1f7cff; font-weight: 600; }
.picker-loading { padding: 24rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.picker-empty { padding: 48rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
</style>

@ -0,0 +1,425 @@
<template>
<view class="page-container">
<view class="fixed-header">
<NavBar :title="t('moldMaintain.detailTitle')" />
</view>
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<view class="hero-card">
<view class="hero-body">
<text class="hero-title">{{ textValue(detailData.moldName) }}</text>
<view class="hero-meta-row">
<view class="hero-meta-item">
<text class="hero-meta-label">{{ t('moldMaintain.taskType') }}:</text>
<text class="hero-meta-value">{{ planTypeText }}</text>
</view>
<view class="hero-meta-item hero-meta-item-right">
<text class="hero-meta-label">{{ t('moldMaintain.planNo') }}:</text>
<text class="hero-meta-value">{{ textValue(detailData.planNo) }}</text>
</view>
</view>
</view>
</view>
<view class="progress-sticky-wrap">
<view class="progress-card">
<view class="progress-header">
<text class="progress-title">{{ t('moldMaintain.progressTitle') }}</text>
<text class="progress-count">{{ completedCount }}/{{ totalCount }}</text>
</view>
<view class="progress-track">
<view class="progress-bar" :style="{ width: `${progressPercent}%` }"></view>
</view>
</view>
</view>
<view v-if="resultLoading" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!resultList.length" class="hint">{{ t('moldMaintain.noResultData') }}</view>
<view v-else class="result-list">
<view v-for="(item, index) in resultList" :key="item.id || index" class="result-card">
<view class="result-header">
<view class="result-index">{{ index + 1 }}</view>
<text class="result-title">{{ textValue(item.inspectionItemName) }}</text>
<view v-if="isRequiredItem(item)" class="required-tag">{{ t('moldMaintain.requiredText') }}</view>
</view>
<view class="result-fields">
<view class="field-row">
<text class="field-label">{{ t('moldMaintain.inspectionMethod') }}</text>
<text class="field-value">{{ inspectionMethodText(item.inspectionMethod) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('moldMaintain.judgmentCriteria') }}</text>
<text class="field-value">{{ textValue(item.judgmentCriteria) }}</text>
</view>
<view v-if="shouldShowInput(item) && isEditableItem(item) && isNumericValueType(item.valueType)" class="field-row">
<text class="field-label">{{ t('moldMaintain.textInput') }}</text>
<view class="number-box-wrap number-box-wrap-inline">
<uni-number-box
:modelValue="numberInputValue(item)"
:min="-999999999"
:max="999999999"
:step="1"
@change="onNumberInputChange(item, $event)"
/>
</view>
</view>
<view v-else-if="shouldShowInput(item)" class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.textInput') }}</text>
<textarea
v-if="isEditableItem(item)"
v-model="item.textInput"
class="form-textarea"
:placeholder="t('moldMaintain.inputPlaceholder')"
maxlength="500"
/>
<view v-else class="readonly-box">{{ textInputDisplay(item) }}</view>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.images') }}</text>
<view class="image-list">
<view v-for="(img, imgIndex) in parseImages(item.images)" :key="imgIndex" class="image-item">
<image
:src="encodeURI(img)"
class="result-image"
mode="aspectFill"
@click="previewImage(encodeURI(img), parseImages(item.images).map(i => encodeURI(i)))"
/>
<view v-if="isEditableItem(item)" class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
<view v-if="isEditableItem(item) && parseImages(item.images).length < 3" class="image-upload" @click="chooseImages(item)">
<text class="image-upload-icon">+</text>
</view>
</view>
</view>
<view v-if="item.remark" class="field-row field-row-top">
<text class="field-label">{{ t('moldMaintain.remark') }}</text>
<text class="field-value multiline">{{ textValue(item.remark) }}</text>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldMaintain.resultText') }}</text>
<view class="result-option-group">
<view
:class="['result-option', resultOptionClass(item, '1')]"
@click="setDecision(item, '1')"
>
{{ t('moldMaintain.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2')]"
@click="setDecision(item, '2')"
>
{{ t('moldMaintain.inspectionResultFail') }}
</view>
<view v-if="isEditableItem(item) && String(item?.inspectionResult || '') === '0'" class="pending-tag">{{ t('moldMaintain.inspectionResultPending') }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
<view class="action-btn back-btn" @click="goBack">{{ t('dashboard.back') }}</view>
<view v-if="!isExecuted" :class="['action-btn', 'save-btn', saveLoading ? 'action-btn-disabled' : '']" @click="handleSave">{{ t('functionCommon.save') }}</view>
</view>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { batchUpdateMoldCheckResults, getMoldCheckResultsPage, uploadMoldCheckImage } from '@/api/mes/moldCheck'
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
const { t } = useI18n()
const detailData = reactive({})
const resultList = ref([])
const resultLoading = ref(false)
const managementId = ref('')
const saveLoading = ref(false)
const isExecuted = computed(() => Number(detailData.jobStatus) === 1)
const planTypeText = computed(() => {
const value = String(detailData.planType || '')
if (value === '1') return t('moldMaintain.taskTypeInspect')
if (value === '2') return t('moldMaintain.taskTypeMaintain')
return textValue(detailData.planType)
})
const totalCount = computed(() => resultList.value.length)
const completedCount = computed(() => resultList.value.filter((item) => isItemCompleted(item)).length)
const progressPercent = computed(() => {
if (!totalCount.value) return 0
return Math.min(100, Math.round((completedCount.value / totalCount.value) * 100))
})
onLoad(async (query) => {
managementId.value = String(query?.id || '')
if (!managementId.value) {
uni.showToast({ title: t('functionCommon.noIdView'), icon: 'none' })
return
}
await initAllDict()
try {
const cached = uni.getStorageSync('moldMaintainDetail')
if (cached) {
Object.assign(detailData, JSON.parse(cached))
uni.removeStorageSync('moldMaintainDetail')
}
} catch (error) {}
await fetchResults()
})
async function fetchResults() {
resultLoading.value = true
try {
const res = await getMoldCheckResultsPage({ managementId: managementId.value })
const root = res && res.data !== undefined ? res.data : res
const items = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || root?.data || root || []
resultList.value = (Array.isArray(items) ? items : []).map((item) => ({
...item,
__editable: !isExecuted.value && String(item?.inspectionResult ?? '0') === '0'
}))
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
resultLoading.value = false
}
}
function isRequiredItem(item) {
const value = item?.required ?? item?.isRequired ?? item?.needCheck ?? item?.mustCheck
return value === true || value === 1 || value === '1'
}
function isPendingItem(item) {
return String(item?.inspectionResult ?? '') === '0'
}
function isEditableItem(item) {
return !isExecuted.value && item?.__editable === true
}
function shouldShowInput(item) {
const valueType = String(item?.valueType ?? '')
return valueType === '0' || valueType === '2' || !!String(item?.textInput || '').trim()
}
function isNumericValueType(value) {
const normalized = String(value ?? '')
const label = String(valueTypeText(value) || '').toLowerCase()
return normalized === '2' || /鏁板€紎鏁板瓧|number|numeric|digit|decimal/.test(label)
}
function textInputDisplay(item) {
const text = String(item?.textInput || '').trim()
return text || t('moldMaintain.inspectionResultPending')
}
function numberInputValue(item) {
const value = Number(item?.textInput)
return Number.isFinite(value) ? value : 0
}
function onNumberInputChange(item, value) {
item.textInput = String(value)
}
function isItemCompleted(item) {
const result = String(item?.inspectionResult ?? '').trim()
return !!result && result !== '0'
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function inspectionMethodText(value) {
return getDictLabel(DICT_TYPE.INSPECTION_METHOD, value, textValue(value))
}
function valueTypeText(value) {
return getDictLabel(DICT_TYPE.VALUE_TYPES, value, textValue(value))
}
function parseImages(value) {
if (!value) return []
if (Array.isArray(value)) return value.map((item) => String(item).trim()).filter(Boolean)
return String(value).split(',').map((item) => item.trim()).filter(Boolean)
}
function joinImages(value) {
return parseImages(value).join(',')
}
function resultOptionClass(item, value) {
const current = String(item?.inspectionResult || '')
if (current !== String(value)) return ''
return String(value) === '1' ? 'result-option-active' : 'result-option-danger'
}
function setDecision(item, value) {
if (!isEditableItem(item)) return
item.inspectionResult = String(value)
}
async function chooseImages(item) {
try {
const currentCount = parseImages(item.images).length
const remain = Math.max(0, 3 - currentCount)
if (!remain) {
uni.showToast({ title: t('moldMaintain.maxUploadCount'), icon: 'none' })
return
}
const res = await uni.chooseImage({ count: remain, sizeType: ['compressed'] })
const files = Array.isArray(res?.tempFilePaths) ? res.tempFilePaths : []
if (!files.length) return
uni.showLoading({ title: t('functionCommon.uploading'), mask: true })
const uploaded = []
for (const filePath of files) {
const uploadRes = await uploadMoldCheckImage(filePath)
const url = String(uploadRes?.data?.fileUrl || uploadRes?.data?.url || uploadRes?.data || uploadRes?.url || '').trim()
if (url) uploaded.push(url)
}
item.images = joinImages([...parseImages(item.images), ...uploaded])
} catch (error) {
const message = String(error?.errMsg || '')
if (!message.includes('cancel')) {
uni.showToast({ title: t('functionCommon.uploadImageFailed'), icon: 'none' })
}
} finally {
uni.hideLoading()
}
}
function removeImage(item, index) {
if (!isEditableItem(item)) return
const next = parseImages(item.images)
next.splice(index, 1)
item.images = next.join(',')
}
function previewImage(current, urls) {
uni.previewImage({ current, urls })
}
function goBack() {
uni.navigateBack()
}
async function handleSave() {
if (saveLoading.value || isExecuted.value) return
const pendingItems = resultList.value.filter((item) => isEditableItem(item))
if (!pendingItems.length) {
uni.navigateBack()
return
}
const hasUnselected = pendingItems.some((item) => String(item?.inspectionResult || '') === '0')
if (hasUnselected) {
uni.showToast({ title: t('moldMaintain.selectAllDecisionError'), icon: 'none' })
return
}
const payload = pendingItems.map((item) => ({
...item,
managementId: item.managementId || managementId.value,
inspectionResult: item.inspectionResult,
images: joinImages(item.images),
textInput: normalizeTextInput(item.textInput)
}))
saveLoading.value = true
try {
await batchUpdateMoldCheckResults(payload)
detailData.jobStatus = 1
uni.setStorageSync('moldMaintainListNeedRefresh', '1')
uni.showToast({ title: t('functionCommon.saveSuccess'), icon: 'success' })
await fetchResults()
} catch (error) {
uni.showToast({ title: t('functionCommon.saveFailed'), icon: 'none' })
} finally {
saveLoading.value = false
}
}
function normalizeTextInput(value) {
if (value === 0 || value === '0') return '0'
const text = String(value ?? '').trim()
return text || undefined
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f5f7fb; }
.fixed-header { position: sticky; top: 0; z-index: 20; }
.detail-scroll { height: calc(100vh - 212rpx); }
.content-section { padding: 20rpx 24rpx 28rpx; }
.hero-card { display: flex; gap: 20rpx; background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.hero-body { flex: 1; min-width: 0; }
.hero-title { display: block; font-size: 42rpx; line-height: 1.2; font-weight: 700; color: #1f2937; }
.hero-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 24rpx; margin-top: 16rpx; }
.hero-meta-item { display: flex; align-items: center; min-width: 0; }
.hero-meta-item-right { justify-content: flex-end; flex-shrink: 0; }
.hero-meta-label { font-size: 25rpx; color: #9ca3af; }
.hero-meta-value { font-size: 25rpx; color: #6b7280; }
.progress-sticky-wrap { position: sticky; top: 0; z-index: 15; padding-top: 20rpx; padding-bottom: 8rpx; background: #f5f7fb; }
.progress-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx; }
.progress-title { font-size: 30rpx; font-weight: 600; color: #374151; }
.progress-count { font-size: 40rpx; font-weight: 700; color: #1f7cff; }
.progress-track { height: 16rpx; border-radius: 999rpx; background: #edf2f7; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999rpx; background: linear-gradient(90deg, #1f7cff, #4da3ff); }
.result-list { margin-top: 20rpx; display: flex; flex-direction: column; gap: 20rpx; }
.result-card { background: #ffffff; border-radius: 24rpx; padding: 24rpx; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.05); }
.result-header { display: flex; align-items: center; gap: 16rpx; }
.result-index { width: 44rpx; height: 44rpx; border-radius: 50%; background: #1f7cff; color: #ffffff; font-size: 24rpx; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.result-title { flex: 1; min-width: 0; font-size: 40rpx; font-weight: 700; color: #1f2937; }
.required-tag { padding: 8rpx 16rpx; border-radius: 10rpx; background: #e8fff2; color: #22c55e; font-size: 24rpx; }
.result-fields { margin-top: 16rpx; display: flex; flex-direction: column; gap: 18rpx; }
.field-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20rpx; }
.field-row-top { align-items: flex-start; }
.field-label { width: 170rpx; font-size: 27rpx; color: #9ca3af; flex-shrink: 0; }
.field-value { flex: 1; text-align: right; font-size: 28rpx; color: #374151; line-height: 1.5; }
.field-value.multiline { text-align: left; }
.field-block { display: flex; flex-direction: column; gap: 14rpx; }
.block-label { width: auto; }
.result-option-group { display: flex; align-items: center; gap: 16rpx; flex-wrap: wrap; }
.result-option { min-width: 160rpx; height: 72rpx; padding: 0 24rpx; border-radius: 14rpx; border: 1rpx solid #d1d5db; color: #6b7280; font-size: 30rpx; display: flex; align-items: center; justify-content: center; background: #ffffff; }
.result-option-active { border-color: #60a5fa; background: #eff6ff; color: #1f7cff; }
.result-option-danger { border-color: #fca5a5; background: #fef2f2; color: #ef4444; }
.pending-tag { padding: 8rpx 14rpx; border-radius: 10rpx; background: #f3f4f6; color: #9ca3af; font-size: 24rpx; }
.readonly-box { min-height: 84rpx; padding: 18rpx 20rpx; border-radius: 14rpx; background: #f8fafc; font-size: 28rpx; color: #374151; line-height: 1.5; }
.form-textarea { width: 100%; min-height: 76rpx; max-height: 108rpx; background: #f8fafc; border-radius: 12rpx; padding: 10rpx 16rpx; font-size: 26rpx; color: #374151; box-sizing: border-box; }
.number-box-wrap { width: 100%; }
.number-box-wrap-inline { width: 320rpx; }
.number-box-wrap :deep(.uni-numbox) { width: 100%; }
.number-box-wrap :deep(.uni-numbox__value) { flex: 1; height: 60rpx; font-size: 24rpx; }
.number-box-wrap :deep(.uni-numbox-btns) { min-width: 60rpx; justify-content: center; }
.number-box-wrap :deep(.uni-numbox--text) { font-size: 18px; }
.image-list { display: flex; flex-wrap: wrap; gap: 12rpx; }
.image-item { position: relative; }
.result-image { width: 140rpx; height: 140rpx; border-radius: 16rpx; background: #f3f4f6; }
.image-remove { position: absolute; top: -12rpx; right: -12rpx; width: 36rpx; height: 36rpx; border-radius: 18rpx; background: rgba(15, 23, 42, 0.72); color: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 24rpx; }
.image-upload { width: 140rpx; height: 140rpx; border-radius: 16rpx; border: 2rpx dashed #cbd5e1; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-upload-icon { font-size: 60rpx; color: #94a3b8; line-height: 1; }
.hint { padding: 48rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); }
.action-btn { flex: 1; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #eef2f7; color: #475569; }
.save-btn { background: #1f4b79; color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
</style>

@ -0,0 +1,560 @@
<template>
<view class="page-container">
<NavBar :title="t('moldMaintain.moduleName')" />
<view class="filter-bar">
<view class="keyword-box">
<input v-model="searchKeyword" class="keyword-input" :placeholder="t('moldMaintain.searchPlaceholder')"
:focus="keywordFocus" confirm-type="search" @blur="keywordFocus = false" @input="handleKeywordInput"
@confirm="handleSearch" />
</view>
<picker mode="selector" :range="jobStatusLabels" :value="jobStatusIndex" @change="onJobStatusChange">
<view class="status-box">
<text class="status-box-text">{{ currentJobStatusLabel }}</text>
<uni-icons type="bottom" size="14" color="#9ca3af"></uni-icons>
</view>
</picker>
<view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
</view>
<scroll-view scroll-y class="list-scroll" :scroll-top="scrollTop" @scroll="onScroll" @scrolltolower="loadMore"
:lower-threshold="80">
<view class="list-wrap">
<view v-for="item in list" :key="item.id" class="task-card" @click="openDetail(item)">
<view class="card-header">
<view class="header-main">
<view class="header-left">
<text
:class="['task-type-tag', String(item.planType) === '1' ? 'tag-inspect' : 'tag-maintain']">{{
taskTypeText(item.planType) }}</text>
<text class="task-name">{{ textValue(item.planNo) }}</text>
</view>
<view class="header-tags">
<text :class="['record-tag', jobStatusClass(item.jobStatus)]">{{
jobStatusText(item.jobStatus) }}</text>
<text :class="['record-tag', jobResultClass(item.jobResult)]">{{
jobResultText(item.jobResult) }}</text>
</view>
</view>
</view>
<view class="card-body">
<view class="row">
<text class="label">{{ t('moldMaintain.moldName') }}</text>
<text class="value">{{ textValue(item.moldName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldMaintain.template') }}</text>
<text class="value">{{ textValue(item.configName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldMaintain.operator') }}</text>
<text class="value">{{ textValue(item.operatorName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldMaintain.taskTime') }}</text>
<text class="value">{{ formatDateTime(item.taskTime) }}</text>
</view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!list.length" class="hint">{{ t('moldMaintain.empty') }}</view>
<view v-else-if="loadingMore" class="hint">{{ t('functionCommon.loadingMore') }}</view>
<view v-else-if="finished" class="hint">{{ t('functionCommon.noMoreData') }}</view>
</view>
</scroll-view>
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
<uni-icons type="arrow-up" size="20" color="#1a3a5c"></uni-icons>
</view>
<view class="add-btn" @click="goAdd">
<text class="add-icon">+</text>
</view>
</view>
</template>
<script setup>
import { computed, nextTick, ref } from 'vue'
import { onLoad, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getMoldCheckPage } from '@/api/mes/moldCheck'
import { DICT_TYPE, getDictLabel, initAllDict, useDict } from '@/utils/dict'
const { t } = useI18n()
const searchKeyword = ref('')
const selectedJobStatus = ref('0')
const list = ref([])
const loading = ref(false)
const loadingMore = ref(false)
const finished = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const scrollTop = ref(0)
const showGoTop = ref(false)
const keywordFocus = ref(false)
let searchTimer = null
//
const { job_status: jobStatusDictOptions } = useDict(DICT_TYPE.JOB_STATUS)
const jobStatusOptions = computed(() => {
const dictList = jobStatusDictOptions.value || []
return [
{ label: t('functionCommon.all'), value: '' },
...dictList.map((item) => ({ label: item.label, value: item.value }))
]
})
const jobStatusLabels = computed(() => jobStatusOptions.value.map((item) => item.label))
const jobStatusIndex = computed(() => {
const index = jobStatusOptions.value.findIndex((item) => item.value === selectedJobStatus.value)
return index >= 0 ? index : 0
})
const currentJobStatusLabel = computed(() => {
const current = jobStatusOptions.value.find((item) => item.value === selectedJobStatus.value)
return current ? current.label : t('functionCommon.all')
})
onLoad(async () => {
await initAllDict()
await fetchList(true)
})
onShow(() => {
activateKeywordFocus()
if (uni.getStorageSync('moldMaintainListNeedRefresh') === '1') {
uni.removeStorageSync('moldMaintainListNeedRefresh')
fetchList(true)
}
})
onUnload(() => {
clearSearchTimer()
})
function normalizePageData(res) {
const root = res && res.data !== undefined ? res.data : res
const candidateList = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || []
const candidateTotal = root?.total ?? root?.data?.total ?? (Array.isArray(candidateList) ? candidateList.length : 0)
return {
list: Array.isArray(candidateList) ? candidateList : [],
total: Number(candidateTotal || 0)
}
}
onReachBottom(() => {
loadMore()
})
async function fetchList(reset) {
if (reset) {
pageNo.value = 1
finished.value = false
}
if (pageNo.value === 1) {
loading.value = true
} else {
loadingMore.value = true
}
try {
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
planNo: searchKeyword.value.trim() || undefined,
planType: '2',
jobStatus: selectedJobStatus.value || undefined
}
const res = await getMoldCheckPage(params)
const page = normalizePageData(res)
list.value = reset ? page.list : [...list.value, ...page.list]
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
} catch (error) {
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
loading.value = false
loadingMore.value = false
}
}
function handleSearch() {
clearSearchTimer()
uni.hideKeyboard()
fetchList(true)
}
function handleKeywordInput() {
clearSearchTimer()
searchTimer = setTimeout(() => {
fetchList(true)
}, 300)
}
async function resetFilters() {
clearSearchTimer()
searchKeyword.value = ''
selectedJobStatus.value = '0'
activateKeywordFocus()
await nextTick()
await fetchList(true)
}
function onJobStatusChange(event) {
const index = Number(event?.detail?.value || 0)
selectedJobStatus.value = jobStatusOptions.value[index]?.value ?? ''
fetchList(true)
}
async function loadMore() {
if (loading.value || loadingMore.value || finished.value) return
pageNo.value += 1
await fetchList(false)
}
function openDetail(item) {
if (!item?.id) {
uni.showToast({ title: t('functionCommon.noIdView'), icon: 'none' })
return
}
uni.setStorageSync('moldMaintainDetail', JSON.stringify(item))
uni.navigateTo({
url: `/pages_function/pages/moldMaintain/detail?id=${encodeURIComponent(String(item.id))}`
})
}
function goAdd() {
uni.navigateTo({
url: '/pages_function/pages/moldMaintain/add'
})
}
function onScroll(event) {
showGoTop.value = (event?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function activateKeywordFocus() {
keywordFocus.value = false
nextTick(() => {
keywordFocus.value = true
})
}
function clearSearchTimer() {
if (searchTimer) {
clearTimeout(searchTimer)
searchTimer = null
}
}
function taskTypeText(value) {
const normalized = String(value)
if (normalized === '1') return t('moldMaintain.taskTypeInspect')
if (normalized === '2') return t('moldMaintain.taskTypeMaintain')
return textValue(value)
}
function jobStatusText(value) {
return getDictLabel(DICT_TYPE.JOB_STATUS, value, textValue(value))
}
function jobStatusClass(value) {
const normalized = String(value)
if (normalized === '2') return 'text-primary'
if (normalized === '1') return 'text-success'
if (normalized === '3') return 'text-danger'
if (normalized === '4') return 'text-muted'
return 'text-warning'
}
function jobResultText(value) {
const normalized = String(value).trim().toUpperCase()
if (normalized === '1' || normalized === 'OK') return t('moldMaintain.jobResultOk')
if (normalized === '2' || normalized === 'NG') return t('moldMaintain.jobResultNg')
if (!normalized || normalized === '0') return '-'
return textValue(value)
}
function jobResultClass(value) {
const normalized = String(value).trim().toUpperCase()
if (normalized === '1' || normalized === 'OK') return 'text-success'
if (normalized === '2' || normalized === 'NG') return 'text-danger'
return ''
}
function textValue(value) {
if (value === 0) return '0'
if (value === null || value === undefined) return '-'
const text = String(value).trim()
return text || '-'
}
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day, hour = 0, minute = 0, second = 0] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
const date = new Date(Number(value))
if (Number.isNaN(date.getTime())) return textValue(value)
const pad = (num) => String(num).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
}
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f4f5f7;
}
.filter-bar {
display: flex;
align-items: center;
gap: 12rpx;
padding: 18rpx 4rpx 0rpx;
}
.keyword-box,
.status-box,
.reset-filter-btn {
min-width:100rpx;
height: 66rpx;
background: #ffffff;
border: 1rpx solid #d9dde5;
box-sizing: border-box;
display: flex;
align-items: center;
}
.keyword-box {
flex: 1;
min-width: 0;
padding: 0 28rpx;
}
.keyword-input {
width: 100%;
font-size: 24rpx;
color: #374151;
}
.status-box {
flex-shrink: 0;
justify-content: space-between;
padding: 0 28rpx;
min-width: 160rpx;
}
.status-box-text {
font-size: 24rpx;
color: #374151;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reset-filter-btn {
justify-content: center;
font-size: 24rpx;
color: #4b5563;
}
.list-scroll {
height: calc(100vh - 194rpx);
}
.list-wrap {
padding: 0 4rpx 140rpx;
}
.task-card {
position: relative;
margin-top: 20rpx;
padding: 28rpx;
background: #fff;
border-radius: 22rpx;
box-shadow: 0 8rpx 28rpx rgba(15, 23, 42, 0.06);
}
.card-header {
margin-bottom: 18rpx;
}
.header-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.header-left {
min-width: 0;
flex: 1;
}
.header-tags {
display: flex;
align-items: center;
gap: 12rpx;
flex-shrink: 0;
}
.task-name {
flex: 1;
font-size: 32rpx;
font-weight: 700;
color: #0f172a;
margin-left: 12rpx
}
.task-type-tag {
padding: 8rpx 18rpx;
border-radius: 8rpx;
font-size: 22rpx;
}
.record-tag {
padding: 8rpx 18rpx;
border-radius: 999rpx;
font-size: 22rpx;
line-height: 1;
background: #e2e8f0;
color: #64748b;
}
.tag-inspect {
color: #1d4ed8;
background: #dbeafe;
}
.tag-maintain {
color: #15803d;
background: #dcfce7;
}
.card-body .row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20rpx;
}
.label {
width: 180rpx;
font-size: 25rpx;
color: #94a3b8;
}
.value {
flex: 1;
text-align: right;
font-size: 27rpx;
color: #334155;
line-height: 1.5;
}
.text-success {
color: #16a34a;
}
.text-danger {
color: #dc2626;
}
.text-warning {
color: #f59e0b;
}
.text-primary {
color: #2563eb;
}
.text-muted {
color: #94a3b8;
}
.record-tag.text-success {
color: #15803d;
background: #dcfce7;
}
.record-tag.text-danger {
color: #dc2626;
background: #fee2e2;
}
.record-tag.text-warning {
color: #d97706;
background: #fef3c7;
}
.record-tag.text-primary {
color: #1d4ed8;
background: #dbeafe;
}
.record-tag.text-muted {
color: #64748b;
background: #e2e8f0;
}
.hint {
padding: 36rpx 0;
text-align: center;
color: #94a3b8;
font-size: 26rpx;
}
.go-top-btn {
position: fixed;
right: 28rpx;
bottom: calc(140rpx + env(safe-area-inset-bottom));
width: 88rpx;
height: 88rpx;
border-radius: 44rpx;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.12);
display: flex;
align-items: center;
justify-content: center;
}
.add-btn,
.go-top-btn {
position: fixed;
right: 32rpx;
width: 92rpx;
height: 92rpx;
border-radius: 46rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 14rpx 30rpx rgba(24, 63, 108, 0.24);
}
.add-btn {
right: 28rpx;
bottom: calc(56rpx + env(safe-area-inset-bottom));
background: #1f4b79;
}
.add-icon {
color: #ffffff;
font-size: 64rpx;
line-height: 1;
margin-top: -4rpx;
}
</style>

@ -0,0 +1,233 @@
<template>
<view class="page-container">
<NavBar :title="t('moldPressureNet.historyTitle')" />
<view class="filter-bar">
<view class="keyword-box">
<input
v-model="brandNameKeyword"
class="keyword-input"
:placeholder="t('moldPressureNet.searchBrandName')"
confirm-type="search"
@confirm="fetchList(true)"
/>
</view>
<view class="keyword-box time-box" @click="openTimePicker">
<text :class="pressureNetTimeFilter ? 'time-text' : 'time-placeholder'">{{ pressureNetTimeFilter || t('moldPressureNet.pressureNetTime') }}</text>
<uni-icons type="calendar" size="18" color="#9ca3af"></uni-icons>
</view>
<view class="filter-btn" @click="fetchList(true)">{{ t('functionCommon.search') }}</view>
<view class="filter-btn" @click="resetFilter">{{ t('functionCommon.reset') }}</view>
</view>
<scroll-view scroll-y class="list-scroll" @scrolltolower="loadMore" :lower-threshold="80">
<view class="list-wrap">
<view v-for="item in list" :key="item.id" class="record-card">
<view class="record-header">
<text class="record-title">{{ item.moldName || '-' }}</text>
<text class="record-time">{{ formatDateTime(item.pressureNetTime) }}</text>
</view>
<view class="record-body">
<view class="record-row">
<text class="record-label">{{ t('moldPressureNet.moldGroup') }}</text>
<text class="record-value">{{ item.moldBrandName || '-' }}</text>
</view>
<view class="record-row">
<text class="record-label">{{ t('moldPressureNet.createTime') }}</text>
<text class="record-value">{{ formatDateTime(item.createTime) }}</text>
</view>
<view class="record-row">
<text class="record-label">{{ t('moldPressureNet.remark') }}</text>
<text class="record-value">{{ item.remark || '-' }}</text>
</view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!list.length" class="hint">{{ t('moldPressureNet.noHistory') }}</view>
<view v-else-if="loadingMore" class="hint">{{ t('functionCommon.loadingMore') }}</view>
<view v-else-if="finished" class="hint">{{ t('functionCommon.noMoreData') }}</view>
</view>
</scroll-view>
<!-- 压网时间筛选弹窗 -->
<view v-if="showTimePicker" class="picker-mask" @click="closeTimePicker">
<view class="picker-popup" @click.stop>
<view class="picker-header">
<text class="picker-title">{{ t('moldPressureNet.pressureNetTime') }}</text>
<view class="picker-close" @click="closeTimePicker">
<uni-icons type="close" size="24" color="#6b7280"></uni-icons>
</view>
</view>
<view class="picker-body">
<picker mode="date" :value="tempDate" @change="onDateChange">
<view class="time-field">{{ tempDate || $t('moldPressureNet.selectDate') }}</view>
</picker>
</view>
<view class="picker-footer-bar">
<view class="picker-footer-btn secondary" @click="clearTimeFilter">{{ $t('functionCommon.clear') }}</view>
<view class="picker-footer-btn primary" @click="confirmTimeFilter">{{ $t('common.complete') }}</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getPressureNetRecordPage } from '@/api/mes/mold'
const { t } = useI18n()
const list = ref([])
const loading = ref(false)
const loadingMore = ref(false)
const finished = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const brandNameKeyword = ref('')
const pressureNetTimeFilter = ref('')
//
const showTimePicker = ref(false)
const tempDate = ref('')
onLoad(() => {
fetchList(true)
})
onReachBottom(() => {
loadMore()
})
function normalizePageData(res) {
const root = res && res.data !== undefined ? res.data : res
const rows = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || []
const total = root?.total ?? root?.data?.total ?? (Array.isArray(rows) ? rows.length : 0)
return {
list: Array.isArray(rows) ? rows : [],
total: Number(total || 0)
}
}
async function fetchList(reset) {
if (reset) {
pageNo.value = 1
finished.value = false
}
if (pageNo.value === 1) {
loading.value = true
} else {
loadingMore.value = true
}
try {
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value
}
const brandName = brandNameKeyword.value.trim()
if (brandName) params.moldBrandName = brandName
const timeVal = pressureNetTimeFilter.value.trim()
if (timeVal) params.pressureNetTime = timeVal
const res = await getPressureNetRecordPage(params)
const page = normalizePageData(res)
list.value = reset ? page.list : [...list.value, ...page.list]
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
} catch (error) {
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
loading.value = false
loadingMore.value = false
}
}
async function loadMore() {
if (loading.value || loadingMore.value || finished.value) return
pageNo.value += 1
await fetchList(false)
}
function resetFilter() {
brandNameKeyword.value = ''
pressureNetTimeFilter.value = ''
fetchList(true)
}
//
function openTimePicker() {
tempDate.value = pressureNetTimeFilter.value || ''
showTimePicker.value = true
}
function closeTimePicker() {
showTimePicker.value = false
}
function onDateChange(event) {
tempDate.value = event?.detail?.value || ''
}
function confirmTimeFilter() {
pressureNetTimeFilter.value = tempDate.value
closeTimePicker()
fetchList(true)
}
function clearTimeFilter() {
pressureNetTimeFilter.value = ''
tempDate.value = ''
closeTimePicker()
fetchList(true)
}
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day, hour = 0, minute = 0, second = 0] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
const date = new Date(value)
if (Number.isNaN(date.getTime())) return String(value)
const pad = (num) => String(num).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background: #f5f7fb; }
.filter-bar { display: flex; align-items: center; gap: 12rpx; padding: 18rpx 24rpx 0; flex-wrap: wrap; }
.keyword-box, .filter-btn { height: 66rpx; background: #ffffff; border: 1rpx solid #d9dde5; box-sizing: border-box; display: flex; align-items: center; }
.keyword-box { flex: 1; min-width: 200rpx; padding: 0 20rpx; }
.keyword-input { width: 100%; font-size: 24rpx; color: #374151; }
.time-box { justify-content: space-between; min-width: 220rpx; }
.time-text { font-size: 24rpx; color: #374151; }
.time-placeholder { font-size: 24rpx; color: #9ca3af; }
.filter-btn { flex-shrink: 0; justify-content: center; min-width: 104rpx; padding: 0 18rpx; font-size: 24rpx; color: #4b5563; }
.list-scroll { height: calc(100vh - 170rpx); }
.list-wrap { padding: 4rpx 24rpx 40rpx; }
.record-card { margin-top: 20rpx; padding: 24rpx; border-radius: 16rpx; background: #ffffff; box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.06); }
.record-header { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; padding-bottom: 18rpx; border-bottom: 1rpx solid #eef2f7; }
.record-title { font-size: 32rpx; font-weight: 700; color: #111827; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-time { flex-shrink: 0; font-size: 24rpx; color: #1f7cff; }
.record-body { margin-top: 16rpx; display: flex; flex-direction: column; gap: 12rpx; }
.record-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20rpx; }
.record-label { width: 150rpx; flex-shrink: 0; font-size: 26rpx; color: #8a94a6; }
.record-value { flex: 1; text-align: right; font-size: 27rpx; color: #374151; line-height: 1.5; word-break: break-all; }
.hint { padding: 40rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.picker-mask { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 100; display: flex; align-items: flex-end; }
.picker-popup { width: 100%; background: #ffffff; border-radius: 24rpx 24rpx 0 0; padding-bottom: env(safe-area-inset-bottom); }
.picker-header { display: flex; align-items: center; justify-content: space-between; padding: 28rpx 32rpx; border-bottom: 1rpx solid #e5e7eb; }
.picker-title { font-size: 34rpx; font-weight: 600; color: #1f2937; }
.picker-close { width: 48rpx; height: 48rpx; display: flex; align-items: center; justify-content: center; }
.picker-body { padding: 32rpx; }
.time-field { height: 80rpx; display: flex; align-items: center; justify-content: center; background: #f8fafc; border: 1rpx solid #e5e7eb; border-radius: 12rpx; font-size: 28rpx; color: #374151; }
.picker-footer-bar { display: flex; gap: 16rpx; padding: 16rpx 32rpx 24rpx; }
.picker-footer-btn { flex: 1; height: 80rpx; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; font-size: 28rpx; font-weight: 600; }
.picker-footer-btn.secondary { background: #f3f4f6; color: #6b7280; }
.picker-footer-btn.primary { background: linear-gradient(135deg, #1f7cff, #3b82f6); color: #ffffff; }
</style>

@ -0,0 +1,432 @@
<template>
<view class="page-container">
<NavBar :title="t('moldPressureNet.moduleName')">
<template #right>
<view class="nav-right-btn" @click="goHistory">
<uni-icons type="clock" size="22" color="#1f7cff"></uni-icons>
<text class="nav-right-text">{{ t('moldPressureNet.history') }}</text>
</view>
</template>
</NavBar>
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<!-- 模具组信息 -->
<view class="section-card">
<view class="section-header">
<view class="section-icon">
<uni-icons type="info" size="24" color="#1f7cff"></uni-icons>
</view>
<text class="section-title">{{ t('moldPressureNet.moldGroup') }}</text>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldPressureNet.selectMoldGroup') }}<text class="required-star">*</text></text>
<view :class="['mold-select-area', selectedBrand.id ? 'selected' : '']" @click="openBrandPicker">
<view class="mold-select-content">
<text :class="selectedBrand.id ? 'mold-select-value' : 'mold-select-placeholder'">{{ selectedBrand.id ? (selectedBrand.name || selectedBrand.code || '-') : t('moldPressureNet.selectMoldGroup') }}</text>
<text v-if="selectedBrand.id" class="mold-select-subtext">{{ selectedBrand.code || t('moldPressureNet.reSelectMoldGroup') }}</text>
</view>
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
</view>
</view>
<view v-if="selectedBrand.id" class="mold-info-panel">
<view class="mold-info-grid">
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldPressureNet.moldGroupCode') }}</text>
<text class="mold-info-value">{{ selectedBrand.code || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldPressureNet.moldGroupName') }}</text>
<text class="mold-info-value">{{ selectedBrand.name || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldPressureNet.product') }}</text>
<text class="mold-info-value">{{ selectedBrand.productName || '-' }}</text>
</view>
</view>
</view>
</view>
<!-- 子模具信息 -->
<view class="section-card">
<view class="section-header">
<view class="section-icon">
<uni-icons type="settings" size="24" color="#1f7cff"></uni-icons>
</view>
<text class="section-title">{{ t('moldPressureNet.subMold') }}</text>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldPressureNet.selectSubMold') }}<text class="required-star">*</text></text>
<view :class="['mold-select-area', selectedSubMoldIds.length ? 'selected' : '']" @click="openSubMoldPicker">
<view class="mold-select-content">
<text :class="selectedSubMoldIds.length ? 'mold-select-value' : 'mold-select-placeholder'">{{ selectedSubMoldIds.length ? t('moldPressureNet.selectedCount', { count: selectedSubMoldIds.length }) : t('moldPressureNet.selectSubMold') }}</text>
<text v-if="selectedSubMoldIds.length" class="mold-select-subtext">{{ t('moldPressureNet.reSelectSubMold') }}</text>
</view>
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
</view>
</view>
<view v-if="selectedSubMoldIds.length" class="sub-mold-tags">
<view v-for="item in selectedSubMoldItems" :key="item.id" class="sub-mold-tag">
<text class="sub-mold-tag-text">{{ item.name || item.code || '-' }}</text>
<view class="sub-mold-tag-remove" @click="removeSubMold(item.id)">×</view>
</view>
</view>
</view>
<!-- 换网信息 -->
<view class="section-card">
<view class="section-header">
<view class="section-icon">
<uni-icons type="compose" size="24" color="#1f7cff"></uni-icons>
</view>
<text class="section-title">{{ t('moldPressureNet.replaceInfo') }}</text>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldPressureNet.pressureNetTime') }}<text class="required-star">*</text></text>
<uni-datetime-picker v-model="pressureNetTime" type="datetime" :clear-icon="false" />
</view>
<view class="form-field">
<text class="form-label">{{ t('moldPressureNet.remark') }}</text>
<textarea
v-model="remark"
class="form-textarea"
:placeholder="t('moldPressureNet.remarkPlaceholder')"
maxlength="200"
/>
</view>
</view>
</view>
</scroll-view>
<view class="action-bar">
<view class="action-btn back-btn" @click="goBack">{{ t('functionCommon.cancel') }}</view>
<view :class="['action-btn', 'submit-btn', submitLoading ? 'action-btn-disabled' : '']" @click="handleSubmit">
{{ t('moldPressureNet.confirmReplace') }}
</view>
</view>
<!-- 模具组选择弹窗 -->
<view v-if="showBrandPicker" class="picker-mask" @click="closeBrandPicker">
<view class="picker-popup" @click.stop>
<view class="picker-header">
<text class="picker-title">{{ t('moldPressureNet.selectMoldGroup') }}</text>
<view class="picker-close" @click="closeBrandPicker">
<uni-icons type="close" size="24" color="#6b7280"></uni-icons>
</view>
</view>
<view class="picker-search">
<input v-model="brandKeyword" class="picker-search-input" :placeholder="t('moldPressureNet.searchMoldGroup')" confirm-type="search" @confirm="loadBrandList" />
</view>
<scroll-view scroll-y class="picker-content">
<view
v-for="item in brandList"
:key="item.id"
:class="['picker-item', selectedBrand.id === String(item.id) ? 'picker-item-active' : '']"
@click="selectBrand(item)"
>
<view class="picker-item-main">
<text class="picker-item-name">{{ item.name || item.code || '-' }}</text>
<text class="picker-item-code">{{ item.code || '' }}</text>
</view>
<text v-if="item.productName" class="picker-item-desc">{{ item.productName }}</text>
</view>
<view v-if="brandLoading" class="picker-loading">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!brandList.length" class="picker-empty">{{ t('moldPressureNet.noMoldGroup') }}</view>
</scroll-view>
</view>
</view>
<!-- 子模具选择弹窗多选 -->
<view v-if="showSubMoldPicker" class="picker-mask" @click="closeSubMoldPicker">
<view class="picker-popup" @click.stop>
<view class="picker-header">
<text class="picker-title">{{ t('moldPressureNet.selectSubMold') }}</text>
<view class="picker-close" @click="closeSubMoldPicker">
<uni-icons type="close" size="24" color="#6b7280"></uni-icons>
</view>
</view>
<scroll-view scroll-y class="picker-content">
<view
v-for="item in subMoldList"
:key="item.id"
:class="['picker-item', isSubMoldSelected(item.id) ? 'picker-item-active' : '']"
@click="toggleSubMold(item)"
>
<view class="picker-item-main">
<view class="picker-checkbox">
<view :class="['checkbox-icon', isSubMoldSelected(item.id) ? 'checked' : '']">
<text v-if="isSubMoldSelected(item.id)" class="checkbox-tick"></text>
</view>
</view>
<view class="picker-item-info">
<text class="picker-item-name">{{ item.name || item.code || '-' }}</text>
<text class="picker-item-code">{{ item.code || '' }}</text>
</view>
</view>
</view>
<view v-if="subMoldLoading" class="picker-loading">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!subMoldList.length" class="picker-empty">{{ t('moldPressureNet.noSubMold') }}</view>
</scroll-view>
<view class="picker-footer">
<text class="picker-footer-count">{{ t('moldPressureNet.selectedCount', { count: tempSelectedIds.length }) }}</text>
<view class="picker-footer-btn" @click="confirmSubMoldSelection">{{ t('common.complete') }}</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { createPressureNetRecord, getBrandList, getMoldList } from '@/api/mes/mold'
const { t } = useI18n()
const selectedBrand = reactive({ id: '', name: '', code: '', productName: '' })
const selectedSubMoldIds = ref([])
const pressureNetTime = ref('')
const remark = ref('')
const submitLoading = ref(false)
//
const brandList = ref([])
const brandLoading = ref(false)
const brandKeyword = ref('')
const showBrandPicker = ref(false)
//
const subMoldList = ref([])
const subMoldLoading = ref(false)
const showSubMoldPicker = ref(false)
const tempSelectedIds = ref([])
//
const selectedSubMoldItems = computed(() => {
return subMoldList.value.filter((item) => selectedSubMoldIds.value.includes(String(item.id)))
})
onLoad(async (query) => {
const brandId = String(query?.brandId || query?.moldBrandId || '')
if (brandId) {
selectedBrand.id = brandId
selectedBrand.name = query?.brandName ? decodeURIComponent(query.brandName) : ''
selectedBrand.code = query?.brandCode ? decodeURIComponent(query.brandCode) : ''
selectedBrand.productName = query?.productName ? decodeURIComponent(query.productName) : ''
await loadSubMolds()
}
})
//
function openBrandPicker() {
showBrandPicker.value = true
if (!brandList.value.length) loadBrandList()
}
function closeBrandPicker() {
showBrandPicker.value = false
}
async function loadBrandList() {
brandLoading.value = true
try {
const params = {}
const keyword = brandKeyword.value.trim()
if (keyword) params.name = keyword
const res = await getBrandList(params)
const root = res && res.data !== undefined ? res.data : res
brandList.value = Array.isArray(root) ? root : (root?.list || root?.rows || root?.records || root?.data?.list || [])
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
brandLoading.value = false
}
}
async function selectBrand(item) {
selectedBrand.id = String(item.id || '')
selectedBrand.name = String(item.name || '')
selectedBrand.code = String(item.code || '')
selectedBrand.productName = String(item.productName || '')
selectedSubMoldIds.value = []
closeBrandPicker()
await loadSubMolds()
}
//
function openSubMoldPicker() {
if (!selectedBrand.id) {
uni.showToast({ title: t('moldPressureNet.selectMoldGroupError'), icon: 'none' })
return
}
tempSelectedIds.value = [...selectedSubMoldIds.value]
showSubMoldPicker.value = true
if (!subMoldList.value.length) loadSubMolds()
}
function closeSubMoldPicker() {
showSubMoldPicker.value = false
}
function isSubMoldSelected(id) {
return tempSelectedIds.value.includes(String(id))
}
function toggleSubMold(item) {
const id = String(item.id)
const index = tempSelectedIds.value.indexOf(id)
if (index > -1) {
tempSelectedIds.value.splice(index, 1)
} else {
tempSelectedIds.value.push(id)
}
}
function confirmSubMoldSelection() {
selectedSubMoldIds.value = [...tempSelectedIds.value]
closeSubMoldPicker()
}
function removeSubMold(id) {
const strId = String(id)
selectedSubMoldIds.value = selectedSubMoldIds.value.filter((item) => item !== strId)
}
async function loadSubMolds() {
if (!selectedBrand.id) return
subMoldLoading.value = true
try {
const res = await getMoldList({ brandId: selectedBrand.id })
const root = res && res.data !== undefined ? res.data : res
subMoldList.value = Array.isArray(root) ? root : (root?.list || root?.rows || root?.records || root?.data?.list || [])
} catch (error) {
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
subMoldLoading.value = false
}
}
function goBack() {
uni.navigateBack()
}
function goHistory() {
uni.navigateTo({ url: '/pages_function/pages/moldPressureNet/history' })
}
async function handleSubmit() {
if (submitLoading.value) return
if (!selectedBrand.id) {
uni.showToast({ title: t('moldPressureNet.selectMoldGroupError'), icon: 'none' })
return
}
if (!selectedSubMoldIds.value.length) {
uni.showToast({ title: t('moldPressureNet.selectSubMoldError'), icon: 'none' })
return
}
if (!pressureNetTime.value) {
uni.showToast({ title: t('moldPressureNet.selectReplaceTimeError'), icon: 'none' })
return
}
submitLoading.value = true
try {
// web MoldMaintainView.vue:
const createReqVOList = selectedSubMoldIds.value.map((moldId) => {
const selected = subMoldList.value.find((item) => String(item.id) === moldId)
return {
moldBrandId: selectedBrand.id,
moldBrandName: selectedBrand.name,
moldId: moldId,
moldName: selected?.name || '',
pressureNetTime: pressureNetTime.value,
remark: remark.value.trim() || undefined
}
})
await createPressureNetRecord(createReqVOList)
uni.showToast({ title: t('moldPressureNet.submitSuccess'), icon: 'success' })
//
selectedBrand.id = ''
selectedBrand.name = ''
selectedBrand.code = ''
selectedBrand.productName = ''
selectedSubMoldIds.value = []
pressureNetTime.value = ''
remark.value = ''
} catch (error) {
uni.showToast({ title: t('moldPressureNet.submitFailed'), icon: 'none' })
} finally {
submitLoading.value = false
}
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f5f7fb; }
.nav-right-btn { display: flex; align-items: center; gap: 6rpx; padding: 8rpx 18rpx; background: #ffffff; border-radius: 999rpx; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08); }
.nav-right-text { font-size: 24rpx; color: #374151; font-weight: 500; }
.detail-scroll { height: calc(100vh - 172rpx); }
.content-section { padding: 20rpx 24rpx 28rpx; }
.section-card { background: #ffffff; border-radius: 20rpx; padding: 24rpx; margin-bottom: 20rpx; border: 1rpx solid #eef2f7; box-shadow: 0 6rpx 18rpx rgba(15, 23, 42, 0.04); }
.section-header { display: flex; align-items: center; gap: 12rpx; margin-bottom: 22rpx; padding-bottom: 18rpx; border-bottom: 1rpx solid #f1f5f9; }
.section-icon { width: 40rpx; height: 40rpx; border-radius: 10rpx; background: #eff6ff; display: flex; align-items: center; justify-content: center; }
.section-title { font-size: 32rpx; font-weight: 600; color: #1f2937; }
.form-field { display: flex; flex-direction: column; gap: 12rpx; }
.form-field + .form-field { margin-top: 24rpx; }
.form-label { font-size: 26rpx; color: #4b5563; font-weight: 500; }
.required-star { color: #ef4444; font-size: 28rpx; margin-left: 4rpx; }
.mold-select-area { display: flex; align-items: center; justify-content: space-between; min-height: 92rpx; padding: 16rpx 22rpx; background: #f8fafc; border: 1rpx solid #e5e7eb; border-radius: 14rpx; box-sizing: border-box; }
.mold-select-area.selected { background: #f9fbff; border-color: #bfdbfe; box-shadow: 0 4rpx 12rpx rgba(31, 124, 255, 0.08); }
.mold-select-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6rpx; }
.mold-select-placeholder { font-size: 28rpx; color: #9ca3af; }
.mold-select-value { font-size: 28rpx; font-weight: 600; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mold-select-subtext { font-size: 24rpx; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mold-info-panel { padding: 20rpx; background: #f8fafc; border: 1rpx solid #e8eef6; border-radius: 16rpx; margin-top: 20rpx; }
.mold-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: #ffffff; border: 1rpx solid #eef2f7; border-radius: 14rpx; overflow: hidden; }
.mold-info-item { min-width: 0; display: flex; flex-direction: column; gap: 8rpx; padding: 18rpx 20rpx; border-right: 1rpx solid #f1f5f9; border-bottom: 1rpx solid #f1f5f9; }
.mold-info-item:nth-child(2n) { border-right: 0; }
.mold-info-item:nth-last-child(-n + 2) { border-bottom: 0; }
.mold-info-label { font-size: 23rpx; color: #8a94a6; }
.mold-info-value { font-size: 28rpx; color: #334155; line-height: 1.35; word-break: break-all; }
.sub-mold-tags { display: flex; flex-wrap: wrap; gap: 12rpx; margin-top: 16rpx; }
.sub-mold-tag { display: flex; align-items: center; gap: 8rpx; padding: 10rpx 18rpx; background: #eff6ff; border: 1rpx solid #bfdbfe; border-radius: 999rpx; }
.sub-mold-tag-text { font-size: 24rpx; color: #1f7cff; max-width: 200rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-mold-tag-remove { width: 32rpx; height: 32rpx; border-radius: 50%; background: rgba(31, 124, 255, 0.15); display: flex; align-items: center; justify-content: center; font-size: 22rpx; color: #1f7cff; }
.template-select { display: flex; align-items: center; justify-content: space-between; height: 88rpx; padding: 0 24rpx; background: #f8fafc; border-radius: 14rpx; }
.template-text { font-size: 28rpx; color: #374151; }
.template-text.placeholder { color: #9ca3af; }
.form-textarea { width: 100%; min-height: 120rpx; background: #f8fafc; border-radius: 14rpx; padding: 18rpx 22rpx; font-size: 26rpx; color: #374151; box-sizing: border-box; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 18rpx; padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom)); background: #ffffff; box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06); }
.action-btn { flex: 1; height: 84rpx; border-radius: 16rpx; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 600; }
.back-btn { background: #eef2f7; color: #475569; }
.submit-btn { background: #1f4b79; color: #ffffff; }
.action-btn-disabled { background: #94a3b8; }
.picker-mask { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 100; display: flex; align-items: flex-end; }
.picker-popup { width: 100%; background: #ffffff; border-radius: 24rpx 24rpx 0 0; padding-bottom: env(safe-area-inset-bottom); }
.picker-header { display: flex; align-items: center; justify-content: space-between; padding: 28rpx 32rpx; border-bottom: 1rpx solid #e5e7eb; }
.picker-title { font-size: 34rpx; font-weight: 600; color: #1f2937; }
.picker-close { width: 48rpx; height: 48rpx; display: flex; align-items: center; justify-content: center; }
.picker-search { padding: 16rpx 32rpx; }
.picker-search-input { width: 100%; height: 72rpx; padding: 0 20rpx; background: #f3f4f6; border-radius: 12rpx; font-size: 26rpx; box-sizing: border-box; }
.picker-content { max-height: 60vh; }
.picker-item { padding: 24rpx 32rpx; border-bottom: 1rpx solid #f3f4f6; }
.picker-item-main { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
.picker-item-name { font-size: 28rpx; color: #374151; flex: 1; min-width: 0; }
.picker-item-code { font-size: 24rpx; color: #9ca3af; flex-shrink: 0; }
.picker-item-desc { font-size: 24rpx; color: #9ca3af; margin-top: 8rpx; }
.picker-item-active { background: #eff6ff; }
.picker-item-active .picker-item-name { color: #1f7cff; font-weight: 600; }
.picker-loading { padding: 24rpx 0; text-align: center; color: #9ca3af; font-size: 26rpx; }
.picker-empty { padding: 48rpx; text-align: center; color: #9ca3af; font-size: 26rpx; }
.picker-checkbox { flex-shrink: 0; margin-right: 8rpx; }
.checkbox-icon { width: 40rpx; height: 40rpx; border-radius: 8rpx; border: 2rpx solid #d1d5db; background: #ffffff; display: flex; align-items: center; justify-content: center; }
.checkbox-icon.checked { background: #1f7cff; border-color: #1f7cff; }
.checkbox-tick { color: #ffffff; font-size: 24rpx; font-weight: 700; line-height: 1; }
.picker-item-info { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
.picker-footer { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 32rpx; border-top: 1rpx solid #e5e7eb; }
.picker-footer-count { font-size: 26rpx; color: #6b7280; }
.picker-footer-btn { height: 72rpx; padding: 0 40rpx; border-radius: 12rpx; background: linear-gradient(135deg, #1f7cff, #3b82f6); color: #ffffff; font-size: 28rpx; font-weight: 600; display: flex; align-items: center; justify-content: center; }
</style>

@ -927,20 +927,20 @@ function goBack() {
.page-footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
gap: 20rpx;
padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
gap: 18rpx;
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #ffffff;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06);
}
.footer-btn {
flex: 1;
height: 84rpx;
border-radius: 42rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
@ -949,12 +949,12 @@ function goBack() {
}
.footer-btn.cancel {
background: #f3f4f6;
color: #4b5563;
background: #eef2f7;
color: #475569;
}
.footer-btn.confirm {
background: #1f4b79;
color: #ffffff;
}
</style>
</style>

@ -24,9 +24,6 @@
</view>
</picker>
<view class="reset-filter-btn" @click="resetFilters">{{ t('functionCommon.reset') }}</view>
<view class="scan-btn" @click="handleScan">
<uni-icons type="scan" size="22" color="#111827"></uni-icons>
</view>
</view>
<scroll-view
@ -227,51 +224,6 @@ function onStatusFilterChange(event) {
fetchList(true)
}
async function handleScan() {
try {
const res = await uni.scanCode({ scanType: ['qrCode', 'barCode'] })
const result = String(res?.result || '').trim()
if (!result) {
uni.showToast({ title: t('moldRepair.scanUnrecognized'), icon: 'none' })
return
}
const scan = parseMoldScanResult(result)
if (!scan.id) {
uni.showToast({ title: t('moldRepair.scanMoldRequired'), icon: 'none' })
return
}
selectedMoldId.value = scan.id
searchKeyword.value = ''
await fetchList(true)
} catch (error) {
const message = String(error?.errMsg || '')
if (message.includes('cancel')) return
uni.showToast({ title: t('moldRepair.scanFailed'), icon: 'none' })
}
}
function parseMoldScanResult(result) {
const text = String(result || '').trim()
const directMatch = text.match(/^([A-Z_]+)-(\d+)$/i)
if (directMatch) {
return {
type: directMatch[1].toUpperCase(),
id: directMatch[1].toUpperCase() === 'MOLD' ? directMatch[2] : ''
}
}
try {
const parsed = JSON.parse(text)
const type = String(parsed?.type || parsed?.bizType || parsed?.codeType || '').toUpperCase()
const id = String(parsed?.id || parsed?.moldId || parsed?.deviceId || '').trim()
return {
type,
id: type === 'MOLD' && id ? id : ''
}
} catch {
return { type: '', id: '' }
}
}
function canEdit(item) {
return !isProcessedRepair(item?.repairStatus)
}
@ -406,7 +358,7 @@ function textValue(value) {
.filter-bar {
display: grid;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx 64rpx;
grid-template-columns: minmax(0, 1fr) 150rpx 96rpx;
align-items: center;
gap: 14rpx;
padding: 18rpx 4rpx 20rpx;
@ -414,8 +366,7 @@ function textValue(value) {
.keyword-box,
.status-box,
.reset-filter-btn,
.scan-btn {
.reset-filter-btn {
height: 66rpx;
background: #ffffff;
border: 1rpx solid #d9dde5;
@ -452,13 +403,6 @@ function textValue(value) {
color: #a8adb7;
}
.scan-btn {
display: flex;
align-items: center;
justify-content: center;
background: #ffffff;
}
.reset-filter-btn {
display: flex;
align-items: center;

@ -33,7 +33,7 @@
</view>
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.productionLine') }}</text>
<text class="info-value">{{ textValue(device.workshopName) }}</text>
<text class="info-value">{{ getTopLineName(device.deviceLine) }}</text>
</view>
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.currentMold') }}</text>
@ -68,6 +68,7 @@ import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getDeviceLedgerList } from '@/api/mes/moldoperate'
import { getDeviceLineTree } from '@/api/mes/deviceLine'
const { t } = useI18n()
@ -76,6 +77,8 @@ const selectedId = ref(null)
const searchText = ref('')
const loading = ref(false)
const lineInfoMap = ref(new Map())
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
@ -163,13 +166,64 @@ function getCurrentMold(device) {
return staticMold === '-' ? t('moldOperate.noMoldOnDevice') : staticMold
}
function flattenLineTree(nodes, parentId) {
if (!Array.isArray(nodes)) return
for (const node of nodes) {
if (node.id != null && node.name != null) {
lineInfoMap.value.set(String(node.id), {
id: node.id,
name: node.name,
parentId: node.parentId != null ? node.parentId : (parentId || null),
parentChain: node.parentChain || ''
})
}
if (Array.isArray(node.children)) {
flattenLineTree(node.children, node.id)
}
}
}
function getTopLineName(deviceLineId) {
if (deviceLineId == null) return '-'
const node = lineInfoMap.value.get(String(deviceLineId))
if (!node) return '-'
if (node.parentChain) {
const firstId = node.parentChain.split(',')[0]?.trim()
if (firstId) {
const topNode = lineInfoMap.value.get(firstId)
if (topNode) return topNode.name
}
}
let current = node
const visited = new Set()
while (current.parentId != null && current.parentId > 0 && !visited.has(current.id)) {
visited.add(current.id)
const parent = lineInfoMap.value.get(String(current.parentId))
if (!parent) break
current = parent
}
return current.name || '-'
}
async function loadLineTree() {
if (lineInfoMap.value.size > 0) return
try {
const res = await getDeviceLineTree()
const tree = (res && res.data !== undefined) ? res.data : res
const nodes = Array.isArray(tree) ? tree : (tree?.list || tree?.children || [])
flattenLineTree(nodes)
} catch (e) {
console.error('load line tree error', e)
}
}
const filteredList = computed(() => {
const keyword = searchText.value.trim().toLowerCase()
if (!keyword) return deviceList.value
return deviceList.value.filter((d) => {
return (d.deviceName || '').toLowerCase().includes(keyword) ||
(d.deviceCode || '').toLowerCase().includes(keyword) ||
(d.workshopName || '').toLowerCase().includes(keyword)
(getTopLineName(d.deviceLine) || '').toLowerCase().includes(keyword)
})
})
@ -203,13 +257,19 @@ function handleConfirm() {
return
}
const device = deviceList.value.find((d) => d.id === selectedId.value)
if (device) {
const lineName = getTopLineName(device.deviceLine)
if (lineName && lineName !== '-') {
device.workshopName = lineName
}
}
// globalData onShow
getApp().globalData._deviceSelectResult = device || null
uni.navigateBack()
}
onShow(async () => {
await loadDevices()
await Promise.allSettled([loadDevices(), loadLineTree()])
})
</script>
@ -343,7 +403,7 @@ onShow(async () => {
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
z-index: 99;
@ -351,16 +411,16 @@ onShow(async () => {
.bottom-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 12rpx;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
background: #1f4b79;
color: #fff;
}
</style>

@ -1,6 +1,14 @@
<template>
<view class="page-container">
<NavBar :title="t('moldOperate.tabDown')" />
<!-- 顶部导航栏 -->
<NavBar :title="t('moldOperate.tabDown')">
<template #right>
<view class="nav-right-btn" @click="goToHistory">
<uni-icons type="clock" size="22" color="#1f7cff"></uni-icons>
<text class="nav-right-text">{{ t('moldPressureNet.history') }}</text>
</view>
</template>
</NavBar>
<!-- 操作按钮区 -->
<view class="action-row">
@ -38,7 +46,7 @@
<view class="grid-row">
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.productionLine') }}</text>
<text class="grid-value">{{ textValue(selectedDevice.workshopName) }}</text>
<text class="grid-value">{{ getTopLineName(selectedDevice.deviceLine) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.deviceStatus') }}</text>
@ -98,13 +106,68 @@
</view>
<!-- 未选设备 -->
<view v-else class="empty-mold-hint" @click="handleSelectDeviceFirst">
<text class="empty-mold-text">+ {{ t('moldOperate.clickSelectDeviceFirst') }}</text>
<view v-else class="empty-mold-hint">
<text class="empty-mold-text empty-gray">{{ t('moldOperate.clickSelectDeviceFirst') }}</text>
</view>
</view>
<!-- 操作人与备注 -->
<view class="section-card">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">{{ t('moldOperate.operator') + ' & ' + t('moldOperate.remark') }}</text>
</view>
<view class="card-body-grid">
<view class="form-row">
<view class="form-cell">
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
<view class="select-dropdown" @click="toggleOperatorDropdown">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedOperator }]">
{{ selectedOperator ? selectedOperator.label : t('moldOperate.placeholderOperator') }}
</text>
<uni-icons type="bottom" size="14" color="#999" class="dropdown-arrow"></uni-icons>
</view>
<view v-if="showOperatorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view
v-for="(item, idx) in operatorOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedOperator?.value === item.value }"
@click.stop="handleSelectOperator(item, idx)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<uni-icons
v-if="selectedOperator?.value === item.value"
type="checkmarkempty"
size="16"
color="#1f7cff"
></uni-icons>
</view>
<view v-if="!operatorOptions.length" class="dropdown-empty"></view>
</scroll-view>
</view>
</view>
</view>
</view>
<view class="form-row">
<view class="form-cell">
<text class="form-label">{{ t('moldOperate.remark') }}</text>
<input
class="form-input"
v-model="remarkText"
:placeholder="t('moldOperate.placeholderRemark')"
:maxlength="200"
/>
</view>
</view>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-actions">
<view class="bottom-btn cancel-btn" @click="handleCancel">{{ t('functionCommon.cancel') }}</view>
<view class="bottom-btn confirm-btn" @click="handleConfirm">{{ t('moldOperate.confirmDismount') }}</view>
</view>
@ -140,9 +203,71 @@ import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getLowerMoldList, getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
import { getDeviceLineTree } from '@/api/mes/deviceLine'
import { getSimpleUserList } from '@/api/system/user'
const { t } = useI18n()
const lineInfoMap = ref(new Map()) // deviceLine id { name, parentId, parentChain }
// 线
function flattenLineTree(nodes, parentId) {
if (!Array.isArray(nodes)) return
for (const node of nodes) {
if (node.id != null && node.name != null) {
lineInfoMap.value.set(String(node.id), {
id: node.id,
name: node.name,
parentId: node.parentId != null ? node.parentId : (parentId || null),
parentChain: node.parentChain || ''
})
}
if (Array.isArray(node.children)) {
flattenLineTree(node.children, node.id)
}
}
}
// 线线 fillTopCategoryInfo
function getTopLineName(deviceLineId) {
if (deviceLineId == null) return '-'
const node = lineInfoMap.value.get(String(deviceLineId))
if (!node) return String(deviceLineId)
// 1 parentChain ID
if (node.parentChain) {
const firstId = node.parentChain.split(',')[0]?.trim()
if (firstId) {
const topNode = lineInfoMap.value.get(firstId)
if (topNode) return topNode.name
}
}
// 2 parentId
let current = node
const visited = new Set()
while (current.parentId != null && current.parentId > 0 && !visited.has(current.id)) {
visited.add(current.id)
const parent = lineInfoMap.value.get(String(current.parentId))
if (!parent) break
current = parent
}
return current.name || String(deviceLineId)
}
// 线
async function loadLineTree() {
if (lineInfoMap.value.size > 0) return
try {
const res = await getDeviceLineTree()
const tree = (res && res.data !== undefined) ? res.data : res
const nodes = Array.isArray(tree) ? tree : (tree?.list || tree?.children || [])
flattenLineTree(nodes)
} catch (e) {
console.error('load line tree error', e)
}
}
// ---- ----
const selectedDevice = ref({})
const deviceOptions = ref([])
@ -155,6 +280,13 @@ const lowerMoldLoading = ref(false)
const moldsLoaded = ref(false)
const tempSelectedMoldId = ref(null)
// ---- ----
const remarkText = ref('')
const operatorOptions = ref([])
const selectedOperator = ref(null)
const operatorIndex = ref(-1)
const showOperatorDropdown = ref(false)
// ---- ----
function textValue(v) {
if (v === 0) return '0'
@ -372,8 +504,40 @@ function confirmLowerMoldSelection() {
function closeLowerMoldPicker() { lowerMoldPickerRef.value?.close() }
function handleSelectDeviceFirst() {
openDevicePicker()
// ---- ----
async function loadOperators() {
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
operatorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadOperators error', e)
}
}
function toggleOperatorDropdown() {
showOperatorDropdown.value = !showOperatorDropdown.value
}
function closeOperatorDropdown() {
showOperatorDropdown.value = false
}
function handleSelectOperator(item, idx) {
selectedOperator.value = item
operatorIndex.value = idx
closeOperatorDropdown()
}
function goToHistory() {
uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=down' })
}
function goBack() {
uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/index/index' }) })
}
// ---- ----
@ -386,16 +550,30 @@ function validForm() {
uni.showToast({ title: t('moldOperate.validatorLowerMoldRequired'), icon: 'none' })
return false
}
if (!selectedOperator.value) {
uni.showToast({ title: t('moldOperate.validatorOperatorRequired'), icon: 'none' })
return false
}
return true
}
async function handleConfirm() {
if (!validForm()) return
try {
const device = selectedDevice.value
const payload = {
operateType: '2',
deviceId: String(selectedDevice.value.id),
moldId: String(selectedMold.value.id)
deviceId: String(device.id),
moldId: String(selectedMold.value.id),
lineId: device.deviceLine != null ? String(device.deviceLine) : undefined,
lineName: device.deviceLine != null ? getTopLineName(device.deviceLine) : (device.lineName || undefined)
}
//
if (selectedOperator.value) {
payload.operatorId = selectedOperator.value.value
}
if (remarkText.value.trim()) {
payload.remark = remarkText.value.trim()
}
console.log('[下模] 提交参数 =', JSON.stringify(payload))
await createMoldOperate(payload)
@ -412,6 +590,9 @@ async function handleConfirm() {
selectedDevice.value = {}
selectedMold.value = {}
lowerMoldOptions.value = []
remarkText.value = ''
selectedOperator.value = null
operatorIndex.value = -1
} catch (e) {
console.error('[下模] 保存失败 =', e)
const errMsg = e?.msg || (typeof e === 'string' ? e : e?.message) || '系统异常'
@ -419,8 +600,15 @@ async function handleConfirm() {
}
}
function handleCancel() {
//
uni.navigateBack({
fail: () => uni.switchTab({ url: '/pages/work' })
})
}
onShow(async () => {
await Promise.allSettled([loadDevices()])
await Promise.allSettled([loadDevices(), loadLineTree(), loadOperators()])
// globalData
const device = getApp().globalData._deviceSelectResult
if (device) {
@ -431,6 +619,23 @@ onShow(async () => {
</script>
<style lang="scss" scoped>
/* ====== 导航栏右侧按钮 ====== */
.nav-right-btn {
display: flex;
align-items: center;
gap: 6rpx;
padding: 8rpx 18rpx;
background: #ffffff;
border-radius: 999rpx;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
}
.nav-right-text {
font-size: 24rpx;
color: #374151;
font-weight: 500;
}
.page-container {
min-height: 100vh;
background: #f5f6f8;
@ -452,7 +657,7 @@ onShow(async () => {
gap: 12rpx;
height: 96rpx;
border-radius: 12rpx;
background: #2563eb;
background: #1f4b79;
color: #fff;
font-size: 28rpx;
font-weight: 600;
@ -480,7 +685,6 @@ onShow(async () => {
margin: 16rpx 24rpx;
background: #ffffff;
border-radius: 14rpx;
overflow: hidden;
}
.section-title-bar {
@ -494,7 +698,7 @@ onShow(async () => {
width: 6rpx;
height: 32rpx;
border-radius: 3rpx;
background: #2563eb;
background: #1f4b79;
}
.section-title {
@ -609,6 +813,130 @@ onShow(async () => {
}
}
/* ====== 表单行(操作人/备注) ====== */
.form-row {
margin-top: 18rpx;
&:first-child {
margin-top: 0;
}
}
.form-cell {
width: 100%;
.form-label {
display: block;
font-size: 24rpx;
color: #999;
margin-bottom: 8rpx;
.required {
color: #dc2626;
margin-right: 4rpx;
}
}
}
/* ====== 下拉选择器(操作人) ====== */
.select-dropdown {
position: relative;
width: 100%;
}
.dropdown-input {
display: flex;
align-items: center;
height: 72rpx;
padding: 0 20rpx;
border: 1rpx solid #e0e0e0;
border-radius: 10rpx;
font-size: 27rpx;
color: #333;
background: #f9fafb;
}
.dropdown-value {
flex: 1;
&.placeholder {
color: #bbb;
}
}
.dropdown-arrow {
position: absolute;
right: 16rpx;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
}
/* ====== 下拉面板(在输入框下方展开) ====== */
.dropdown-panel {
position: absolute;
top: 76rpx;
left: 0;
right: 0;
z-index: 99;
background: #ffffff;
border: 1rpx solid #e0e0e0;
border-radius: 12rpx;
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.dropdown-scroll {
max-height: 400rpx;
}
.dropdown-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 22rpx 28rpx;
font-size: 27rpx;
color: #333;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
&:active {
background: #f5f7fa;
}
&.active {
color: #1f7cff;
background: #f0f7ff;
}
}
.dropdown-item-text {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dropdown-empty {
padding: 32rpx;
text-align: center;
font-size: 26rpx;
color: #999;
}
.form-input {
height: 72rpx;
padding: 0 20rpx;
border: 1rpx solid #e0e0e0;
border-radius: 10rpx;
font-size: 27rpx;
color: #333;
background: #f9fafb;
}
/* ====== 空提示 ====== */
.empty-mold-hint {
padding: 40rpx 24rpx;
@ -620,33 +948,44 @@ onShow(async () => {
color: #2563eb;
}
.empty-gray {
color: #9ca3af;
}
/* ====== 底部操作栏 ====== */
.bottom-actions {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
display: flex;
gap: 18rpx;
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
z-index: 99;
}
.bottom-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 12rpx;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
background: #1f4b79;
color: #fff;
}
.cancel-btn {
background: #eef2f7;
color: #475569;
}
/* ====== 弹窗通用 ====== */
.picker-popup {
background: #fff;

@ -0,0 +1,694 @@
<template>
<view class="page-container">
<!-- 顶部导航栏 -->
<NavBar :title="pageTitle" />
<!-- Tab 切换路由指定 type 时隐藏 -->
<view v-if="!pageType" class="tab-bar">
<view
class="tab-item"
:class="{ active: activeTab === 'up' }"
@click="switchTab('up')"
>
<text class="tab-text">{{ t('moldOperate.tabUp') }}</text>
<view v-if="activeTab === 'up'" class="tab-line"></view>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'down' }"
@click="switchTab('down')"
>
<text class="tab-text">{{ t('moldOperate.tabDown') }}</text>
<view v-if="activeTab === 'down'" class="tab-line"></view>
</view>
</view>
<!-- 搜索区域 -->
<view class="search-bar">
<view class="search-input-wrap">
<input
v-model="searchKeyword"
class="search-input"
:placeholder="t('moldOperate.searchPlaceholder')"
placeholder-class="search-placeholder"
confirm-type="search"
@confirm="handleSearch"
/>
</view>
<view class="search-select" @click="toggleFilter">
<text class="select-text">{{ filterLabel }}</text>
<text class="select-arrow">&#9662;</text>
</view>
<view class="search-btn reset" @click="handleReset">
<text>{{ t('functionCommon.reset') }}</text>
</view>
<view class="search-btn filter" @click="toggleFilter">
<text class="filter-icon">&#9776;</text>
</view>
</view>
<!-- 筛选条件弹层 -->
<view v-if="showFilter" class="filter-dropdown">
<view
v-for="opt in filterOptions"
:key="opt.key"
class="filter-option"
:class="{ active: filterType === opt.key }"
@click="selectFilter(opt.key)"
>
<text>{{ opt.label }}</text>
<text v-if="filterType === opt.key" class="check-mark">&#10003;</text>
</view>
</view>
<!-- 列表内容 -->
<scroll-view scroll-y class="list-scroll" :scroll-top="scrollTop" :style="{ height: pageType ? 'calc(100vh - 88rpx - 98rpx)' : 'calc(100vh - 88rpx - 80rpx - 98rpx)' }">
<template v-if="displayList.length > 0">
<view
v-for="(item, index) in displayList"
:key="item.id || index"
class="history-card"
>
<!-- 顶部模具名称 + 标签 -->
<view class="card-top">
<text class="card-title">{{ item.moldName || '-' }}</text>
<view class="type-tag" :class="(item.operateType === '1' || item.operateType === 1) ? 'type-up' : 'type-down'">
<text>{{ (item.operateType === '1' || item.operateType === 1) ? t('moldOperate.tabUp') : t('moldOperate.tabDown') }}</text>
</view>
</view>
<!-- 信息行 Web 端表格列对齐 -->
<view class="info-row">
<text class="info-label">{{ t('moldOperate.deviceName') }}</text>
<text class="info-value">{{ item.deviceName || getDeviceName(item.deviceId) || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldOperate.productionLine') }}</text>
<text class="info-value">{{ item.lineName || getTopLineName(item.lineId) || getLineNameByDeviceId(item.deviceId) || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldOperate.operator') }}</text>
<text class="info-value">{{ item.creatorName || item.operator || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldOperate.remark') }}</text>
<text class="info-value">{{ item.remark || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldOperate.operateTime') }}</text>
<text class="info-value">{{ formatDateTime(item.operateTime || item.createTime) }}</text>
</view>
<!-- 右下角删除 -->
<view class="card-footer">
<view class="delete-wrap" @click="handleDelete(item)">
<u-icon name="trash" size="22" color="#dc2626"></u-icon>
</view>
</view>
</view>
</template>
<!-- 空状态 -->
<view v-else class="empty-wrap">
<text class="empty-text">{{ loading ? t('functionCommon.loading') : t('moldOperate.historyEmpty') }}</text>
</view>
<!-- 分页 -->
<view v-if="displayList.length > 0" class="pagination-bar">
<text class="pagination-total">{{ t('moldOperate.totalPrefix') }}{{ total }}{{ t('moldOperate.totalSuffix') }}</text>
<view class="pagination-ctrl">
<text
class="page-btn"
:class="{ disabled: pageNo <= 1 }"
@click="changePage(pageNo - 1)"
>&lt;</text>
<text class="page-current">{{ pageNo }}</text>
<text
class="page-btn"
:class="{ disabled: pageNo >= totalPages }"
@click="changePage(pageNo + 1)"
>&gt;</text>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, watch } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getMoldOperatePage, deleteMoldOperate, getDeviceLedgerList } from '@/api/mes/moldoperate'
import { getDeviceLineTree } from '@/api/mes/deviceLine'
const { t } = useI18n()
const pageType = ref('')
const activeTab = ref('up')
const searchKeyword = ref('')
const filterType = ref('all')
const showFilter = ref(false)
const allList = ref([])
const loading = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const scrollTop = ref(0)
const lineInfoMap = ref(new Map())
const deviceMap = ref(new Map())
const total = computed(() => filteredList.value.length)
const totalPages = computed(() => Math.ceil(total.value / pageSize.value) || 1)
const filterLabel = computed(() => {
if (filterType.value === 'all') return t('moldOperate.filterAll')
if (filterType.value === 'today') return t('moldOperate.filterToday')
if (filterType.value === 'week') return t('moldOperate.filterWeek')
return t('moldOperate.filterAll')
})
const filterOptions = [
{ key: 'all', label: t('moldOperate.filterAll') },
{ key: 'today', label: t('moldOperate.filterToday') },
{ key: 'week', label: t('moldOperate.filterWeek') }
]
const filteredList = computed(() => {
let list = allList.value
if (filterType.value === 'today') {
const today = new Date().toDateString()
list = list.filter(item => {
const d = item.operateTime || item.createTime
return d && new Date(d).toDateString() === today
})
} else if (filterType.value === 'week') {
const now = new Date()
const weekAgo = new Date(now.getTime() - 7 * 24 * 3600 * 1000)
list = list.filter(item => {
const d = item.operateTime || item.createTime
return d && new Date(d) >= weekAgo
})
}
if (searchKeyword.value.trim()) {
const kw = searchKeyword.value.trim().toLowerCase()
list = list.filter(item => {
return (item.deviceName || '').toLowerCase().includes(kw) ||
(item.moldCode || '').toLowerCase().includes(kw) ||
(item.moldName || '').toLowerCase().includes(kw) ||
(item.operator || '').toLowerCase().includes(kw) ||
(item.creatorName || '').toLowerCase().includes(kw)
})
}
return list
})
const displayList = computed(() => {
const start = (pageNo.value - 1) * pageSize.value
return filteredList.value.slice(start, start + pageSize.value)
})
function getDeviceName(deviceId) {
if (!deviceId) return '-'
const d = deviceMap.value.get(String(deviceId))
return d?.deviceName || '-'
}
function getLineNameByDeviceId(deviceId) {
if (!deviceId) return null
const d = deviceMap.value.get(String(deviceId))
if (!d) return null
if (d.deviceLine != null) {
return getTopLineName(d.deviceLine)
}
return d.workshopName || null
}
function flattenLineTree(nodes, parentId) {
if (!Array.isArray(nodes)) return
for (const node of nodes) {
if (node.id != null && node.name != null) {
lineInfoMap.value.set(String(node.id), {
id: node.id,
name: node.name,
parentId: node.parentId != null ? node.parentId : (parentId || null),
parentChain: node.parentChain || ''
})
}
if (Array.isArray(node.children)) {
flattenLineTree(node.children, node.id)
}
}
}
function getTopLineName(lineId) {
if (lineId == null) return '-'
const node = lineInfoMap.value.get(String(lineId))
if (!node) return '-'
if (node.parentChain) {
const firstId = node.parentChain.split(',')[0]?.trim()
if (firstId) {
const topNode = lineInfoMap.value.get(firstId)
if (topNode) return topNode.name
}
}
let current = node
const visited = new Set()
while (current.parentId != null && current.parentId > 0 && !visited.has(current.id)) {
visited.add(current.id)
const parent = lineInfoMap.value.get(String(current.parentId))
if (!parent) break
current = parent
}
return current.name || String(lineId)
}
async function loadLineTree() {
if (lineInfoMap.value.size > 0) return
try {
const res = await getDeviceLineTree()
const tree = (res && res.data !== undefined) ? res.data : res
const nodes = Array.isArray(tree) ? tree : (tree?.list || tree?.children || [])
flattenLineTree(nodes)
} catch (e) {
console.error('load line tree error', e)
}
}
async function loadDevices() {
if (deviceMap.value.size > 0) return
try {
const res = await getDeviceLedgerList({ pageNo: 1, pageSize: 99 })
const root = res && res.data !== undefined ? res.data : res
const data = Array.isArray(root)
? root
: Array.isArray(root?.list) ? root.list
: Array.isArray(root?.records) ? root.records
: []
data.forEach(d => {
if (d.id != null) deviceMap.value.set(String(d.id), d)
})
} catch (e) {
console.error('load devices error', e)
}
}
async function fetchAll() {
if (loading.value) return
loading.value = true
try {
const operateType = activeTab.value === 'up' ? '1' : '2'
let page = 1
const batchSize = 99
const all = []
while (true) {
const res = await getMoldOperatePage({ pageNo: page, pageSize: batchSize, operateType })
const root = res && res.data !== undefined ? res.data : res
const rows = Array.isArray(root)
? root
: Array.isArray(root?.list) ? root.list
: Array.isArray(root?.rows) ? root.rows
: Array.isArray(root?.records) ? root.records
: []
if (rows.length === 0) break
all.push(...rows)
if (rows.length < batchSize) break
page++
if (page > 10) break
}
allList.value = all
} catch (e) {
console.error('fetch history error', e)
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
loading.value = false
}
}
function switchTab(tab) {
activeTab.value = tab
pageNo.value = 1
searchKeyword.value = ''
filterType.value = 'all'
fetchAll()
}
function toggleFilter() {
showFilter.value = !showFilter.value
}
function selectFilter(key) {
filterType.value = key
showFilter.value = false
pageNo.value = 1
}
function handleSearch() {
pageNo.value = 1
}
function handleReset() {
searchKeyword.value = ''
filterType.value = 'all'
pageNo.value = 1
}
function changePage(p) {
if (p < 1 || p > totalPages.value) return
pageNo.value = p
scrollTop.value = scrollTop.value === 0 ? 1 : 0
}
function handleDelete(item) {
if (!item.id) return
uni.showModal({
title: t('functionCommon.confirmTitle'),
content: t('moldOperate.confirmDeleteHistory'),
confirmColor: '#dc2626',
success: async (res) => {
if (res.confirm) {
try {
await deleteMoldOperate(item.id)
uni.showToast({ title: t('functionCommon.deleteSuccess'), icon: 'success' })
allList.value = allList.value.filter(i => i.id !== item.id)
} catch (e) {
console.error('delete history error', e)
uni.showToast({ title: t('functionCommon.deleteFailed'), icon: 'none' })
}
}
}
})
}
const pageTitle = computed(() => {
if (!pageType.value) return t('moldOperate.historyTitle')
const type = pageType.value === 'up' ? t('moldOperate.tabUp') : t('moldOperate.tabDown')
return type + t('moldOperate.historySuffix')
})
function formatDateTime(value) {
if (!value) return '-'
if (Array.isArray(value) && value.length >= 3) {
const [year, month, day, hour = 0, minute = 0, second = 0] = value
const pad = (num) => String(num).padStart(2, '0')
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`
}
const date = new Date(value)
if (Number.isNaN(date.getTime())) return String(value)
const pad = (num) => String(num).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
}
watch(searchKeyword, () => {
pageNo.value = 1
})
onLoad((options) => {
if (options && options.type) {
pageType.value = options.type
activeTab.value = options.type
}
})
onShow(async () => {
await Promise.allSettled([fetchAll(), loadDevices(), loadLineTree()])
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
}
/* ====== Tab 切换 ====== */
.tab-bar {
display: flex;
background: #fff;
border-bottom: 1rpx solid #eee;
.tab-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: 20rpx 0;
position: relative;
.tab-text {
font-size: 28rpx;
color: #666;
}
&.active .tab-text {
color: #2563eb;
font-weight: 600;
}
.tab-line {
position: absolute;
bottom: 0;
width: 48rpx;
height: 4rpx;
background: #2563eb;
border-radius: 2rpx;
}
}
}
/* ====== 搜索区域 ====== */
.search-bar {
display: flex;
align-items: center;
padding: 12rpx 16rpx;
background: #fff;
gap: 8rpx;
.search-input-wrap {
flex: 1;
height: 64rpx;
background: #f5f6f8;
border-radius: 32rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
}
.search-input {
flex: 1;
font-size: 26rpx;
height: 100%;
}
.search-placeholder {
color: #999;
}
.search-select {
display: flex;
align-items: center;
padding: 0 16rpx;
height: 64rpx;
border-radius: 32rpx;
background: #f5f6f8;
gap: 4rpx;
}
.select-text {
font-size: 24rpx;
color: #666;
}
.select-arrow {
font-size: 18rpx;
color: #999;
}
.search-btn {
height: 64rpx;
line-height: 64rpx;
padding: 0 20rpx;
border-radius: 32rpx;
font-size: 24rpx;
&.reset {
background: #fff;
color: #666;
border: 1rpx solid #ddd;
}
&.filter {
background: #2563eb;
color: #fff;
.filter-icon {
font-size: 28rpx;
}
}
}
}
/* ====== 筛选下拉 ====== */
.filter-dropdown {
position: absolute;
top: 176rpx;
right: 16rpx;
background: #fff;
border-radius: 8rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.12);
z-index: 99;
overflow: hidden;
.filter-option {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 32rpx;
font-size: 26rpx;
color: #333;
min-width: 160rpx;
&.active {
color: #2563eb;
background: #f0f5ff;
font-weight: 500;
}
.check-mark {
color: #2563eb;
font-size: 24rpx;
}
}
}
/* ====== 列表 ====== */
.list-scroll {
padding: 16rpx 16rpx 32rpx;
}
.history-card {
background: #fff;
border-radius: 12rpx;
margin-bottom: 16rpx;
padding: 16rpx 24rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10rpx;
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #1a365d;
flex: 1;
}
.type-tag {
padding: 2rpx 10rpx;
border-radius: 6rpx;
font-size: 20rpx;
color: #fff;
flex-shrink: 0;
&.type-up {
background: #f97316;
}
&.type-down {
background: #f97316;
}
}
}
.info-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 4rpx 0;
.info-label {
font-size: 22rpx;
color: #999;
flex-shrink: 0;
}
.info-value {
font-size: 22rpx;
color: #333;
text-align: right;
flex: 1;
margin-left: 16rpx;
word-break: break-all;
}
}
.card-footer {
display: flex;
justify-content: flex-end;
margin-top: 6rpx;
.delete-wrap {
padding: 6rpx;
}
}
}
.empty-wrap {
display: flex;
align-items: center;
justify-content: center;
padding: 120rpx 0;
.empty-text {
font-size: 28rpx;
color: #999;
}
}
/* ====== 分页 ====== */
.pagination-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0;
.pagination-total {
font-size: 24rpx;
color: #999;
}
.pagination-ctrl {
display: flex;
align-items: center;
gap: 12rpx;
.page-btn {
width: 56rpx;
height: 56rpx;
line-height: 56rpx;
text-align: center;
background: #fff;
border-radius: 8rpx;
font-size: 28rpx;
color: #333;
border: 1rpx solid #ddd;
&.disabled {
color: #ccc;
background: #f5f5f5;
}
}
.page-current {
font-size: 28rpx;
color: #333;
min-width: 40rpx;
text-align: center;
}
}
}
</style>

@ -1,13 +1,14 @@
<template>
<view class="page-container">
<!-- 顶部导航栏 -->
<view class="custom-nav">
<view class="nav-back" @click="goBack">
<text class="back-icon">&lt;</text>
</view>
<text class="nav-title">{{ t('moldOperate.tabUp') }}</text>
<view class="nav-placeholder"></view>
</view>
<NavBar :title="t('moldOperate.tabUp')">
<template #right>
<view class="nav-right-btn" @click="goToHistory">
<uni-icons type="clock" size="22" color="#1f7cff"></uni-icons>
<text class="nav-right-text">{{ t('moldPressureNet.history') }}</text>
</view>
</template>
</NavBar>
<!-- ========== 上模 ========== -->
<!-- 操作按钮区 -->
@ -104,10 +105,66 @@
</view>
</view>
<!-- 操作人与备注 -->
<view class="section-card">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">{{ t('moldOperate.operator') + ' & ' + t('moldOperate.remark') }}</text>
</view>
<view class="card-body-grid">
<view class="form-row">
<view class="form-cell">
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
<!-- 下拉选择器 -->
<view class="select-dropdown" @click="toggleOperatorDropdown">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedOperator }]">
{{ selectedOperator ? selectedOperator.label : t('moldOperate.placeholderOperator') }}
</text>
<uni-icons type="bottom" size="14" color="#999" class="dropdown-arrow"></uni-icons>
</view>
<!-- 下拉列表在输入框下方展开 -->
<view v-if="showOperatorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view
v-for="(item, idx) in operatorOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedOperator?.value === item.value }"
@click.stop="handleSelectOperator(item, idx)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<uni-icons
v-if="selectedOperator?.value === item.value"
type="checkmarkempty"
size="16"
color="#1f7cff"
></uni-icons>
</view>
<view v-if="!operatorOptions.length" class="dropdown-empty"></view>
</scroll-view>
</view>
</view>
</view>
</view>
<view class="form-row">
<view class="form-cell">
<text class="form-label">{{ t('moldOperate.remark') }}</text>
<input
class="form-input"
v-model="remarkText"
:placeholder="t('moldOperate.placeholderRemark')"
:maxlength="200"
/>
</view>
</view>
</view>
</view>
<!-- 底部操作栏 - 上模 -->
<view class="bottom-actions">
<view class="bottom-btn confirm-btn" @click="handleConfirmMount">{{ t('moldOperate.confirmMount') }}</view>
<view class="bottom-btn cancel-btn" @click="handleCancel">{{ t('functionCommon.cancel') }}</view>
<view class="bottom-btn confirm-btn" @click="handleConfirmMount">{{ t('moldOperate.confirmMount') }}</view>
</view>
</view>
@ -117,7 +174,9 @@
import { computed, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
import { getSimpleUserList } from '@/api/system/user'
const { t } = useI18n()
@ -157,6 +216,10 @@ const selectedDevice = ref({})
const selectedMountMolds = ref([])
const tempSelectedDeviceId = ref(null)
const remarkText = ref('')
const operatorOptions = ref([])
const selectedOperator = ref(null)
const operatorIndex = ref(-1)
// -
const deviceStatusClass = computed(() => {
@ -238,6 +301,36 @@ const currentMoldDisplay = computed(() => {
return textValue(selectedDevice.value.currentMold)
})
// ---- ----
async function loadOperators() {
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
operatorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadOperators error', e)
}
}
const showOperatorDropdown = ref(false)
function toggleOperatorDropdown() {
showOperatorDropdown.value = !showOperatorDropdown.value
}
function closeOperatorDropdown() {
showOperatorDropdown.value = false
}
function handleSelectOperator(item, idx) {
selectedOperator.value = item
operatorIndex.value = idx
closeOperatorDropdown()
}
function selectDevice(device) {
selectedDevice.value = device || {}
tempSelectedDeviceId.value = device ? device.id : null
@ -269,6 +362,10 @@ function validFormMount() {
uni.showToast({ title: t('moldOperate.validatorMoldRequired'), icon: 'none' })
return false
}
if (!selectedOperator.value) {
uni.showToast({ title: t('moldOperate.validatorOperatorRequired'), icon: 'none' })
return false
}
return true
}
@ -279,7 +376,16 @@ async function handleConfirmMount() {
const payload = {
operateType: '1',
deviceId: String(selectedDevice.value.id),
moldId: moldIds.length === 1 ? String(moldIds[0]) : moldIds.map(String).join(',')
moldId: moldIds.length === 1 ? String(moldIds[0]) : moldIds.map(String).join(','),
lineName: selectedDevice.value.workshopName || '',
lineId: selectedDevice.value.deviceLine || ''
}
//
if (selectedOperator.value) {
payload.operatorId = selectedOperator.value.value
}
if (remarkText.value.trim()) {
payload.remark = remarkText.value.trim()
}
console.log('=== 上模提交参数 ===', JSON.stringify(payload))
console.log('=== deviceId type:', typeof payload.deviceId, 'value:', payload.deviceId)
@ -342,14 +448,21 @@ function handleScan() {
function handleCancel() {
selectedDevice.value = {}
selectedMountMolds.value = []
remarkText.value = ''
selectedOperator.value = null
operatorIndex.value = -1
//
uni.navigateBack({
fail: () => uni.switchTab({ url: '/pages/work' })
})
}
function goBack() {
uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/index/index' }) })
function goToHistory() {
uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=up' })
}
onShow(async () => {
await Promise.allSettled([loadDevices()])
await Promise.allSettled([loadDevices(), loadOperators()])
// globalData
const device = getApp().globalData._deviceSelectResult
if (device) {
@ -372,37 +485,21 @@ onShow(async () => {
padding-bottom: 140rpx;
}
/* ====== 自定义导航栏 ====== */
.custom-nav {
/* ====== 导航栏右侧按钮 ====== */
.nav-right-btn {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
padding: 0 24rpx;
background: #1a365d;
color: #fff;
.nav-back {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.back-icon {
font-size: 36rpx;
font-weight: bold;
}
.nav-title {
font-size: 34rpx;
font-weight: 600;
}
gap: 6rpx;
padding: 8rpx 18rpx;
background: #ffffff;
border-radius: 999rpx;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
}
.nav-placeholder {
width: 60rpx;
}
.nav-right-text {
font-size: 24rpx;
color: #374151;
font-weight: 500;
}
/* ====== 操作按钮区 ====== */
@ -420,7 +517,7 @@ onShow(async () => {
gap: 12rpx;
height: 96rpx;
border-radius: 12rpx;
background: #2563eb;
background: #1f4b79;
color: #fff;
font-size: 28rpx;
font-weight: 600;
@ -448,7 +545,6 @@ onShow(async () => {
margin: 16rpx 24rpx;
background: #ffffff;
border-radius: 14rpx;
overflow: hidden;
}
.section-title-bar {
@ -567,6 +663,132 @@ onShow(async () => {
.change-text { font-size: 26rpx; color: #666; }
}
/* ====== 表单行(操作人/备注) ====== */
.form-row {
margin-top: 18rpx;
&:first-child {
margin-top: 0;
}
}
.form-cell {
width: 100%;
.form-label {
display: block;
font-size: 24rpx;
color: #999;
margin-bottom: 8rpx;
.required {
color: #dc2626;
margin-right: 4rpx;
}
}
}
/* ====== 下拉选择器(操作人) ====== */
.select-dropdown {
position: relative;
width: 100%;
}
.dropdown-input {
display: flex;
align-items: center;
height: 72rpx;
padding: 0 20rpx;
border: 1rpx solid #e0e0e0;
border-radius: 10rpx;
font-size: 27rpx;
color: #333;
background: #f9fafb;
}
.dropdown-value {
flex: 1;
&.placeholder {
color: #bbb;
}
}
.dropdown-arrow {
position: absolute;
right: 16rpx;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
}
/* ====== 下拉面板(在输入框下方展开) ====== */
.dropdown-panel {
position: absolute;
top: 76rpx;
left: 0;
right: 0;
z-index: 99;
background: #ffffff;
border: 1rpx solid #e0e0e0;
border-radius: 12rpx;
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.dropdown-scroll {
max-height: 400rpx;
}
.dropdown-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 22rpx 28rpx;
font-size: 27rpx;
color: #333;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
&:active {
background: #f5f7fa;
}
&.active {
color: #1f7cff;
background: #f0f7ff;
}
}
.dropdown-item-text {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dropdown-empty {
padding: 32rpx;
text-align: center;
font-size: 26rpx;
color: #999;
}
.form-input {
height: 72rpx;
padding: 0 20rpx;
border: 1rpx solid #e0e0e0;
border-radius: 10rpx;
font-size: 27rpx;
color: #333;
background: #f9fafb;
}
/* ====== 空提示 ====== */
.empty-mold-hint {
padding: 40rpx 24rpx;
@ -593,10 +815,10 @@ onShow(async () => {
right: 0;
bottom: 0;
display: flex;
gap: 20rpx;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
gap: 18rpx;
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #ffffff;
box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06);
z-index: 99;
&.single-btn {
@ -605,25 +827,23 @@ onShow(async () => {
}
.bottom-btn {
height: 88rpx;
line-height: 88rpx;
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 12rpx;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
flex: 1;
background: #2563eb;
color: #fff;
background: #1f4b79;
color: #ffffff;
}
.cancel-btn {
flex: 1;
background: #fff;
color: #666;
border: 1rpx solid #ddd;
background: #eef2f7;
color: #475569;
}

@ -328,7 +328,7 @@ onShow(async () => {
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
padding: 18rpx 24rpx calc(18rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
z-index: 99;
@ -336,16 +336,16 @@ onShow(async () => {
.bottom-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 12rpx;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
background: #1f4b79;
color: #fff;
}
</style>

@ -30,6 +30,15 @@ const MENU_ROUTE_MAP = {
moldtaskconfig: '/pages_function/pages/moldTaskConfiguration/index',
'点检记录': '/pages_function/pages/moldWorkOrderInquiry/index',
moldworkorderinquiry: '/pages_function/pages/moldWorkOrderInquiry/index',
'模具保养': '/pages_function/pages/moldMaintain/index',
'保养记录': '/pages_function/pages/moldMaintain/index',
moldmaintain: '/pages_function/pages/moldMaintain/index',
moldmaintenance: '/pages_function/pages/moldMaintain/index',
'更换压网': '/pages_function/pages/moldPressureNet/index',
'压网更换': '/pages_function/pages/moldPressureNet/index',
'压网记录': '/pages_function/pages/moldPressureNet/index',
moldpressurenet: '/pages_function/pages/moldPressureNet/index',
pressurenet: '/pages_function/pages/moldPressureNet/index',
'产品物料分类': '/pages_function/pages/materialCategory/index',
materialcategory: '/pages_function/pages/materialCategory/index',
'产品物料信息': '/pages_function/pages/materialInfo/index',

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Loading…
Cancel
Save