@lingxiteam/ebe-utils 0.3.6 → 0.3.10
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.
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export const CHECK_ALL_VALUE = 'LING_XI_CHECK_ALL';
|
|
4
2
|
|
|
5
|
-
|
|
6
3
|
const typeFn: any = {
|
|
7
4
|
string: String,
|
|
8
5
|
number: Number,
|
|
@@ -35,17 +32,13 @@ export const localFilterOption = (input: string = '', option: any) => {
|
|
|
35
32
|
// 判断data类型是不是是labelInValue格式
|
|
36
33
|
export const isLabelInValue = (data: any) => {
|
|
37
34
|
if (Object.prototype.toString.call(data) === '[object Object]') {
|
|
38
|
-
if (Object.keys(data).includes('label') &&
|
|
39
|
-
(Object.keys(data).includes('value') || Object.keys(data).includes('key'))) {
|
|
35
|
+
if (Object.keys(data).includes('label') && (Object.keys(data).includes('value') || Object.keys(data).includes('key'))) {
|
|
40
36
|
return true;
|
|
41
37
|
}
|
|
42
38
|
} else if (Object.prototype.toString.call(data) === '[object Array]' && data.length) {
|
|
43
39
|
let isLabelInValueCount = 0;
|
|
44
40
|
data.forEach((v: any) => {
|
|
45
|
-
if (
|
|
46
|
-
Object.keys(v).includes('label') &&
|
|
47
|
-
(Object.keys(v).includes('value') || Object.keys(v).includes('key'))
|
|
48
|
-
) {
|
|
41
|
+
if (Object.keys(v).includes('label') && (Object.keys(v).includes('value') || Object.keys(v).includes('key'))) {
|
|
49
42
|
isLabelInValueCount += 1;
|
|
50
43
|
}
|
|
51
44
|
});
|
|
@@ -90,7 +83,6 @@ export const transformValueType = (v: any, curVal: any) => {
|
|
|
90
83
|
return v;
|
|
91
84
|
};
|
|
92
85
|
|
|
93
|
-
|
|
94
86
|
export const getRules = (min?: number, max?: number, getLocale?: any) => {
|
|
95
87
|
if (!min && !max) {
|
|
96
88
|
return [];
|
|
@@ -120,7 +112,7 @@ export const getChangeSelectData = (dataSource: any[], val: string[] | Object, m
|
|
|
120
112
|
return undefined;
|
|
121
113
|
}
|
|
122
114
|
const sltData = dataSource.find((c: any) => c.value?.toString() === v?.toString());
|
|
123
|
-
return
|
|
115
|
+
return sltData ? [sltData] : undefined;
|
|
124
116
|
};
|
|
125
117
|
|
|
126
118
|
export const getSelectedAllData = (checked: boolean, dataSource: any[], value: any[], max?: number) => {
|
|
@@ -165,7 +157,7 @@ export const getSelectedAllData = (checked: boolean, dataSource: any[], value: a
|
|
|
165
157
|
|
|
166
158
|
// 获取当前列表数据下的全选状态
|
|
167
159
|
export const checkIfSelectedAll = (dataSource: any[], value: any[], filterValue: string = '') => {
|
|
168
|
-
const localFilterData = dataSource.filter(d => localFilterOption(filterValue, d));
|
|
160
|
+
const localFilterData = dataSource.filter((d) => localFilterOption(filterValue, d));
|
|
169
161
|
if (localFilterData?.length && Array.isArray(value)) {
|
|
170
162
|
// 如果是多选,value肯定是字符串类型的数组
|
|
171
163
|
const checkData = localFilterData.filter((f: any) => value.includes(f.value));
|
|
@@ -182,7 +174,7 @@ export const checkIfSelectedAll = (dataSource: any[], value: any[], filterValue:
|
|
|
182
174
|
* @param labelKey
|
|
183
175
|
* @returns
|
|
184
176
|
*/
|
|
185
|
-
export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Object, valueKey?: string, labelKey?: string
|
|
177
|
+
export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Object, valueKey?: string, labelKey?: string) => {
|
|
186
178
|
const valueKeys: any = [];
|
|
187
179
|
let newDataSoure: any[] = [];
|
|
188
180
|
if (Array.isArray(dataSource)) {
|
|
@@ -190,18 +182,19 @@ export const handleDataSource = (dataSource: any[], appendDataSoure?: any[] | Ob
|
|
|
190
182
|
const label = v?.[labelKey || 'label'];
|
|
191
183
|
const value = v?.[valueKey || 'value'] || v?.key;
|
|
192
184
|
if (value) {
|
|
193
|
-
|
|
185
|
+
// TODO: 为什么 id 是数字就不行??
|
|
186
|
+
valueKeys.push(value + '');
|
|
194
187
|
newDataSoure.push({
|
|
195
188
|
...v,
|
|
196
189
|
label,
|
|
197
|
-
value,
|
|
190
|
+
value: value + '',
|
|
198
191
|
});
|
|
199
192
|
}
|
|
200
193
|
});
|
|
201
194
|
}
|
|
202
195
|
let newAppednDataSoure = [];
|
|
203
196
|
if (Array.isArray(appendDataSoure) && appendDataSoure.length > 0) {
|
|
204
|
-
newAppednDataSoure = appendDataSoure.filter(item => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
|
197
|
+
newAppednDataSoure = appendDataSoure.filter((item) => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
|
205
198
|
}
|
|
206
199
|
if (Object.prototype.toString.call(appendDataSoure) === '[object Object]') {
|
|
207
200
|
newAppednDataSoure = [appendDataSoure].filter((item: any) => !valueKeys?.includes(item?.[valueKey || 'value'] || item?.key));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import engineServices from '@/services/api/engine';
|
|
2
2
|
import { messageApi } from '@/utils/messageApi';
|
|
3
3
|
import { exportFileShowProgress } from './tool';
|
|
4
|
+
import { APPID } from '@/constants';
|
|
4
5
|
|
|
5
6
|
const SERVICE_SOURCE = {
|
|
6
7
|
// 服务来源
|
|
@@ -567,101 +568,106 @@ const exportPathMap: ExportPathMapType = {
|
|
|
567
568
|
multiExport: engineServices.exportMultiServiceResultPath(),
|
|
568
569
|
};
|
|
569
570
|
const exportCustomData = (exportSheet: any = [], custFileName: any, selectedKeyMap: { [x: string]: any }, async: string) => {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if (type === SERVICE_SOURCE.OBJECT) {
|
|
593
|
-
// 对象类型
|
|
594
|
-
req = engineServices
|
|
595
|
-
.queryBusiObjectRowColumnsList({
|
|
596
|
-
busiObjectIds: selectedKeyMap[type].join(','),
|
|
597
|
-
})
|
|
598
|
-
.then((res: any) => {
|
|
599
|
-
const m: any = {};
|
|
600
|
-
(res || []).forEach((c: any) => (m[c.busiObjectId] = c.rowColumns));
|
|
601
|
-
return m;
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
if (type === SERVICE_SOURCE.STD) {
|
|
605
|
-
// 编排类服务
|
|
606
|
-
// @ts-ignore
|
|
607
|
-
req = engineServices
|
|
608
|
-
.queryServiceResponseColumnsList({
|
|
609
|
-
serviceVersionIds: (selectedKeyMap[type] || []).join(','),
|
|
610
|
-
appId: APPID,
|
|
611
|
-
})
|
|
612
|
-
.then((res: any) => {
|
|
613
|
-
const m: any = {};
|
|
614
|
-
(res || []).forEach((c: any) => (m[c.serviceVersionId] = getResponseAttr(c.response)));
|
|
615
|
-
return m;
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
if (req) {
|
|
619
|
-
req?.then((r: any) => {
|
|
620
|
-
selectedRowMap[type] = r;
|
|
571
|
+
return new Promise((resolve,reject)=>{
|
|
572
|
+
// 获取到的服务出参列表
|
|
573
|
+
const selectedRowMap: any = {};
|
|
574
|
+
messageApi.loading('正在导出中,请稍候...', 0);
|
|
575
|
+
try {
|
|
576
|
+
const columnsReq = Object.keys(selectedKeyMap).map(type => {
|
|
577
|
+
if (!selectedKeyMap[type] || !selectedKeyMap[type]?.length) {
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
// 获取不同类型服务的出参列表
|
|
581
|
+
let req;
|
|
582
|
+
if (type === SERVICE_SOURCE.QUERY) {
|
|
583
|
+
// SQL类型
|
|
584
|
+
req = engineServices
|
|
585
|
+
.getSqlQueryColumnsList({
|
|
586
|
+
serviceCodes: selectedKeyMap[type].join(','),
|
|
587
|
+
appId: APPID,
|
|
588
|
+
})
|
|
589
|
+
.then((res: any) => {
|
|
590
|
+
const m: any = {};
|
|
591
|
+
(res || []).forEach((c: any) => (m[c.serviceCode] = c.rowColumns));
|
|
592
|
+
return m;
|
|
621
593
|
});
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
594
|
+
}
|
|
595
|
+
if (type === SERVICE_SOURCE.OBJECT) {
|
|
596
|
+
// 对象类型
|
|
597
|
+
req = engineServices
|
|
598
|
+
.queryBusiObjectRowColumnsList({
|
|
599
|
+
busiObjectIds: selectedKeyMap[type].join(','),
|
|
600
|
+
})
|
|
601
|
+
.then((res: any) => {
|
|
602
|
+
const m: any = {};
|
|
603
|
+
(res || []).forEach((c: any) => (m[c.busiObjectId] = c.rowColumns));
|
|
604
|
+
return m;
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
if (type === SERVICE_SOURCE.STD) {
|
|
608
|
+
// 编排类服务
|
|
609
|
+
// @ts-ignore
|
|
610
|
+
req = engineServices
|
|
611
|
+
.queryServiceResponseColumnsList({
|
|
612
|
+
serviceVersionIds: (selectedKeyMap[type] || []).join(','),
|
|
613
|
+
})
|
|
614
|
+
.then((res: any) => {
|
|
615
|
+
const m: any = {};
|
|
616
|
+
(res || []).forEach((c: any) => (m[c.serviceVersionId] = getResponseAttr(c.response)));
|
|
617
|
+
return m;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
if (req) {
|
|
621
|
+
req?.then((r: any) => {
|
|
622
|
+
selectedRowMap[type] = r;
|
|
638
623
|
});
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
624
|
+
}
|
|
625
|
+
return req;
|
|
626
|
+
});
|
|
627
|
+
Promise.all(columnsReq).then(async () => {
|
|
628
|
+
const sheetItemList = exportSheet;
|
|
629
|
+
const serviceExecuteParams = sheetItemList.map((sheet: ExportItem) => {
|
|
630
|
+
const { parameters, objValue, objType, custSheetName, source } = sheet;
|
|
631
|
+
const resultList = (selectedRowMap[source] || {})[objValue] || [];
|
|
632
|
+
const columns = getExportColumns(sheet, resultList);
|
|
633
|
+
return {
|
|
634
|
+
objValue,
|
|
635
|
+
objType,
|
|
636
|
+
parameters,
|
|
637
|
+
sheetName: custSheetName,
|
|
638
|
+
...columns,
|
|
639
|
+
};
|
|
640
|
+
});
|
|
641
|
+
const exportFileName = custFileName;
|
|
642
|
+
const fileName = `${exportFileName}.xlsx`;
|
|
643
|
+
const downloadIndex = `${fileName}_${Math.random()}`;
|
|
644
|
+
await exportFileShowProgress?.({
|
|
645
|
+
downloadIndex,
|
|
646
|
+
fileName,
|
|
647
|
+
methodType: 'POST',
|
|
648
|
+
fileOrigin: 'multiExport',
|
|
649
|
+
async,
|
|
650
|
+
params: {
|
|
651
|
+
serviceExecuteParams,
|
|
644
652
|
fileName,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
messageApi.destroy();
|
|
654
|
-
},
|
|
655
|
-
onFail: () => {
|
|
656
|
-
messageApi.destroy();
|
|
657
|
-
messageApi.error('导出失败');
|
|
658
|
-
},
|
|
659
|
-
});
|
|
653
|
+
},
|
|
654
|
+
onSuccess: () => {
|
|
655
|
+
messageApi.destroy();
|
|
656
|
+
},
|
|
657
|
+
onFail: () => {
|
|
658
|
+
messageApi.destroy();
|
|
659
|
+
messageApi.error('导出失败');
|
|
660
|
+
},
|
|
660
661
|
});
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
662
|
+
});
|
|
663
|
+
resolve(true);
|
|
664
|
+
} catch {
|
|
665
|
+
messageApi.destroy();
|
|
666
|
+
messageApi.error('导出失败');
|
|
667
|
+
reject()
|
|
668
|
+
}
|
|
669
|
+
})
|
|
670
|
+
|
|
665
671
|
};
|
|
666
672
|
|
|
667
673
|
export default exportCustomData;
|
|
@@ -921,14 +921,9 @@ const ImportBusiObjModal = forwardRef<ImportBusiObjModalHooks, ImportBusiObjModa
|
|
|
921
921
|
<Button
|
|
922
922
|
onClick={() => {
|
|
923
923
|
const { fileCode } = params.custTpl || {};
|
|
924
|
-
// @ts-ignore
|
|
925
|
-
const downloadUrl = params.custTplUrl || (fileCode ? getAppFileUrlByFileCode(fileCode) : null);
|
|
926
|
-
if (!downloadUrl) {
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
// 下载导入模板自定义名称无效处理
|
|
930
924
|
const xhr = new XMLHttpRequest();
|
|
931
|
-
|
|
925
|
+
// 文件放到本地
|
|
926
|
+
xhr.open('GET', `${process.env.PUBLIC_PATH}appFile/${fileCode}.xlsx`, true);
|
|
932
927
|
xhr.responseType = 'blob'; // 通过文件下载url拿到对应的blob对象
|
|
933
928
|
xhr.onload = () => {
|
|
934
929
|
if (xhr.status === 200) {
|
|
@@ -943,6 +938,8 @@ const ImportBusiObjModal = forwardRef<ImportBusiObjModalHooks, ImportBusiObjModa
|
|
|
943
938
|
link.click();
|
|
944
939
|
link.remove();
|
|
945
940
|
window.URL?.revokeObjectURL(link.href);
|
|
941
|
+
}else{
|
|
942
|
+
console.log('文件不存在',fileCode)
|
|
946
943
|
}
|
|
947
944
|
};
|
|
948
945
|
xhr.send();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.3.
|
|
22
|
+
"@lingxiteam/ebe": "0.3.10"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|