From 0af5e35af8338cc8a2e38c19ab79efbb9eff0b2c Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 16 九月 2026 17:02:52 +0800
Subject: [PATCH] feat(crm): 信用评级评定人改为下拉选择并默认当前账号
---
src/views/erp/purchase/order/index.vue | 165 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 142 insertions(+), 23 deletions(-)
diff --git a/src/views/erp/purchase/order/index.vue b/src/views/erp/purchase/order/index.vue
index 288b0b0..e260992 100644
--- a/src/views/erp/purchase/order/index.vue
+++ b/src/views/erp/purchase/order/index.vue
@@ -2,30 +2,48 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
-import { ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
-import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src';
-import { downloadFileFromBlobPart, isEmpty } from '../../../../packages/utils/src';
+import { Page, useVbenModal } from '@vben/common-ui';
+import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
+import { useUserStore } from '@vben/stores';
-import { message } from 'ant-design-vue';
+import { message, Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
+ confirmReceipt,
deletePurchaseOrder,
exportPurchaseOrder,
+ getPurchaseOrderApproverUserIds,
getPurchaseOrderPage,
- updatePurchaseOrderStatus,
+ submitPurchaseOrder,
} from '#/api/erp/purchase/order';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
+import AuditModal from './modules/audit-modal.vue';
import Form from './modules/form.vue';
/** ERP 閲囪喘璁㈠崟鍒楄〃 */
defineOptions({ name: 'ErpPurchaseOrder' });
+const route = useRoute();
+const userStore = useUserStore();
+
+/** 褰撳墠涓氬姟绫诲瀷鐨勫鎵逛汉缂栧彿闆嗗悎锛岀敤浜庡垽鏂槸鍚﹀睍绀哄鏍告寜閽� */
+const approverIds = ref<number[]>([]);
+/** 褰撳墠鐧诲綍鐢ㄦ埛缂栧彿 */
+const currentUserId = userStore.userInfo?.id;
+
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
+ destroyOnClose: true,
+});
+
+const [AuditModalComp, auditModalApi] = useVbenModal({
+ connectedComponent: AuditModal,
destroyOnClose: true,
});
@@ -65,18 +83,72 @@
}
}
-/** 瀹℃壒/鍙嶅鎵规搷浣� */
-async function handleUpdateStatus(
- row: ErpPurchaseOrderApi.PurchaseOrder,
- status: number,
-) {
+/** 鎻愪氦瀹℃牳 - 鍚庣鎸夊鎵归厤缃牎楠屽鎵逛汉锛屾棤闇�鍓嶇閫夋嫨娴佺▼ */
+async function handleSubmit(row: ErpPurchaseOrderApi.PurchaseOrder) {
const hideLoading = message.loading({
- content: `纭畾${status === 20 ? '瀹℃壒' : '鍙嶅鎵�'}璇ヨ鍗曞悧锛焋,
+ content: '姝e湪鎻愪氦瀹℃牳...',
duration: 0,
});
try {
- await updatePurchaseOrderStatus(row.id!, status);
- message.success(`${status === 20 ? '瀹℃壒' : '鍙嶅鎵�'}鎴愬姛`);
+ await submitPurchaseOrder(row.id!);
+ message.success('鎻愪氦鎴愬姛锛岀瓑寰呭鎵逛汉瀹℃牳');
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 瀹℃牳 - 閫氳繃 / 涓嶉�氳繃 */
+function handleAudit(row: ErpPurchaseOrderApi.PurchaseOrder, pass: boolean) {
+ auditModalApi.setData({ pass, row }).open();
+}
+
+/** 褰撳墠鐢ㄦ埛鏄惁涓鸿涓氬姟绫诲瀷鐨勫鎵逛汉 */
+function canAudit(row: ErpPurchaseOrderApi.PurchaseOrder) {
+ return (
+ row.status === 10 && approverIds.value.includes(currentUserId as number)
+ );
+}
+
+/** 鏌ョ湅瀹℃壒璇︽儏 - 鏀归�犱负杞婚噺绾у鎵瑰悗灞曠ず瀹℃牳璁板綍锛屼笉鍐嶈烦杞� BPM 娴佺▼璇︽儏 */
+function handleViewProcess(row: ErpPurchaseOrderApi.PurchaseOrder) {
+ const parts: string[] = [];
+ if (row.reviewerName) {
+ parts.push(`瀹℃牳浜猴細${row.reviewerName}`);
+ }
+ if (row.reviewTime) {
+ parts.push(`瀹℃牳鏃堕棿锛�${row.reviewTime}`);
+ }
+ if (row.reviewRemark) {
+ parts.push(
+ `${row.status === 30 ? '涓嶉�氳繃鍘熷洜' : '瀹℃牳鎰忚'}锛�${row.reviewRemark}`,
+ );
+ }
+ if (parts.length === 0) {
+ message.info('璇ヨ鍗曟殏鏃犲鏍歌褰�');
+ return;
+ }
+ message.info(parts.join('銆�'));
+}
+
+/** 鍔犺浇褰撳墠涓氬姟绫诲瀷鐨勫鎵逛汉缂栧彿闆嗗悎 */
+async function loadApproverIds() {
+ try {
+ approverIds.value = (await getPurchaseOrderApproverUserIds()) ?? [];
+ } catch {
+ approverIds.value = [];
+ }
+}
+
+/** 纭鏀惰揣 */
+async function handleConfirmReceipt(row: ErpPurchaseOrderApi.PurchaseOrder) {
+ const hideLoading = message.loading({
+ content: '纭鏀惰揣涓�...',
+ duration: 0,
+ });
+ try {
+ const arrivalNoticeId = await confirmReceipt(row.id!);
+ message.success(`纭鏀惰揣鎴愬姛锛屽凡鐢熸垚鍒拌揣閫氱煡鍗昤);
handleRefresh();
} finally {
hideLoading();
@@ -130,10 +202,20 @@
checkboxChange: handleRowCheckboxChange,
},
});
+
+onMounted(() => {
+ loadApproverIds();
+ const id = route.query.id;
+ if (id) {
+ formModalApi.setData({ formType: 'detail', id: Number(id) }).open();
+ }
+});
</script>
<template>
- <Page auto-content-height><FormModal @success="handleRefresh" />
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <AuditModalComp @success="handleRefresh" />
<Grid table-title="閲囪喘璁㈠崟鍒楄〃">
<template #toolbar-tools>
<TableAction
@@ -167,6 +249,11 @@
]"
/>
</template>
+ <template #inStatus="{ row }">
+ <Tag v-if="row.inStatus === 0" color="default">鏈叆搴�</Tag>
+ <Tag v-else-if="row.inStatus === 1" color="warning">閮ㄥ垎鍏ュ簱</Tag>
+ <Tag v-else-if="row.inStatus === 2" color="success">鍏ㄩ儴鍏ュ簱</Tag>
+ </template>
<template #actions="{ row }">
<TableAction
:actions="[
@@ -182,21 +269,53 @@
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['erp:purchase-order:update'],
- ifShow: () => row.status !== 20,
+ // 瀹℃壒涓笉鍙慨鏀癸細闇�鍏堛�屽鏍镐笉閫氳繃銆嶉��鍥烇紱宸插鏍镐笉鍙慨鏀�
+ ifShow: () => row.status === 0 || row.status === 30,
onClick: handleEdit.bind(null, row),
},
{
- label: row.status === 10 ? '瀹℃壒' : '鍙嶅鎵�',
+ label: '鎻愪氦',
+ type: 'link',
+ auth: ['erp:purchase-order:update-status'],
+ // 鏈彁浜や笌瀹℃牳涓嶉�氳繃鍧囧彲鎻愪氦锛屽鏍镐笉閫氳繃闇�淇敼鍚庨噸鏂版彁浜�
+ ifShow: () => row.status === 0 || row.status === 30,
+ onClick: handleSubmit.bind(null, row),
+ },
+ {
+ label: '瀹℃牳',
type: 'link',
icon: ACTION_ICON.AUDIT,
- auth: ['erp:purchase-order:update-status'],
+ auth: ['erp:purchase-order:audit'],
+ // 浠呫�屽鎵逛腑 + 褰撳墠鐧诲綍鐢ㄦ埛鏄鎵逛汉銆嶆墠鏄剧ず锛屽叾浠栦汉鐪嬩笉鍒拌鎸夐挳
+ ifShow: canAudit(row),
+ onClick: handleAudit.bind(null, row, true),
+ },
+ {
+ label: '瀹℃牳涓嶉�氳繃',
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.AUDIT,
+ auth: ['erp:purchase-order:audit'],
+ ifShow: canAudit(row),
+ onClick: handleAudit.bind(null, row, false),
+ },
+ {
+ label: '鏌ョ湅瀹℃壒',
+ type: 'link',
+ icon: ACTION_ICON.VIEW,
+ auth: ['erp:purchase-order:query'],
+ ifShow: () => row.status === 20 || row.status === 30,
+ onClick: handleViewProcess.bind(null, row),
+ },
+ {
+ label: '纭鏀惰揣',
+ type: 'link',
+ icon: ACTION_ICON.VIEW,
+ auth: ['erp:purchase-order:confirm-receipt'],
+ ifShow: () => row.status === 20 && row.inStatus !== 2,
popConfirm: {
- title: `纭${row.status === 10 ? '瀹℃壒' : '鍙嶅鎵�'}${row.no}鍚楋紵`,
- confirm: handleUpdateStatus.bind(
- null,
- row,
- row.status === 10 ? 20 : 10,
- ),
+ title: `纭鏀惰揣${row.no}鍚楋紵`,
+ confirm: handleConfirmReceipt.bind(null, row),
},
},
{
--
Gitblit v1.9.3