| | |
| | | import type { MesProFeedbackApi } from '#/api/mes/pro/feedback'; |
| | | |
| | | import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | |
| | | import { |
| | | DICT_TYPE, |
| | | MesProFeedbackStatusEnum, |
| | | } from '@vben/constants'; |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | import { useAccess } from '@vben/access'; |
| | | |
| | | import { Button, message, Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | |
| | | |
| | | const props = defineProps<{ |
| | | taskId?: number; |
| | | task?: Record<string, any>; |
| | | /** 外部触发刷新 */ |
| | | refreshKey?: number; |
| | | }>(); |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const { hasAccessByCodes } = useAccess(); |
| | | const router = useRouter(); |
| | | |
| | | const batchDialogRef = ref<InstanceType<typeof BatchInputDialog>>(); |
| | | const approvingRow = ref<MesProFeedbackApi.Feedback>(); |
| | | const batchActionType = ref<'submit' | 'approve'>('approve'); |
| | | const actionRow = ref<MesProFeedbackApi.Feedback>(); |
| | | |
| | | /** 执行提交(含批次属性) */ |
| | | async function doSubmit(row: MesProFeedbackApi.Feedback, batchFields?: Record<string, unknown>) { |
| | | await submitFeedback({ id: row.id!, ...batchFields }); |
| | | message.success('报工单已提交'); |
| | | refreshGrid(); |
| | | emit('reported'); |
| | | } |
| | | |
| | | /** 执行审批(含批次属性) */ |
| | | async function doApprove(row: MesProFeedbackApi.Feedback, batchFields?: Record<string, unknown>) { |
| | |
| | | |
| | | /** 提交(仅草稿) */ |
| | | async function handleSubmit(row: MesProFeedbackApi.Feedback) { |
| | | await submitFeedback(row.id!); |
| | | message.success('报工单已提交'); |
| | | refreshGrid(); |
| | | emit('reported'); |
| | | if (props.task?.feedbackApprove) { |
| | | await doSubmit(row); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | const checkResult = await getBatchRequirements(row.id!); |
| | | if (checkResult?.needBatchInput) { |
| | | batchActionType.value = 'submit'; |
| | | actionRow.value = row; |
| | | batchDialogRef.value?.open({ checkResult }); |
| | | } else { |
| | | await doSubmit(row); |
| | | } |
| | | } catch { |
| | | await doSubmit(row); |
| | | } |
| | | } |
| | | |
| | | /** 审批通过(仅审批中) */ |
| | |
| | | try { |
| | | const checkResult = await getBatchRequirements(row.id!); |
| | | if (checkResult?.needBatchInput) { |
| | | approvingRow.value = row; |
| | | batchActionType.value = 'approve'; |
| | | actionRow.value = row; |
| | | batchDialogRef.value?.open({ checkResult }); |
| | | } else { |
| | | await doApprove(row); |
| | |
| | | |
| | | /** 批次弹窗确认回调 */ |
| | | function handleBatchConfirm(batchData: Record<string, unknown>) { |
| | | if (approvingRow.value) { |
| | | doApprove(approvingRow.value, batchData); |
| | | if (actionRow.value) { |
| | | if (batchActionType.value === 'approve') { |
| | | doApprove(actionRow.value, batchData); |
| | | } else if (batchActionType.value === 'submit') { |
| | | doSubmit(actionRow.value, batchData); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | message.success('报工单已驳回'); |
| | | refreshGrid(); |
| | | emit('reported'); |
| | | } |
| | | |
| | | /** 查看审批详情 */ |
| | | function handleViewProcess(row: MesProFeedbackApi.Feedback) { |
| | | if (!row.processInstanceId) { |
| | | message.warning('该报工尚未提交审批'); |
| | | return; |
| | | } |
| | | router.push({ path: '/bpm/process-instance/detail', query: { id: row.processInstanceId } }); |
| | | } |
| | | |
| | | /** 状态常量供模板使用 */ |
| | |
| | | 删除 |
| | | </Button> |
| | | </Popconfirm> |
| | | <!-- 审批中:审批通过、驳回 --> |
| | | <Popconfirm |
| | | <!-- 审批中:查看审批 --> |
| | | <Button |
| | | v-if="row.status === STATUS_APPROVING" |
| | | type="link" |
| | | size="small" |
| | | @click="handleViewProcess(row)" |
| | | > |
| | | 查看审批 |
| | | </Button> |
| | | <!-- |
| | | <Popconfirm |
| | | v-if="row.status === STATUS_APPROVING && hasAccessByCodes(['mes:pro-feedback:approve'])" |
| | | title="确认审批通过该报工单?" |
| | | @confirm="handleApprove(row)" |
| | | > |
| | |
| | | </Button> |
| | | </Popconfirm> |
| | | <Popconfirm |
| | | v-if="row.status === STATUS_APPROVING" |
| | | v-if="row.status === STATUS_APPROVING && hasAccessByCodes(['mes:pro-feedback:approve'])" |
| | | title="确认驳回该报工单?" |
| | | @confirm="handleReject(row)" |
| | | > |
| | |
| | | 驳回 |
| | | </Button> |
| | | </Popconfirm> |
| | | --> |
| | | </Space> |
| | | </template> |
| | | </Grid> |