Merge remote-tracking branch 'origin/master'

master
liutao 4 days ago
commit 96e1ff570b

@ -0,0 +1,93 @@
import upload from '@/utils/upload'
import request from '@/utils/request'
// 模具点检工单分页
export function getMoldCheckPage(params = {}) {
return request({
url: '/admin-api/mes/mold-ticket-management/page',
method: 'get',
params
})
}
// 模具点检结果分页
export function getMoldCheckResultsPage(params = {}) {
return request({
url: '/admin-api/mes/mold-ticket-results/page',
method: 'get',
params
})
}
// 批量更新点检结果
export function batchUpdateMoldCheckResults(data) {
return request({
url: '/admin-api/mes/mold-ticket-results/batchUpdate',
method: 'put',
data
})
}
// 图片上传
export function uploadMoldCheckImage(filePath, name = 'file') {
return upload({
url: '/admin-api/infra/file/upload',
name,
filePath,
showLoading: false
})
}
// 点检模板分页(项目表单)
export function getPlanMaintenancePage(params = {}) {
return request({
url: '/admin-api/mes/mold-plan-maintenance/page',
method: 'get',
params
})
}
// 获取模板下的点检项
export function getSubjectList(id) {
return request({
url: '/admin-api/mes/mold-plan-maintenance/getSubjectList',
method: 'get',
params: { id }
})
}
// 直接创建模具点检工单
export function createMoldTicketDirect(data) {
return request({
url: '/admin-api/mes/mold-task-management/createMoldTicketDirect',
method: 'post',
data
})
}
// 获取模具详情
export function getMoldBrandDetail(id) {
return request({
url: '/admin-api/erp/mold-brand/get',
method: 'get',
params: { id }
})
}
// 获取模具列表(选择模具用)
export function getMoldList(params = {}) {
return request({
url: '/admin-api/erp/mold-brand/getMoldList',
method: 'get',
params
})
}
// 批量更新工单状态
export function batchUpdateMoldCheckStatus(data) {
return request({
url: '/admin-api/mes/mold-ticket-management/batchUpdateStatus',
method: 'put',
data
})
}

