refactor(aftersales): 故障赔付/服务补偿单审核改为审批配置状态机
- 提交审批不再弹选 BPM 流程,直接提交至审批配置指定审批人
- 审核/审核不通过合并为统一审核弹窗(审核不通过必填意见)
- 新增审批人集合接口 approver-ids,仅名单内用户可见审核按钮
- 删除流程选择弹窗 process-select-modal.vue
Co-Authored-By: Claude <noreply@anthropic.com>
| | |
| | | reason?: string; // èµä»åå |
| | | auditStatus?: number; // 审æ¹ç¶æï¼0æªæäº¤ 10审æ¹ä¸ 20å®¡æ ¸éè¿ 30å®¡æ ¸ä¸éè¿ 40已忶 |
| | | auditStatusName?: string; // 审æ¹ç¶æåç§° |
| | | processInstanceId?: string; // å®¡æ¹æµç¨å®ä¾ç¼å· |
| | | auditUserId?: number; // å®¡æ ¸äºº |
| | | auditTime?: string; // å®¡æ ¸æ¶é´ |
| | | auditRemark?: string; // å®¡æ ¸å¤æ³¨ |
| | | reviewerId?: number; // å®¡æ ¸äººç¨æ·ç¼å· |
| | | reviewerName?: string; // å®¡æ ¸äººå§å |
| | | reviewTime?: string; // å®¡æ ¸æ¶é´ |
| | | reviewRemark?: string; // å®¡æ ¸æè§ï¼ä¸éè¿æ¶å³ä¸éè¿åå ï¼ |
| | | payStatus?: number; // æ¯ä»ç¶æï¼è´¦å¡èå¨é¢çï¼ |
| | | remark?: string; // 夿³¨ |
| | | createTime?: string; |
| | | } |
| | | |
| | | /** 审æ¹åæ° */ |
| | | export interface AuditReq { |
| | | id: number; |
| | | auditStatus: number; // 20éè¿ 30驳å |
| | | remark?: string; |
| | | } |
| | | } |
| | | |
| | |
| | | ); |
| | | } |
| | | |
| | | /** æäº¤èµä»/æå¡è¡¥å¿åå®¡æ¹ */ |
| | | export function submitCompensation(id: number, processDefinitionKey: string) { |
| | | /** |
| | | * æäº¤èµä»/æå¡è¡¥å¿å审æ¹ï¼æªæäº¤/å®¡æ ¸ä¸éè¿ â 审æ¹ä¸ï¼ |
| | | * 审æ¹äººç±ãç³»ç»ç®¡ç - 审æ¹é
ç½®ãç»ä¸é
ç½®ï¼æäº¤æ¶æ éæå®ã |
| | | */ |
| | | export function submitCompensation(id: number) { |
| | | return requestClient.put<boolean>('/aftersales/compensation/submit', null, { |
| | | params: { id, processDefinitionKey }, |
| | | params: { id }, |
| | | }); |
| | | } |
| | | |
| | | /** 审æ¹èµä»/æå¡è¡¥å¿å */ |
| | | export function auditCompensation(data: AfterSaleCompensationApi.AuditReq) { |
| | | return requestClient.put<boolean>('/aftersales/compensation/audit', data); |
| | | /** è·å¾å®¡æ¹äººç¼å·éåï¼ä¾åè¡¨é¡µå¤ææ¯å¦å±ç¤ºå®¡æ ¸æé® */ |
| | | export function getCompensationApproverIds() { |
| | | return requestClient.get<number[]>('/aftersales/compensation/approver-ids'); |
| | | } |
| | | |
| | | /** è·åèµä»/æå¡è¡¥å¿åå®¡æ¹æµç¨å®ä¹å表 */ |
| | | export function getApproveProcessList() { |
| | | return requestClient.get<{ id: string; name: string; version: number; key: string }[]>( |
| | | '/aftersales/compensation/approve-process-list', |
| | | ); |
| | | /** |
| | | * å®¡æ ¸èµä»/æå¡è¡¥å¿åï¼å®¡æ¹ä¸ â å®¡æ ¸éè¿ / å®¡æ ¸ä¸éè¿ï¼ |
| | | * |
| | | * @param id èµä»åç¼å· |
| | | * @param pass true=å®¡æ ¸éè¿ / false=å®¡æ ¸ä¸éè¿ |
| | | * @param reviewRemark å®¡æ ¸æè§ï¼pass=false æ¶å¿
å¡« |
| | | */ |
| | | export function auditCompensation( |
| | | id: number, |
| | | pass: boolean, |
| | | reviewRemark?: string, |
| | | ) { |
| | | return requestClient.put<boolean>('/aftersales/compensation/audit', { |
| | | id, |
| | | pass, |
| | | reviewRemark, |
| | | }); |
| | | } |
| | |
| | | import type { AfterSaleCompensationApi } from '#/api/aftersales/compensation'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { isEmpty } from '@vben/utils'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | |
| | | import { message, Tag } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deleteCompensation, |
| | | getApproveProcessList, |
| | | getCompensationApproverIds, |
| | | getCompensationPage, |
| | | submitCompensation, |
| | | } from '#/api/aftersales/compensation'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { AUDIT_STATUS, useGridColumns, useGridFormSchema } from './data'; |
| | | import AuditModal from './modules/audit-modal.vue'; |
| | | import Form from './modules/form.vue'; |
| | | import ProcessSelectModal from './modules/process-select-modal.vue'; |
| | | |
| | | /** å®åèµä»/æå¡è¡¥å¿åå表 */ |
| | | defineOptions({ name: 'AfterSaleCompensation' }); |
| | | |
| | | const router = useRouter(); |
| | | const userStore = useUserStore(); |
| | | const currentUserId = userStore.userInfo?.id; // å½åç»å½ç¨æ· IDï¼ç¨äºå®¡æ¹äººæé夿 |
| | | |
| | | /** 审æ¹é
ç½®ä¸è¯¥ä¸å¡ç审æ¹äººç¼å·éåï¼å³å®ãå®¡æ ¸ / å®¡æ ¸ä¸éè¿ãæé®æ¯å¦å±ç¤º */ |
| | | const approverIds = ref<number[]>([]); |
| | | |
| | | /** æå审æ¹äººéåï¼å¤±è´¥æ¶ä¿æä¸ºç©ºï¼æé®ä¸å±ç¤ºï¼ï¼ä¸é»æå表å è½½ */ |
| | | async function loadApproverIds() { |
| | | try { |
| | | approverIds.value = (await getCompensationApproverIds()) ?? []; |
| | | } catch { |
| | | approverIds.value = []; |
| | | } |
| | | } |
| | | |
| | | /** å½åç»å½ç¨æ·æ¯å¦ä¸ºè¯¥ä¸å¡ç审æ¹äººï¼ä¸èµä»åå¤äºå®¡æ¹ä¸ï¼10ï¼ */ |
| | | function canAudit(row: AfterSaleCompensationApi.Compensation) { |
| | | return ( |
| | | row.auditStatus === AUDIT_STATUS.PROCESS && |
| | | !!currentUserId && |
| | | approverIds.value.includes(currentUserId) |
| | | ); |
| | | } |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ProcessModal, processModalApi] = useVbenModal({ |
| | | connectedComponent: ProcessSelectModal, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** å·æ°è¡¨æ ¼ä¸å®¡æ¹äººéå */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | loadApproverIds(); |
| | | } |
| | | |
| | | function handleCreate() { |
| | |
| | | } |
| | | } |
| | | |
| | | /** æäº¤å®¡æ¹ - å
è·åæµç¨å表 */ |
| | | /** æäº¤å®¡æ¹ - 审æ¹äººç±ãç³»ç»ç®¡ç - 审æ¹é
ç½®ãç»ä¸æå®ï¼æ¤å¤æ ééæ© */ |
| | | async function handleSubmit(row: AfterSaleCompensationApi.Compensation) { |
| | | const hideLoading = message.loading({ |
| | | content: 'è·åå®¡æ¹æµç¨...', |
| | | content: 'æ£å¨æäº¤å®¡æ¹...', |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | const processList = await getApproveProcessList(); |
| | | hideLoading(); |
| | | if (!processList || processList.length === 0) { |
| | | message.warning('ææ å¯ç¨å®¡æ¹æµç¨ï¼è¯·å
é
ç½® BPM æµç¨'); |
| | | return; |
| | | } |
| | | processModalApi.setData({ id: row.id, processList }).open(); |
| | | } catch { |
| | | await submitCompensation(row.id!); |
| | | message.success('æäº¤å®¡æ¹æå'); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** 审æ¹ï¼éè¿/驳åï¼ */ |
| | | function handleAudit(row: AfterSaleCompensationApi.Compensation) { |
| | | auditModalApi.setData({ id: row.id }).open(); |
| | | } |
| | | |
| | | /** æ¥ç审æ¹è¯¦æ
*/ |
| | | function handleViewProcess(row: AfterSaleCompensationApi.Compensation) { |
| | | if (!row.processInstanceId) { |
| | | message.warning('è¯¥åæ®å°æªæäº¤å®¡æ¹'); |
| | | return; |
| | | } |
| | | router.push({ |
| | | name: 'BpmProcessInstanceDetail', |
| | | query: { id: row.processInstanceId }, |
| | | }); |
| | | /** å®¡æ ¸ - éè¿ / ä¸éè¿ */ |
| | | function handleAudit(row: AfterSaleCompensationApi.Compensation, pass: boolean) { |
| | | auditModalApi.setData({ pass, row }).open(); |
| | | } |
| | | |
| | | const checkedIds = ref<number[]>([]); |
| | |
| | | checkboxChange: handleRowCheckboxChange, |
| | | }, |
| | | }); |
| | | |
| | | // è¿å
¥é¡µé¢å³æå审æ¹äººéåï¼ç¨äºå¤æãå®¡æ ¸ãæé®æ¯å¦å±ç¤º |
| | | loadApproverIds(); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <ProcessModal @success="handleRefresh" /> |
| | | <AuditFormModal @success="handleRefresh" /> |
| | | <Grid table-title="èµä»/æå¡è¡¥å¿åå表"> |
| | | <template #toolbar-tools> |
| | |
| | | label: 'æäº¤å®¡æ¹', |
| | | type: 'link', |
| | | auth: ['aftersales:compensation:submit'], |
| | | ifShow: row.auditStatus === AUDIT_STATUS.DRAFT || row.auditStatus === AUDIT_STATUS.REJECT, |
| | | onClick: handleSubmit.bind(null, row), |
| | | // 审æ¹äººç±å®¡æ¹é
ç½®ç»ä¸æå®ï¼æäº¤åä»
äºæ¬¡ç¡®è®¤ï¼ä¸åå¼¹éæµç¨æ¡ |
| | | popConfirm: { |
| | | title: '确认æäº¤å®¡æ¹ï¼æäº¤åç±å®¡æ¹é
ç½®ä¸æå®ç审æ¹äººå¤çã', |
| | | confirm: handleSubmit.bind(null, row), |
| | | }, |
| | | // æªæäº¤(0) ä¸ å®¡æ ¸ä¸éè¿(30) åå¯æäº¤ï¼åè
éä¿®æ¹åéæ°æäº¤ |
| | | ifShow: |
| | | row.auditStatus === AUDIT_STATUS.DRAFT || |
| | | row.auditStatus === AUDIT_STATUS.REJECT, |
| | | }, |
| | | { |
| | | label: '审æ¹', |
| | | label: 'å®¡æ ¸', |
| | | type: 'link', |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['aftersales:compensation:audit'], |
| | | ifShow: row.auditStatus === AUDIT_STATUS.PROCESS, |
| | | onClick: handleAudit.bind(null, row), |
| | | // ä»
ã审æ¹ä¸ + å½åç»å½ç¨æ·å¨å®¡æ¹é
ç½®ç审æ¹äººååå
ãææ¾ç¤º |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, true), |
| | | }, |
| | | { |
| | | label: 'æ¥ç审æ¹', |
| | | label: 'å®¡æ ¸ä¸éè¿', |
| | | type: 'link', |
| | | ifShow: row.auditStatus !== AUDIT_STATUS.DRAFT && !!row.processInstanceId, |
| | | onClick: handleViewProcess.bind(null, row), |
| | | danger: true, |
| | | auth: ['aftersales:compensation:audit'], |
| | | // åä¸ï¼ä¸ãå®¡æ ¸ãæå¯¹åºç° |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, false), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | |
| | | <script lang="ts" setup> |
| | | import { ref } from 'vue'; |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { AfterSaleCompensationApi } from '#/api/aftersales/compensation'; |
| | | |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | |
| | | import { useVbenForm } from '#/adapter/form'; |
| | | import { auditCompensation } from '#/api/aftersales/compensation'; |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | const emit = defineEmits(['success']); |
| | | import { useVbenForm } from '#/adapter/form'; |
| | | import { auditCompensation } from '#/api/aftersales/compensation'; |
| | | |
| | | const compensationId = ref<number>(); |
| | | const emit = defineEmits(['success']); |
| | | |
| | | const [Form, formApi] = useVbenForm({ |
| | | commonConfig: { |
| | | componentProps: { |
| | | class: 'w-full', |
| | | }, |
| | | labelWidth: 100, |
| | | }, |
| | | wrapperClass: 'grid-cols-1', |
| | | layout: 'vertical', |
| | | schema: [ |
| | | { |
| | | fieldName: 'auditStatus', |
| | | label: '审æ¹ç»æ', |
| | | component: 'RadioGroup', |
| | | const pass = ref(true); // true=å®¡æ ¸éè¿ / false=å®¡æ ¸ä¸éè¿ |
| | | const rowData = ref<AfterSaleCompensationApi.Compensation>(); |
| | | const getTitle = computed(() => (pass.value ? 'å®¡æ ¸éè¿' : 'å®¡æ ¸ä¸éè¿')); |
| | | |
| | | const [Form, formApi] = useVbenForm({ |
| | | commonConfig: { |
| | | componentProps: { |
| | | options: [ |
| | | { label: 'éè¿', value: 20 }, |
| | | { label: '驳å', value: 30 }, |
| | | ], |
| | | class: 'w-full', |
| | | }, |
| | | rules: 'selectRequired', |
| | | formItemClass: 'col-span-1', |
| | | labelWidth: 90, |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | | label: '审æ¹å¤æ³¨', |
| | | component: 'Textarea', |
| | | componentProps: { |
| | | placeholder: '请è¾å
¥å®¡æ¹å¤æ³¨', |
| | | rows: 3, |
| | | }, |
| | | }, |
| | | ], |
| | | showDefaultActions: false, |
| | | }); |
| | | wrapperClass: 'grid-cols-1', |
| | | layout: 'horizontal', |
| | | schema: [], |
| | | showDefaultActions: false, |
| | | }); |
| | | |
| | | const [Modal, modalApi] = useVbenModal({ |
| | | async onConfirm() { |
| | | const { valid } = await formApi.validate(); |
| | | if (!valid) { |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | try { |
| | | const values = await formApi.getValues<{ |
| | | auditStatus: number; |
| | | remark?: string; |
| | | /** å®¡æ ¸è¡¨ååæ®µï¼ä¸éè¿æ¶å¿
须填ååå */ |
| | | function useAuditSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'reviewRemark', |
| | | label: 'å®¡æ ¸æè§', |
| | | component: 'Textarea', |
| | | formItemClass: 'col-span-1', |
| | | componentProps: { |
| | | rows: 3, |
| | | placeholder: pass.value |
| | | ? '请è¾å
¥å®¡æ ¸æè§ï¼å¯éï¼' |
| | | : '请è¾å
¥ä¸éè¿åå ï¼å¿
å¡«ï¼', |
| | | }, |
| | | rules: pass.value ? '' : 'required', |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | const [Modal, modalApi] = useVbenModal({ |
| | | async onConfirm() { |
| | | const { valid } = await formApi.validate(); |
| | | if (!valid) { |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | const values = await formApi.getValues(); |
| | | try { |
| | | await auditCompensation( |
| | | rowData.value!.id!, |
| | | pass.value, |
| | | values.reviewRemark, |
| | | ); |
| | | await modalApi.close(); |
| | | emit('success'); |
| | | message.success(pass.value ? 'å®¡æ ¸éè¿' : 'å·²éåï¼å¯ä¿®æ¹åéæ°æäº¤'); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | }, |
| | | async onOpenChange(isOpen: boolean) { |
| | | if (!isOpen) { |
| | | rowData.value = undefined; |
| | | return; |
| | | } |
| | | const data = modalApi.getData<{ |
| | | pass: boolean; |
| | | row: AfterSaleCompensationApi.Compensation; |
| | | }>(); |
| | | await auditCompensation({ |
| | | id: compensationId.value!, |
| | | auditStatus: values.auditStatus, |
| | | remark: values.remark, |
| | | }); |
| | | await modalApi.close(); |
| | | emit('success'); |
| | | message.success('审æ¹å®æ'); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | }, |
| | | async onOpenChange(isOpen: boolean) { |
| | | if (!isOpen) { |
| | | compensationId.value = undefined; |
| | | await formApi.resetForm(); |
| | | return; |
| | | } |
| | | const data = modalApi.getData<{ id: number }>(); |
| | | compensationId.value = data?.id; |
| | | await formApi.setValues({ auditStatus: 20 }); |
| | | }, |
| | | }); |
| | | rowData.value = data.row; |
| | | pass.value = data.pass; |
| | | formApi.setState({ schema: useAuditSchema() }); |
| | | formApi.resetForm(); |
| | | }, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Modal title="审æ¹èµä»/æå¡è¡¥å¿å" class="w-1/3"> |
| | | <Form class="mx-3" /> |
| | | <Modal :title="getTitle" class="w-2/5"> |
| | | <div v-if="rowData" class="mx-4 mb-4 text-sm text-gray-600"> |
| | | <div>èµä»åå·ï¼{{ rowData.compensationNo }}</div> |
| | | <div>èµä»éé¢ï¼{{ rowData.amount }}</div> |
| | | </div> |
| | | <Form class="mx-4" /> |
| | | </Modal> |
| | | </template> |