Skip to content

Commit 27bbc33

Browse files
committed
feat: module approval config
1 parent bfe2d1c commit 27bbc33

File tree

10 files changed

+329
-118
lines changed

10 files changed

+329
-118
lines changed

frontend/packages/lib-shared/enums/moduleEnum.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ export enum ReasonTypeEnum {
5454
OPPORTUNITY_FAIL_RS = 'OPPORTUNITY_FAIL_RS', // 商机失败原因
5555
CUSTOMER_POOL_RS = 'CUSTOMER_POOL_RS', // 公海原因
5656
CLUE_POOL_RS = 'CLUE_POOL_RS', // 线索移入原因
57+
CONTRACT_APPROVAL = 'CONTRACT_APPROVAL', // 合同审批
58+
INVOICE_APPROVAL = 'INVOICE_APPROVAL', // 发票审批
59+
QUOTATION_APPROVAL = 'QUOTATION_APPROVAL', // 报价审批
5760
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { FormDesignKeyEnum } from '@lib/shared/enums/formDesignEnum';
2+
import { ReasonTypeEnum } from '@lib/shared/enums/moduleEnum';
3+
4+
import { getReasonConfig } from '@/api/modules';
5+
6+
import { FilterOption } from 'naive-ui/es/data-table/src/interface';
7+
8+
export type ApprovalConfigType =
9+
| FormDesignKeyEnum.CONTRACT
10+
| FormDesignKeyEnum.INVOICE
11+
| FormDesignKeyEnum.OPPORTUNITY_QUOTATION;
12+
13+
const dicApprovalKeyMap: Record<ApprovalConfigType, ReasonTypeEnum> = {
14+
[FormDesignKeyEnum.CONTRACT]: ReasonTypeEnum.CONTRACT_APPROVAL,
15+
[FormDesignKeyEnum.INVOICE]: ReasonTypeEnum.INVOICE_APPROVAL,
16+
[FormDesignKeyEnum.OPPORTUNITY_QUOTATION]: ReasonTypeEnum.QUOTATION_APPROVAL,
17+
};
18+
19+
export default function useApprovalConfig(formKey: FormDesignKeyEnum) {
20+
const reasonOptions = ref<FilterOption[]>([]);
21+
const dicApprovalEnable = ref(false);
22+
const dicKey = ref();
23+
dicKey.value = dicApprovalKeyMap[formKey as keyof typeof dicApprovalKeyMap];
24+
25+
async function initApprovalConfig() {
26+
if (!dicKey.value) return;
27+
try {
28+
const { dictList, enable } = await getReasonConfig(dicKey.value);
29+
reasonOptions.value = dictList.map((e) => ({ label: e.name, value: e.id }));
30+
dicApprovalEnable.value = enable;
31+
} catch (error) {
32+
// eslint-disable-next-line no-console
33+
console.log(error);
34+
}
35+
}
36+
37+
return {
38+
initApprovalConfig,
39+
dicApprovalEnable,
40+
};
41+
}

frontend/packages/web/src/hooks/useFormCreateTable.ts

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
contractStatusOptions,
2525
} from '@/config/contract';
2626
import { quotationStatusOptions } from '@/config/opportunity';
27+
import useApprovalConfig from '@/hooks/useApprovalConfig';
2728
import useFormCreateAdvanceFilter from '@/hooks/useFormCreateAdvanceFilter';
2829
import useReasonConfig from '@/hooks/useReasonConfig';
2930

@@ -77,6 +78,7 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
7778
const { t } = useI18n();
7879
const { getFilterListConfig, customFieldsFilterConfig } = useFormCreateAdvanceFilter();
7980
const { reasonOptions, initReasonConfig } = useReasonConfig(props.formKey);
81+
const { initApprovalConfig, dicApprovalEnable } = useApprovalConfig(props.formKey);
8082
const loading = ref(false);
8183
const showPagination = props.showPagination ?? true;
8284
let columns: CrmDataTableColumn[] = [];
@@ -125,6 +127,8 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
125127

