修复:
采购管理--采购申请:
采购申请的状态显示不正确,全都显示审批中
| | |
| | | export function getApproveProcessList(id: number) { |
| | | return requestClient.get(`/erp/purchase-request/approve-process-list`, { params: { id } }); |
| | | } |
| | | |
| | | /** BPM 流程实例状态 → 业务状态映射 */ |
| | | export const BPM_STATUS_TO_BIZ: Record<number, number> = { |
| | | 1: 10, // RUNNING → 审批中 |
| | | 2: 20, // APPROVE → 审核通过 |
| | | 3: 30, // REJECT → 审核不通过 |
| | | 4: 40, // CANCEL → 已取消 |
| | | }; |
| | | |
| | | /** |
| | | * 同步采购申请的业务状态(根据 BPM 流程实例实际状态) |
| | | * 用于修复后端监听器未正确回写导致的业务状态不一致问题 |
| | | */ |
| | | export async function syncPurchaseRequestStatus(items: ErpPurchaseRequestApi.PurchaseRequest[]) { |
| | | const processingItems = items.filter( |
| | | (item) => item.status === 10 && item.processInstanceId, |
| | | ); |
| | | if (processingItems.length === 0) return; |
| | | |
| | | const { getApprovalDetail } = await import('#/api/bpm/processInstance'); |
| | | for (const item of processingItems) { |
| | | try { |
| | | const detail = await getApprovalDetail({ |
| | | processInstanceId: item.processInstanceId, |
| | | }); |
| | | const bizStatus = BPM_STATUS_TO_BIZ[detail.processInstance?.status]; |
| | | if (bizStatus && bizStatus !== 10) { |
| | | item.status = bizStatus; |
| | | } |
| | | } catch { |
| | | // 查询失败时保持原有状态 |
| | | } |
| | | } |
| | | } |
| | |
| | | options: [ |
| | | { label: '未提交', value: 0 }, |
| | | { label: '审批中', value: 10 }, |
| | | { label: '审核通过', value: 20 }, |
| | | { label: '审核不通过', value: 30 }, |
| | | { label: '审批通过', value: 20 }, |
| | | { label: '审批不通过', value: 30 }, |
| | | { label: '已取消', value: 40 }, |
| | | ], |
| | | placeholder: '请选择状态', |
| | |
| | | getApproveProcessList, |
| | | getPurchaseRequestPage, |
| | | submitPurchaseRequest, |
| | | syncPurchaseRequestStatus, |
| | | } from '#/api/erp/purchase/request'; |
| | | import { $t } from '#/locales'; |
| | | |
| | |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | return await getPurchaseRequestPage({ |
| | | const result = await getPurchaseRequestPage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }); |
| | | const processingItems = (result.list || []).filter( |
| | | (item) => item.status === 10 && item.processInstanceId, |
| | | ); |
| | | if (processingItems.length > 0) { |
| | | await syncPurchaseRequestStatus(processingItems); |
| | | } |
| | | return result; |
| | | }, |
| | | }, |
| | | }, |
| | |
| | | <template #status="{ row }"> |
| | | <Tag v-if="row.status === 0" color="default">未提交</Tag> |
| | | <Tag v-else-if="row.status === 10" color="processing">审批中</Tag> |
| | | <Tag v-else-if="row.status === 20" color="success">审核通过</Tag> |
| | | <Tag v-else-if="row.status === 30" color="error">审核不通过</Tag> |
| | | <Tag v-else-if="row.status === 20" color="success">审批通过</Tag> |
| | | <Tag v-else-if="row.status === 30" color="error">审批不通过</Tag> |
| | | <Tag v-else-if="row.status === 40" color="warning">已取消</Tag> |
| | | </template> |
| | | <template #inStatus="{ row }"> |