@ibiz-template/runtime 0.7.41-alpha.112 → 0.7.41-alpha.113
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/index.esm.js +84 -25
- package/dist/index.system.min.js +1 -1
- package/out/constant/predefined-attributes.d.ts +5 -1
- package/out/constant/predefined-attributes.d.ts.map +1 -1
- package/out/constant/predefined-attributes.js +4 -0
- package/out/controller/control/grid/grid/grid.controller.d.ts +4 -0
- package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid/grid.controller.js +35 -6
- package/out/controller/control/md-ctrl/md-ctrl.controller.d.ts +2 -1
- package/out/controller/control/md-ctrl/md-ctrl.controller.d.ts.map +1 -1
- package/out/controller/control/md-ctrl/md-ctrl.controller.js +27 -4
- package/out/controller/utils/data-file-util/data-file-util.d.ts +2 -1
- package/out/controller/utils/data-file-util/data-file-util.d.ts.map +1 -1
- package/out/controller/utils/data-file-util/data-file-util.js +11 -6
- package/out/interface/api/util/i-api-excel-util.d.ts +53 -1
- package/out/interface/api/util/i-api-excel-util.d.ts.map +1 -1
- package/out/interface/provider/i-platform-provider.d.ts +54 -2
- package/out/interface/provider/i-platform-provider.d.ts.map +1 -1
- package/out/platform/provider/platform-provider-base.d.ts.map +1 -1
- package/out/platform/provider/platform-provider-base.js +1 -2
- package/package.json +3 -3
- package/src/constant/predefined-attributes.ts +5 -0
- package/src/controller/control/grid/grid/grid.controller.ts +51 -9
- package/src/controller/control/md-ctrl/md-ctrl.controller.ts +40 -5
- package/src/controller/utils/data-file-util/data-file-util.ts +21 -9
- package/src/interface/api/util/i-api-excel-util.ts +38 -1
- package/src/interface/provider/i-platform-provider.ts +43 -2
- package/src/platform/provider/platform-provider-base.ts +1 -2
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
IStorageColumnStates,
|
|
50
50
|
IApiGridColumnMapping,
|
|
51
51
|
IApiExportParams,
|
|
52
|
+
IFrontExportParams,
|
|
52
53
|
} from '../../../../interface';
|
|
53
54
|
import { calcDeCodeNameById, calcUIActionGroup } from '../../../../model';
|
|
54
55
|
import {
|
|
@@ -76,6 +77,7 @@ import {
|
|
|
76
77
|
switchRowEditDynamic,
|
|
77
78
|
initModelByEntitySchema,
|
|
78
79
|
} from './auto-grid.util';
|
|
80
|
+
import { PredefinedAttributes } from '../../../../constant';
|
|
79
81
|
|
|
80
82
|
/**
|
|
81
83
|
* 表格控制器
|
|
@@ -1649,16 +1651,29 @@ export class GridController<
|
|
|
1649
1651
|
* 获取数据导出模型
|
|
1650
1652
|
* @returns
|
|
1651
1653
|
*/
|
|
1652
|
-
getDataExcelModel(): {
|
|
1654
|
+
getDataExcelModel(): {
|
|
1655
|
+
header: string[];
|
|
1656
|
+
fields: string[];
|
|
1657
|
+
exportColumns: IData[];
|
|
1658
|
+
colWidths: { wpx: number }[];
|
|
1659
|
+
} {
|
|
1653
1660
|
const { dedataExportId, degridColumns = [] } = this.model;
|
|
1654
|
-
const excelModel: {
|
|
1661
|
+
const excelModel: {
|
|
1662
|
+
header: string[];
|
|
1663
|
+
fields: string[];
|
|
1664
|
+
exportColumns: IData[];
|
|
1665
|
+
colWidths: { wpx: number }[];
|
|
1666
|
+
} = {
|
|
1655
1667
|
header: [],
|
|
1656
1668
|
fields: [],
|
|
1669
|
+
exportColumns: [],
|
|
1670
|
+
colWidths: [],
|
|
1657
1671
|
};
|
|
1658
1672
|
if (dedataExportId) {
|
|
1659
1673
|
if (this.allExportColumns.length) {
|
|
1660
1674
|
excelModel.fields = this.allExportColumns.map(x => x.appDEFieldId!);
|
|
1661
1675
|
excelModel.header = this.allExportColumns.map(x => x.caption!);
|
|
1676
|
+
excelModel.exportColumns = this.allExportColumns;
|
|
1662
1677
|
}
|
|
1663
1678
|
} else {
|
|
1664
1679
|
const exportColumns = this.state.columnStates
|
|
@@ -1676,6 +1691,12 @@ export class GridController<
|
|
|
1676
1691
|
});
|
|
1677
1692
|
excelModel.fields = exportColumns.map(item => item.id!);
|
|
1678
1693
|
excelModel.header = exportColumns.map(item => item.caption!);
|
|
1694
|
+
excelModel.colWidths = exportColumns.map(item => {
|
|
1695
|
+
return {
|
|
1696
|
+
wpx: item.width || 150,
|
|
1697
|
+
};
|
|
1698
|
+
});
|
|
1699
|
+
excelModel.exportColumns = exportColumns;
|
|
1679
1700
|
}
|
|
1680
1701
|
return excelModel;
|
|
1681
1702
|
}
|
|
@@ -1829,18 +1850,18 @@ export class GridController<
|
|
|
1829
1850
|
await this.excuteBackendExport(args.params);
|
|
1830
1851
|
return;
|
|
1831
1852
|
}
|
|
1832
|
-
|
|
1853
|
+
// 导出前先填充导出代码表数据
|
|
1854
|
+
await this.fillExportCodelistMap();
|
|
1855
|
+
const data = await this.getExportData(args.params);
|
|
1856
|
+
const { header, fields, exportColumns, colWidths } =
|
|
1857
|
+
this.getDataExcelModel();
|
|
1833
1858
|
if (!header) {
|
|
1834
1859
|
throw new RuntimeError(
|
|
1835
1860
|
ibiz.i18n.t('runtime.controller.control.grid.tabularColumns'),
|
|
1836
1861
|
);
|
|
1837
1862
|
}
|
|
1838
|
-
// 导出前先填充导出代码表数据
|
|
1839
|
-
await this.fillExportCodelistMap();
|
|
1840
|
-
const data = await this.getExportData(args.params);
|
|
1841
1863
|
const formatData = this.formatExcelData(data, fields);
|
|
1842
1864
|
const table = formatData.map(v => Object.values(v));
|
|
1843
|
-
|
|
1844
1865
|
// 获取导出文件名,如果有自定义文件名格式则使用自定义文件名格式
|
|
1845
1866
|
let fileName = this.model.logicName!;
|
|
1846
1867
|
if (this.dataExport?.fileNameFormat) {
|
|
@@ -1851,12 +1872,33 @@ export class GridController<
|
|
|
1851
1872
|
now: new Date(),
|
|
1852
1873
|
});
|
|
1853
1874
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1875
|
+
// 准备前台导出参数
|
|
1876
|
+
const frontExportParams: IFrontExportParams = {
|
|
1856
1877
|
header,
|
|
1857
1878
|
data: table,
|
|
1858
1879
|
fileName,
|
|
1880
|
+
colWidths: () => {
|
|
1881
|
+
return colWidths;
|
|
1882
|
+
},
|
|
1883
|
+
};
|
|
1884
|
+
// 前台导出注入属性识别
|
|
1885
|
+
const frontExportAttri = this.model.controlAttributes?.find(item => {
|
|
1886
|
+
return item.attrName === PredefinedAttributes.BEFORE_FRONT_EXPORT;
|
|
1859
1887
|
});
|
|
1888
|
+
if (frontExportAttri) {
|
|
1889
|
+
const { attrValue } = frontExportAttri;
|
|
1890
|
+
if (attrValue) {
|
|
1891
|
+
const frontExportResult = await ScriptFactory.asyncExecScriptFn(
|
|
1892
|
+
{ exportColumns, data },
|
|
1893
|
+
attrValue,
|
|
1894
|
+
);
|
|
1895
|
+
if (frontExportResult) {
|
|
1896
|
+
Object.assign(frontExportParams, frontExportResult);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
// 导出数据
|
|
1901
|
+
await ibiz.platform.frontExport(frontExportParams);
|
|
1860
1902
|
}
|
|
1861
1903
|
|
|
1862
1904
|
/**
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ISearchGroupData,
|
|
21
21
|
IExportColumn,
|
|
22
22
|
IApiExportParams,
|
|
23
|
+
IFrontExportParams,
|
|
23
24
|
} from '../../../interface';
|
|
24
25
|
import { MDCtrlService } from './md-ctrl.service';
|
|
25
26
|
import { MobMDCtrlRowState } from './md-ctrl-row.state';
|
|
@@ -28,6 +29,8 @@ import { ControlVO } from '../../../service';
|
|
|
28
29
|
import { UIActionUtil } from '../../../ui-action';
|
|
29
30
|
import { ButtonContainerState, UIActionButtonState } from '../../utils';
|
|
30
31
|
import { calcUIActionGroup, getAllUIActionItems } from '../../../model';
|
|
32
|
+
import { ScriptFactory } from '../../../utils';
|
|
33
|
+
import { PredefinedAttributes } from '../../../constant';
|
|
31
34
|
|
|
32
35
|
export class MDCtrlController
|
|
33
36
|
extends MDControlController<IDEMobMDCtrl, IMobMdCtrlState, IMobMDCtrlEvent>
|
|
@@ -611,19 +614,29 @@ export class MDCtrlController
|
|
|
611
614
|
|
|
612
615
|
/**
|
|
613
616
|
* @description 获取数据导出模型
|
|
614
|
-
* @returns {*} {{ header: string[]
|
|
617
|
+
* @returns {*} {{ header: string[], fields: string[], exportColumns: IData[] }}
|
|
615
618
|
* @memberof MDCtrlController
|
|
616
619
|
*/
|
|
617
|
-
getDataExcelModel(): {
|
|
620
|
+
getDataExcelModel(): {
|
|
621
|
+
header: string[];
|
|
622
|
+
fields: string[];
|
|
623
|
+
exportColumns: IData[];
|
|
624
|
+
} {
|
|
618
625
|
const { dedataExportId } = this.model;
|
|
619
|
-
const excelModel: {
|
|
626
|
+
const excelModel: {
|
|
627
|
+
header: string[];
|
|
628
|
+
fields: string[];
|
|
629
|
+
exportColumns: IData[];
|
|
630
|
+
} = {
|
|
620
631
|
header: [],
|
|
621
632
|
fields: [],
|
|
633
|
+
exportColumns: [],
|
|
622
634
|
};
|
|
623
635
|
if (dedataExportId) {
|
|
624
636
|
if (this.allExportColumns.length) {
|
|
625
637
|
excelModel.fields = this.allExportColumns.map(x => x.appDEFieldId!);
|
|
626
638
|
excelModel.header = this.allExportColumns.map(x => x.caption!);
|
|
639
|
+
excelModel.exportColumns = this.allExportColumns;
|
|
627
640
|
}
|
|
628
641
|
}
|
|
629
642
|
return excelModel;
|
|
@@ -799,7 +812,7 @@ export class MDCtrlController
|
|
|
799
812
|
await this.excuteBackendExport(args.params || {});
|
|
800
813
|
return;
|
|
801
814
|
}
|
|
802
|
-
const { header, fields } = this.getDataExcelModel();
|
|
815
|
+
const { header, fields, exportColumns } = this.getDataExcelModel();
|
|
803
816
|
if (!header) {
|
|
804
817
|
throw new RuntimeError(
|
|
805
818
|
ibiz.i18n.t('runtime.controller.common.md.tabularColumns'),
|
|
@@ -808,10 +821,32 @@ export class MDCtrlController
|
|
|
808
821
|
const data = await this.getExportData(args.params || {});
|
|
809
822
|
const formatData = this.formatExcelData(data, fields);
|
|
810
823
|
const table = formatData.map(v => Object.values(v));
|
|
811
|
-
|
|
824
|
+
// 准备前台导出参数
|
|
825
|
+
const frontExportParams: IFrontExportParams = {
|
|
812
826
|
header,
|
|
813
827
|
data: table,
|
|
814
828
|
fileName: this.model.logicName!,
|
|
829
|
+
colWidths: () => {
|
|
830
|
+
return [];
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
// 前台导出注入属性识别
|
|
834
|
+
const frontExportAttri = this.model.controlAttributes?.find(item => {
|
|
835
|
+
return item.attrName === PredefinedAttributes.BEFORE_FRONT_EXPORT;
|
|
815
836
|
});
|
|
837
|
+
if (frontExportAttri) {
|
|
838
|
+
const { attrValue } = frontExportAttri;
|
|
839
|
+
if (attrValue) {
|
|
840
|
+
const frontExportResult = await ScriptFactory.asyncExecScriptFn(
|
|
841
|
+
{ exportColumns, data },
|
|
842
|
+
attrValue,
|
|
843
|
+
);
|
|
844
|
+
if (frontExportResult) {
|
|
845
|
+
Object.assign(frontExportParams, frontExportResult);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
// 导出数据
|
|
850
|
+
await ibiz.platform.frontExport(frontExportParams);
|
|
816
851
|
}
|
|
817
852
|
}
|
|
@@ -10,7 +10,7 @@ import { IAppDEDataImport, IAppDataEntity } from '@ibiz/model-core';
|
|
|
10
10
|
import { mergeRight } from 'ramda';
|
|
11
11
|
import { calcResPath } from '../../../service';
|
|
12
12
|
import { OpenAppViewCommand } from '../../../command';
|
|
13
|
-
import { IViewConfig } from '../../../interface';
|
|
13
|
+
import { IViewConfig, IFrontExportParams } from '../../../interface';
|
|
14
14
|
|
|
15
15
|
// 异步导入URL
|
|
16
16
|
const asyncImportUrl = 'asyncimportdata2';
|
|
@@ -250,9 +250,7 @@ export async function importData2(opts: {
|
|
|
250
250
|
* @return {*} {Promise<IExportDataResult>}
|
|
251
251
|
*/
|
|
252
252
|
export async function exportData(
|
|
253
|
-
|
|
254
|
-
data: IData[][],
|
|
255
|
-
fileName: string,
|
|
253
|
+
args: IFrontExportParams,
|
|
256
254
|
): Promise<IExportDataResult> {
|
|
257
255
|
if (!ibiz.util.getExcelUtil) {
|
|
258
256
|
throw new RuntimeError(
|
|
@@ -266,11 +264,25 @@ export async function exportData(
|
|
|
266
264
|
);
|
|
267
265
|
}
|
|
268
266
|
try {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
const {
|
|
268
|
+
fileName,
|
|
269
|
+
header,
|
|
270
|
+
data,
|
|
271
|
+
rowHeights,
|
|
272
|
+
colWidths,
|
|
273
|
+
multiHeader,
|
|
274
|
+
merges,
|
|
275
|
+
cellStyle,
|
|
276
|
+
} = args;
|
|
277
|
+
exportExcel.exportJsonToExcelWithStyle({
|
|
278
|
+
fileName,
|
|
279
|
+
header,
|
|
280
|
+
data,
|
|
281
|
+
rowHeights,
|
|
282
|
+
colWidths,
|
|
283
|
+
multiHeader,
|
|
284
|
+
merges,
|
|
285
|
+
cellStyle,
|
|
274
286
|
});
|
|
275
287
|
return { ok: true };
|
|
276
288
|
} catch (error) {
|
|
@@ -7,7 +7,7 @@ import { IApiData } from '@ibiz-template/core';
|
|
|
7
7
|
*/
|
|
8
8
|
export interface IApiExcelUtil {
|
|
9
9
|
/**
|
|
10
|
-
* @description
|
|
10
|
+
* @description 导出excel文件
|
|
11
11
|
* @param {{
|
|
12
12
|
* header: string[]; // 表头内容
|
|
13
13
|
* data: IApiData[]; // 数据内容
|
|
@@ -22,4 +22,41 @@ export interface IApiExcelUtil {
|
|
|
22
22
|
filename: string;
|
|
23
23
|
autoWidth: boolean;
|
|
24
24
|
}): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description 导出excel文件(附加样式处理)
|
|
28
|
+
* @param {({
|
|
29
|
+
* fileName: string; // 文件名
|
|
30
|
+
* header: string[]; // 表头内容
|
|
31
|
+
* data: string[][]; // 数据内容
|
|
32
|
+
* rowHeights?:(rows: string[][]) => { hpx: number }[] | { hpt: number }[]; // 行高,hpt(磅)/ hpx(像素)
|
|
33
|
+
* colWidths?:(rows: string[][]) => { wch: number }[] | { wpx: number }[]; // 列宽,wch(字符数)/ wpx(像素)
|
|
34
|
+
* multiHeader?: string[][]; // 多表头数据
|
|
35
|
+
* merges?: { s: { r: number; c: number }; e: { r: number; c: number } }[]; // 合并单元格,s: 起始坐标, e: 结束坐标
|
|
36
|
+
* cellStyle?: ( // 单元格样式
|
|
37
|
+
* rows:string[][],
|
|
38
|
+
* value: unknown,
|
|
39
|
+
* rowIndex: number,
|
|
40
|
+
* colIndex: number,
|
|
41
|
+
* isHeaderCell: boolean,
|
|
42
|
+
* ) => { fill?: IData; font?: IData; alignment?: IData; border?: IData };
|
|
43
|
+
* })} args
|
|
44
|
+
* @memberof IApiExcelUtil
|
|
45
|
+
*/
|
|
46
|
+
exportJsonToExcelWithStyle(args: {
|
|
47
|
+
fileName: string;
|
|
48
|
+
header: string[];
|
|
49
|
+
data: string[][];
|
|
50
|
+
rowHeights?: (rows: string[][]) => { hpx: number }[] | { hpt: number }[];
|
|
51
|
+
colWidths?: (rows: string[][]) => { wch: number }[] | { wpx: number }[];
|
|
52
|
+
multiHeader?: string[][];
|
|
53
|
+
merges?: { s: { r: number; c: number }; e: { r: number; c: number } }[];
|
|
54
|
+
cellStyle?: (
|
|
55
|
+
rows: string[][],
|
|
56
|
+
value: unknown,
|
|
57
|
+
rowIndex: number,
|
|
58
|
+
colIndex: number,
|
|
59
|
+
isHeaderCell: boolean,
|
|
60
|
+
) => { fill?: IData; font?: IData; alignment?: IData; border?: IData };
|
|
61
|
+
}): void;
|
|
25
62
|
}
|
|
@@ -62,10 +62,51 @@ export interface IFrontExportParams {
|
|
|
62
62
|
header: string[];
|
|
63
63
|
/**
|
|
64
64
|
* @description 表格数据
|
|
65
|
-
* @type {
|
|
65
|
+
* @type {string[][]}
|
|
66
66
|
* @memberof IFrontExportParams
|
|
67
67
|
*/
|
|
68
|
-
data:
|
|
68
|
+
data: string[][];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description 行高集合
|
|
72
|
+
* @type hpt(磅)/ hpx(像素)
|
|
73
|
+
* @memberof IFrontExportParams
|
|
74
|
+
*/
|
|
75
|
+
rowHeights?: (rows: string[][]) => { hpx: number }[] | { hpt: number }[];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @description 列宽集合
|
|
79
|
+
* @type wch(字符数)/ wpx(像素)
|
|
80
|
+
* @memberof IFrontExportParams
|
|
81
|
+
*/
|
|
82
|
+
colWidths?: (rows: string[][]) => { wch: number }[] | { wpx: number }[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @description 多表头数据
|
|
86
|
+
* @type {string[][]}
|
|
87
|
+
* @memberof IFrontExportParams
|
|
88
|
+
*/
|
|
89
|
+
multiHeader?: string[][];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @description 合并单元格
|
|
93
|
+
* @type {{ s: { r: number; c: number }; e: { r: number; c: number } }[]} s: 起始坐标, e: 结束坐标
|
|
94
|
+
* @memberof IFrontExportParams
|
|
95
|
+
*/
|
|
96
|
+
merges?: { s: { r: number; c: number }; e: { r: number; c: number } }[];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @description 单元格样式,详情参考:https://gitbrent.github.io/xlsx-js-style/
|
|
100
|
+
* @type {(rows: string[][], value: unknown, rowIndex: number, colIndex: number, isHeaderCell: boolean) => { fill?: IData; font?: IData; alignment?: IData; border?: IData }}
|
|
101
|
+
* @memberof IFrontExportParams
|
|
102
|
+
*/
|
|
103
|
+
cellStyle?: (
|
|
104
|
+
rows: string[][],
|
|
105
|
+
value: unknown,
|
|
106
|
+
rowIndex: number,
|
|
107
|
+
colIndex: number,
|
|
108
|
+
isHeaderCell: boolean,
|
|
109
|
+
) => { fill?: IData; font?: IData; alignment?: IData; border?: IData };
|
|
69
110
|
}
|
|
70
111
|
|
|
71
112
|
/**
|
|
@@ -107,8 +107,7 @@ export abstract class PlatformProviderBase implements IPlatformProvider {
|
|
|
107
107
|
* @memberof PlatformProviderBase
|
|
108
108
|
*/
|
|
109
109
|
async frontExport(args: IFrontExportParams): Promise<boolean> {
|
|
110
|
-
|
|
111
|
-
await exportData(header, data, fileName);
|
|
110
|
+
await exportData(args);
|
|
112
111
|
return true;
|
|
113
112
|
}
|
|
114
113
|
|