| | |
| | | updateFeedback, |
| | | } from '#/api/mes/pro/feedback'; |
| | | import { getRouteProcessByRouteAndProcess } from '#/api/mes/pro/route/process'; |
| | | import { getTask } from '#/api/mes/pro/task'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useFormSchema } from '../../../pro/feedback/data'; |
| | | import { |
| | | loadParamDetails, |
| | | paramDetails, |
| | | resetWaitConfig, |
| | | waitDuration, |
| | | waitStartTime, |
| | | waitTaskId, |
| | | } from '../../../pro/feedback/param-state'; |
| | | import BatchInputDialog from '../../../pro/feedback/modules/batch-input-dialog.vue'; |
| | | import WaitCountdown from '../../../pro/feedback/modules/wait-countdown.vue'; |
| | | const batchDialogRef = ref<InstanceType<typeof BatchInputDialog>>(); |
| | | const batchActionType = ref<'' | 'submit' | 'approve'>(''); |
| | | const pendingSubmitMode = ref<'saveAndSubmit' | 'submit'>('submit'); |
| | |
| | | |
| | | /** 提交前对齐数量:报工只填写报工数量,合格/不良/废品数量由质检确定,报工环节不采集 */ |
| | | function alignQuantity(data: any) { |
| | | if (data.needReportQuantity === false) { |
| | | data.feedbackQuantity = 0; |
| | | } |
| | | data.uncheckQuantity = data.checkFlag ? data.feedbackQuantity : 0; |
| | | delete data.qualifiedQuantity; |
| | | delete data.unqualifiedQuantity; |
| | | delete data.laborScrapQuantity; |
| | | delete data.materialScrapQuantity; |
| | | delete data.otherScrapQuantity; |
| | | delete data.needReportQuantity; |
| | | } |
| | | |
| | | async function getAlignedData() { |
| | |
| | | })); |
| | | } |
| | | |
| | | /** 加载 checkFlag */ |
| | | async function resolveCheckFlag(routeId?: number, processId?: number) { |
| | | if (!routeId || !processId) return true; |
| | | /** 加载工序配置(checkFlag / 等待时长 / 报工数量规则) */ |
| | | async function resolveRouteProcessConfig(routeId?: number, processId?: number) { |
| | | if (!routeId || !processId) { |
| | | return { checkFlag: true, needReportQuantity: true }; |
| | | } |
| | | try { |
| | | const rp = await getRouteProcessByRouteAndProcess(routeId, processId); |
| | | return rp?.checkFlag ?? false; |
| | | waitDuration.value = rp?.waitDuration; |
| | | return { |
| | | checkFlag: rp?.checkFlag ?? false, |
| | | needReportQuantity: rp?.needReportQuantity ?? true, |
| | | }; |
| | | } catch { |
| | | return true; |
| | | waitDuration.value = undefined; |
| | | return { checkFlag: true, needReportQuantity: true }; |
| | | } |
| | | } |
| | | |
| | |
| | | feedbackId.value = undefined; |
| | | feedbackStatus.value = undefined; |
| | | originalSnapshot.value = ''; |
| | | resetWaitConfig(); |
| | | |
| | | formApi.setState({ schema: useFormSchema(formType.value, formApi) }); |
| | | |
| | | const code = await generateAutoCode(MesAutoCodeRuleCode.PRO_FEEDBACK_CODE); |
| | | const checkFlag = await resolveCheckFlag(task.routeId, task.processId); |
| | | const config = await resolveRouteProcessConfig(task.routeId, task.processId); |
| | | // 加载任务绑定的工艺参数(必填参数校验 + 参数值回显) |
| | | await loadParamDetails(task.id); |
| | | |
| | | waitTaskId.value = task.id; |
| | | waitStartTime.value = task.waitStartTime; |
| | | |
| | | await formApi.setValues({ |
| | | code, |
| | |
| | | reportableQuantity: task.reportableQuantity, |
| | | scheduledQuantity: task.quantity, |
| | | feedbackApprove: task.feedbackApprove, |
| | | checkFlag, |
| | | checkFlag: config.checkFlag, |
| | | needReportQuantity: config.needReportQuantity, |
| | | }); |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData()); |
| | | } |
| | |
| | | feedbackStatus.value = data.status; |
| | | formType.value = 'update'; |
| | | formApi.setState({ schema: useFormSchema(formType.value, formApi) }); |
| | | const checkFlag = await resolveCheckFlag(data.routeId, data.processId); |
| | | const config = await resolveRouteProcessConfig(data.routeId, data.processId); |
| | | await loadParamDetails(data.taskId); |
| | | await formApi.setValues({ ...data, checkFlag }); |
| | | waitTaskId.value = data.taskId; |
| | | waitStartTime.value = undefined; |
| | | if (data.taskId) { |
| | | try { |
| | | const task = await getTask(data.taskId); |
| | | waitStartTime.value = task?.waitStartTime; |
| | | } catch { |
| | | // 任务不存在时忽略倒计时回显 |
| | | } |
| | | } |
| | | await formApi.setValues({ |
| | | ...data, |
| | | checkFlag: config.checkFlag, |
| | | needReportQuantity: config.needReportQuantity, |
| | | }); |
| | | originalSnapshot.value = JSON.stringify(await getAlignedData()); |
| | | } |
| | | |
| | |
| | | |
| | | <Form class="feedback-tab__form" /> |
| | | |
| | | <!-- 报工倒计时(工序配置等待时长时展示) --> |
| | | <div v-if="waitDuration" class="feedback-tab__params"> |
| | | <div class="feedback-tab__params-title">报工倒计时</div> |
| | | <WaitCountdown |
| | | :task-id="waitTaskId" |
| | | :wait-duration="waitDuration" |
| | | :wait-start-time="waitStartTime" |
| | | :disabled="!isEditable" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- 工艺参数(任务绑定参数时展示,必填参数未填会被后端拦截) --> |
| | | <div v-if="paramDetails.length" class="feedback-tab__params"> |
| | | <div class="feedback-tab__params-title">工艺参数</div> |