Skip to content

Commit 37ade13

Browse files
committed
feat: business header supports import update
1 parent de942a5 commit 37ade13

File tree

12 files changed

+123
-24
lines changed

12 files changed

+123
-24
lines changed

frontend/packages/lib-shared/api/modules/contract.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,10 @@ export default function useContractApi(CDR: CordysAxios) {
475475
}
476476

477477
// 合同-工商抬头导入
478-
function preCheckImportBusinessTitle(file: File) {
478+
function preCheckImportBusinessTitle(file: File, importType?: string) {
479479
return CDR.uploadFile<{ data: ValidateInfo }>(
480480
{ url: PreCheckBusinessTitleImportUrl },
481-
{ fileList: [file] },
481+
{ fileList: [file], request: {importType } },
482482
'file'
483483
);
484484
}
@@ -493,8 +493,8 @@ export default function useContractApi(CDR: CordysAxios) {
493493
);
494494
}
495495

496-
function importBusinessTitle(file: File) {
497-
return CDR.uploadFile({ url: ImportBusinessTitleUrl }, { fileList: [file] }, 'file');
496+
function importBusinessTitle(file: File, importType?: string) {
497+
return CDR.uploadFile({ url: ImportBusinessTitleUrl }, { fileList: [file], request: {importType} }, 'file');
498498
}
499499

500500
// 工商抬头列表

frontend/packages/lib-shared/models/contract.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export interface BusinessTitleItem {
147147
name: string;
148148
type: 'THIRD_PARTY' | 'CUSTOM';
149149
identificationNumber: string;
150-
area: string; // 所属地区
150+
province: string; // 省
151+
city: string; // 市
152+
remark: string;
151153
scale: string; // 企业规模
152154
industry: string; // 国标行业
153155
openingBank: string;
@@ -180,7 +182,9 @@ export interface SaveBusinessTitleParams {
180182
companySize: string; // 公司规模
181183
registrationNumber: string; //工商注册号
182184
type: string; // 来源类型
183-
area: string; // 所属地区
185+
province: string; // 省
186+
city: string; // 市
187+
remark: string;
184188
scale: string; // 企业规模
185189
industry: string; // 国标行业
186190
}

frontend/packages/web/src/components/business/crm-import-button/components/importModal.vue

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,40 @@
2222
</div>
2323
</div>
2424
</n-alert>
25+
<n-radio-group v-if="props.showImportRadio" v-model:value="importType" class="mb-[16px]" name="radiogroup">
26+
<n-space class="!gap-[24px]">
27+
<n-radio key="ADD" value="ADD">
28+
<div class="flex items-center gap-[8px]">
29+
{{ t('crmImportButton.importNew') }}
30+
<n-tooltip trigger="hover" placement="right">
31+
<template #trigger>
32+
<CrmIcon
33+
type="iconicon_help_circle"
34+
:size="16"
35+
class="cursor-pointer text-[var(--text-n4)] hover:text-[var(--primary-1)]"
36+
/>
37+
</template>
38+
{{ t('crmImportButton.importNew.tooltip') }}
39+
</n-tooltip>
40+
</div>
41+
</n-radio>
42+
<n-radio key="UPDATE" value="UPDATE">
43+
<div class="flex items-center gap-[8px]">
44+
{{ t('crmImportButton.importUpdates') }}
45+
<n-tooltip trigger="hover" placement="right">
46+
<template #trigger>
47+
<CrmIcon
48+
type="iconicon_help_circle"
49+
:size="16"
50+
class="cursor-pointer text-[var(--text-n4)] hover:text-[var(--primary-1)]"
51+
/>
52+
</template>
53+
{{ t('crmImportButton.importUpdates.tooltip') }}
54+
</n-tooltip>
55+
</div>
56+
</n-radio>
57+
</n-space>
58+
</n-radio-group>
2559
<CrmUpload
2660
v-model:file-list="fileList"
2761
:is-all-screen="true"
@@ -38,7 +72,7 @@
3872

3973
<script setup lang="ts">
4074
import { ref } from 'vue';
41-
import { NAlert, useMessage } from 'naive-ui';
75+
import { NAlert, NRadio, NRadioGroup, NSpace, NTooltip, useMessage } from 'naive-ui';
4276
4377
import { useI18n } from '@lib/shared/hooks/useI18n';
4478
import useLocale from '@lib/shared/locale/useLocale';
@@ -58,10 +92,11 @@
5892
title?: string; // 标题
5993
descriptionTip?: string; // 描述提示内容
6094
downloadTemplateApi?: () => Promise<any>; // 下载模板Api
95+
showImportRadio?: boolean;
6196
}>();
6297
6398
const emit = defineEmits<{
64-
(e: 'validate', files: CrmFileItem[]): void;
99+
(e: 'validate', files: CrmFileItem[], importType?: string): void;
65100
(e: 'close'): void;
66101
}>();
67102
@@ -71,10 +106,12 @@
71106
});
72107
73108
const fileList = ref<CrmFileItem[]>([]);
109+
const importType = ref('ADD');
74110
75111
function cancel() {
76112
showModal.value = false;
77113
fileList.value = [];
114+
importType.value = 'ADD';
78115
emit('close');
79116
}
80117
@@ -109,7 +146,7 @@
109146
const validateLoading = ref<boolean>(false);
110147
111148
function validate() {
112-
emit('validate', fileList.value);
149+
emit('validate', fileList.value, importType.value);
113150
}
114151
</script>
115152

