@gct-paas/render-web 0.1.6-dev.19 → 0.1.6-dev.20
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.min.css +1 -1
- package/dist/loader.esm.min.js +3 -2
- package/es/components/collapse-detail/components/collapse-list.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/es/components/collapse-detail/index.vue.d.ts +9 -1
- package/es/components/collapse-detail/index.vue.mjs +2 -2
- package/es/components/collapse-detail/index.vue_vue_type_script_setup_true_name_collapse-detail_lang.mjs +4 -3
- package/es/components/collapse-detail/{index.vue_vue_type_style_index_0_scoped_53e7e2bf_lang.css → index.vue_vue_type_style_index_0_scoped_b4b9903c_lang.css} +19 -19
- package/es/components/field-search-cascader/field-cascader.vue.d.ts +17 -0
- package/es/components/field-search-cascader/field-cascader.vue.mjs +8 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_script_setup_true_lang.mjs +297 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_style_index_0_scoped_cb5e4d67_lang.css +52 -0
- package/es/components/field-search-cascader/field-cascader.vue_vue_type_style_index_1_lang.css +3 -0
- package/es/components/field-search-cascader/index.d.ts +2 -0
- package/es/components/field-search-cascader/index.mjs +1 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.mjs +4 -0
- package/es/components/rich-editor/index.d.ts +2 -0
- package/es/components/rich-editor/index.mjs +1 -0
- package/es/components/rich-editor/rich-editor.vue.d.ts +22 -0
- package/es/components/rich-editor/rich-editor.vue.mjs +5 -0
- package/es/components/rich-editor/rich-editor.vue_vue_type_script_setup_true_lang.mjs +150 -0
- package/es/components/rich-editor/style.css +747 -0
- package/es/constants/xlsx-parser.d.ts +15 -0
- package/es/constants/xlsx-parser.mjs +58 -0
- package/es/enums/xlsx-parser.d.ts +293 -0
- package/es/enums/xlsx-parser.mjs +36 -0
- package/es/index.d.ts +1 -0
- package/es/index.mjs +5 -1
- package/es/interface/xlsx-parser/base.d.ts +151 -0
- package/es/interface/xlsx-parser/index.d.ts +246 -0
- package/es/types/shims-modules.d.ts +11 -0
- package/es/utils/cell-border.d.ts +73 -0
- package/es/utils/cell-border.mjs +203 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +1 -0
- package/es/utils/xlsx-parser.d.ts +141 -0
- package/es/utils/xlsx-parser.mjs +262 -0
- package/package.json +16 -11
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { CellType, Orientation, ParamModelTypeEnum, SubTableType } from '../../enums/xlsx-parser';
|
|
2
|
+
import { IBindField, ICellBorder, IFormTmplBom, IModelMetaMap, IToFieldItem } from './base';
|
|
3
|
+
import { CellWidget } from './cell-widget';
|
|
4
|
+
import { PaperWidget } from './paper-widget';
|
|
5
|
+
export type ICellStyle = Record<string, string | number | undefined>;
|
|
6
|
+
export interface IColRange {
|
|
7
|
+
l: number;
|
|
8
|
+
r: number;
|
|
9
|
+
}
|
|
10
|
+
export interface IRowRange {
|
|
11
|
+
t: number;
|
|
12
|
+
b: number;
|
|
13
|
+
}
|
|
14
|
+
export type IRange = IColRange & IRowRange;
|
|
15
|
+
export interface IMedia {
|
|
16
|
+
id: string;
|
|
17
|
+
src: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IImage {
|
|
20
|
+
id: string;
|
|
21
|
+
mediaId: string;
|
|
22
|
+
layout: {
|
|
23
|
+
top: number;
|
|
24
|
+
left: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface IParamToField {
|
|
30
|
+
id: string;
|
|
31
|
+
key: string;
|
|
32
|
+
toModel: string;
|
|
33
|
+
toField: string;
|
|
34
|
+
subModelField?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface IGlobalOption {
|
|
37
|
+
id: string;
|
|
38
|
+
title: string;
|
|
39
|
+
options: {
|
|
40
|
+
id: string;
|
|
41
|
+
text: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
export interface ICheckTableDataSource {
|
|
46
|
+
id: string;
|
|
47
|
+
data: any[];
|
|
48
|
+
modelKey: string;
|
|
49
|
+
subFieldKey: string;
|
|
50
|
+
}
|
|
51
|
+
export interface IJoinIpaasConfig {
|
|
52
|
+
/** 请求方式 */
|
|
53
|
+
reqMethod: string | undefined;
|
|
54
|
+
/** 请求url路径 */
|
|
55
|
+
reqPath: string | undefined;
|
|
56
|
+
/** body参数 */
|
|
57
|
+
metaHeader: string | undefined;
|
|
58
|
+
/** 头部参数 */
|
|
59
|
+
metaBody: string | undefined;
|
|
60
|
+
/** 查询参数 */
|
|
61
|
+
metaQuery: string | undefined;
|
|
62
|
+
/** 路径参数 */
|
|
63
|
+
metaUri: string | undefined;
|
|
64
|
+
/** 出参查看 */
|
|
65
|
+
outputBodyParameters: string | undefined;
|
|
66
|
+
}
|
|
67
|
+
export interface IParameterMapping {
|
|
68
|
+
/** 唯一标识 */
|
|
69
|
+
id: string;
|
|
70
|
+
/** 参数key */
|
|
71
|
+
formKey: string | undefined;
|
|
72
|
+
/** 参数映射类型 */
|
|
73
|
+
paramMapType: ParamModelTypeEnum | undefined;
|
|
74
|
+
/** 模型key */
|
|
75
|
+
modelKey: string | undefined;
|
|
76
|
+
/** 是否是子表 */
|
|
77
|
+
subModel: number | undefined;
|
|
78
|
+
/** 子表字段key */
|
|
79
|
+
subFieldKey: string | undefined;
|
|
80
|
+
/** 映射的字段信息 */
|
|
81
|
+
toFields: IToFieldItem[];
|
|
82
|
+
}
|
|
83
|
+
export interface IFieldMapItem {
|
|
84
|
+
/** 唯一标识 */
|
|
85
|
+
id: string;
|
|
86
|
+
/** 模型key */
|
|
87
|
+
modelKey: string | undefined;
|
|
88
|
+
/** 是否是子表 */
|
|
89
|
+
subModel: number | undefined;
|
|
90
|
+
/** 子表字段key */
|
|
91
|
+
subFieldKey: string | undefined;
|
|
92
|
+
/**是否检验表 */
|
|
93
|
+
isCheckTable: boolean | undefined;
|
|
94
|
+
fields: {
|
|
95
|
+
/** 当前表单模型字段key */
|
|
96
|
+
leftFieldKey: string;
|
|
97
|
+
/** 映射的字段key */
|
|
98
|
+
rightFieldKey: string | undefined;
|
|
99
|
+
/** 所属模型pos */
|
|
100
|
+
cascaderKey: string | undefined;
|
|
101
|
+
/** 是否是关联模型字段 */
|
|
102
|
+
isFieldModel?: boolean | undefined;
|
|
103
|
+
/** 字段链路 */
|
|
104
|
+
fieldLink?: string | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
}
|
|
107
|
+
export interface IExpressionItem {
|
|
108
|
+
/** 唯一标识 */
|
|
109
|
+
id: string;
|
|
110
|
+
/** 字段key */
|
|
111
|
+
fieldKey: string | undefined;
|
|
112
|
+
/** 字段类型 */
|
|
113
|
+
fieldType: string | undefined;
|
|
114
|
+
/** 条件 */
|
|
115
|
+
operator: string | undefined;
|
|
116
|
+
/** 参数key */
|
|
117
|
+
formKey: string | undefined;
|
|
118
|
+
/** 参数映射类型 */
|
|
119
|
+
paramMapType: ParamModelTypeEnum | undefined;
|
|
120
|
+
}
|
|
121
|
+
export interface ICustomDataSource {
|
|
122
|
+
/** 唯一标识 */
|
|
123
|
+
id: string;
|
|
124
|
+
/** 关联模型类型 */
|
|
125
|
+
joinModelType: string | undefined;
|
|
126
|
+
/** 关联表单id */
|
|
127
|
+
joinFormRefId: string | undefined;
|
|
128
|
+
/** 关联模型key */
|
|
129
|
+
joinModelKey: string | undefined;
|
|
130
|
+
/** 是否是子表 */
|
|
131
|
+
joinSubModel: boolean | undefined;
|
|
132
|
+
/** 关联SQL语句 */
|
|
133
|
+
joinSqlJson: string | undefined;
|
|
134
|
+
/** 关联IPAAS配置 */
|
|
135
|
+
joinIpaasConfig: IJoinIpaasConfig;
|
|
136
|
+
/** 关联内置业务配置 */
|
|
137
|
+
joinBuiltinConfig: string | undefined;
|
|
138
|
+
/** 模型关联条件 */
|
|
139
|
+
onExpressions: IExpressionItem[];
|
|
140
|
+
/** 字段映射 */
|
|
141
|
+
onFieldMap: IFieldMapItem[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 子表
|
|
145
|
+
*/
|
|
146
|
+
export interface ITable {
|
|
147
|
+
id: string;
|
|
148
|
+
name: string;
|
|
149
|
+
field: string;
|
|
150
|
+
model: string;
|
|
151
|
+
mainModel: string;
|
|
152
|
+
range: IRange;
|
|
153
|
+
thName?: string;
|
|
154
|
+
thRange?: IRange;
|
|
155
|
+
type?: SubTableType;
|
|
156
|
+
colField?: string;
|
|
157
|
+
colModel?: string;
|
|
158
|
+
dgRange?: IRange;
|
|
159
|
+
autoFill?: boolean;
|
|
160
|
+
quickFill?: boolean;
|
|
161
|
+
fillDirection?: 'x' | 'y';
|
|
162
|
+
indexedTd?: boolean;
|
|
163
|
+
refColField?: string;
|
|
164
|
+
refRowField?: string;
|
|
165
|
+
checkDsId?: string;
|
|
166
|
+
rowRange?: IRange;
|
|
167
|
+
/** 物料消耗表的业务配置 */
|
|
168
|
+
mcBomConfig?: IFormTmplBom;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 固定表
|
|
172
|
+
*/
|
|
173
|
+
export type IFixedTable = ITable;
|
|
174
|
+
export interface ICell {
|
|
175
|
+
type?: CellType;
|
|
176
|
+
value?: any;
|
|
177
|
+
style?: ICellStyle;
|
|
178
|
+
border?: ICellBorder;
|
|
179
|
+
/**
|
|
180
|
+
* 字段信息
|
|
181
|
+
*/
|
|
182
|
+
fieldMeta?: IBindField;
|
|
183
|
+
/**
|
|
184
|
+
* 字段渲染组件
|
|
185
|
+
*/
|
|
186
|
+
fieldWidget?: CellWidget.BasicSchema;
|
|
187
|
+
/**
|
|
188
|
+
* 组件
|
|
189
|
+
*/
|
|
190
|
+
paperWidget?: PaperWidget.BasicSchema;
|
|
191
|
+
/**
|
|
192
|
+
* 组合字段
|
|
193
|
+
*/
|
|
194
|
+
multiFields?: boolean;
|
|
195
|
+
multiFieldsContent?: {
|
|
196
|
+
id: string;
|
|
197
|
+
type?: CellType;
|
|
198
|
+
fieldMeta?: IBindField;
|
|
199
|
+
fieldWidget?: CellWidget.BasicSchema;
|
|
200
|
+
}[];
|
|
201
|
+
autoMerge?: boolean;
|
|
202
|
+
xAutoMerge?: boolean;
|
|
203
|
+
fillDirection?: 'x' | 'y';
|
|
204
|
+
}
|
|
205
|
+
export interface IPaper {
|
|
206
|
+
/** 当前sheet页的唯一标识 */
|
|
207
|
+
sheetId: string;
|
|
208
|
+
orientation: Orientation;
|
|
209
|
+
padding: IRange;
|
|
210
|
+
cols: {
|
|
211
|
+
width: number;
|
|
212
|
+
manual?: boolean;
|
|
213
|
+
}[];
|
|
214
|
+
rows: {
|
|
215
|
+
height: number;
|
|
216
|
+
manual?: boolean;
|
|
217
|
+
}[];
|
|
218
|
+
cells: ICell[][];
|
|
219
|
+
mergedCells: IRange[];
|
|
220
|
+
thead?: {
|
|
221
|
+
thName?: string;
|
|
222
|
+
thRange?: IRange;
|
|
223
|
+
};
|
|
224
|
+
dynamicTables?: ITable[];
|
|
225
|
+
fixedTables?: IFixedTable[];
|
|
226
|
+
medias?: IMedia[];
|
|
227
|
+
images?: IImage[];
|
|
228
|
+
paramToField?: IParamToField[];
|
|
229
|
+
paperHeader?: boolean;
|
|
230
|
+
paperHeaderWidgets?: PaperWidget.BasicSchema[];
|
|
231
|
+
paperFooter?: boolean;
|
|
232
|
+
paperFooterWidgets?: PaperWidget.BasicSchema[];
|
|
233
|
+
javascript?: string;
|
|
234
|
+
/** 全局配置-枚举分组 */
|
|
235
|
+
globalOptions?: IGlobalOption[];
|
|
236
|
+
/** 数据初始化-参数映射 */
|
|
237
|
+
parameterMapping?: IParameterMapping[];
|
|
238
|
+
/** 数据初始化-数据源 */
|
|
239
|
+
customDataSource?: ICustomDataSource[];
|
|
240
|
+
/** 检验表的数据源 */
|
|
241
|
+
checkTableDataSource?: ICheckTableDataSource[];
|
|
242
|
+
/** 主模型key */
|
|
243
|
+
mainModelKey?: string;
|
|
244
|
+
/** 缓存的临时数据模型结构 */
|
|
245
|
+
modelMetaMap?: IModelMetaMap;
|
|
246
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare module '@wangeditor/editor-for-vue' {
|
|
2
|
+
import type { DefineComponent } from 'vue';
|
|
3
|
+
|
|
4
|
+
export const Editor: DefineComponent;
|
|
5
|
+
export const Toolbar: DefineComponent;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module 'unit-to-px' {
|
|
9
|
+
function toPx(length: string, element?: Element): number;
|
|
10
|
+
export default toPx;
|
|
11
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ICellBorder } from '../interface/xlsx-parser/base';
|
|
2
|
+
import { ICell, IPaper } from '../interface/xlsx-parser';
|
|
3
|
+
/**
|
|
4
|
+
* 获取单元格坐标
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param paper
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前单元格指定方向的单元格
|
|
12
|
+
* @param x
|
|
13
|
+
* @param y
|
|
14
|
+
* @param paper
|
|
15
|
+
*/
|
|
16
|
+
export declare class CellBorder {
|
|
17
|
+
/**
|
|
18
|
+
* 获取指定单元格的指定方向的相邻单元格
|
|
19
|
+
* @author lingxiaoming
|
|
20
|
+
* @date 2024-07-02 04:23:11
|
|
21
|
+
* @static
|
|
22
|
+
* @param {number} x
|
|
23
|
+
* @param {number} y
|
|
24
|
+
* @param {IPaper} paper
|
|
25
|
+
* @param {('top' | 'bottom' | 'left' | 'right')} position
|
|
26
|
+
* @return {*}
|
|
27
|
+
*/
|
|
28
|
+
static getAdjacentCell(x: number, y: number, paper: IPaper, position: 'top' | 'bottom' | 'left' | 'right'): ICell | undefined;
|
|
29
|
+
static setLeft(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
30
|
+
static setRight(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
31
|
+
static setTop(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
32
|
+
static setBottom(x: number, y: number, paper: IPaper, bold?: boolean, value?: boolean): void;
|
|
33
|
+
static clearBorder(x: number, y: number, paper: IPaper): void;
|
|
34
|
+
/**
|
|
35
|
+
* 获取单元格是否有下边框 作用于分页时判断最后一行是否有下边框
|
|
36
|
+
* @param x
|
|
37
|
+
* @param y
|
|
38
|
+
* @param paper
|
|
39
|
+
*/
|
|
40
|
+
static getBottomBorder(x: number, y: number, paper: IPaper): boolean;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param x
|
|
44
|
+
* @param y
|
|
45
|
+
* @param paper
|
|
46
|
+
*/
|
|
47
|
+
static getTopBorder(x: number, y: number, paper: IPaper): boolean;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param x
|
|
51
|
+
* @param y
|
|
52
|
+
* @param paper
|
|
53
|
+
*/
|
|
54
|
+
static getLeftBorder(x: number, y: number, paper: IPaper): boolean;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param x
|
|
58
|
+
* @param y
|
|
59
|
+
* @param paper
|
|
60
|
+
*/
|
|
61
|
+
static getRightBorder(x: number, y: number, paper: IPaper): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 获取单元格的边框信息,合并单元格只有左上角那个一会获得汇总后的边框信息
|
|
64
|
+
* @author lingxiaoming
|
|
65
|
+
* @date 2024-07-04 06:35:10
|
|
66
|
+
* @static
|
|
67
|
+
* @param {number} x
|
|
68
|
+
* @param {number} y
|
|
69
|
+
* @param {IPaper} paper
|
|
70
|
+
* @return {*} {(ICellBorder | undefined)}
|
|
71
|
+
*/
|
|
72
|
+
static getCellBorder(x: number, y: number, paper: IPaper): ICellBorder | undefined;
|
|
73
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { range } from "lodash-es";
|
|
2
|
+
//#region src/utils/cell-border.ts
|
|
3
|
+
/**
|
|
4
|
+
* 获取单元格坐标
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param paper
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前单元格指定方向的单元格
|
|
12
|
+
* @param x
|
|
13
|
+
* @param y
|
|
14
|
+
* @param paper
|
|
15
|
+
*/
|
|
16
|
+
var CellBorder = class {
|
|
17
|
+
/**
|
|
18
|
+
* 获取指定单元格的指定方向的相邻单元格
|
|
19
|
+
* @author lingxiaoming
|
|
20
|
+
* @date 2024-07-02 04:23:11
|
|
21
|
+
* @static
|
|
22
|
+
* @param {number} x
|
|
23
|
+
* @param {number} y
|
|
24
|
+
* @param {IPaper} paper
|
|
25
|
+
* @param {('top' | 'bottom' | 'left' | 'right')} position
|
|
26
|
+
* @return {*}
|
|
27
|
+
*/
|
|
28
|
+
static getAdjacentCell(x, y, paper, position) {
|
|
29
|
+
let targetCell;
|
|
30
|
+
switch (position) {
|
|
31
|
+
case "top":
|
|
32
|
+
targetCell = paper.cells[y - 1 - 1]?.[x - 1];
|
|
33
|
+
break;
|
|
34
|
+
case "bottom":
|
|
35
|
+
targetCell = paper.cells[y + 1 - 1]?.[x - 1];
|
|
36
|
+
break;
|
|
37
|
+
case "left":
|
|
38
|
+
targetCell = paper.cells[y - 1]?.[x - 1 - 1];
|
|
39
|
+
break;
|
|
40
|
+
case "right":
|
|
41
|
+
targetCell = paper.cells[y - 1]?.[x + 1 - 1];
|
|
42
|
+
break;
|
|
43
|
+
default: return;
|
|
44
|
+
}
|
|
45
|
+
if (!targetCell) return;
|
|
46
|
+
return targetCell;
|
|
47
|
+
}
|
|
48
|
+
static setLeft(x, y, paper, bold = false, value = true) {
|
|
49
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
50
|
+
targetCellData.border = {
|
|
51
|
+
...targetCellData.border,
|
|
52
|
+
left: value,
|
|
53
|
+
bold,
|
|
54
|
+
boldLeft: bold
|
|
55
|
+
};
|
|
56
|
+
if (value === false) {
|
|
57
|
+
const leftCell = this.getAdjacentCell(x, y, paper, "left");
|
|
58
|
+
if (leftCell) leftCell.border = {
|
|
59
|
+
...leftCell.border,
|
|
60
|
+
right: false,
|
|
61
|
+
bold: false,
|
|
62
|
+
boldLeft: false
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static setRight(x, y, paper, bold = false, value = true) {
|
|
67
|
+
const targetCellData = paper.cells[y - 1][x - 1] || {};
|
|
68
|
+
targetCellData.border = {
|
|
69
|
+
...targetCellData.border,
|
|
70
|
+
right: value,
|
|
71
|
+
bold,
|
|
72
|
+
boldRight: bold
|
|
73
|
+
};
|
|
74
|
+
if (value === false) {
|
|
75
|
+
const rightCell = this.getAdjacentCell(x, y, paper, "right");
|
|
76
|
+
if (rightCell) rightCell.border = {
|
|
77
|
+
...rightCell.border,
|
|
78
|
+
left: false,
|
|
79
|
+
bold: false,
|
|
80
|
+
boldRight: bold
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static setTop(x, y, paper, bold = false, value = true) {
|
|
85
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
86
|
+
targetCellData.border = {
|
|
87
|
+
...targetCellData.border,
|
|
88
|
+
top: value,
|
|
89
|
+
bold,
|
|
90
|
+
boldTop: bold
|
|
91
|
+
};
|
|
92
|
+
if (value === false) {
|
|
93
|
+
const topCell = this.getAdjacentCell(x, y, paper, "top");
|
|
94
|
+
if (topCell) topCell.border = {
|
|
95
|
+
...topCell.border,
|
|
96
|
+
bottom: false,
|
|
97
|
+
bold: false,
|
|
98
|
+
boldTop: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
static setBottom(x, y, paper, bold = false, value = true) {
|
|
103
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
104
|
+
targetCellData.border = {
|
|
105
|
+
...targetCellData.border,
|
|
106
|
+
bottom: value,
|
|
107
|
+
bold,
|
|
108
|
+
boldBottom: bold
|
|
109
|
+
};
|
|
110
|
+
if (value === false) {
|
|
111
|
+
const bottomCell = this.getAdjacentCell(x, y, paper, "bottom");
|
|
112
|
+
if (bottomCell) bottomCell.border = {
|
|
113
|
+
...bottomCell.border,
|
|
114
|
+
top: false,
|
|
115
|
+
bold: false,
|
|
116
|
+
boldBottom: false
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
static clearBorder(x, y, paper) {
|
|
121
|
+
this.setLeft(x, y, paper, false, false);
|
|
122
|
+
this.setRight(x, y, paper, false, false);
|
|
123
|
+
this.setTop(x, y, paper, false, false);
|
|
124
|
+
this.setBottom(x, y, paper, false, false);
|
|
125
|
+
const targetCellData = paper.cells[y - 1][x - 1];
|
|
126
|
+
targetCellData.border = void 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 获取单元格是否有下边框 作用于分页时判断最后一行是否有下边框
|
|
130
|
+
* @param x
|
|
131
|
+
* @param y
|
|
132
|
+
* @param paper
|
|
133
|
+
*/
|
|
134
|
+
static getBottomBorder(x, y, paper) {
|
|
135
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
136
|
+
if (mergeCell) return range(mergeCell.l, mergeCell.r).every((v) => !!paper.cells[mergeCell.b - 1][v - 1]?.border?.bottom);
|
|
137
|
+
else return !!paper.cells[y - 1][x - 1].border?.bottom;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param x
|
|
142
|
+
* @param y
|
|
143
|
+
* @param paper
|
|
144
|
+
*/
|
|
145
|
+
static getTopBorder(x, y, paper) {
|
|
146
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
147
|
+
if (mergeCell) return range(mergeCell.l, mergeCell.r).every((v) => !!paper.cells[mergeCell.t - 1][v - 1]?.border?.top);
|
|
148
|
+
else return !!paper.cells[y - 1][x - 1].border?.top;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param x
|
|
153
|
+
* @param y
|
|
154
|
+
* @param paper
|
|
155
|
+
*/
|
|
156
|
+
static getLeftBorder(x, y, paper) {
|
|
157
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
158
|
+
if (mergeCell) {
|
|
159
|
+
console.log(x, y, range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.l - 1]?.border?.left));
|
|
160
|
+
return range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.l - 1]?.border?.left);
|
|
161
|
+
} else return !!paper.cells[y - 1][x - 1].border?.left;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param x
|
|
166
|
+
* @param y
|
|
167
|
+
* @param paper
|
|
168
|
+
*/
|
|
169
|
+
static getRightBorder(x, y, paper) {
|
|
170
|
+
const mergeCell = paper.mergedCells.find((c) => c.t === y && c.l === x);
|
|
171
|
+
if (mergeCell) return range(mergeCell.t, mergeCell.b).every((v) => !!paper.cells[v - 1][mergeCell.r - 1]?.border?.right);
|
|
172
|
+
else return !!paper.cells[y - 1][x - 1].border?.right;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 获取单元格的边框信息,合并单元格只有左上角那个一会获得汇总后的边框信息
|
|
176
|
+
* @author lingxiaoming
|
|
177
|
+
* @date 2024-07-04 06:35:10
|
|
178
|
+
* @static
|
|
179
|
+
* @param {number} x
|
|
180
|
+
* @param {number} y
|
|
181
|
+
* @param {IPaper} paper
|
|
182
|
+
* @return {*} {(ICellBorder | undefined)}
|
|
183
|
+
*/
|
|
184
|
+
static getCellBorder(x, y, paper) {
|
|
185
|
+
const mergedCell = (paper.mergedCells ?? []).find((c) => c.l <= x && c.r >= x && c.t <= y && c.b >= y);
|
|
186
|
+
if (mergedCell) {
|
|
187
|
+
if (mergedCell.t === y && mergedCell.l === x) return {
|
|
188
|
+
top: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.top),
|
|
189
|
+
bottom: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.b - 1][v - 1]?.border?.bottom),
|
|
190
|
+
left: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.l - 1]?.border?.left),
|
|
191
|
+
right: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.r - 1]?.border?.right),
|
|
192
|
+
bold: range(mergedCell.l, mergedCell.r + 1).some((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.bold) ?? false,
|
|
193
|
+
boldTop: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.t - 1][v - 1]?.border?.boldTop) ?? false,
|
|
194
|
+
boldBottom: range(mergedCell.l, mergedCell.r + 1).every((v) => !!paper.cells[mergedCell.b - 1][v - 1]?.border?.boldBottom) ?? false,
|
|
195
|
+
boldLeft: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.l - 1]?.border?.boldLeft) ?? false,
|
|
196
|
+
boldRight: range(mergedCell.t, mergedCell.b + 1).every((v) => !!paper.cells[v - 1][mergedCell.r - 1]?.border?.boldRight) ?? false
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return paper.cells[y - 1][x - 1]?.border || {};
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
//#endregion
|
|
203
|
+
export { CellBorder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { XlsxParser } from './xlsx-parser';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./xlsx-parser.mjs";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { default as ExcelJs } from 'exceljs';
|
|
2
|
+
import { ICell, IImage, IPaper, IRange } from '../interface/xlsx-parser/index';
|
|
3
|
+
import { CellField, ImportedFieldMeta } from '../interface/xlsx-parser/base';
|
|
4
|
+
export declare const isTypeInGroup: (type: string, group: string[]) => boolean;
|
|
5
|
+
export declare const generateAutoFieldKey: (type: string, fieldGroup: string[], keyList: string[]) => string | undefined;
|
|
6
|
+
type PaperViewportRange = [string, string];
|
|
7
|
+
export declare class XlsxParser {
|
|
8
|
+
static xlsx2json(file: IObject): Promise<{
|
|
9
|
+
sheetId: string;
|
|
10
|
+
orientation: import('../enums/xlsx-parser').Orientation;
|
|
11
|
+
padding: IRange;
|
|
12
|
+
cols: {
|
|
13
|
+
width: number;
|
|
14
|
+
manual?: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
rows: {
|
|
17
|
+
height: number;
|
|
18
|
+
manual?: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
cells: ICell[][];
|
|
21
|
+
mergedCells: IRange[];
|
|
22
|
+
thead?: {
|
|
23
|
+
thName?: string;
|
|
24
|
+
thRange?: IRange;
|
|
25
|
+
};
|
|
26
|
+
dynamicTables?: import('../interface/xlsx-parser/index').ITable[];
|
|
27
|
+
fixedTables?: import('../interface/xlsx-parser/index').IFixedTable[];
|
|
28
|
+
medias?: import('../interface/xlsx-parser/index').IMedia[];
|
|
29
|
+
images?: IImage[];
|
|
30
|
+
paramToField?: import('../interface/xlsx-parser/index').IParamToField[];
|
|
31
|
+
paperHeader?: boolean;
|
|
32
|
+
paperHeaderWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
33
|
+
paperFooter?: boolean;
|
|
34
|
+
paperFooterWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
35
|
+
javascript?: string;
|
|
36
|
+
globalOptions?: import('../interface/xlsx-parser/index').IGlobalOption[];
|
|
37
|
+
parameterMapping?: import('../interface/xlsx-parser/index').IParameterMapping[];
|
|
38
|
+
customDataSource?: import('../interface/xlsx-parser/index').ICustomDataSource[];
|
|
39
|
+
checkTableDataSource?: import('../interface/xlsx-parser/index').ICheckTableDataSource[];
|
|
40
|
+
mainModelKey?: string;
|
|
41
|
+
modelMetaMap?: import('../interface/xlsx-parser/base').IModelMetaMap;
|
|
42
|
+
} | undefined>;
|
|
43
|
+
static xlsx2jsonWithFields(file: IObject, keyList: string[]): Promise<{
|
|
44
|
+
paper: {
|
|
45
|
+
sheetId: string;
|
|
46
|
+
orientation: import('../enums/xlsx-parser').Orientation;
|
|
47
|
+
padding: IRange;
|
|
48
|
+
cols: {
|
|
49
|
+
width: number;
|
|
50
|
+
manual?: boolean;
|
|
51
|
+
}[];
|
|
52
|
+
rows: {
|
|
53
|
+
height: number;
|
|
54
|
+
manual?: boolean;
|
|
55
|
+
}[];
|
|
56
|
+
cells: ICell[][];
|
|
57
|
+
mergedCells: IRange[];
|
|
58
|
+
thead?: {
|
|
59
|
+
thName?: string;
|
|
60
|
+
thRange?: IRange;
|
|
61
|
+
};
|
|
62
|
+
dynamicTables?: import('../interface/xlsx-parser/index').ITable[];
|
|
63
|
+
fixedTables?: import('../interface/xlsx-parser/index').IFixedTable[];
|
|
64
|
+
medias?: import('../interface/xlsx-parser/index').IMedia[];
|
|
65
|
+
images?: IImage[];
|
|
66
|
+
paramToField?: import('../interface/xlsx-parser/index').IParamToField[];
|
|
67
|
+
paperHeader?: boolean;
|
|
68
|
+
paperHeaderWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
69
|
+
paperFooter?: boolean;
|
|
70
|
+
paperFooterWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
71
|
+
javascript?: string;
|
|
72
|
+
globalOptions?: import('../interface/xlsx-parser/index').IGlobalOption[];
|
|
73
|
+
parameterMapping?: import('../interface/xlsx-parser/index').IParameterMapping[];
|
|
74
|
+
customDataSource?: import('../interface/xlsx-parser/index').ICustomDataSource[];
|
|
75
|
+
checkTableDataSource?: import('../interface/xlsx-parser/index').ICheckTableDataSource[];
|
|
76
|
+
mainModelKey?: string;
|
|
77
|
+
modelMetaMap?: import('../interface/xlsx-parser/base').IModelMetaMap;
|
|
78
|
+
} | null;
|
|
79
|
+
fields: ImportedFieldMeta[] | null;
|
|
80
|
+
paperFields: CellField[];
|
|
81
|
+
}>;
|
|
82
|
+
static sheetToPaper(paperSheet: ExcelJs.Worksheet & {
|
|
83
|
+
_rows?: IObject[];
|
|
84
|
+
_merges?: IObject;
|
|
85
|
+
_media?: IObject[];
|
|
86
|
+
}, xlsxData: IObject): {
|
|
87
|
+
sheetId: string;
|
|
88
|
+
orientation: import('../enums/xlsx-parser').Orientation;
|
|
89
|
+
padding: IRange;
|
|
90
|
+
cols: {
|
|
91
|
+
width: number;
|
|
92
|
+
manual?: boolean;
|
|
93
|
+
}[];
|
|
94
|
+
rows: {
|
|
95
|
+
height: number;
|
|
96
|
+
manual?: boolean;
|
|
97
|
+
}[];
|
|
98
|
+
cells: ICell[][];
|
|
99
|
+
mergedCells: IRange[];
|
|
100
|
+
thead?: {
|
|
101
|
+
thName?: string;
|
|
102
|
+
thRange?: IRange;
|
|
103
|
+
};
|
|
104
|
+
dynamicTables?: import('../interface/xlsx-parser/index').ITable[];
|
|
105
|
+
fixedTables?: import('../interface/xlsx-parser/index').IFixedTable[];
|
|
106
|
+
medias?: import('../interface/xlsx-parser/index').IMedia[];
|
|
107
|
+
images?: IImage[];
|
|
108
|
+
paramToField?: import('../interface/xlsx-parser/index').IParamToField[];
|
|
109
|
+
paperHeader?: boolean;
|
|
110
|
+
paperHeaderWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
111
|
+
paperFooter?: boolean;
|
|
112
|
+
paperFooterWidgets?: import("../interface/xlsx-parser/paper-widget").PaperWidget.BasicSchema[];
|
|
113
|
+
javascript?: string;
|
|
114
|
+
globalOptions?: import('../interface/xlsx-parser/index').IGlobalOption[];
|
|
115
|
+
parameterMapping?: import('../interface/xlsx-parser/index').IParameterMapping[];
|
|
116
|
+
customDataSource?: import('../interface/xlsx-parser/index').ICustomDataSource[];
|
|
117
|
+
checkTableDataSource?: import('../interface/xlsx-parser/index').ICheckTableDataSource[];
|
|
118
|
+
mainModelKey?: string;
|
|
119
|
+
modelMetaMap?: import('../interface/xlsx-parser/base').IModelMetaMap;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* 根据 sheet 内容解析字段信息
|
|
123
|
+
* @param sheet
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
static sheetToFields(sheet: ExcelJs.Worksheet & {
|
|
127
|
+
_rows?: IObject[];
|
|
128
|
+
}, keyList: string[]): ImportedFieldMeta[];
|
|
129
|
+
/**
|
|
130
|
+
* 字段信息转换为元数据
|
|
131
|
+
* @param field
|
|
132
|
+
*/
|
|
133
|
+
static _field2Meta(field: IObject, keyList: string[]): void;
|
|
134
|
+
/**
|
|
135
|
+
* @param paper 导入的纸张数据
|
|
136
|
+
* @param range 最大显示范围
|
|
137
|
+
* @param mode 缩放模式 x: 横向 y: 纵向
|
|
138
|
+
*/
|
|
139
|
+
static contentFitToPaper(paper: IPaper, range: PaperViewportRange, mode?: string): void;
|
|
140
|
+
}
|
|
141
|
+
export {};
|