126128
// 静态列和高级筛选增加原因配置筛选
127129
await initReasonConfig();
130+
// 审批配置
131+
await initApprovalConfig();
128132
const opportunityInternalColumns: CrmDataTableColumn[] = [
129133
{
130134
title: t('org.department'),
@@ -418,16 +422,20 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
418422
];
419423

420424
const invoiceInternalColumns: CrmDataTableColumn[] = [
421-
{
422-
title: t('contract.businessTitle.status'),
423-
width: 120,
424-
key: 'approvalStatus',
425-
filterOptions: contractInvoiceStatusOptions,
426-
sortOrder: false,
427-
sorter: true,
428-
filter: true,
429-
render: props.specialRender?.approvalStatus,
430-
},
425+
...((dicApprovalEnable.value
426+
? [
427+
{
428+
title: t('contract.businessTitle.status'),
429+
width: 120,
430+
key: 'approvalStatus',
431+
filterOptions: contractInvoiceStatusOptions,
432+
sortOrder: false,
433+
sorter: true,
434+
filter: true,
435+
render: props.specialRender?.approvalStatus,
436+
},
437+
]
438+
: []) as CrmDataTableColumn[]),
431439
{
432440
title: t('org.department'),
433441
width: 120,
@@ -738,16 +746,20 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
738746
sorter: true,
739747
render: (row: any) => row.departmentName || '-',
740748
},
741-
{
742-
title: t('common.status'),
743-
width: 120,
744-
key: 'approvalStatus',
745-
filterOptions: quotationStatusOptions,
746-
sortOrder: false,
747-
sorter: true,
748-
filter: true,
749-
render: props.specialRender?.approvalStatus,
750-
},
749+
...((dicApprovalEnable.value
750+
? [
751+
{
752+
title: t('common.status'),
753+
width: 120,
754+
key: 'approvalStatus',
755+
filterOptions: quotationStatusOptions,
756+
sortOrder: false,
757+
sorter: true,
758+
filter: true,
759+
render: props.specialRender?.approvalStatus,
760+
},
761+
]
762+
: []) as CrmDataTableColumn[]),
751763
],
752764
[FormDesignKeyEnum.CONTRACT]: [
753765
{
@@ -786,16 +798,22 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
786798
sortOrder: false,
787799
sorter: true,
788800
},
789-
{
790-
title: t('contract.approvalStatus'),
791-
width: 120,
792-
key: 'approvalStatus',
793-
filterOptions: quotationStatusOptions.filter((item) => ![QuotationStatusEnum.VOIDED].includes(item.value)),
794-
sortOrder: false,
795-
sorter: true,
796-
filter: true,
797-
render: props.specialRender?.approvalStatus,
798-
},
801+
...((dicApprovalEnable.value
802+
? [
803+
{
804+
title: t('contract.approvalStatus'),
805+
width: 120,
806+
key: 'approvalStatus',
807+
filterOptions: quotationStatusOptions.filter(
808+
(item) => ![QuotationStatusEnum.VOIDED].includes(item.value)
809+
),
810+
sortOrder: false,
811+
sorter: true,
812+
filter: true,
813+
render: props.specialRender?.approvalStatus,
814+
},
815+
]
816+
: []) as CrmDataTableColumn[]),
799817
],
800818
[FormDesignKeyEnum.CONTRACT_PAYMENT]: paymentInternalColumns,
801819
[FormDesignKeyEnum.CONTRACT_CONTRACT_PAYMENT]: paymentInternalColumns,
@@ -1327,6 +1345,7 @@ export default async function useFormCreateTable(props: FormCreateTableProps) {
13271345
useTableRes,
13281346
customFieldsFilterConfig,
13291347
reasonOptions,
1348+
dicApprovalEnable,
13301349
fieldList,
13311350
};
13321351
}

