| | |
| | | import { |
| | | approveFeedback, |
| | | deleteFeedback, |
| | | getFeedbackListByTask, |
| | | getBatchRequirements, |
| | | getFeedbackPage, |
| | | rejectFeedback, |
| | | submitFeedback, |
| | | } from '#/api/mes/pro/feedback'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import FeedbackForm from '../../../pro/feedback/modules/form.vue'; |
| | | import BatchInputDialog from '../../../pro/feedback/modules/batch-input-dialog.vue'; |
| | | |
| | | defineOptions({ name: 'WorkbenchFeedbackHistoryTab' }); |
| | | |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const batchDialogRef = ref<InstanceType<typeof BatchInputDialog>>(); |
| | | const approvingRow = ref<MesProFeedbackApi.Feedback>(); |
| | | |
| | | /** 执行审批(含批次属性) */ |
| | | async function doApprove(row: MesProFeedbackApi.Feedback, batchFields?: Record<string, unknown>) { |
| | | const finished = await approveFeedback({ id: row.id!, ...batchFields }); |
| | | message.success( |
| | | finished ? '报工单已审批完成' : '报工成功,请等待质量检验完成!', |
| | | ); |
| | | refreshGrid(); |
| | | emit('reported'); |
| | | } |
| | | |
| | | /** 查看详情 */ |
| | | function handleDetail(row: MesProFeedbackApi.Feedback) { |
| | | formModalApi.setData({ formType: 'detail', id: row.id }).open(); |
| | |
| | | |
| | | /** 编辑(仅草稿) */ |
| | | function handleEdit(row: MesProFeedbackApi.Feedback) { |
| | | formModalApi.setData({ formType: 'update', id: row.id }).open(); |
| | | formModalApi.setData({ formType: 'update', id: row.id, showSubmitButton: false }).open(); |
| | | } |
| | | |
| | | /** 删除(仅草稿) */ |
| | |
| | | |
| | | /** 审批通过(仅审批中) */ |
| | | async function handleApprove(row: MesProFeedbackApi.Feedback) { |
| | | const finished = await approveFeedback(row.id!); |
| | | message.success( |
| | | finished ? '报工单已审批完成' : '报工成功,请等待质量检验完成!', |
| | | ); |
| | | refreshGrid(); |
| | | emit('reported'); |
| | | try { |
| | | const checkResult = await getBatchRequirements(row.id!); |
| | | if (checkResult?.needBatchInput) { |
| | | approvingRow.value = row; |
| | | batchDialogRef.value?.open({ checkResult }); |
| | | } else { |
| | | await doApprove(row); |
| | | } |
| | | } catch { |
| | | await doApprove(row); |
| | | } |
| | | } |
| | | |
| | | /** 批次弹窗确认回调 */ |
| | | function handleBatchConfirm(batchData: Record<string, unknown>) { |
| | | if (approvingRow.value) { |
| | | doApprove(approvingRow.value, batchData); |
| | | } |
| | | } |
| | | |
| | | /** 驳回(仅审批中) */ |
| | |
| | | width: 160, |
| | | slots: { default: 'code' }, |
| | | }, |
| | | { field: 'workOrderCode', title: '工单编码', width: 140 }, |
| | | { field: 'taskCode', title: '任务编码', width: 140 }, |
| | | { field: 'processName', title: '工序', width: 100 }, |
| | | { field: 'itemName', title: '产品', minWidth: 120 }, |
| | | { field: 'feedbackQuantity', title: '报工数量', width: 100 }, |
| | |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async () => { |
| | | query: async ({ page }) => { |
| | | if (!props.taskId) { |
| | | return []; |
| | | return { list: [], total: 0 }; |
| | | } |
| | | return await getFeedbackListByTask(props.taskId); |
| | | return await getFeedbackPage({ |
| | | taskId: props.taskId, |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | }); |
| | | }, |
| | | }, |
| | | }, |
| | |
| | | <template> |
| | | <div class="feedback-history-tab"> |
| | | <FormModal @success="refreshGrid" /> |
| | | <BatchInputDialog ref="batchDialogRef" @confirm="handleBatchConfirm" /> |
| | | |
| | | <div v-if="!taskId" class="feedback-history-tab__empty"> |
| | | 请从左侧工单列表选择一条任务查看报工记录 |
| | |
| | | <template #actions="{ row }"> |
| | | <Space :size="4" wrap> |
| | | <Button type="link" size="small" @click="handleDetail(row)"> |
| | | {{ $t('common.view') }} |
| | | 查看 |
| | | </Button> |
| | | <!-- 草稿:编辑、删除、提交 --> |
| | | <Button |
| | |
| | | size="small" |
| | | @click="handleEdit(row)" |
| | | > |
| | | {{ $t('common.edit') }} |
| | | 编辑 |
| | | </Button> |
| | | <Popconfirm |
| | | v-if="row.status === STATUS_PREPARE" |
| | |
| | | @confirm="handleSubmit(row)" |
| | | > |
| | | <Button type="link" size="small"> |
| | | {{ $t('common.submit') }} |
| | | 提交 |
| | | </Button> |
| | | </Popconfirm> |
| | | <Popconfirm |
| | |
| | | @confirm="handleDelete(row)" |
| | | > |
| | | <Button type="link" size="small" danger> |
| | | {{ $t('common.delete') }} |
| | | 删除 |
| | | </Button> |
| | | </Popconfirm> |
| | | <!-- 审批中:审批通过、驳回 --> |
| | |
| | | @confirm="handleApprove(row)" |
| | | > |
| | | <Button type="link" size="small"> |
| | | {{ $t('common.approve') }} |
| | | 审批通过 |
| | | </Button> |
| | | </Popconfirm> |
| | | <Popconfirm |