@cfmm/umi-plugins-ui-v2 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CrudTable.tpl +272 -27
- package/dist/cjs/locales/en-US.d.ts +3 -0
- package/dist/cjs/locales/enUS/common.d.ts +3 -0
- package/dist/cjs/locales/enUS/common.js +3 -0
- package/dist/cjs/locales/enUS/index.d.ts +3 -0
- package/dist/cjs/locales/th-TH.d.ts +3 -0
- package/dist/cjs/locales/zh-CN.d.ts +3 -0
- package/dist/cjs/locales/zh-TW.d.ts +3 -0
- package/dist/cjs/locales/zhCN/common.d.ts +3 -0
- package/dist/cjs/locales/zhCN/common.js +3 -0
- package/dist/cjs/locales/zhCN/index.d.ts +3 -0
- package/dist/cjs/locales/zhTW/common.d.ts +3 -0
- package/dist/cjs/locales/zhTW/common.js +3 -0
- package/dist/cjs/locales/zhTW/index.d.ts +3 -0
- package/dist/cjs/services/index.tpl +4 -4
- package/dist/cjs/types/CrudTableTypes.d.ts +1 -1
- package/dist/cjs/types/CrudTableTypes.js +1 -1
- package/dist/cjs/types/EditMultiLangFormTypes.d.ts +1 -1
- package/dist/cjs/types/EditMultiLangFormTypes.js +1 -1
- package/dist/cjs/utils/excelHelper.tpl +44 -36
- package/dist/esm/components/CrudTable.tpl +272 -27
- package/dist/esm/locales/en-US.d.ts +3 -0
- package/dist/esm/locales/enUS/common.d.ts +3 -0
- package/dist/esm/locales/enUS/common.js +3 -0
- package/dist/esm/locales/enUS/index.d.ts +3 -0
- package/dist/esm/locales/th-TH.d.ts +3 -0
- package/dist/esm/locales/zh-CN.d.ts +3 -0
- package/dist/esm/locales/zh-TW.d.ts +3 -0
- package/dist/esm/locales/zhCN/common.d.ts +3 -0
- package/dist/esm/locales/zhCN/common.js +3 -0
- package/dist/esm/locales/zhCN/index.d.ts +3 -0
- package/dist/esm/locales/zhTW/common.d.ts +3 -0
- package/dist/esm/locales/zhTW/common.js +3 -0
- package/dist/esm/locales/zhTW/index.d.ts +3 -0
- package/dist/esm/services/index.tpl +4 -4
- package/dist/esm/types/CrudTableTypes.d.ts +1 -1
- package/dist/esm/types/CrudTableTypes.js +1 -1
- package/dist/esm/types/EditMultiLangFormTypes.d.ts +1 -1
- package/dist/esm/types/EditMultiLangFormTypes.js +1 -1
- package/dist/esm/utils/excelHelper.tpl +44 -36
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { CloudDownloadOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
|
2
|
-
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
|
3
|
-
import { cfmmUtils, ImportExecl, useIntl } from '@umijs/max';
|
|
4
|
-
import { Button, Dropdown, MenuProps, Modal } from 'antd';
|
|
1
|
+
import { CloudDownloadOutlined, DownloadOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
|
2
|
+
import { ActionType, ColumnsState, ProColumns, ProTable } from '@ant-design/pro-components';
|
|
3
|
+
import { cfmmUtils, ImportExecl, useFormatLocale, useIntl, useModel } from '@umijs/max';
|
|
4
|
+
import { Button, Dropdown, MenuProps, message, Modal, Progress } from 'antd';
|
|
5
5
|
import React, { ForwardedRef, forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import useAction from '../hooks/useAction';
|
|
7
7
|
import useAuthority from '../hooks/useAuthority';
|
|
8
8
|
import useMemoizedFn from '../hooks/useMemoizedFn';
|
|
9
9
|
import useQueryTableList from '../hooks/useQueryTableList';
|
|
10
|
-
import { API, CrudTableConfig, CrudTableRefType,
|
|
10
|
+
import { API, CrudTableConfig, CrudTableRefType, ExportMultiLangListItem, LangInfoItem, RefDrawerFormRefType } from '../types';
|
|
11
11
|
import ActionLogDrawer from './ActionLogDrawer';
|
|
12
12
|
import CreateForm from './AddDrawerForm';
|
|
13
13
|
import DropdownButton from './DropdownButton';
|
|
14
14
|
import EditMultiLangForm from './EditMultiLangForm';
|
|
15
15
|
import MyFooterToolbar from './MyFooterToolbar';
|
|
16
16
|
import ViewTableItemDrawer from './ViewTableItemDrawer';
|
|
17
|
-
import { genExcelAdvanced } from '../utils/excelHelper';
|
|
18
|
-
import { importMultiLangList,
|
|
19
|
-
import { handleImportList } from '../utils/importHelper';
|
|
17
|
+
import { genExcel, genExcelAdvanced, getExportColumns, getExportValueForColumns } from '../utils/excelHelper';
|
|
18
|
+
import { importMultiLangList, queryLangInfoExportList } from '../services';
|
|
19
|
+
import { handleImportList, showCheckErrorTips } from '../utils/importHelper';
|
|
20
20
|
|
|
21
21
|
const { confirm } = Modal;
|
|
22
22
|
export const TABLE_SCROLL = { x: 'max-content' };
|
|
@@ -38,6 +38,9 @@ const generateDefaultAuthCodes = (localCode: string | undefined) => {
|
|
|
38
38
|
remove: `${baseCode}_remove`,
|
|
39
39
|
record: `${baseCode}_record`,
|
|
40
40
|
lang: `${baseCode}_lang`,
|
|
41
|
+
templateDownload: `${baseCode}_templateDownload`,
|
|
42
|
+
import: `${baseCode}_import`,
|
|
43
|
+
export: `${baseCode}_export`,
|
|
41
44
|
};
|
|
42
45
|
};
|
|
43
46
|
|
|
@@ -58,6 +61,7 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
58
61
|
createConfig = {},
|
|
59
62
|
updateConfig = {},
|
|
60
63
|
actionColumnConfig = {} as CrudTableConfig['actionColumnConfig'],
|
|
64
|
+
downloadTemplate = {},
|
|
61
65
|
onAdd,
|
|
62
66
|
onAfterSearch,
|
|
63
67
|
onBeforeEdit,
|
|
@@ -65,6 +69,7 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
65
69
|
onAfterDelete,
|
|
66
70
|
onBeforeAction,
|
|
67
71
|
onAfterAction,
|
|
72
|
+
onAfterImport,
|
|
68
73
|
} = props;
|
|
69
74
|
|
|
70
75
|
const defaultAuthCodes = {
|
|
@@ -74,8 +79,14 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
74
79
|
|
|
75
80
|
const { formatMessage } = useIntl();
|
|
76
81
|
const { getAuthorityFn } = useAuthority();
|
|
82
|
+
const {
|
|
83
|
+
templateDownloadModalOpenChange,
|
|
84
|
+
handleTemplateDownloadModalSearchParamsChange,
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
} = window.__POWERED_BY_QIANKUN__ ? useModel('@@qiankunStateFromMaster') : useModel('global');
|
|
77
87
|
const actionRef = useRef<ActionType>();
|
|
78
88
|
const updateDrawerRef = useRef<RefDrawerFormRefType>();
|
|
89
|
+
const timer = useRef<NodeJS.Timeout>();
|
|
79
90
|
|
|
80
91
|
// 状态管理
|
|
81
92
|
const [tableList, setTableList] = useState<T[]>([]);
|
|
@@ -90,9 +101,18 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
90
101
|
const [editLangModalOpen, setEditLangModalOpen] = useState<boolean>(false);
|
|
91
102
|
const [currentLangInfo, setCurrentLangInfo] = useState<LangInfoItem | undefined>();
|
|
92
103
|
|
|
104
|
+
// 导出execl
|
|
105
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
106
|
+
const [percent, setPercent] = useState<number>(0);
|
|
107
|
+
const [downloadButtonLoading, setDownloadButtonLoading] = useState<boolean>(false);
|
|
108
|
+
const [columnsStateMap, setColumnsStateMap] = useState<Record<string, ColumnsState>>({});
|
|
109
|
+
// 用于导出查询,不能使用formRef,会造成与表格数据不一致
|
|
110
|
+
const [tableSearchParams, setTableSearchParams] = useState<any>({});
|
|
111
|
+
|
|
93
112
|
// Hooks
|
|
94
113
|
const { queryList } = useQueryTableList(baseLocalCode ? { baseLocalCode, baseLocalName } : undefined);
|
|
95
114
|
const { doAction, loading: actionLoading } = useAction(baseLocalCode ? { baseLocalCode, baseLocalName } : undefined);
|
|
115
|
+
const { getLocalDate } = useFormatLocale();
|
|
96
116
|
|
|
97
117
|
/**
|
|
98
118
|
* 处理多语言字段点击
|
|
@@ -113,19 +133,19 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
113
133
|
setEditLangModalOpen(true);
|
|
114
134
|
});
|
|
115
135
|
|
|
116
|
-
const queryMultiLangData = useMemoizedFn(async (tableName: string, columnName: string): Promise<
|
|
117
|
-
if(!multiLang) return [];
|
|
136
|
+
const queryMultiLangData = useMemoizedFn(async (tableName: string, columnName: string): Promise<ExportMultiLangListItem[]> => {
|
|
137
|
+
if (!multiLang) return [];
|
|
118
138
|
|
|
119
|
-
if(multiLang.multiLangList) {
|
|
139
|
+
if (multiLang.multiLangList) {
|
|
120
140
|
return multiLang.multiLangList;
|
|
121
141
|
}
|
|
122
142
|
|
|
123
|
-
if (multiLang.
|
|
124
|
-
return await multiLang.
|
|
143
|
+
if (multiLang.queryExportMultiLangData) {
|
|
144
|
+
return await multiLang.queryExportMultiLangData(tableName, columnName);
|
|
125
145
|
}
|
|
126
146
|
|
|
127
147
|
const result = await doAction('GET', { tableName, columnName }, {
|
|
128
|
-
actionFn:
|
|
148
|
+
actionFn: queryLangInfoExportList,
|
|
129
149
|
});
|
|
130
150
|
|
|
131
151
|
if (result.success && result.data) {
|
|
@@ -135,7 +155,7 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
135
155
|
});
|
|
136
156
|
|
|
137
157
|
const handleExportMultiLang = useMemoizedFn(async () => {
|
|
138
|
-
if(multiLang?.exportMultiLangData) {
|
|
158
|
+
if (multiLang?.exportMultiLangData) {
|
|
139
159
|
return await multiLang.exportMultiLangData();
|
|
140
160
|
}
|
|
141
161
|
|
|
@@ -150,8 +170,8 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
150
170
|
|
|
151
171
|
const { tableName, columnName } = multiLang.fields[0];
|
|
152
172
|
const data = await queryMultiLangData(tableName, columnName);
|
|
153
|
-
|
|
154
|
-
if(!data.length) return;
|
|
173
|
+
|
|
174
|
+
if (!data.length) return;
|
|
155
175
|
|
|
156
176
|
const handleData = data.map(item => [item.dataId, item.columnValue, item.zh_CN, item.zh_TW, item.en_US, item.th_TH]);
|
|
157
177
|
|
|
@@ -174,16 +194,16 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
174
194
|
|
|
175
195
|
// 导入多语言数据
|
|
176
196
|
const importMultiLang = useMemoizedFn(async (list: any[]) => {
|
|
177
|
-
if(!multiLang?.fields) return;
|
|
197
|
+
if (!multiLang?.fields) return;
|
|
178
198
|
|
|
179
199
|
const { tableName, columnName } = multiLang.fields[0];
|
|
180
200
|
|
|
181
|
-
if(multiLang.importMultiLangData) {
|
|
201
|
+
if (multiLang.importMultiLangData) {
|
|
182
202
|
return await multiLang.importMultiLangData(list, tableName, columnName);
|
|
183
203
|
}
|
|
184
|
-
|
|
204
|
+
|
|
185
205
|
// 处理导入数据,正确赋值字段以及转格式
|
|
186
|
-
const newList = handleImportList<
|
|
206
|
+
const newList = handleImportList<ExportMultiLangListItem>(list, { needHandleUnderline: false });
|
|
187
207
|
|
|
188
208
|
// 导入校验提示
|
|
189
209
|
// const errorMessageList = checkImportExecl(newList);
|
|
@@ -192,7 +212,7 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
192
212
|
// return Promise.resolve({ success: false });
|
|
193
213
|
// }
|
|
194
214
|
|
|
195
|
-
const result =
|
|
215
|
+
const result = await doAction('IMPORT', {
|
|
196
216
|
tableName: tableName,
|
|
197
217
|
columnName: columnName,
|
|
198
218
|
i18nDataList: newList.filter(item => item.en_US || item.zh_CN || item.zh_TW || item.th_TH),
|
|
@@ -207,6 +227,42 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
207
227
|
return result;
|
|
208
228
|
});
|
|
209
229
|
|
|
230
|
+
/**
|
|
231
|
+
* 查询导出数据
|
|
232
|
+
* @param params
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
|
+
const handleSearchAll = async () => {
|
|
236
|
+
if (loading) return { success: false } as API.Result_TableListType<T>;
|
|
237
|
+
|
|
238
|
+
// 请求前拦截器
|
|
239
|
+
let processedParams = { ...tableSearchParams };
|
|
240
|
+
if (interceptors.query?.request) {
|
|
241
|
+
processedParams = interceptors.query.request(processedParams);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
setLoading(true);
|
|
245
|
+
const result = await queryList<T[]>(tableSearchParams, {
|
|
246
|
+
queryFn: apis.query,
|
|
247
|
+
});
|
|
248
|
+
setLoading(false);
|
|
249
|
+
|
|
250
|
+
if (!result.success && result.error?.response?.status === 504) {
|
|
251
|
+
message.error(
|
|
252
|
+
formatMessage({ id: 'pages.File.export.timeOut.help', defaultMessage: '数据量过大,请联系工作人员帮助导出' }),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 请求后拦截器
|
|
257
|
+
let processedResult = result;
|
|
258
|
+
if (interceptors.query?.response) {
|
|
259
|
+
processedResult = interceptors.query.response(result);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
setTableList(processedResult.data);
|
|
263
|
+
return processedResult;
|
|
264
|
+
};
|
|
265
|
+
|
|
210
266
|
/**
|
|
211
267
|
* 查询表格数据
|
|
212
268
|
*/
|
|
@@ -338,6 +394,118 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
338
394
|
});
|
|
339
395
|
});
|
|
340
396
|
|
|
397
|
+
// 将导入的列表数据提交给后端
|
|
398
|
+
const submitListData = async (list: T[]) => {
|
|
399
|
+
return await doAction('IMPORT', list, {
|
|
400
|
+
actionFn: apis.importData,
|
|
401
|
+
showMsg: false,
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// 导入物料
|
|
406
|
+
const importListData = useMemoizedFn(async (list: T[]) => {
|
|
407
|
+
if(!apis.importData && !interceptors.importData?.submitImportListData) return;
|
|
408
|
+
|
|
409
|
+
// 处理导入数据,正确赋值字段以及转格式
|
|
410
|
+
const newList = interceptors.importData?.request?.(list) ?? handleImportList<T>(list);
|
|
411
|
+
|
|
412
|
+
// 导入校验提示
|
|
413
|
+
const errorMessageList = interceptors.importData?.checkImportExecl?.(newList) || [];
|
|
414
|
+
|
|
415
|
+
if (errorMessageList.length) {
|
|
416
|
+
interceptors.importData?.showCheckErrorTips?.(errorMessageList) || showCheckErrorTips(errorMessageList);
|
|
417
|
+
return Promise.resolve({ success: false });
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const resutl = await interceptors.importData?.submitImportListData?.(newList) || await submitListData(newList);
|
|
421
|
+
|
|
422
|
+
onAfterImport?.(resutl);
|
|
423
|
+
|
|
424
|
+
if (resutl.success) {
|
|
425
|
+
actionRef.current?.reload();
|
|
426
|
+
}
|
|
427
|
+
return resutl;
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const handlePercentChange = (value: number) => {
|
|
431
|
+
setPercent(value);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* 下载数据为Excel
|
|
436
|
+
*/
|
|
437
|
+
const handleDownloadExcel = async () => {
|
|
438
|
+
const result = await handleSearchAll();
|
|
439
|
+
if (!result.success || result.error || !result.data) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const MAX_DOWNLOAD = cfmmUtils?.MAX_DOWNLOAD || 65536;
|
|
444
|
+
|
|
445
|
+
setDownloadButtonLoading(true);
|
|
446
|
+
|
|
447
|
+
const exportColums = getExportColumns<T>({ columns, columnsStateMap });
|
|
448
|
+
|
|
449
|
+
//固定列名
|
|
450
|
+
let columnsName: any[] = exportColums.map((item) => item.title).filter(Boolean);
|
|
451
|
+
//文件名根据多语言形成
|
|
452
|
+
const fileName = formatMessage({
|
|
453
|
+
id: `${baseLocalCode}.title`,
|
|
454
|
+
defaultMessage: '数据列表',
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
//创建导出Excel
|
|
458
|
+
genExcel(fileName + '.xlsx', 'sheet1', columnsName, function () {
|
|
459
|
+
//生成数据
|
|
460
|
+
return new Promise((resolve) => {
|
|
461
|
+
//所有数据行
|
|
462
|
+
getExportValueForColumns({
|
|
463
|
+
columns: exportColums,
|
|
464
|
+
data: result.data,
|
|
465
|
+
getLocalDate,
|
|
466
|
+
handlePercentChange,
|
|
467
|
+
})
|
|
468
|
+
.then((allRows) => {
|
|
469
|
+
if (allRows.length > MAX_DOWNLOAD) {
|
|
470
|
+
Modal.warning({
|
|
471
|
+
title: formatMessage({ id: 'common.download.exceed.max.title', defaultMessage: `下载数据过大提醒` }),
|
|
472
|
+
content: formatMessage(
|
|
473
|
+
{
|
|
474
|
+
id: 'common.download.exceed.max.tips',
|
|
475
|
+
defaultMessage: `超出最大下载数据 ${MAX_DOWNLOAD} 条,超出部分请重新下载`,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
count: MAX_DOWNLOAD,
|
|
479
|
+
},
|
|
480
|
+
),
|
|
481
|
+
onOk: () => resolve(allRows.slice(0, MAX_DOWNLOAD)),
|
|
482
|
+
});
|
|
483
|
+
} else {
|
|
484
|
+
resolve(allRows);
|
|
485
|
+
}
|
|
486
|
+
})
|
|
487
|
+
.catch((err) => console.log('err', err))
|
|
488
|
+
.finally(() => {
|
|
489
|
+
timer.current = setTimeout(() => {
|
|
490
|
+
setDownloadButtonLoading(false);
|
|
491
|
+
setPercent(0);
|
|
492
|
+
}, 2000);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* 下载模板
|
|
500
|
+
*/
|
|
501
|
+
const handleDownloadTemplate = () => {
|
|
502
|
+
handleTemplateDownloadModalSearchParamsChange({
|
|
503
|
+
templateTypeCode: downloadTemplate.templateTypeCode,
|
|
504
|
+
moduleCode: downloadTemplate.moduleCode,
|
|
505
|
+
});
|
|
506
|
+
templateDownloadModalOpenChange(true);
|
|
507
|
+
};
|
|
508
|
+
|
|
341
509
|
/**
|
|
342
510
|
* 增强的列配置(添加操作列)
|
|
343
511
|
*/
|
|
@@ -455,8 +623,44 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
455
623
|
],
|
|
456
624
|
);
|
|
457
625
|
|
|
626
|
+
// 判断是布尔值还是其他值,返回布尔值判断是否显示按钮
|
|
627
|
+
const isShowButton = (buttonAuth: string | boolean | undefined): boolean => {
|
|
628
|
+
return typeof buttonAuth === 'boolean' ? buttonAuth : getAuthorityFn(buttonAuth) ?? false;
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// 处理表格额外操作按钮列表
|
|
632
|
+
const handleTableButtonList = (allButtons: MenuProps['items']) => {
|
|
633
|
+
if(!allButtons?.length) return allButtons;
|
|
634
|
+
|
|
635
|
+
let renderList: MenuProps['items'] | any[] = [...(allButtons ?? [])];
|
|
636
|
+
|
|
637
|
+
// 将额外的按钮按指定位置放入渲染列表
|
|
638
|
+
if (tableProps.extraTableButtonList?.length) {
|
|
639
|
+
tableProps.extraTableButtonList.forEach((v, idx) => {
|
|
640
|
+
const item = {
|
|
641
|
+
key: typeof v.auth === 'string' ? v.auth : 'extra-' + idx,
|
|
642
|
+
label: v.label,
|
|
643
|
+
icon: v.icon,
|
|
644
|
+
auth: isShowButton(v.auth),
|
|
645
|
+
};
|
|
646
|
+
if (v.position === 'start') {
|
|
647
|
+
renderList.unshift(item);
|
|
648
|
+
}
|
|
649
|
+
if (v.position === 'end') {
|
|
650
|
+
renderList.push(item);
|
|
651
|
+
}
|
|
652
|
+
if (typeof v.position === 'number') {
|
|
653
|
+
renderList.splice(v.position, 0, item);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return renderList.filter((item) => item?.auth);
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
// 处理表格顶部操作按钮列表
|
|
458
662
|
const getBarButtons = useMemo<MenuProps['items'] | any[]>(() => {
|
|
459
|
-
|
|
663
|
+
let allButtons: MenuProps['items'] | any[] = [
|
|
460
664
|
{
|
|
461
665
|
auth: getAuthorityFn(defaultAuthCodes.add),
|
|
462
666
|
key: 'add',
|
|
@@ -489,16 +693,50 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
489
693
|
</ImportExecl>
|
|
490
694
|
),
|
|
491
695
|
},
|
|
696
|
+
{
|
|
697
|
+
auth: getAuthorityFn(defaultAuthCodes.templateDownload),
|
|
698
|
+
key: 'templateDownload',
|
|
699
|
+
label: (
|
|
700
|
+
<a onClick={handleDownloadTemplate} key="templateDownload">
|
|
701
|
+
<DownloadOutlined style={{ marginRight: 6 }} />
|
|
702
|
+
{formatMessage({ id: 'cfmmUI.common.button.importData', defaultMessage: '下载模板' })}
|
|
703
|
+
</a>
|
|
704
|
+
),
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
auth: getAuthorityFn(defaultAuthCodes.import) && (apis.importData || interceptors.importData?.submitImportListData),
|
|
708
|
+
key: 'import',
|
|
709
|
+
label: (
|
|
710
|
+
<ImportExecl key="importMaterial" rangeStart={{ c: 0, r: 2 }} onChange={importListData}>
|
|
711
|
+
<div style={{ color: !actionLoading ? 'rgba(0, 0, 0, 0.88)' : 'rgba(0, 0, 0, 0.25)' }}>
|
|
712
|
+
<UploadOutlined style={{ marginRight: 8 }} />
|
|
713
|
+
{formatMessage({ id: 'cfmmUI.common.button.importData', defaultMessage: '导入数据' })}
|
|
714
|
+
</div>
|
|
715
|
+
</ImportExecl>
|
|
716
|
+
),
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
auth: getAuthorityFn(defaultAuthCodes.export),
|
|
720
|
+
key: 'export',
|
|
721
|
+
disabled: !tableList.length || loading,
|
|
722
|
+
label: <a onClick={handleDownloadExcel} key="export">
|
|
723
|
+
<CloudDownloadOutlined style={{ marginRight: 6 }} />
|
|
724
|
+
{formatMessage({ id: 'cfmmUI.common.button.exportData', defaultMessage: '导出数据' })}
|
|
725
|
+
</a>
|
|
726
|
+
},
|
|
492
727
|
];
|
|
493
728
|
|
|
729
|
+
allButtons = handleTableButtonList(allButtons);
|
|
730
|
+
|
|
494
731
|
// 过滤有权限的按钮,并移除 auth 属性避免传递到 DOM
|
|
495
|
-
return allButtons
|
|
732
|
+
return allButtons!
|
|
496
733
|
.filter((button) => button.auth)
|
|
497
734
|
.map(({ auth, ...rest }) => rest);
|
|
498
|
-
}, []);
|
|
735
|
+
}, [tableList, loading, columnsStateMap]);
|
|
499
736
|
|
|
500
737
|
return (
|
|
501
738
|
<>
|
|
739
|
+
{downloadButtonLoading ? <Progress percent={percent} size="small" /> : null}
|
|
502
740
|
<ProTable<T>
|
|
503
741
|
headerTitle={formatMessage({
|
|
504
742
|
id: `${baseLocalCode}.title`,
|
|
@@ -510,9 +748,9 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
510
748
|
search={cfmmUtils?.getTableSearchFormLayout()}
|
|
511
749
|
scroll={cfmmUtils?.TABLE_SCROLL ?? TABLE_SCROLL}
|
|
512
750
|
toolBarRender={useMemoizedFn(() => {
|
|
513
|
-
if(!getBarButtons?.length) return [];
|
|
751
|
+
if (!getBarButtons?.length) return [];
|
|
514
752
|
return [
|
|
515
|
-
<Dropdown.Button type="primary" loading={actionLoading} menu={{ items: getBarButtons.slice(1) }}>
|
|
753
|
+
<Dropdown.Button type="primary" loading={actionLoading || downloadButtonLoading} menu={{ items: getBarButtons.slice(1) }}>
|
|
516
754
|
{getBarButtons[0].icon}
|
|
517
755
|
{getBarButtons[0].label}
|
|
518
756
|
</Dropdown.Button>
|
|
@@ -520,10 +758,17 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
520
758
|
})}
|
|
521
759
|
request={useMemoizedFn(async (params, sorter) => {
|
|
522
760
|
const { current, pageIndex = params.current, pageSize, ...otherParams } = params;
|
|
761
|
+
|
|
762
|
+
setTableSearchParams({ ...otherParams, orderBy: { ...sorter } });
|
|
763
|
+
|
|
523
764
|
const result = await handleSearch({ pageIndex, pageSize, orderBy: { ...sorter }, ...otherParams });
|
|
524
765
|
return result;
|
|
525
766
|
})}
|
|
526
767
|
columns={enhancedColumns}
|
|
768
|
+
columnsState={{
|
|
769
|
+
value: columnsStateMap,
|
|
770
|
+
onChange: setColumnsStateMap,
|
|
771
|
+
}}
|
|
527
772
|
rowSelection={useMemo(
|
|
528
773
|
() => ({
|
|
529
774
|
onChange: (selectedRowKeys, selectedRows) => {
|
|
@@ -111,6 +111,9 @@ declare const _default: {
|
|
|
111
111
|
'cfmmUI.common.button.back': string;
|
|
112
112
|
'cfmmUI.common.button.exportMultiLang': string;
|
|
113
113
|
'cfmmUI.common.button.importMultiLang': string;
|
|
114
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
115
|
+
"cfmmUI.common.button.importData": string;
|
|
116
|
+
"cfmmUI.common.button.exportData": string;
|
|
114
117
|
'cfmmUI.common.button.exportMultiLang.notice': string;
|
|
115
118
|
'cfmmUI.action.create.waitingMessage': string;
|
|
116
119
|
'cfmmUI.action.update.waitingMessage': string;
|
|
@@ -22,6 +22,9 @@ declare const _default: {
|
|
|
22
22
|
'cfmmUI.common.button.back': string;
|
|
23
23
|
'cfmmUI.common.button.exportMultiLang': string;
|
|
24
24
|
'cfmmUI.common.button.importMultiLang': string;
|
|
25
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
26
|
+
"cfmmUI.common.button.importData": string;
|
|
27
|
+
"cfmmUI.common.button.exportData": string;
|
|
25
28
|
'cfmmUI.common.button.exportMultiLang.notice': string;
|
|
26
29
|
'cfmmUI.action.create.waitingMessage': string;
|
|
27
30
|
'cfmmUI.action.update.waitingMessage': string;
|
|
@@ -30,6 +30,9 @@ var _default = exports.default = {
|
|
|
30
30
|
'cfmmUI.common.button.back': 'Back',
|
|
31
31
|
'cfmmUI.common.button.exportMultiLang': 'Export Multi Language',
|
|
32
32
|
'cfmmUI.common.button.importMultiLang': 'Import Multi Language',
|
|
33
|
+
"cfmmUI.common.button.templateDownload": "Template Download",
|
|
34
|
+
"cfmmUI.common.button.importData": "Import Data",
|
|
35
|
+
"cfmmUI.common.button.exportData": "Export Data",
|
|
33
36
|
'cfmmUI.common.button.exportMultiLang.notice': 'Please do not modify the table structure',
|
|
34
37
|
//操作提示
|
|
35
38
|
'cfmmUI.action.create.waitingMessage': 'Being Added',
|
|
@@ -111,6 +111,9 @@ declare const _default: {
|
|
|
111
111
|
'cfmmUI.common.button.back': string;
|
|
112
112
|
'cfmmUI.common.button.exportMultiLang': string;
|
|
113
113
|
'cfmmUI.common.button.importMultiLang': string;
|
|
114
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
115
|
+
"cfmmUI.common.button.importData": string;
|
|
116
|
+
"cfmmUI.common.button.exportData": string;
|
|
114
117
|
'cfmmUI.common.button.exportMultiLang.notice': string;
|
|
115
118
|
'cfmmUI.action.create.waitingMessage': string;
|
|
116
119
|
'cfmmUI.action.update.waitingMessage': string;
|
|
@@ -111,6 +111,9 @@ declare const _default: {
|
|
|
111
111
|
'cfmmUI.common.button.back': string;
|
|
112
112
|
'cfmmUI.common.button.exportMultiLang': string;
|
|
113
113
|
'cfmmUI.common.button.importMultiLang': string;
|
|
114
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
115
|
+
"cfmmUI.common.button.importData": string;
|
|
116
|
+
"cfmmUI.common.button.exportData": string;
|
|
114
117
|
'cfmmUI.common.button.exportMultiLang.notice': string;
|
|
115
118
|
'cfmmUI.action.create.waitingMessage': string;
|
|
116
119
|
'cfmmUI.action.update.waitingMessage': string;
|
|
@@ -111,6 +111,9 @@ declare const _default: {
|
|
|
111
111
|
"cfmmUI.common.button.back": string;
|
|
112
112
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
113
113
|
"cfmmUI.common.button.importMultiLang": string;
|
|
114
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
115
|
+
"cfmmUI.common.button.importData": string;
|
|
116
|
+
"cfmmUI.common.button.exportData": string;
|
|
114
117
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
115
118
|
"cfmmUI.action.create.waitingMessage": string;
|
|
116
119
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -110,6 +110,9 @@ declare const _default: {
|
|
|
110
110
|
"cfmmUI.common.button.back": string;
|
|
111
111
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
112
112
|
"cfmmUI.common.button.importMultiLang": string;
|
|
113
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
114
|
+
"cfmmUI.common.button.importData": string;
|
|
115
|
+
"cfmmUI.common.button.exportData": string;
|
|
113
116
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
114
117
|
"cfmmUI.action.create.waitingMessage": string;
|
|
115
118
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -22,6 +22,9 @@ declare const _default: {
|
|
|
22
22
|
"cfmmUI.common.button.back": string;
|
|
23
23
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
24
24
|
"cfmmUI.common.button.importMultiLang": string;
|
|
25
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
26
|
+
"cfmmUI.common.button.importData": string;
|
|
27
|
+
"cfmmUI.common.button.exportData": string;
|
|
25
28
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
26
29
|
"cfmmUI.action.create.waitingMessage": string;
|
|
27
30
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -30,6 +30,9 @@ var _default = exports.default = {
|
|
|
30
30
|
"cfmmUI.common.button.back": "返回",
|
|
31
31
|
"cfmmUI.common.button.exportMultiLang": "导出多语言",
|
|
32
32
|
"cfmmUI.common.button.importMultiLang": "导入多语言",
|
|
33
|
+
"cfmmUI.common.button.templateDownload": "模板下载",
|
|
34
|
+
"cfmmUI.common.button.importData": "导入数据",
|
|
35
|
+
"cfmmUI.common.button.exportData": "导出数据",
|
|
33
36
|
"cfmmUI.common.button.exportMultiLang.notice": "请勿修改表格结构",
|
|
34
37
|
//操作提示
|
|
35
38
|
"cfmmUI.action.create.waitingMessage": "正在新增",
|
|
@@ -111,6 +111,9 @@ declare const _default: {
|
|
|
111
111
|
"cfmmUI.common.button.back": string;
|
|
112
112
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
113
113
|
"cfmmUI.common.button.importMultiLang": string;
|
|
114
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
115
|
+
"cfmmUI.common.button.importData": string;
|
|
116
|
+
"cfmmUI.common.button.exportData": string;
|
|
114
117
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
115
118
|
"cfmmUI.action.create.waitingMessage": string;
|
|
116
119
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -22,6 +22,9 @@ declare const _default: {
|
|
|
22
22
|
"cfmmUI.common.button.back": string;
|
|
23
23
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
24
24
|
"cfmmUI.common.button.importMultiLang": string;
|
|
25
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
26
|
+
"cfmmUI.common.button.importData": string;
|
|
27
|
+
"cfmmUI.common.button.exportData": string;
|
|
25
28
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
26
29
|
"cfmmUI.action.create.waitingMessage": string;
|
|
27
30
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -30,6 +30,9 @@ var _default = exports.default = {
|
|
|
30
30
|
"cfmmUI.common.button.back": "返回",
|
|
31
31
|
"cfmmUI.common.button.exportMultiLang": "導出多語言",
|
|
32
32
|
"cfmmUI.common.button.importMultiLang": "導入多語言",
|
|
33
|
+
"cfmmUI.common.button.templateDownload": "模板下載",
|
|
34
|
+
"cfmmUI.common.button.importData": "導入數據",
|
|
35
|
+
"cfmmUI.common.button.exportData": "導出數據",
|
|
33
36
|
"cfmmUI.common.button.exportMultiLang.notice": "請勿修改表格結構",
|
|
34
37
|
//操作提示
|
|
35
38
|
"cfmmUI.action.create.waitingMessage": "正在新增",
|
|
@@ -110,6 +110,9 @@ declare const _default: {
|
|
|
110
110
|
"cfmmUI.common.button.back": string;
|
|
111
111
|
"cfmmUI.common.button.exportMultiLang": string;
|
|
112
112
|
"cfmmUI.common.button.importMultiLang": string;
|
|
113
|
+
"cfmmUI.common.button.templateDownload": string;
|
|
114
|
+
"cfmmUI.common.button.importData": string;
|
|
115
|
+
"cfmmUI.common.button.exportData": string;
|
|
113
116
|
"cfmmUI.common.button.exportMultiLang.notice": string;
|
|
114
117
|
"cfmmUI.action.create.waitingMessage": string;
|
|
115
118
|
"cfmmUI.action.update.waitingMessage": string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { request } from '@umijs/max';
|
|
2
2
|
import { BASE_API } from '../constants';
|
|
3
|
-
import { API, DicDataItem,
|
|
3
|
+
import { API, DicDataItem, ExportMultiLangListItem, EditMultiLangDataType, LangInfoItem, EditMultiLangSubmitData } from '../types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 删除minio文件
|
|
@@ -48,8 +48,8 @@ export async function queryDictionary(params: ParamsType) {
|
|
|
48
48
|
* @param params.recordId - 记录ID
|
|
49
49
|
* @returns 多语言信息列表
|
|
50
50
|
*/
|
|
51
|
-
export async function
|
|
52
|
-
return request<API.Result_Base<
|
|
51
|
+
export async function queryLangInfoExportList(params: {tableName: string, columnName: string}) {
|
|
52
|
+
return request<API.Result_Base<ExportMultiLangListItem[]>>(`${BASE_API}/i18n/export`, {
|
|
53
53
|
method: 'GET',
|
|
54
54
|
params,
|
|
55
55
|
});
|
|
@@ -63,7 +63,7 @@ export async function queryLangInfoExprotList(params: {tableName: string, column
|
|
|
63
63
|
* @param.langInfos 数据
|
|
64
64
|
* @returns 多语言信息列表
|
|
65
65
|
*/
|
|
66
|
-
export async function importMultiLangList(params: {tableName: string, columnName: string, i18nDataList:
|
|
66
|
+
export async function importMultiLangList(params: {tableName: string, columnName: string, i18nDataList: ExportMultiLangListItem[]}) {
|
|
67
67
|
return request<API.Result_Base<number>>(`${BASE_API}/i18n/importData`, {
|
|
68
68
|
method: 'POST',
|
|
69
69
|
data: params,
|