frontend/packages/web/src/views/contract/contract/components/contractTable.vue

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -237,54 +237,6 @@
237237
}
238238
}
239239
240-
// 表格
241-
const filterConfigList = computed<FilterFormItem[]>(() => [
242-
{
243-
title: t('opportunity.department'),
244-
dataIndex: 'departmentId',
245-
type: FieldTypeEnum.TREE_SELECT,
246-
treeSelectProps: {
247-
labelField: 'name',
248-
keyField: 'id',
249-
multiple: true,
250-
clearFilterAfterSelect: false,
251-
type: 'department',
252-
checkable: true,
253-
showContainChildModule: true,
254-
containChildIds: [],
255-
},
256-
},
257-
{
258-
title: t('contract.status'),
259-
dataIndex: 'stage',
260-
type: FieldTypeEnum.SELECT_MULTIPLE,
261-
operatorOption: COMMON_SELECTION_OPERATORS,
262-
selectProps: {
263-
options: contractStatusOptions,
264-
},
265-
},
266-
{
267-
title: t('contract.voidReason'),
268-
dataIndex: 'voidReason',
269-
type: FieldTypeEnum.INPUT,
270-
},
271-
{
272-
title: t('contract.alreadyPayAmount'),
273-
dataIndex: 'alreadyPayAmount',
274-
type: FieldTypeEnum.INPUT_NUMBER,
275-
},
276-
{
277-
title: t('contract.approvalStatus'),
278-
dataIndex: 'approvalStatus',
279-
operatorOption: COMMON_SELECTION_OPERATORS,
280-
type: FieldTypeEnum.SELECT_MULTIPLE,
281-
selectProps: {
282-
options: quotationStatusOptions.filter((item) => ![QuotationStatusEnum.VOIDED].includes(item.value)),
283-
},
284-
},
285-
...baseFilterConfigList,
286-
]);
287-
288240
function getOperationGroupList(row: ContractItem) {
289241
if (row.approvalStatus === QuotationStatusEnum.APPROVING) {
290242
return [
@@ -454,7 +406,7 @@
454406
}
455407
}
456408
457-
const { useTableRes, customFieldsFilterConfig, fieldList } = await useFormCreateTable({
409+
const { useTableRes, customFieldsFilterConfig, fieldList, dicApprovalEnable } = await useFormCreateTable({
458410
formKey: FormDesignKeyEnum.CONTRACT,
459411
operationColumn: {
460412
key: 'operation',
@@ -556,6 +508,58 @@
556508
};
557509
});
558510
511+
// 表格
512+
const filterConfigList = computed<FilterFormItem[]>(() => [
513+
{
514+
title: t('opportunity.department'),
515+
dataIndex: 'departmentId',
516+
type: FieldTypeEnum.TREE_SELECT,
517+
treeSelectProps: {
518+
labelField: 'name',
519+
keyField: 'id',
520+
multiple: true,
521+
clearFilterAfterSelect: false,
522+
type: 'department',
523+
checkable: true,
524+
showContainChildModule: true,
525+
containChildIds: [],
526+
},
527+
},
528+
{
529+
title: t('contract.status'),
530+
dataIndex: 'stage',
531+
type: FieldTypeEnum.SELECT_MULTIPLE,
532+
operatorOption: COMMON_SELECTION_OPERATORS,
533+
selectProps: {
534+
options: contractStatusOptions,
535+
},
536+
},
537+
{
538+
title: t('contract.voidReason'),
539+
dataIndex: 'voidReason',
540+
type: FieldTypeEnum.INPUT,
541+
},
542+
{
543+
title: t('contract.alreadyPayAmount'),
544+
dataIndex: 'alreadyPayAmount',
545+
type: FieldTypeEnum.INPUT_NUMBER,
546+
},
547+
...(dicApprovalEnable.value
548+
? [
549+
{
550+
title: t('contract.approvalStatus'),
551+
dataIndex: 'approvalStatus',
552+
operatorOption: COMMON_SELECTION_OPERATORS,
553+
type: FieldTypeEnum.SELECT_MULTIPLE,
554+
selectProps: {
555+
options: quotationStatusOptions.filter((item) => ![QuotationStatusEnum.VOIDED].includes(item.value)),
556+
},
557+
},
558+
]
559+
: []),
560+
...baseFilterConfigList,
561+
]);
562+
559563
const crmTableRef = ref<InstanceType<typeof CrmTable>>();
560564
const tableAdvanceFilterRef = ref<InstanceType<typeof CrmAdvanceFilter>>();
561565

frontend/packages/web/src/views/contract/invoice/components/invoiceTable.vue

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -247,35 +247,6 @@
247247
}
248248
}
249249
250-
// 表格
251-
const filterConfigList = computed<FilterFormItem[]>(() => [
252-
{
253-
title: t('opportunity.department'),
254-
dataIndex: 'departmentId',
255-
type: FieldTypeEnum.TREE_SELECT,
256-
treeSelectProps: {
257-
labelField: 'name',
258-
keyField: 'id',
259-
multiple: true,
260-
clearFilterAfterSelect: false,
261-
type: 'department',
262-
checkable: true,
263-
showContainChildModule: true,
264-
containChildIds: [],
265-
},
266-
},
267-
{
268-
title: t('contract.approvalStatus'),
269-
dataIndex: 'approvalStatus',
270-
type: FieldTypeEnum.SELECT_MULTIPLE,
271-
operatorOption: COMMON_SELECTION_OPERATORS,
272-
selectProps: {
273-
options: contractInvoiceStatusOptions,
274-
},
275-
},
276-
...baseFilterConfigList,
277-
]);
278-
279250
function getOperationGroupList(row: ContractInvoiceItem) {
280251
if (props.readonly) {
281252
return [];
@@ -412,7 +383,7 @@
412383
});
413384
}
414385
415-
const { useTableRes, customFieldsFilterConfig } = await useFormCreateTable({
386+
const { useTableRes, customFieldsFilterConfig, dicApprovalEnable } = await useFormCreateTable({
416387
formKey: props.isContractTab ? FormDesignKeyEnum.CONTRACT_INVOICE : FormDesignKeyEnum.INVOICE,
417388
operationColumn: {
418389
key: 'operation',
@@ -495,6 +466,39 @@
495466
};
496467
});
497468
469+
// 表格
470+
const filterConfigList = computed<FilterFormItem[]>(() => [
471+
{
472+
title: t('opportunity.department'),
473+
dataIndex: 'departmentId',
474+
type: FieldTypeEnum.TREE_SELECT,
475+
treeSelectProps: {
476+
labelField: 'name',
477+
keyField: 'id',
478+
multiple: true,
479+
clearFilterAfterSelect: false,
480+
type: 'department',
481+
checkable: true,
482+
showContainChildModule: true,
483+
containChildIds: [],
484+
},
485+
},
486+
...(dicApprovalEnable.value
487+
? [
488+
{
489+
title: t('contract.approvalStatus'),
490+
dataIndex: 'approvalStatus',
491+
type: FieldTypeEnum.SELECT_MULTIPLE,
492+
operatorOption: COMMON_SELECTION_OPERATORS,
493+
selectProps: {
494+
options: contractInvoiceStatusOptions,
495+
},
496+
},
497+
]
498+
: []),
499+
...baseFilterConfigList,
500+
]);
501+
498502
const crmTableRef = ref<InstanceType<typeof CrmTable>>();
499503
const tableAdvanceFilterRef = ref<InstanceType<typeof CrmAdvanceFilter>>();
500504

0 commit comments

Comments
 (0)