@ -50,8 +50,8 @@ export function getLowerMoldList(id) {
export function getDeviceLedgerList(params = {}) {
return request({
url: '/admin-api/mes/device-ledger/list',
url: '/admin-api/mes/device-ledger/page',
method: 'get',
params
params: { pageNo: params.pageNo || 1, pageSize: params.pageSize || 100, ...params }
})
}

@ -211,6 +211,7 @@ function getUviewIconName(icon) {
function handleClick(menu) {
const url = resolveMenuUrl(menu)
console.log('[PermissionMenu] 点击菜单:', menu?.name, '| _splitKey:', menu?._splitKey, '| 路由:', url)
if (url) {
uni.navigateTo({ url })
return

@ -183,6 +183,7 @@ export default {
search: 'Search',
reset: 'Reset',
cancel: 'Cancel',
confirm: 'Confirm',
save: 'Save',
loading: 'Loading...',
loadingMore: 'Loading more...',
@ -339,7 +340,35 @@ export default {
validatorMoldRequired: 'Select at least one mold for mounting',
validatorLowerMoldRequired: 'Select at least one mold for dismounting',
loadEditFailed: 'Failed to load edit data',
confirmDelete: 'Confirm delete this mold operate record?'
confirmDelete: 'Confirm delete this mold operate record?',
scanDevice: 'Scan Device',
selectDevice: 'Select Device',
selectedDevice: 'Selected Device',
deviceCode: 'Device Code',
productionLine: 'Production Line',
currentMold: 'Current Mold',
deviceStatus: 'Device Status',
statusRunning: 'Running',
statusStop: 'Stopped',
statusFault: 'Fault',
selectMountMold: 'Select Mold to Mount',
product: 'Product',
status: 'Status',
pendingMount: 'Pending Mount',
confirmMount: 'Confirm Mount',
clickSelectMold: 'Click to select mold',
noDeviceData: 'No device data',
deviceNotFound: 'Device not found',
deviceInfo: 'Device Info',
currentMoldInfo: 'Current Mold on Machine',
mountTime: 'Mount Time',
useCount: 'Usage Count',
countUnit: '',
changeMountTarget: 'Change Mount Target',
changeTarget: 'Change Dismount Target',
confirmDismount: 'Confirm Dismount',
clickSelectDeviceFirst: 'Please select a device first',
noMoldOnDevice: 'No mold on this device'
},
moldInspectionItems: {
moduleName: 'Inspection Items',
@ -989,6 +1018,143 @@ export default {
validatorNameRequired: 'Component name is required',
confirmDeleteContent: 'Confirm delete component [{name}]?'
},
moldLedger: {
moduleName: 'Mold Ledger',
subTitle: 'Mold ledger management',
detailTitle: 'Mold Detail',
basicInfo: 'Mold Basic Info',
moldPlaceholder: 'Mold',
moldName: 'Mold Name',
product: 'Product',
moldCode: 'Mold Code',
status: 'Status',
versionSpec: 'Version/Spec',
cavityCount: 'Cavity Count',
currentDevice: 'Current Device',
useCount: 'Use Count',
expand: 'Expand',
collapse: 'Collapse',
tabChildMold: 'Sub-molds',
tabInspection: 'Inspection',
tabRepair: 'Repair',
tabMaintenance: 'Maintenance',
tabInstall: 'Installation',
installLocation: 'Install Location',
material: 'Material',
quantity: 'Quantity',
lastReplace: 'Last Replace',
usedDays: 'Used {days} days',
remark: 'Remark',
noChildMold: 'No sub-mold data',
noInspection: 'No inspection records',
noRepair: 'No repair records',
noMaintenance: 'No maintenance records',
noInstall: 'No installation records',
inspectionMethod: 'Inspection Method',
criteria: 'Criteria',
inspectionTime: 'Inspection Time',
maintainMethod: 'Maintenance Method',
maintainTime: 'Maintenance Time',
repairProject: 'Repair Project',
projectContent: 'Project Content',
finishTime: 'Finish Time',
operateMold: 'Mold',
operator: 'Operator',
time: 'Time',
upperMold: 'Mount',
lowerMold: 'Dismount',
missingBrandId: 'Missing mold brand ID',
detailLoadFailed: 'Failed to load detail',
childLoadFailed: 'Failed to load sub-molds',
inspectionLoadFailed: 'Failed to load inspection records',
repairLoadFailed: 'Failed to load repair records',
maintainLoadFailed: 'Failed to load maintenance records',
installLoadFailed: 'Failed to load installation records',
resultPending: 'Pending',
resultPass: 'Pass',
resultWarning: 'Warning',
repairCompleted: 'Completed',
repairAbnormal: 'Abnormal',
repairProcessing: 'Processing',
searchPlaceholder: 'Enter mold code or name',
allStatus: 'All',
selectMoldStatus: 'Select Mold Status',
clear: 'Clear',
name: 'Name',
createTime: 'Created At',
confirmDeleteContent: 'Confirm delete mold brand "{name}"?',
empty: 'No mold ledger data',
scanUnrecognized: 'Unrecognized QR code',
scanFormatError: 'Invalid QR code format',
scanFailed: 'Scan failed',
noIdView: 'Missing ID, cannot view details',
noIdDelete: 'Missing ID, cannot delete'
},
moldCheck: {
moduleName: 'Mold Inspection',
addTitle: 'Add Inspection',
detailTitle: 'Inspection Detail',
searchPlaceholder: 'Enter inspection No.',
empty: 'No inspection records',
add: 'Add',
moldName: 'Mold Name',
moldCode: 'Mold Code',
product: 'Product',
status: 'Status',
taskType: 'Task Type',
taskTypeInspect: 'Inspection',
taskTypeMaintain: 'Maintenance',
planNo: 'Inspection No.',
taskTime: 'Task Time',
template: 'Template',
operator: 'Operator',
jobStatusPending: 'Pending',
jobStatusProcessing: 'Processing',
jobStatusCompleted: 'Completed',
jobStatusTimeout: 'Timeout',
jobStatusCancelled: 'Cancelled',
jobResultOk: 'OK',
jobResultNg: 'NG',
progressTitle: 'Progress',
noResultData: 'No inspection result data',
requiredText: 'Required',
inspectionMethod: 'Inspection 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 inspection 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 inspection template',
noItems: 'Please select inspection template first',
noTemplate: 'No templates',
submit: 'Submit Inspection',
submitSuccess: 'Inspection submitted successfully',
submitFailed: 'Failed to submit inspection',
reInspect: 'Re-inspect'
},
moldRepair: {
moduleName: 'Mold Repair',
createTitle: 'Create Mold Repair',

@ -106,6 +106,8 @@ const literalMap = {
'模具入库': 'moldReturn.moduleName',
'模具入库详情': 'moldReturn.detailTitle',
'上下模': 'moldOperate.moduleName',
'上模': 'moldOperate.tabUp',
'下模': 'moldOperate.tabDown',
'上下模详情': 'moldOperate.detailTitle',
'点检项库': 'moldInspectionItems.moduleName',
'点检项库详情': 'moldInspectionItems.detailTitle',
@ -122,7 +124,12 @@ const literalMap = {
'设备点检记录': 'equipmentInspectionRecord.moduleName',
'设备点检记录详情': 'equipmentInspectionRecord.detailTitle',
'点检记录': 'moldWorkOrder.moduleName',
'点检记录详情': 'moldWorkOrder.detailTitle'
'点检记录详情': 'moldWorkOrder.detailTitle',
'模具台账': 'moldLedger.moduleName',
'模具详情': 'moldLedger.detailTitle',
'模具点检': 'moldCheck.moduleName',
'点检详情': 'moldCheck.detailTitle',
'新增点检': 'moldCheck.addTitle'
}
export function getCurrentLocale() {

@ -183,6 +183,7 @@ export default {
search: '查询',
reset: '重置',
cancel: '取消',
confirm: '确认',
save: '保存',
loading: '加载中...',
loadingMore: '正在加载更多...',
@ -339,7 +340,35 @@ export default {
validatorMoldRequired: '请至少选择一个上模模具',
validatorLowerMoldRequired: '请至少选择一个下模模具',
loadEditFailed: '加载编辑数据失败',
confirmDelete: '确认删除该上下模记录吗?'
confirmDelete: '确认删除该上下模记录吗?',
scanDevice: '扫设备码',
selectDevice: '选择设备',
selectedDevice: '已选设备',
deviceCode: '设备编码',
productionLine: '所属产线',
currentMold: '当前在机模具',
deviceStatus: '设备状态',
statusRunning: '运行中',
statusStop: '已停止',
statusFault: '故障',
selectMountMold: '选择待上模模具',
product: '产品',
status: '状态',
pendingMount: '待上模',
confirmMount: '确认上模',
clickSelectMold: '点击选择模具',
noDeviceData: '暂无设备数据',
deviceNotFound: '未找到对应设备',
deviceInfo: '设备信息',
currentMoldInfo: '当前在机模具',
mountTime: '上模时间',
useCount: '使用次数',
countUnit: '次',
changeMountTarget: '更换上模对象',
changeTarget: '更换下模对象',
confirmDismount: '确认下模',
clickSelectDeviceFirst: '请先选择设备',
noMoldOnDevice: '该设备暂无在机模具'
},
moldInspectionItems: {
moduleName: '点检项库',
@ -992,6 +1021,143 @@ export default {
validatorNameRequired: '关键件名称不能为空',
confirmDeleteContent: '确认删除关键件【{name}】吗?'
},
moldLedger: {
moduleName: '模具台账',
subTitle: '模具台账管理',
detailTitle: '模具详情',
basicInfo: '模具基本信息',
moldPlaceholder: '模具',
moldName: '模具名称',
product: '产品',
moldCode: '模具编号',
status: '状态',
versionSpec: '版本/规格',
cavityCount: '模穴数',
currentDevice: '当前设备',
useCount: '使用次数',
expand: '展开',
collapse: '收起',
tabChildMold: '子模具',
tabInspection: '点检记录',
tabRepair: '维修记录',
tabMaintenance: '保养记录',
tabInstall: '安装记录',
installLocation: '安装位置',
material: '材质',
quantity: '数量',
lastReplace: '上次更换',
usedDays: '已使用{days}天',
remark: '备注',
noChildMold: '暂无子模具数据',
noInspection: '暂无点检记录',
noRepair: '暂无维修记录',
noMaintenance: '暂无保养记录',
noInstall: '暂无安装记录',
inspectionMethod: '点检方式',
criteria: '判定标准',
inspectionTime: '点检时间',
maintainMethod: '保养方式',
maintainTime: '保养时间',
repairProject: '维修项目',
projectContent: '项目内容',
finishTime: '完成时间',
operateMold: '模具',
operator: '操作人',
time: '时间',
upperMold: '上模',
lowerMold: '下模',
missingBrandId: '缺少模具组ID',
detailLoadFailed: '详情加载失败',
childLoadFailed: '子模具加载失败',
inspectionLoadFailed: '点检记录加载失败',
repairLoadFailed: '维修记录加载失败',
maintainLoadFailed: '保养记录加载失败',
installLoadFailed: '安装记录加载失败',
resultPending: '待处理',
resultPass: '合格',
resultWarning: '警告',
repairCompleted: '完成',
repairAbnormal: '异常',
repairProcessing: '处理中',
searchPlaceholder: '请输入模具组编码或名称',
allStatus: '全部',
selectMoldStatus: '选择模具状态',
clear: '清空',
name: '名称',
createTime: '创建时间',
confirmDeleteContent: '确认删除模具组"{name}"吗?',
empty: '暂无模具台账数据',
scanUnrecognized: '无法识别二维码',
scanFormatError: '二维码格式不正确',
scanFailed: '扫描失败',
noIdView: '缺少ID无法查看详情',
noIdDelete: '缺少ID无法删除'
},
moldCheck: {
moduleName: '模具点检',
addTitle: '新增点检',
detailTitle: '点检详情',
searchPlaceholder: '请输入点检单号',
empty: '暂无点检记录',
add: '新增',
moldName: '模具名称',
moldCode: '模具编号',
product: '产品',
status: '状态',
taskType: '任务类型',
taskTypeInspect: '点检',
taskTypeMaintain: '保养',
planNo: '点检单号',
taskTime: '执行时间',
template: '配置模板',
operator: '操作员',
jobStatusPending: '待执行',
jobStatusProcessing: '执行中',
jobStatusCompleted: '已完成',
jobStatusTimeout: '已超时',
jobStatusCancelled: '已取消',
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: '暂无模板',
submit: '提交点检',
submitSuccess: '点检提交成功',
submitFailed: '点检提交失败',
reInspect: '再次点检'
},
moldRepair: {
moduleName: '模具维修',
createTitle: '新增模具维修',

@ -578,7 +578,7 @@
{
"path": "moldoperate/index",
"style": {
"navigationBarTitleText": "上模",
"navigationBarTitleText": "上模",
"navigationStyle": "custom"
}
},
@ -589,6 +589,27 @@
"navigationStyle": "custom"
}
},
{
"path": "moldoperate/dismount",
"style": {
"navigationBarTitleText": "下模",
"navigationStyle": "custom"
}
},
{
"path": "moldoperate/deviceSelect",
"style": {
"navigationBarTitleText": "选择设备",
"navigationStyle": "custom"
}
},
{
"path": "moldoperate/moldSelect",
"style": {
"navigationBarTitleText": "选择待上模模具",
"navigationStyle": "custom"
}
},
{
"path": "moldRepair/index",
"style": {
@ -700,6 +721,27 @@
"navigationBarTitleText": "任务计划",
"navigationStyle": "custom"
}
},
{
"path": "moldCheck/index",
"style": {
"navigationBarTitleText": "模具点检",
"navigationStyle": "custom"
}
},
{
"path": "moldCheck/detail",
"style": {
"navigationBarTitleText": "点检详情",
"navigationStyle": "custom"
}
},
{
"path": "moldCheck/add",
"style": {
"navigationBarTitleText": "新增点检",
"navigationStyle": "custom"
}
}
]
}

@ -0,0 +1,724 @@
<template>
<view class="page-container">
<NavBar :title="t('moldCheck.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('moldCheck.currentMoldInfo') }}</text>
</view>
<view class="form-field mold-select-field">
<text class="form-label">{{ t('moldCheck.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('moldCheck.selectMold') }}</text>
<text v-if="moldInfo.id" class="mold-select-subtext">{{ moldInfo.code || t('moldCheck.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('moldCheck.moldGroupCode') }}</text>
<text class="mold-info-value">{{ moldInfo.code || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldCheck.moldGroupName') }}</text>
<text class="mold-info-value">{{ moldInfo.name || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldCheck.cavityCount') }}</text>
<text class="mold-info-value">{{ moldInfo.moldSize || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldCheck.product') }}</text>
<text class="mold-info-value">{{ moldInfo.productName || '-' }}</text>
</view>
<view class="mold-info-item">
<text class="mold-info-label">{{ t('moldCheck.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('moldCheck.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('moldCheck.taskInfo') }}</text>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldCheck.taskName') }}<text class="required-star">*</text></text>
<input
v-model="taskName"
class="form-input"
:placeholder="t('moldCheck.placeholderTaskName')"
/>
</view>
<view class="form-field">
<text class="form-label">{{ t('moldCheck.templateSelection') }}<text class="required-star">*</text></text>
<view class="template-select" @click="openTemplatePicker">
<text :class="['template-text', selectedTemplate ? '' : 'placeholder']">{{ selectedTemplate?.planName || t('moldCheck.selectTemplate') }}</text>
<uni-icons type="right" size="18" color="#9ca3af"></uni-icons>
</view>
</view>
</view>
<!-- 点检项列表 -->
<view v-if="!inspectionItems.length" class="hint">{{ t('moldCheck.noItems') }}</view>
<view v-else 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('moldCheck.requiredText') }}</view>
</view>
<view class="inspection-fields">
<view class="field-row">
<text class="field-label">{{ t('moldCheck.inspectionMethod') }}</text>
<text class="field-value">{{ inspectionMethodText(item.inspectionMethod) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('moldCheck.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('moldCheck.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('moldCheck.textInput') }}</text>
<textarea
v-model="item.textInput"
class="form-textarea"
:placeholder="t('moldCheck.inputPlaceholder')"
maxlength="500"
/>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldCheck.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 class="image-remove" @click="removeImage(item, imgIndex)">×</view>
</view>
<view v-if="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('moldCheck.remark') }}</text>
<textarea
v-model="item.remark"
class="form-textarea"
:placeholder="t('moldCheck.inputPlaceholder')"
maxlength="500"
/>
</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')]"
@click="setDecision(item, '1')"
>
{{ t('moldCheck.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2')]"
@click="setDecision(item, '2')"
>
{{ t('moldCheck.inspectionResultFail') }}
</view>
<view v-if="String(item?.inspectionResult || '0') === '0'" class="pending-tag">{{ t('moldCheck.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 :class="['action-btn', 'submit-btn', submitLoading ? 'action-btn-disabled' : '']" @click="handleSubmit">{{ t('moldCheck.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('moldCheck.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('moldCheck.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('moldCheck.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('moldCheck.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-maintain' : 'type-inspect']">
{{ String(template.planType) === '1' ? t('moldCheck.taskTypeMaintain') : t('moldCheck.taskTypeInspect') }}
</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('moldCheck.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()
//
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 submitLoading = ref(false)
const statusClass = ref('')
//
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 {
// ID
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' || moldInfo.statusLabel.includes('正常') || moldInfo.statusLabel.includes('使用')) {
statusClass.value = 'status-success'
} else if (status === '2' || moldInfo.statusLabel.includes('维修') || moldInfo.statusLabel.includes('警')) {
statusClass.value = 'status-warning'
} else if (status === '3' || moldInfo.statusLabel.includes('报废') || moldInfo.statusLabel.includes('停')) {
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
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) {
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) {
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('moldCheck.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) {
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()
}
async function handleSubmit() {
if (submitLoading.value) return
if (!moldInfo.id) {
uni.showToast({ title: t('moldCheck.selectMoldError'), icon: 'none' })
return
}
if (!taskName.value.trim()) {
uni.showToast({ title: t('moldCheck.placeholderTaskName'), icon: 'none' })
return
}
if (!selectedTemplate.value) {
uni.showToast({ title: t('moldCheck.selectTemplateError'), icon: 'none' })
return
}
const hasUnselected = inspectionItems.value.some((item) => String(item?.inspectionResult || '0') === '0')
if (inspectionItems.value.length && hasUnselected) {
uni.showToast({ title: t('moldCheck.selectAllDecisionError'), icon: 'none' })
return
}
submitLoading.value = true
try {
await createMoldTicketDirect({
name: taskName.value.trim(),
taskType: '1',
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('moldCheckListNeedRefresh', '1')
uni.showToast({ title: t('moldCheck.submitSuccess'), icon: 'success' })
setTimeout(() => {
uni.navigateBack()
}, 1500)
} catch (error) {
uni.showToast({ title: t('moldCheck.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-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; }
.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: 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-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,424 @@
<template>
<view class="page-container">
<view class="fixed-header">
<NavBar :title="t('moldCheck.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('moldCheck.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('moldCheck.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('moldCheck.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('moldCheck.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('moldCheck.requiredText') }}</view>
</view>
<view class="result-fields">
<view class="field-row">
<text class="field-label">{{ t('moldCheck.inspectionMethod') }}</text>
<text class="field-value">{{ inspectionMethodText(item.inspectionMethod) }}</text>
</view>
<view class="field-row">
<text class="field-label">{{ t('moldCheck.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('moldCheck.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('moldCheck.textInput') }}</text>
<textarea
v-if="isEditableItem(item)"
v-model="item.textInput"
class="form-textarea"
:placeholder="t('moldCheck.inputPlaceholder')"
maxlength="500"
/>
<view v-else class="readonly-box">{{ textInputDisplay(item) }}</view>
</view>
<view class="field-block">
<text class="field-label block-label">{{ t('moldCheck.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="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('moldCheck.remark') }}</text>
<text class="field-value multiline">{{ textValue(item.remark) }}</text>
</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')]"
@click="setDecision(item, '1')"
>
{{ t('moldCheck.inspectionResultPass') }}
</view>
<view
:class="['result-option', resultOptionClass(item, '2')]"
@click="setDecision(item, '2')"
>
{{ t('moldCheck.inspectionResultFail') }}
</view>
<view v-if="isEditableItem(item) && String(item?.inspectionResult || '') === '0'" class="pending-tag">{{ t('moldCheck.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('moldCheck.taskTypeInspect')
if (value === '2') return t('moldCheck.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('moldCheckDetail')
if (cached) {
Object.assign(detailData, JSON.parse(cached))
uni.removeStorageSync('moldCheckDetail')
}
} 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('moldCheck.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('moldCheck.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('moldCheck.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.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: 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-btn-disabled { background: #94a3b8; }
</style>

@ -0,0 +1,560 @@
<template>
<view class="page-container">
<NavBar :title="t('moldCheck.moduleName')" />
<view class="filter-bar">
<view class="keyword-box">
<input v-model="searchKeyword" class="keyword-input" :placeholder="t('moldCheck.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('moldCheck.moldName') }}</text>
<text class="value">{{ textValue(item.moldName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldCheck.template') }}</text>
<text class="value">{{ textValue(item.configName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldCheck.operator') }}</text>
<text class="value">{{ textValue(item.operatorName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldCheck.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('moldCheck.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('moldCheckListNeedRefresh') === '1') {
uni.removeStorageSync('moldCheckListNeedRefresh')
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: '1',
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('moldCheckDetail', JSON.stringify(item))
uni.navigateTo({
url: `/pages_function/pages/moldCheck/detail?id=${encodeURIComponent(String(item.id))}`
})
}
function goAdd() {
uni.navigateTo({
url: '/pages_function/pages/moldCheck/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('moldCheck.taskTypeInspect')
if (normalized === '2') return t('moldCheck.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('moldCheck.jobResultOk')
if (normalized === '2' || normalized === 'NG') return t('moldCheck.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>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,366 @@
<template>
<view class="page-container">
<NavBar :title="t('moldOperate.selectDevice')" />
<!-- 搜索区 -->
<view class="search-bar">
<view class="search-input-wrap">
<text class="search-icon iconfont icon-search"></text>
<input class="search-input" v-model="searchText" :placeholder="t('equipmentLedger.placeholderDeviceName')" @input="onSearch" placeholder-class="search-placeholder" />
<text v-if="searchText" class="search-clear" @click="clearSearch"></text>
</view>
</view>
<!-- 设备列表 -->
<scroll-view scroll-y class="device-list" v-if="filteredList.length > 0">
<view
v-for="device in filteredList"
:key="device.id"
class="device-card"
:class="{ active: selectedId === device.id }"
@click="selectedId = device.id"
>
<view class="device-card-header">
<text class="device-name">{{ textValue(device.deviceName) }}</text>
<view class="device-status-tag" :class="getStatusClass(device.deviceStatus)">
{{ getStatusLabel(device) }}
</view>
</view>
<view class="device-card-body">
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.deviceCode') }}</text>
<text class="info-value">{{ textValue(device.deviceCode) }}</text>
</view>
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.productionLine') }}</text>
<text class="info-value">{{ textValue(device.workshopName) }}</text>
</view>
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.currentMold') }}</text>
<text class="info-value">{{ getCurrentMold(device) }}</text>
</view>
<view class="device-info-row">
<text class="info-label">{{ t('moldOperate.deviceStatus') }}</text>
<text class="info-value">{{ getStatusLabel(device) }}</text>
</view>
</view>
</view>
</scroll-view>
<!-- 空状态 -->
<view v-else class="empty-wrap">
<text v-if="loading" class="empty-text">{{ t('functionCommon.loading') }}</text>
<text v-else class="empty-text">{{ t('moldOperate.noDeviceData') }}</text>
</view>
<!-- 底部确认按钮 -->
<view class="bottom-actions">
<view class="bottom-btn confirm-btn" @click="handleConfirm">
{{ t('functionCommon.confirm') }}
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getDeviceLedgerList } from '@/api/mes/moldoperate'
const { t } = useI18n()
const deviceList = ref([])
const selectedId = ref(null)
const searchText = ref('')
const loading = ref(false)
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function getStatusClass(status) {
const s = Number(status)
if (s === 0) return 'running-tag'
if (s === 1) return 'stop-tag'
if (s >= 2) return 'fault-tag'
return ''
}
function getStatusLabel(device) {
const status = Number(device.deviceStatus)
const map = {
0: t('moldOperate.statusRunning'),
1: t('moldOperate.statusStop'),
2: t('moldOperate.statusFault'),
3: t('moldOperate.statusFault')
}
return map[status] || textValue(device.deviceStatus) || '-'
}
// - fallback
function getCurrentMold(device) {
const deviceId = device?.id
const deviceCode = device?.deviceCode
// 1. _mountedMoldInfoMap deviceId deviceCode fallback
try {
const map = uni.getStorageSync('_mountedMoldInfoMap') || {}
// id
const key = String(deviceId)
let info = deviceId != null ? map[key] : null
// deviceCode id
if (!info && deviceCode) {
const found = Object.values(map).find((item) => item?.deviceCode === deviceCode)
if (found) info = found
}
//
if (!getCurrentMold._logged) {
getCurrentMold._logged = true
console.log('[deviceSelect] === 调试信息 ===')
console.log('[deviceSelect] storage map keys:', Object.keys(map))
console.log('[deviceSelect] storage map values:', map)
console.log('[deviceSelect] 当前设备 deviceId:', deviceId, 'type:', typeof deviceId, 'key:', key)
console.log('[deviceSelect] 当前设备 deviceCode:', deviceCode)
console.log('[deviceSelect] id匹配结果:', info ? '命中' : '未命中')
if (!info) {
console.log('[deviceSelect] 尝试 deviceCode fallback...')
for (const [k, v] of Object.entries(map)) {
console.log('[deviceSelect] storage[', k, '].deviceCode =', v?.deviceCode, 'vs 设备 code =', deviceCode, '匹配:', v?.deviceCode === deviceCode)
}
}
// fallback
const saved = uni.getStorageSync('_mountedMoldInfo') || null
console.log('[deviceSelect] 旧版 _mountedMoldInfo:', saved)
console.log('[deviceSelect] 设备台账字段 currentMold:', device?.currentMold, 'moldName:', device?.moldName, 'moldId:', device?.moldId)
}
if (info?.mold) {
return info.mold.name || info.mold.moldName || '-'
}
} catch (e) {
console.warn('[deviceSelect] read _mountedMoldInfoMap error', e)
}
// 2. _mountedMoldInfo
let saved = null
try { saved = uni.getStorageSync('_mountedMoldInfo') || null } catch {}
if (saved) {
const idMatch = deviceId != null && String(saved.deviceId) === String(deviceId)
const codeMatch = deviceCode && saved.deviceCode === deviceCode
if (idMatch || codeMatch) {
return saved.mold?.name || saved.mold?.moldName || '-'
}
}
// 3. fallback
const staticMold = textValue(device.currentMold || device.moldName || device.moldId)
return staticMold === '-' ? t('moldOperate.noMoldOnDevice') : staticMold
}
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)
})
})
function onSearch() {}
function clearSearch() {
searchText.value = ''
}
async function loadDevices() {
loading.value = true
try {
const res = await getDeviceLedgerList({ pageNo: 1, pageSize: 100 })
const root = res && res.data !== undefined ? res.data : res
deviceList.value = Array.isArray(root)
? root
: Array.isArray(root?.list) ? root.list
: Array.isArray(root?.rows) ? root.rows
: Array.isArray(root?.records) ? root.records
: []
} catch (e) {
console.error('loadDevices error', e)
} finally {
loading.value = false
}
}
function handleConfirm() {
if (!selectedId.value) {
uni.showToast({ title: t('moldOperate.validatorDeviceRequired'), icon: 'none' })
return
}
const device = deviceList.value.find((d) => d.id === selectedId.value)
// globalData onShow
getApp().globalData._deviceSelectResult = device || null
uni.navigateBack()
}
onShow(async () => {
await loadDevices()
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: 140rpx;
}
/* 搜索栏 */
.search-bar {
padding: 16rpx 24rpx;
background: #fff;
}
.search-input-wrap {
display: flex;
align-items: center;
height: 72rpx;
padding: 0 16rpx;
background: #f5f6f8;
border-radius: 36rpx;
}
.search-icon {
font-size: 32rpx;
color: #999;
margin-right: 12rpx;
}
.search-input {
flex: 1;
font-size: 28rpx;
color: #333;
}
.search-placeholder {
color: #bbb;
}
.search-clear {
font-size: 28rpx;
color: #999;
padding: 8rpx;
}
/* 设备列表 */
.device-list {
padding: 16rpx 24rpx;
}
.device-card {
background: #fff;
border-radius: 14rpx;
padding: 24rpx;
margin-bottom: 16rpx;
border: 2rpx solid transparent;
&.active {
border-color: #2563eb;
background: #f0f5ff;
}
}
.device-card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.device-name {
font-size: 30rpx;
font-weight: 700;
color: #1a1a1a;
}
.device-status-tag {
padding: 4rpx 16rpx;
border-radius: 6rpx;
font-size: 22rpx;
font-weight: 500;
&.running-tag { color: #059669; background: #ecfdf5; border: 1rpx solid #a7f3d0; }
&.stop-tag { color: #d97706; background: #fffbeb; border: 1rpx solid #fde68a; }
&.fault-tag { color: #dc2626; background: #fef2f2; border: 1rpx solid #fecaca; }
}
.device-card-body {
border-top: 1rpx solid #f0f0f0;
padding-top: 16rpx;
}
.device-info-row {
display: flex;
align-items: center;
margin-bottom: 10rpx;
&:last-child {
margin-bottom: 0;
}
}
.info-label {
width: 140rpx;
font-size: 24rpx;
color: #999;
flex-shrink: 0;
}
.info-value {
font-size: 26rpx;
color: #333;
}
/* 空状态 */
.empty-wrap {
padding: 120rpx 0;
text-align: center;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
/* 底部确认按钮 */
.bottom-actions {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + 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;
text-align: center;
border-radius: 12rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
color: #fff;
}
</style>

@ -0,0 +1,733 @@
<template>
<view class="page-container">
<NavBar :title="t('moldOperate.tabDown')" />
<!-- 操作按钮区 -->
<view class="action-row">
<view class="action-btn scan-btn" @click="handleScan">
<view class="btn-icon-wrap">
<text class="iconfont icon-scan btn-icon"></text>
</view>
<text class="btn-text">{{ t('moldOperate.scanDevice') }}</text>
</view>
<view class="action-btn select-btn" @click="openDevicePicker">
<view class="btn-icon-wrap">
<text class="iconfont icon-device btn-icon"></text>
</view>
<text class="btn-text">{{ t('moldOperate.selectDevice') }}</text>
</view>
</view>
<!-- 设备信息卡片 -->
<view class="section-card">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">{{ t('moldOperate.deviceInfo') }}</text>
</view>
<view class="card-body-grid">
<view class="grid-row">
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.deviceName') }}</text>
<text class="grid-value">{{ textValue(selectedDevice.deviceName) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.deviceCode') }}</text>
<text class="grid-value">{{ textValue(selectedDevice.deviceCode) }}</text>
</view>
</view>
<view class="grid-row">
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.productionLine') }}</text>
<text class="grid-value">{{ textValue(selectedDevice.workshopName) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.deviceStatus') }}</text>
<view class="status-tag" :class="deviceStatusClass">{{ deviceStatusLabel }}</view>
</view>
</view>
</view>
</view>
<!-- 当前在机模具 -->
<view class="section-card">
<view class="section-title-bar">
<view class="section-bar-line"></view>
<text class="section-title">{{ t('moldOperate.currentMoldInfo') }}</text>
</view>
<template v-if="selectedMold && selectedMold.id">
<view class="card-body-grid">
<view class="grid-row">
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.moldName') }}</text>
<text class="grid-value highlight">{{ textValue(selectedMold.moldName) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.moldCode') }}</text>
<text class="grid-value">{{ textValue(selectedMold.moldCode) }}</text>
</view>
</view>
<view class="grid-row">
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.product') }}</text>
<text class="grid-value">{{ textValue(selectedMold.productName) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.mountTime') }}</text>
<text class="grid-value">{{ textValue(selectedMold.mountTime) }}</text>
</view>
</view>
<view class="grid-row">
<view class="grid-cell full-width">
<text class="grid-label">{{ t('moldOperate.useCount') }}</text>
<text class="grid-value highlight">{{ formatUseCount(selectedMold.useCount) }}</text>
</view>
</view>
</view>
<!-- 更换下模对象按钮 -->
<view class="change-target-btn" @click="openLowerMoldPicker">
<text class="change-icon">&#8644;</text>
<text class="change-text">{{ t('moldOperate.changeTarget') }}</text>
</view>
</template>
<!-- 已选设备但无在机模具 -->
<view v-else-if="selectedDevice.id && moldsLoaded" class="empty-mold-hint">
<text class="empty-mold-text empty-gray">{{ t('moldOperate.noMoldOnDevice') }}</text>
</view>
<!-- 未选设备 -->
<view v-else class="empty-mold-hint" @click="handleSelectDeviceFirst">
<text class="empty-mold-text">+ {{ t('moldOperate.clickSelectDeviceFirst') }}</text>
</view>
</view>
<!-- 底部操作栏 -->
<view class="bottom-actions">
<view class="bottom-btn confirm-btn" @click="handleConfirm">{{ t('moldOperate.confirmDismount') }}</view>
</view>
<!-- 在机模具选择弹框更换下模对象 -->
<uni-popup ref="lowerMoldPickerRef" type="bottom">
<view class="picker-popup">
<view class="picker-header">
<text class="picker-close-left" @click="closeLowerMoldPicker">{{ t('functionCommon.cancel') }}</text>
<text class="picker-title">{{ t('moldOperate.currentMoldInfo') }}</text>
<text class="picker-close-right" @click="confirmLowerMoldSelection">{{ t('functionCommon.confirm') }}</text>
</view>
<scroll-view scroll-y class="picker-scroll">
<view v-for="m in lowerMoldOptions" :key="m.id || m.moldId"
class="picker-item" :class="{ active: tempSelectedMoldId === String(m.id || m.moldId) }"
@click="tempSelectedMoldId = String(m.id || m.moldId)">
<view class="picker-item-content">
<text class="picker-item-name">{{ textValue(m.moldName || m.name) }}</text>
<text class="picker-item-code">{{ textValue(m.moldCode || m.code) }}</text>
</view>
<text class="picker-check-icon" v-if="tempSelectedMoldId === String(m.id || m.moldId)">&#10003;</text>
</view>
<view v-if="lowerMoldLoading" class="picker-hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!lowerMoldOptions.length" class="picker-empty">{{ t('moldOperate.noMoldOnDevice') }}</view>
</scroll-view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue'
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'
const { t } = useI18n()
// ---- ----
const selectedDevice = ref({})
const deviceOptions = ref([])
// ---- ----
const selectedMold = ref({})
const lowerMoldPickerRef = ref(null)
const lowerMoldOptions = ref([])
const lowerMoldLoading = ref(false)
const moldsLoaded = ref(false)
const tempSelectedMoldId = ref(null)
// ---- ----
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
function formatUseCount(count) {
if (count == null) return '-'
const num = Number(count)
if (isNaN(num)) return String(count)
return num.toLocaleString() + ' ' + t('moldOperate.countUnit')
}
function formatTime(time) {
if (!time) return '-'
if (typeof time === 'string') {
if (time.includes('-') || time.includes('T')) {
return time.replace(/T/, ' ').substring(0, 19)
}
const ts = Number(time)
if (!isNaN(ts) && ts > 1e10) return new Date(ts).toLocaleString()
else if (!isNaN(ts) && ts > 1e7) return new Date(ts * 1000).toLocaleString()
return time
}
if (typeof time === 'number') {
if (time > 1e10) return new Date(time).toLocaleString()
if (time > 1e7) return new Date(time * 1000).toLocaleString()
return String(time)
}
return '-'
}
const deviceStatusClass = computed(() => {
const status = Number(selectedDevice.value?.deviceStatus)
if (status === 0) return 'running-tag'
if (status === 1) return 'stop-tag'
if (status >= 2) return 'fault-tag'
return ''
})
const deviceStatusLabel = computed(() => {
const status = Number(selectedDevice.value?.deviceStatus)
const map = {
0: t('moldOperate.statusRunning'),
1: t('moldOperate.statusStop'),
2: t('moldOperate.statusFault'),
3: t('moldOperate.statusFault')
}
return map[status] || textValue(selectedDevice.value?.deviceStatus) || '-'
})
// ---- ----
async function loadDevices() {
try {
const res = await getDeviceLedgerList({ pageNo: 1, pageSize: 100 })
const root = res && res.data !== undefined ? res.data : res
const data = Array.isArray(root)
? root
: Array.isArray(root?.list) ? root.list
: Array.isArray(root?.rows) ? root.rows
: []
deviceOptions.value = data.map((d) => ({
value: d.id,
label: `${d.deviceCode || ''} ${d.deviceName || ''}`.trim(),
raw: d
}))
} catch (e) {
console.error('loadDevices error', e)
}
}
//
function findArr(obj, d = 0) {
if (!obj || typeof obj !== 'object' || d > 3) return []
if (Array.isArray(obj)) return obj
for (const k of ['list', 'rows', 'records', 'items', 'data']) {
if (Array.isArray(obj[k])) return obj[k]
}
for (const v of Object.values(obj)) {
const found = findArr(v, d + 1)
if (found.length) return found
}
return []
}
async function loadLowerMolds(deviceId) {
lowerMoldLoading.value = true
try {
// ====== 1ID======
let map = {}
try { map = uni.getStorageSync('_mountedMoldInfoMap') || {} } catch {}
const savedInfo = map[String(deviceId)] || null
console.log('[下模] 持久化在机模具信息 =', savedInfo ? JSON.stringify(savedInfo) : 'null', 'deviceId=', deviceId)
if (savedInfo && savedInfo.mold) {
console.log('[下模] 命中持久化数据, deviceId=', deviceId)
const m = savedInfo.mold
lowerMoldOptions.value = [{
id: m.id,
moldId: m.id,
moldName: m.name || m.moldName || '-',
moldCode: m.code || m.moldCode || '-',
productName: m.productName || '-',
mountTime: formatTime(savedInfo.mountTime),
useCount: '-'
}]
console.log('[下模] 使用持久化数据 =', JSON.stringify(lowerMoldOptions.value[0]))
return
}
console.log('[下模] 未命中持久化数据,进入接口查询')
// ====== 2fallback - ======
let list = []
try {
const res = await getLowerMoldList(deviceId)
const root = (res && res.data !== undefined) ? res.data : res
list = findArr(root)
} catch (apiErr) {
console.warn('[下模] getLowerMoldList 接口异常', apiErr)
}
lowerMoldOptions.value = list
console.log('[下模] loadLowerMolds 返回 list.length =', list.length)
} catch (e) {
console.error('loadLowerMolds error', e)
} finally {
lowerMoldLoading.value = false
}
}
// ---- ----
function handleScan() {
uni.scanCode({
onlyFromCamera: false,
scanType: ['qrCode', 'barCode'],
success(res) {
const code = res.result?.trim()
if (!code) return
const matched = deviceOptions.value.find((d) =>
d.raw.deviceCode === code || String(d.raw.code) === code || d.label.includes(code)
)
if (matched) {
selectDevice(matched.raw)
} else {
uni.showToast({ title: t('moldOperate.deviceNotFound'), icon: 'none' })
}
},
fail(err) {
if (err.errMsg && !err.errMsg.includes('cancel')) {
console.warn('scan failed:', err)
}
}
})
}
// ---- ----
function selectDevice(device) {
selectedDevice.value = device || {}
moldsLoaded.value = false
selectedMold.value = {}
if (device?.id) {
loadLowerMolds(device.id).then(() => {
moldsLoaded.value = true
if (lowerMoldOptions.value.length > 0) {
const first = lowerMoldOptions.value[0]
selectedMold.value = {
id: first.id || first.moldId,
moldName: first.moldName || first.name,
moldCode: first.moldCode || first.code,
productName: first.productName || '-',
mountTime: first.mountTime || '-',
useCount: first.useCount ?? '-'
}
}
})
}
}
function openDevicePicker() {
uni.navigateTo({ url: '/pages_function/pages/moldoperate/deviceSelect' })
}
// ---- ----
function openLowerMoldPicker() {
if (!selectedDevice.value?.id) {
uni.showToast({ title: t('moldOperate.validatorDeviceRequired'), icon: 'none' })
return
}
tempSelectedMoldId.value = selectedMold.value ? String(selectedMold.value.id || selectedMold.value.moldId) : null
loadLowerMolds(selectedDevice.value.id).then(() => {
lowerMoldPickerRef.value?.open()
})
}
function confirmLowerMoldSelection() {
const mold = lowerMoldOptions.value.find(
(m) => String(m.id || m.moldId) === tempSelectedMoldId.value
)
if (mold) {
selectedMold.value = {
id: mold.id || mold.moldId,
moldName: mold.moldName || mold.name,
moldCode: mold.moldCode || mold.code,
productName: mold.productName || '-',
mountTime: mold.mountTime || '-',
useCount: mold.useCount ?? '-'
}
}
lowerMoldPickerRef.value?.close()
}
function closeLowerMoldPicker() { lowerMoldPickerRef.value?.close() }
function handleSelectDeviceFirst() {
openDevicePicker()
}
// ---- ----
function validForm() {
if (!selectedDevice.value?.id) {
uni.showToast({ title: t('moldOperate.validatorDeviceRequired'), icon: 'none' })
return false
}
if (!selectedMold.value?.id) {
uni.showToast({ title: t('moldOperate.validatorLowerMoldRequired'), icon: 'none' })
return false
}
return true
}
async function handleConfirm() {
if (!validForm()) return
try {
const payload = {
operateType: '2',
deviceId: String(selectedDevice.value.id),
moldId: String(selectedMold.value.id)
}
console.log('[下模] 提交参数 =', JSON.stringify(payload))
await createMoldOperate(payload)
uni.showToast({ title: t('functionCommon.createSuccess'), icon: 'success' })
//
if (selectedDevice.value?.id) {
try {
const map = uni.getStorageSync('_mountedMoldInfoMap') || {}
delete map[String(selectedDevice.value.id)]
uni.setStorageSync('_mountedMoldInfoMap', map)
} catch {}
}
//
selectedDevice.value = {}
selectedMold.value = {}
lowerMoldOptions.value = []
} catch (e) {
console.error('[下模] 保存失败 =', e)
const errMsg = e?.msg || (typeof e === 'string' ? e : e?.message) || '系统异常'
uni.showToast({ title: t('functionCommon.saveFailed') + ': ' + errMsg, icon: 'none', duration: 3000 })
}
}
onShow(async () => {
await Promise.allSettled([loadDevices()])
// globalData
const device = getApp().globalData._deviceSelectResult
if (device) {
getApp().globalData._deviceSelectResult = null
selectDevice(device)
}
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: 140rpx;
}
/* ====== 操作按钮区 ====== */
.action-row {
display: flex;
gap: 20rpx;
padding: 20rpx 24rpx;
}
.action-btn {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
gap: 12rpx;
height: 96rpx;
border-radius: 12rpx;
background: #2563eb;
color: #fff;
font-size: 28rpx;
font-weight: 600;
.btn-icon-wrap {
width: 44rpx;
height: 44rpx;
display: flex;
align-items: center;
justify-content: center;
}
.btn-icon {
font-size: 36rpx;
color: #fff;
}
.btn-text {
font-size: 28rpx;
}
}
/* ====== 卡片通用样式 ====== */
.section-card {
margin: 16rpx 24rpx;
background: #ffffff;
border-radius: 14rpx;
overflow: hidden;
}
.section-title-bar {
display: flex;
align-items: center;
gap: 10rpx;
padding: 22rpx 24rpx 0;
}
.section-bar-line {
width: 6rpx;
height: 32rpx;
border-radius: 3rpx;
background: #2563eb;
}
.section-title {
font-size: 30rpx;
font-weight: 700;
color: #1a1a1a;
}
.card-body-grid {
padding: 20rpx 24rpx 28rpx;
}
/* ====== 网格布局 ====== */
.grid-row {
display: flex;
gap: 20rpx;
margin-top: 18rpx;
&:first-child {
margin-top: 0;
}
}
.grid-cell {
flex: 1;
min-width: 0;
&.full-width {
flex-basis: 100%;
display: flex;
align-items: center;
gap: 12rpx;
}
}
.grid-label {
display: block;
font-size: 24rpx;
color: #999;
margin-bottom: 6rpx;
}
.grid-value {
display: block;
font-size: 27rpx;
color: #333;
word-break: break-all;
&.highlight {
color: #2563eb;
font-weight: 600;
}
}
/* ====== 状态标签 ====== */
.status-tag {
display: inline-flex;
align-items: center;
padding: 6rpx 18rpx;
border-radius: 6rpx;
font-size: 24rpx;
font-weight: 500;
&.running-tag {
color: #059669;
background: #ecfdf5;
border: 1rpx solid #a7f3d0;
}
&.stop-tag {
color: #d97706;
background: #fffbeb;
border: 1rpx solid #fde68a;
}
&.fault-tag {
color: #dc2626;
background: #fef2f2;
border: 1rpx solid #fecaca;
}
&.pending-tag {
color: #2563eb;
background: #eff6ff;
border: 1rpx solid #bfdbfe;
}
}
/* ====== 更换下模对象按钮 ====== */
.change-target-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
margin: 0 24rpx 24rpx;
padding: 20rpx 0;
border: 1rpx dashed #ccc;
border-radius: 10rpx;
.change-icon {
font-size: 28rpx;
color: #666;
}
.change-text {
font-size: 26rpx;
color: #666;
}
&:active {
background: #fafafa;
}
}
/* ====== 空提示 ====== */
.empty-mold-hint {
padding: 40rpx 24rpx;
text-align: center;
}
.empty-mold-text {
font-size: 28rpx;
color: #2563eb;
}
/* ====== 底部操作栏 ====== */
.bottom-actions {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + 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;
text-align: center;
border-radius: 12rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
color: #fff;
}
/* ====== 弹窗通用 ====== */
.picker-popup {
background: #fff;
border-radius: 24rpx 24rpx 0 0;
max-height: 75vh;
}
.picker-header {
height: 96rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.picker-close-left,
.picker-close-right {
font-size: 28rpx;
color: #2563eb;
padding: 8rpx 0;
}
.picker-title {
font-size: 30rpx;
font-weight: 700;
color: #1a1a1a;
}
.picker-scroll {
max-height: calc(75vh - 96rpx);
padding: 12rpx 0 32rpx;
}
.picker-item {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 24rpx 12rpx;
padding: 22rpx 20rpx;
border-radius: 12rpx;
background: #f8fafc;
&.active {
background: #eff6ff;
border: 1rpx solid #bfdbfe;
}
}
.picker-item-content {
flex: 1;
min-width: 0;
}
.picker-item-name {
display: block;
font-size: 28rpx;
color: #1a1a1a;
font-weight: 500;
}
.picker-item-code {
display: block;
font-size: 23rpx;
color: #999;
margin-top: 4rpx;
}
.picker-check-icon {
font-size: 30rpx;
color: #2563eb;
font-weight: 700;
margin-left: 16rpx;
flex-shrink: 0;
}
.picker-empty,
.picker-hint {
text-align: center;
color: #999;
padding: 60rpx 0;
font-size: 26rpx;
}
</style>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,351 @@
<template>
<view class="page-container">
<NavBar :title="t('moldOperate.selectMountMold')" />
<!-- 搜索区 -->
<view class="search-bar">
<view class="search-input-wrap">
<text class="search-icon iconfont icon-search"></text>
<input class="search-input" v-model="searchText" :placeholder="t('moldOperate.searchName')" @input="onSearch" placeholder-class="search-placeholder" />
<text v-if="searchText" class="search-clear" @click="clearSearch"></text>
</view>
</view>
<!-- 模具列表 -->
<scroll-view scroll-y class="mold-list" v-if="filteredList.length > 0">
<view
v-for="mold in filteredList"
:key="mold.id"
class="mold-card"
:class="{ active: selectedIds.has(String(mold.id)) }"
@click="toggleMold(mold)"
>
<view class="mold-card-header">
<text class="mold-name">{{ textValue(mold.name) }}</text>
<text class="mold-check-icon" v-if="selectedIds.has(String(mold.id))">&#10003;</text>
</view>
<view class="mold-card-body">
<view class="info-row">
<text class="info-label">{{ t('moldOperate.moldCode') }}</text>
<text class="info-value">{{ textValue(mold.code) }}</text>
</view>
<view class="info-row">
<text class="info-label">产品型号</text>
<text class="info-value">{{ textValue(mold.productName) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldOperate.status') }}</text>
<view :class="['status-tag', getStatusClass(mold.status)]">{{ getStatusText(mold.status) }}</view>
</view>
</view>
</view>
</scroll-view>
<!-- 空状态 -->
<view v-else class="empty-wrap">
<text v-if="loading" class="empty-text">{{ t('functionCommon.loading') }}</text>
<text v-else class="empty-text">{{ t('moldOperate.noMoldData') }}</text>
</view>
<!-- 底部确认按钮 -->
<view class="bottom-actions">
<view class="bottom-btn confirm-btn" @click="handleConfirm">
{{ t('functionCommon.confirm') }}{{ selectedIds.size > 0 ? `(${selectedIds.size})` : '' }}
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getMoldBrandPage } from '@/api/mes/mold'
const { t } = useI18n()
const moldList = ref([])
const selectedIds = ref(new Set())
const searchText = ref('')
const loading = ref(false)
function textValue(v) {
if (v === 0) return '0'
if (v == null) return '-'
const s = String(v).trim()
return s || '-'
}
const STATUS_MAP = { 0: '在机', 1: '待用', 2: '维修', 3: '报废' }
function getStatusText(s) { return STATUS_MAP[s] || textValue(s) }
function getStatusClass(s) {
if (s === 0) return 'in-use-tag'
if (s === 2) return 'repairing-tag'
if (s === 3) return 'scrapped-tag'
return 'standby-tag'
}
const filteredList = computed(() => {
const keyword = searchText.value.trim().toLowerCase()
if (!keyword) return moldList.value
return moldList.value.filter((m) => {
return (m.name || '').toLowerCase().includes(keyword) ||
(m.code || '').toLowerCase().includes(keyword) ||
(m.productName || '').toLowerCase().includes(keyword)
})
})
function onSearch() {}
function clearSearch() {
searchText.value = ''
}
async function loadMolds() {
loading.value = true
try {
const res = await getMoldBrandPage({ pageNo: 1, pageSize: 100 })
const root = (res && res.data !== undefined) ? res.data : res
// list/rows/records
function findList(obj, depth = 0) {
if (!obj || typeof obj !== 'object' || depth > 3) return []
if (Array.isArray(obj)) return obj
for (const key of ['list', 'rows', 'records', 'items', 'data']) {
if (Array.isArray(obj[key])) return obj[key]
}
for (const val of Object.values(obj)) {
const found = findList(val, depth + 1)
if (found.length) return found
}
return []
}
moldList.value = findList(root)
//
if (!moldList.value.length) console.error('moldSelect: 未找到模具数据', root)
} catch (e) {
console.error('loadMolds error', e)
} finally {
loading.value = false
}
}
function toggleMold(mold) {
const id = String(mold.id)
const set = new Set(selectedIds.value)
if (set.has(id)) {
set.delete(id)
} else {
//
set.clear()
set.add(id)
}
selectedIds.value = set
}
function handleConfirm() {
if (selectedIds.value.size === 0) {
uni.showToast({ title: t('moldOperate.validatorMoldRequired'), icon: 'none' })
return
}
const selected = moldList.value.filter((m) => selectedIds.value.has(String(m.id)))
.map((m) => ({
id: m.id,
name: m.name,
code: m.code,
productName: m.productName || '-',
status: m.status
}))
getApp().globalData._moldSelectResult = selected
uni.navigateBack()
}
onShow(async () => {
// index.vue
const preSelected = getApp().globalData._moldSelectPreSelected
if (preSelected && Array.isArray(preSelected)) {
selectedIds.value = new Set(preSelected.map((id) => String(id)))
getApp().globalData._moldSelectPreSelected = null
} else {
selectedIds.value = new Set()
}
await loadMolds()
})
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: 140rpx;
}
/* 搜索栏 */
.search-bar {
padding: 16rpx 24rpx;
background: #fff;
}
.search-input-wrap {
display: flex;
align-items: center;
height: 72rpx;
padding: 0 16rpx;
background: #f5f6f8;
border-radius: 36rpx;
}
.search-icon {
font-size: 32rpx;
color: #999;
margin-right: 12rpx;
}
.search-input {
flex: 1;
font-size: 28rpx;
color: #333;
}
.search-placeholder {
color: #bbb;
}
.search-clear {
font-size: 28rpx;
color: #999;
padding: 8rpx;
}
/* 模具列表 */
.mold-list {
padding: 16rpx 24rpx;
}
.mold-card {
background: #fff;
border-radius: 14rpx;
padding: 24rpx;
margin-bottom: 16rpx;
border: 2rpx solid transparent;
&.active {
border-color: #2563eb;
background: #f0f5ff;
}
}
.mold-card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
}
.mold-name {
font-size: 30rpx;
font-weight: 700;
color: #1a1a1a;
}
.mold-check-icon {
font-size: 32rpx;
color: #2563eb;
font-weight: 700;
flex-shrink: 0;
width: 40rpx;
height: 40rpx;
line-height: 36rpx;
text-align: center;
border: 2rpx solid #2563eb;
border-radius: 50%;
}
.mold-card-body {
border-top: 1rpx solid #f0f0f0;
padding-top: 16rpx;
}
.info-row {
display: flex;
align-items: center;
margin-bottom: 10rpx;
&:last-child {
margin-bottom: 0;
}
}
.info-label {
width: 140rpx;
font-size: 24rpx;
color: #999;
flex-shrink: 0;
}
.info-value {
font-size: 26rpx;
color: #333;
}
/* 状态标签 */
.status-tag {
display: inline-flex;
align-items: center;
padding: 4rpx 16rpx;
border-radius: 6rpx;
font-size: 22rpx;
font-weight: 500;
&.standby-tag {
color: #2563eb; background: #eff6ff; border: 1rpx solid #bfdbfe;
}
&.in-use-tag {
color: #059669; background: #ecfdf5; border: 1rpx solid #a7f3d0;
}
&.repairing-tag {
color: #d97706; background: #fffbeb; border: 1rpx solid #fde68a;
}
&.scrapped-tag {
color: #dc2626; background: #fef2f2; border: 1rpx solid #fecaca;
}
}
/* 空状态 */
.empty-wrap {
padding: 120rpx 0;
text-align: center;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
/* 底部确认按钮 */
.bottom-actions {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 16rpx 24rpx calc(16rpx + 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;
text-align: center;
border-radius: 12rpx;
font-size: 30rpx;
font-weight: 600;
}
.confirm-btn {
background: #2563eb;
color: #fff;
}
</style>

@ -13,6 +13,7 @@ export enum DICT_TYPE {
VALUE_TYPES = "value_types",
JOB_STATUS = "job_status",
MES_TASK_STATUS = "mes_task_status",
SUBMOLD_TYPE = "submold_type",
}
type DictItem = {

@ -73,6 +73,8 @@ const MENU_ROUTE_MAP = {
moldget: '/pages_function/pages/moldget/index',
moldreturn: '/pages_function/pages/moldreturn/index',
moldoperate: '/pages_function/pages/moldoperate/index',
moldmount: '/pages_function/pages/moldoperate/index',
molddismount: '/pages_function/pages/moldoperate/dismount',
mold: '/pages_function/pages/mold/index',
equipment: '/pages_function/pages/equipment/index',
spare: '/pages_function/pages/spare/index',
@ -228,6 +230,32 @@ export function findTabMenuByPage(menus, pagePath) {
return dynamicMenus.find((menu) => normalizePagePath(resolveMenuUrl(menu)) === targetPath) || null
}
// 上下模拆分映射
const MOLD_OPERATE_SPLIT_MAP = {
'上下模': [
{ name: '上模', key: 'moldmount' },
{ name: '下模', key: 'molddismount' }
],
moldoperate: [
{ name: '上模', key: 'moldmount' },
{ name: '下模', key: 'molddismount' }
]
}
function splitMoldOperateEntry(entry) {
const keys = [String(entry.name || '').trim(), normalizeMenuKey(entry.component || ''), normalizeMenuKey(entry.enName || '')]
for (const k of keys) {
if (MOLD_OPERATE_SPLIT_MAP[k]) {
return MOLD_OPERATE_SPLIT_MAP[k].map((item) => ({
...entry,
name: item.name,
_splitKey: item.key
}))
}
}
return null
}
export function buildPageModules(tabMenu) {
return toArray(tabMenu?.children)
.map((module) => {
@ -236,12 +264,18 @@ export function buildPageModules(tabMenu) {
if (hasNestedEntries) {
return {
...module,
children: directChildren.flatMap((child) => toArray(child.children))
children: directChildren.flatMap((child) => toArray(child.children).flatMap((entry) => {
const splitted = splitMoldOperateEntry(entry)
return splitted || [entry]
}))
}
}
return {
...module,
children: directChildren
children: directChildren.flatMap((entry) => {
const splitted = splitMoldOperateEntry(entry)
return splitted || [entry]
})
}
})
.filter((module) => (module.children || []).length > 0)
@ -252,6 +286,11 @@ export function resolveMenuUrl(menu) {
return '/pages/index'
}
// 拆分后的上下模子项,优先用 _splitKey 匹配(必须在 directRoute 之前)
if (menu?._splitKey && MENU_ROUTE_MAP[menu._splitKey]) {
return MENU_ROUTE_MAP[menu._splitKey]
}
const directRoute = getDirectRoute(menu?.path) || getDirectRoute(menu?.component)
if (directRoute) {
return directRoute

@ -21,6 +21,10 @@ const request = <T>(config: RequestConfig): Promise<ResponseData<T>> => {
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// POST/PUT 请求明确设置 Content-Type 为 application/json
if ((config.method === 'POST' || config.method === 'PUT') && config.data) {
config.header['Content-Type'] = 'application/json'
}
// get请求映射params参数
if (config.params) {
let url = config.url + '?' + tansParams(config.params)
@ -65,7 +69,8 @@ const request = <T>(config: RequestConfig): Promise<ResponseData<T>> => {
return
} else if (code === 500) {
toast(msg)
reject('500')
// 将完整的 data 对象 reject便于调用方拿到后端错误信息
reject(data)
return
} else if (code !== 200) {
toast(msg)

Loading…
Cancel
Save