frontend/packages/web/src/components/business/crm-import-button/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:description-tip="props.descriptionTip"
1010
:confirm-loading="validateLoading"
1111
:download-template-api="importApiMap[props.apiType]?.download"
12+
:show-import-radio="props.showImportRadio"
1213
@validate="validateTemplate"
1314
/>
1415

@@ -54,6 +55,7 @@
5455
title?: string;
5556
buttonText?: string;
5657
descriptionTip?: string; // 描述提示
58+
showImportRadio?: boolean; // 导入新建和导入更新
5759
}>();
5860
5961
const emit = defineEmits<{
@@ -94,11 +96,12 @@
9496
// 导入
9597
const fileList = ref<CrmFileItem[]>([]);
9698
const importLoading = ref<boolean>(false);
99+
const importType = ref('');
97100
98101
async function importHandler() {
99102
try {
100103
importLoading.value = true;
101-
await importApiMap[props.apiType].save(fileList.value[0].file as File);
104+
await importApiMap[props.apiType].save(fileList.value[0].file as File, importType.value);
102105
Message.success(t('common.importSuccess'));
103106
104107
emit('importSuccess');
@@ -113,8 +116,11 @@
113116
}
114117
115118
// 校验导入模板
116-
async function validateTemplate(files: CrmFileItem[]) {
119+
async function validateTemplate(files: CrmFileItem[], type?: string) {
117120
fileList.value = files;
121+
if (type) {
122+
importType.value = type;
123+
}
118124
const file = fileList.value[0].file as File;
119125
120126
// 防止修改后未上传就校验
@@ -134,7 +140,7 @@
134140
validateModal.value = true;
135141
start();
136142
137-
const result = await importApiMap[props.apiType].preCheck(file);
143+
const result = await importApiMap[props.apiType].preCheck(file, type);
138144
validateInfo.value = result.data;
139145
finish();
140146
} catch (error) {

frontend/packages/web/src/components/business/crm-import-button/locale/en-US.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ export default {
2020
'crmImportButton.formExcelImport': 'Import from Excel file',
2121
'crmImportButton.onlyAllowFileTypeTip': 'Only files in xls/xlsx format are supported',
2222
'crmImportButton.fileChange': 'The file has been modified. Please re-upload it',
23+
'crmImportButton.importNew': 'Import new',
24+
'crmImportButton.importNew.tooltip':
25+
'Company name is unique. If multiple duplicate records exist, only the first one will be imported.',
26+
'crmImportButton.importUpdates': 'Import updates',
27+
'crmImportButton.importUpdates.tooltip':
28+
'After matching by company name, columns with valid values in the Excel file will overwrite the corresponding records in the system.',
2329
};

frontend/packages/web/src/components/business/crm-import-button/locale/zh-CN.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ export default {
1818
'crmImportButton.importErrorData': '导入失败数据',
1919
'crmImportButton.formExcelImport': '从 Excel 文件导入',
2020
'crmImportButton.onlyAllowFileTypeTip': '仅支持 xls/xlsx 格式的文件',
21-
'crmImportButton.fileChange': '文件已被修改,请重新上传',
21+
'crmImportButton.importNew': '导入新建',
22+
'crmImportButton.importNew.tooltip': '公司名称唯一,若存在多条重复信息,仅导入第一条。',
23+
'crmImportButton.importUpdates': '导入更新',
24+
'crmImportButton.importUpdates.tooltip': '系统按公司名称匹配成功后,Excel 中存在有效值的列将覆盖系统对应记录。',
2225
};

frontend/packages/web/src/components/business/crm-import-button/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export type ImportApiType =
4040
| ImportTypeExcludeFormDesignEnum.CONTRACT_BUSINESS_TITLE_IMPORT;
4141

4242
export interface importRequestType {
43-
preCheck: (file: File) => Promise<{ data: ValidateInfo }>;
44-
save: (file: File) => Promise<any>;
43+
preCheck: (file: File, importType?: string) => Promise<{ data: ValidateInfo }>;
44+
save: (file: File, importType?: string) => Promise<any>;
4545
download?: () => Promise<File>;
4646
}
4747

frontend/packages/web/src/config/contract.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@ export const businessTitleFormConfigList: {
159159
value: 'registrationNumber',
160160
},
161161
{
162-
label: t('contract.businessTitle.area'),
163-
value: 'area',
162+
label: t('contract.businessTitle.province'),
163+
value: 'province',
164+
},
165+
{
166+
label: t('contract.businessTitle.city'),
167+
value: 'city',
164168
},
165169
{
166170
label: t('contract.businessTitle.scale'),
@@ -170,6 +174,10 @@ export const businessTitleFormConfigList: {
170174
label: t('contract.businessTitle.industry'),
171175
value: 'industry',
172176
},
177+
{
178+
label: t('common.remark'),
179+
value: 'remark',
180+
},
173181
];
174182

175183
export const allBusinessTitleFormConfigList: {

frontend/packages/web/src/views/contract/businessTitle/components/businessTitleTable.vue

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<CrmImportButton
2222
v-if="hasAnyPermission(['CONTRACT_BUSINESS_TITLE:IMPORT'])"
2323
:api-type="ImportTypeExcludeFormDesignEnum.CONTRACT_BUSINESS_TITLE_IMPORT"
24+
showImportRadio
2425
:title="t('module.businessTitle')"
2526
@import-success="() => searchData()"
2627
/>
@@ -344,8 +345,18 @@
344345
width: 200,
345346
},
346347
{
347-
title: t('contract.businessTitle.area'),
348-
key: 'area',
348+
title: t('contract.businessTitle.province'),
349+
key: 'province',
350+
sortOrder: false,
351+
sorter: true,
352+
ellipsis: {
353+
tooltip: true,
354+
},
355+
width: 200,
356+
},
357+
{
358+
title: t('contract.businessTitle.city'),
359+
key: 'city',
349360
sortOrder: false,
350361
sorter: true,
351362
ellipsis: {
@@ -373,6 +384,16 @@
373384
},
374385
width: 200,
375386
},
387+
{
388+
title: t('common.remark'),
389+
key: 'remark',
390+
sortOrder: false,
391+
sorter: true,
392+
ellipsis: {
393+
tooltip: true,
394+
},
395+
width: 200,
396+
},
376397
{
377398
title: t('common.createTime'),
378399
key: 'createTime',
@@ -539,8 +560,13 @@
539560
type: FieldTypeEnum.INPUT,
540561
},
541562
{
542-
title: t('contract.businessTitle.area'),
543-
dataIndex: 'area',
563+
title: t('contract.businessTitle.province'),
564+
dataIndex: 'province',
565+
type: FieldTypeEnum.INPUT,
566+
},
567+
{
568+
title: t('contract.businessTitle.city'),
569+
dataIndex: 'city',
544570
type: FieldTypeEnum.INPUT,
545571
},
546572
{
@@ -553,6 +579,11 @@
553579
dataIndex: 'industry',
554580
type: FieldTypeEnum.INPUT,
555581
},
582+
{
583+
title: t('common.remark'),
584+
dataIndex: 'remark',
585+
type: FieldTypeEnum.INPUT,
586+
},
556587
...baseFilterConfigList,
557588
]);
558589

frontend/packages/web/src/views/contract/businessTitle/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export const initBusinessTitleForm: SaveBusinessTitleParams = {
1515
companySize: '',
1616
registrationNumber: '',
1717
registrationAddress: '',
18-
area: '',
18+
province: '', // 省
19+
city: '', // 市
20+
remark: '',
1921
scale: '',
2022
industry: '',
2123
};

0 commit comments

Comments
 (0)