Skip to content

Commit 620660c

Browse files
fit2cloudwxxfit2-zhao
authored andcommitted
feat: module approval operation
1 parent c84b2bf commit 620660c

File tree

9 files changed

+284
-111
lines changed

9 files changed

+284
-111
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import { FilterOption } from 'naive-ui/es/data-table/src/interface';
88
export type ApprovalConfigType =
99
| FormDesignKeyEnum.CONTRACT
1010
| FormDesignKeyEnum.INVOICE
11+
| FormDesignKeyEnum.CONTRACT_INVOICE
1112
| FormDesignKeyEnum.OPPORTUNITY_QUOTATION;
1213

1314
const dicApprovalKeyMap: Record<ApprovalConfigType, ReasonTypeEnum> = {
1415
[FormDesignKeyEnum.CONTRACT]: ReasonTypeEnum.CONTRACT_APPROVAL,
1516
[FormDesignKeyEnum.INVOICE]: ReasonTypeEnum.INVOICE_APPROVAL,
17+
[FormDesignKeyEnum.CONTRACT_INVOICE]: ReasonTypeEnum.INVOICE_APPROVAL,
1618
[FormDesignKeyEnum.OPPORTUNITY_QUOTATION]: ReasonTypeEnum.QUOTATION_APPROVAL,
1719
};
1820

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

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,6 @@
193193
checkedRowKeys.value = [];
194194
}
195195
196-
const actionConfig: BatchActionConfig = {
197-
baseAction: [
198-
{
199-
label: t('common.exportChecked'),
200-
key: 'exportChecked',
201-
permission: ['CONTRACT:EXPORT'],
202-
},
203-
{
204-
label: t('common.batchApproval'),
205-
key: 'approval',
206-
permission: ['CONTRACT:APPROVAL'],
207-
},
208-
],
209-
};
210-
211196
const showApprovalModal = ref(false);
212197
const batchOperationName = ref('');
213198
const batchResult = ref<BatchOperationResult>({
@@ -237,7 +222,7 @@
237222
}
238223
}
239224
240-
function getOperationGroupList(row: ContractItem) {
225+
function getEnableApprovalGroupList(row: ContractItem) {
241226
if (row.approvalStatus === QuotationStatusEnum.APPROVING) {
242227
return [
243228
{
@@ -294,6 +279,30 @@
294279
];
295280
}
296281
282+
function getOperationGroupList(row: ContractItem, dicApprovalEnable: boolean) {
283+
return dicApprovalEnable
284+
? getEnableApprovalGroupList(row)
285+
: [
286+
{
287+
label: t('common.edit'),
288+
key: 'edit',
289+
permission: ['CONTRACT:UPDATE'],
290+
},
291+
{
292+
label: t('contract.payment'),
293+
key: 'paymentRecord',
294+
permission: ['CONTRACT:PAYMENT'],
295+
disabled: !row.amount || row.alreadyPayAmount >= row.amount,
296+
tooltipContent: row.alreadyPayAmount >= row.amount ? t('contract.noPaymentRequired') : undefined,
297+
},
298+
{
299+
label: t('common.delete'),
300+
key: 'delete',
301+
permission: ['CONTRACT:DELETE'],
302+
},
303+
];
304+
}
305+
297306
const showDetailDrawer = ref(false);
298307
299308
function handleEdit(id: string) {
@@ -413,9 +422,9 @@
413422
width: currentLocale.value === 'en-US' ? 180 : 150,
414423
fixed: 'right',
415424
render: (row: ContractItem) =>
416-
getOperationGroupList(row).length
425+
getOperationGroupList(row, dicApprovalEnable.value).length
417426
? h(CrmOperationButton, {
418-
groupList: getOperationGroupList(row),
427+
groupList: getOperationGroupList(row, dicApprovalEnable.value),
419428
onSelect: (key: string) => handleActionSelect(row, key),
420429
})
421430
: '-',
@@ -508,6 +517,27 @@
508517
};
509518
});
510519
520+
const actionConfig = computed(() => {
521+
return {
522+
baseAction: [
523+
{
524+
label: t('common.exportChecked'),
525+
key: 'exportChecked',
526+
permission: ['CONTRACT:EXPORT'],
527+
},
528+
...(dicApprovalEnable.value
529+
? [
530+
{
531+
label: t('common.batchApproval'),
532+
key: 'approval',
533+
permission: ['CONTRACT:APPROVAL'],
534+
},
535+
]
536+
: []),
537+
],
538+
};
539+
});
540+
511541
// 表格
512542
const filterConfigList = computed<FilterFormItem[]>(() => [
513543
{

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
105105
import { approvalContract, deleteContract, revokeContract } from '@/api/modules';
106106
import { contractStatusOptions } from '@/config/contract';
107+
import useApprovalConfig from '@/hooks/useApprovalConfig';
107108
import useFormCreateApi from '@/hooks/useFormCreateApi';
108109
import useModal from '@/hooks/useModal';
109110
import { useUserStore } from '@/store';
@@ -160,7 +161,7 @@
160161
].filter((item) => hasAnyPermission(item.permission))
161162
);
162163
163-
const buttonList = computed(() => {
164+
function getApprovalEnableBtnList() {
164165
if (detailInfo.value?.approvalStatus === QuotationStatusEnum.APPROVING) {
165166
return [
166167
{
@@ -249,7 +250,44 @@
249250
permission: ['CONTRACT:DELETE'],
250251
},
251252
];
252-
});
253+
}
254+
255+
const { initApprovalConfig, dicApprovalEnable } = useApprovalConfig(FormDesignKeyEnum.CONTRACT);
256+
257+
const buttonList = computed(() =>
258+
dicApprovalEnable.value
259+
? getApprovalEnableBtnList()
260+
: [
261+
{
262+
key: 'edit',
263+
label: t('common.edit'),
264+
permission: ['CONTRACT:UPDATE'],
265+
text: false,
266+
ghost: true,
267+
class: 'n-btn-outline-primary',
268+
},
269+
{
270+
label: t('contract.payment'),
271+
key: 'paymentRecord',
272+
permission: ['CONTRACT:PAYMENT'],
273+
text: false,
274+
ghost: true,
275+
class: 'n-btn-outline-primary',
276+
disabled: !detailInfo.value?.amount || detailInfo.value?.alreadyPayAmount >= detailInfo.value?.amount,
277+
tooltipContent:
278+
detailInfo.value?.alreadyPayAmount >= detailInfo.value?.amount ? t('contract.noPaymentRequired') : '',
279+
},
280+
{
281+
label: t('common.delete'),
282+
key: 'delete',
283+
text: false,
284+
ghost: true,
285+
danger: true,
286+
class: 'n-btn-outline-primary',
287+
permission: ['CONTRACT:DELETE'],
288+
},
289+
]
290+
);
253291
254292
function handleInit(type?: CollaborationType, name?: string, detail?: Record<string, any>) {
255293
title.value = name || '';
@@ -368,4 +406,13 @@
368406
function showBusinessTitleDetail(params: { id: string }) {
369407
emit('openBusinessTitleDrawer', params);
370408
}
409+
410+
watch(
411+
() => visible.value,
412+
(val) => {
413+
if (val) {
414+
initApprovalConfig();
415+
}
416+
}
417+
);
371418
</script>

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
5656
import { approvalInvoiced, deleteInvoiced, revokeInvoiced } from '@/api/modules';
5757
import { deleteInvoiceContentMap } from '@/config/contract';
58+
import useApprovalConfig from '@/hooks/useApprovalConfig';
5859
import useModal from '@/hooks/useModal';
5960
import useUserStore from '@/store/modules/user';
6061
@@ -82,8 +83,9 @@
8283
function handleInit(type?: CollaborationType, name?: string, detail?: Record<string, any>) {
8384
detailInfo.value = detail;
8485
}
86+
const { initApprovalConfig, dicApprovalEnable } = useApprovalConfig(FormDesignKeyEnum.INVOICE);
8587
86-
const buttonList = computed(() => {
88+
function getApprovalEnableBtnList() {
8789
if (detailInfo.value?.approvalStatus === ContractInvoiceStatusEnum.APPROVING) {
8890
return [
8991
{
@@ -157,7 +159,31 @@
157159
permission: ['CONTRACT_INVOICE:DELETE'],
158160
},
159161
];
160-
});
162+
}
163+
164+
const buttonList = computed(() =>
165+
dicApprovalEnable.value
166+
? getApprovalEnableBtnList()
167+
: [
168+
{
169+
key: 'edit',
170+
label: t('common.edit'),
171+
permission: ['CONTRACT_INVOICE:UPDATE'],
172+
text: false,
173+
ghost: true,
174+
class: 'n-btn-outline-primary',
175+
},
176+
{
177+
label: t('common.delete'),
178+
key: 'delete',
179+
text: false,
180+
ghost: true,
181+
danger: true,
182+
class: 'n-btn-outline-primary',
183+
permission: ['CONTRACT_INVOICE:DELETE'],
184+
},
185+
]
186+
);
161187
162188
const refreshKey = ref(0);
163189
function handleSaved() {
@@ -238,4 +264,13 @@
238264
break;
239265
}
240266
}
267+
268+
watch(
269+
() => visible.value,
270+
(val) => {
271+
if (val) {
272+
initApprovalConfig();
273+
}
274+
}
275+
);
241276
</script>

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@
247247
}
248248
}
249249
250-
function getOperationGroupList(row: ContractInvoiceItem) {
251-
if (props.readonly) {
252-
return [];
253-
}
250+
function getApprovalEnableGroupList(row: ContractInvoiceItem) {
254251
if (row.approvalStatus === ContractInvoiceStatusEnum.APPROVING) {
255252
return [
256253
{
@@ -296,6 +293,27 @@
296293
];
297294
}
298295
296+
function getOperationGroupList(row: ContractInvoiceItem, dicApprovalEnable: boolean) {
297+
if (props.readonly) {
298+
return [];
299+
}
300+
if (dicApprovalEnable) {
301+
return getApprovalEnableGroupList(row);
302+
}
303+
return [
304+
{
305+
label: t('common.edit'),
306+
key: 'edit',
307+
permission: ['CONTRACT_INVOICE:UPDATE'],
308+
},
309+
{
310+
label: t('common.delete'),
311+
key: 'delete',
312+
permission: ['CONTRACT_INVOICE:DELETE'],
313+
},
314+
];
315+
}
316+
299317
const showDetailDrawer = ref(false);
300318
301319
function handleDelete(row: any) {
@@ -383,15 +401,22 @@
383401
});
384402
}
385403
404+
function getOperationWidth(approvalEnable: boolean) {
405+
if (approvalEnable) {
406+
return currentLocale.value === 'en-US' ? 180 : 150;
407+
}
408+
return 120;
409+
}
410+
386411
const { useTableRes, customFieldsFilterConfig, dicApprovalEnable } = await useFormCreateTable({
387412
formKey: props.isContractTab ? FormDesignKeyEnum.CONTRACT_INVOICE : FormDesignKeyEnum.INVOICE,
388413
operationColumn: {
389414
key: 'operation',
390-
width: currentLocale.value === 'en-US' ? 180 : 150,
415+
width: computed(() => getOperationWidth(dicApprovalEnable.value)) as unknown as number,
391416
fixed: 'right',
392417
render: (row: ContractInvoiceItem) =>
393418
h(CrmOperationButton, {
394-
groupList: getOperationGroupList(row),
419+
groupList: getOperationGroupList(row, dicApprovalEnable.value),
395420
onSelect: (key: string) => handleActionSelect(row, key),
396421
}),
397422
},

0 commit comments

Comments
 (0)