@ebuilding/base 2.0.0 → 2.0.2

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.
@@ -0,0 +1,2335 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EventEmitter, forwardRef, ViewChild, Output, Input, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
3
+ import * as i4 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i5 from '@angular/forms';
6
+ import { ReactiveFormsModule, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
7
+ import * as i6 from 'ng-zorro-antd/input';
8
+ import { NzInputModule } from 'ng-zorro-antd/input';
9
+ import * as i7 from 'ng-zorro-antd/collapse';
10
+ import { NzCollapseModule } from 'ng-zorro-antd/collapse';
11
+ import { NzIconModule } from 'ng-zorro-antd/icon';
12
+ import * as i8 from 'ng-zorro-antd/button';
13
+ import { NzButtonModule } from 'ng-zorro-antd/button';
14
+ import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
15
+ import CodeMirror from 'codemirror';
16
+ import * as i11 from '@ebuilding/base/shared.pipe';
17
+ import { GramPipeModule } from '@ebuilding/base/shared.pipe';
18
+ import _ from 'lodash';
19
+ import * as i1 from 'ng-zorro-antd/message';
20
+ import * as i2 from 'ng-zorro-antd/core/config';
21
+ import * as i9 from 'ng-zorro-antd/core/transition-patch';
22
+ import * as i10 from 'ng-zorro-antd/core/wave';
23
+
24
+ const KRE_CODEMIRROR_TOKEN = new InjectionToken("KRE_CODEMIRROR_TOKEN");
25
+ class Formula {
26
+ FormulaUsage = [
27
+ {
28
+ category: "数学函数",
29
+ contains: [
30
+ {
31
+ name: "ABS",
32
+ intro: "ABS函数可以获取一个数的绝对值",
33
+ usage: "ABS(数字)",
34
+ example: "ABS(-1)可以返回1,也就是-1的绝对值",
35
+ },
36
+ {
37
+ name: "AVERAGE",
38
+ intro: "AVERAGE函数可以获取一组数值的算术平均值",
39
+ usage: "AVERAGE(数字1,数字2,...)",
40
+ example: "AVERAGE({语文成绩},{数学成绩}, {英语成绩})返回三门课程的平均分",
41
+ },
42
+ {
43
+ name: "CEILING",
44
+ intro: "CEILING函数可以将数字增大到最接近原值的指定因数的倍数",
45
+ usage: "CEILING(数字,因数)",
46
+ example: "CEILING(7,6)返回12,因为12比7大的同时,也是6的倍数中最接近7的数字",
47
+ },
48
+ {
49
+ name: "COUNT",
50
+ intro: "COUNT函数可以获取参数的数量",
51
+ usage: "COUNT(值,值,...)",
52
+ example: "COUNT(小明,小王,小张,小李)返回4,也就是人员的数量",
53
+ },
54
+ {
55
+ name: "COUNTIF",
56
+ intro: "COUNTIF函数可以获取数组中满足条件的参数个数",
57
+ usage: 'COUNTIF(数组,"条件")',
58
+ example: 'COUNTIF(子表单.性别, "女"),可得到子表单中性别填的是"女"的数据条数;COUNTIF([1,2,3,4],">2"),可得到1,2,3,4中大于2的数字数量,结果为2。',
59
+ },
60
+ {
61
+ name: "FIXED",
62
+ intro: "FIXED函数可将数字舍入到指定的小数位数并输出为文本",
63
+ usage: "FIXED(数字,小数位数)",
64
+ example: 'FIXED(3.1415,2)返回"3.14"',
65
+ },
66
+ {
67
+ name: "FLOOR",
68
+ intro: "FLOOR函数可将数字减小到最接近原值的指定因数的倍数",
69
+ usage: "FLOOR(数字,因数)",
70
+ example: "FLOOR(7,6)返回6,因为6比7小的同时,也是6的倍数中最接近7的数字",
71
+ },
72
+ {
73
+ name: "INT",
74
+ intro: "INT函数可以获取一个数的整数部分",
75
+ usage: "INT(数字)",
76
+ example: "INT(3.1415)返回3,也就是3.1415的整数部分",
77
+ },
78
+ {
79
+ name: "LARGE",
80
+ intro: "LARGE函数可以获取数据集中第k个最大值",
81
+ usage: "LARGE(数组,k)",
82
+ example: 'LARGE({学生成绩.数学成绩},1)返回子表单"学生成绩"中排名第1的"数学成绩"',
83
+ },
84
+ {
85
+ name: "LOG",
86
+ intro: "LOG函数可以根据指定底数返回数字的对数",
87
+ usage: "LOG(数字,底数)",
88
+ example: "LOG(100,10)返回2,也就是以10为底数100的对数",
89
+ },
90
+ {
91
+ name: "MAX",
92
+ intro: "MAX函数可以获取一组数值的最大值",
93
+ usage: "MAX(数字1,数字2,...)",
94
+ example: "MAX({语文成绩},{数学成绩},{英语成绩})返回三门课程中的最高分",
95
+ },
96
+ {
97
+ name: "MIN",
98
+ intro: "MIN函数可以获取一组数值的最小值",
99
+ usage: "MIN(数字1,数字2,...)",
100
+ example: "MAX({语文成绩},{数学成绩},{英语成绩})返回三门课程中的最低分",
101
+ },
102
+ {
103
+ name: "MOD",
104
+ intro: "MOD函数可以获取两数相除的余数",
105
+ usage: "MOD(被除数,除数)",
106
+ example: "MOD(4,3)返回1,也就是4/3的余数",
107
+ },
108
+ {
109
+ name: "POWER",
110
+ intro: "POWER函数可以获取数字乘幂的结果",
111
+ usage: "POWER(数字,指数)",
112
+ example: "POWER(3,2)返回9,也就是3的2次方",
113
+ },
114
+ {
115
+ name: "PRODUCT",
116
+ intro: "PRODUCT函数可以获取一组数值的乘积",
117
+ usage: "PRODUCT(数字1,数字2,...)",
118
+ example: "PRODUCT({单价}, {数量})获取总价,也就是单价和数量的乘积",
119
+ },
120
+ {
121
+ name: "ROUND",
122
+ intro: "ROUND函数可以将数字四舍五入到指定的位数",
123
+ usage: "ROUND(数字,数字位数)",
124
+ example: "ROUND(3.1485,2)返回3.15",
125
+ },
126
+ {
127
+ name: "SQRT",
128
+ intro: "SQRT函数可以获取一个数字的正平方根",
129
+ usage: "SQRT(数字)",
130
+ example: "SQRT(9)返回3,也就是9的正平方根",
131
+ },
132
+ {
133
+ name: "SUM",
134
+ intro: "SUM函数可以获取一组数值的总和",
135
+ usage: "SUM(数字1,数字2,...)",
136
+ example: "SUM({语文成绩},{数学成绩}, {英语成绩})返回三门课程的总分",
137
+ },
138
+ {
139
+ name: "SUMPRODUCT",
140
+ intro: "SUMPRODUCT函数可以将数组间对应的元素相乘,并返回乘积之和,适用于加权求和",
141
+ usage: "SUMPRODUCT(数组,数组...)",
142
+ example: "SUMPRODUCT([1,2,3],[0.1,0.2,0.3])返回1.4,也就是 1×0.1 + 2×0.2 + 3×0.3的值",
143
+ },
144
+ ],
145
+ },
146
+ {
147
+ category: "文本函数",
148
+ contains: [
149
+ {
150
+ name: "CONCATENATE",
151
+ intro: "CONCATENATE函数可以将多个文本合并成一个文本",
152
+ usage: "CONCATENATE(文本1,文本2,...)",
153
+ example: 'CONCATENATE("小小人力资源科技股份有限公司","张三")会返回"小小人力资源科技股份有限公司张三"',
154
+ },
155
+ {
156
+ name: "EXACT",
157
+ intro: "EXACT函数可以比较两个文本是否完全相同,完全相同则返回true,否则返回false",
158
+ usage: "EXACT(文本1, 文本2)",
159
+ example: "EXACT({手机号},{中奖手机号}),如果两者相同,返回true,如果不相同,返回false",
160
+ },
161
+ {
162
+ name: "GETUSERNAME",
163
+ intro: "GETUSERNAME函数可以获取当前用户的昵称",
164
+ usage: "GETUSERNAME()",
165
+ example: "略",
166
+ },
167
+ {
168
+ name: "ISEMPTY",
169
+ intro: "ISEMPTY函数可以用来判断值是否为空文本、空对象或者空数组",
170
+ usage: "ISEMPTY(文本)",
171
+ example: "略",
172
+ },
173
+ {
174
+ name: "LEFT",
175
+ intro: "LEFT函数可以从一个文本的第一个字符开始返回指定个数的字符",
176
+ usage: "LEFT(文本,文本长度)",
177
+ example: 'LEFT("上海小小人力资源科技股份有限公司张三",2)返回"上海",也就是"上海小小人力资源科技股份有限公司张三"的从左往右的前2个字符',
178
+ },
179
+ {
180
+ name: "LEN",
181
+ intro: "LEN函数可以获取文本中的字符个数",
182
+ usage: "LEN(文本)",
183
+ example: 'LEN("朝辞白帝彩云间")返回7,因为这句诗中有7个字符',
184
+ },
185
+ {
186
+ name: "LOWER",
187
+ intro: "LOWER函数可以将一个文本中的所有大写字母转换为小写字母",
188
+ usage: "LOWER(文本)",
189
+ example: 'LOWER("JAYZ")返回"jayz"',
190
+ },
191
+ {
192
+ name: "SUBSTRING",
193
+ intro: "SUBSTRING返回文本中从指定位置开始到指定位置结束的字符",
194
+ usage: "SUBSTRING(文本,开始位置_数字,结束位置_数字)",
195
+ example: 'SUBSTRING("小小数字化组织效能提升专家",3,5)返回"数字化"',
196
+ },
197
+ {
198
+ name: "REPLACE",
199
+ intro: "REPLACE函数可以根据指定的字符数,将部分文本替换为不同的文本",
200
+ usage: "REPLACE(文本,开始位置,替换长度,新文本)",
201
+ example: 'REPLACE("小小应用定制工具",5,6,"企业数据管理平台")返回"小小企业数据管理平台"',
202
+ },
203
+ {
204
+ name: "REPT",
205
+ intro: "REPT函数可以将文本重复一定次数",
206
+ usage: "REPT(文本,重复次数)",
207
+ example: 'REPT("小小",3)返回"小小小小小小"',
208
+ },
209
+ {
210
+ name: "RIGHT",
211
+ intro: "RIGHT函数可以获取由给定文本右端指定数量的字符构成的文本值",
212
+ usage: "RIGHT(文本,文本长度)",
213
+ example: 'RIGHT("三年二班周杰伦",3)返回"周杰伦",也就是"三年二班周杰伦"从右往左的前3个字符',
214
+ },
215
+ {
216
+ name: "SEARCH",
217
+ intro: "SEARCH函数可以获取文本1在文本2中的开始位置",
218
+ usage: "SEARCH(文本1,文本2)",
219
+ example: 'SEARCH("2021","小小2021")返回4',
220
+ },
221
+ {
222
+ name: "SPLIT",
223
+ intro: "SPLIT函数可以将文本按指定分割符分割成数组",
224
+ usage: "SPLIT(文本,分隔符_文本)",
225
+ example: 'SPLIT("小小-应用定制工具","-")返回"小小,应用定制工具"',
226
+ },
227
+ {
228
+ name: "TEXT",
229
+ intro: "TEXT函数可以将数字转化成文本",
230
+ usage: "TEXT(数字)",
231
+ example: 'TEXT(3.1415)返回"3.1415"',
232
+ },
233
+ {
234
+ name: "TRIM",
235
+ intro: "TRIM函数可以删除文本首尾的空格",
236
+ usage: "TRIM(文本)",
237
+ example: 'TRIM(" 小小 ")返回"小小"',
238
+ },
239
+ {
240
+ name: "UPPER",
241
+ intro: "UPPER函数可以将一个文本中的所有小写字母转换为大写字母",
242
+ usage: "UPPER(文本)",
243
+ example: 'UPPER("jayz")返回"JAYZ"',
244
+ },
245
+ {
246
+ name: "VALUE",
247
+ intro: "VALUE函数可以将文本转化为数字",
248
+ usage: "VALUE(文本)",
249
+ example: 'VALUE("3.1415")返回3.1415',
250
+ },
251
+ ],
252
+ },
253
+ {
254
+ category: "日期函数",
255
+ contains: [
256
+ {
257
+ name: "DATE",
258
+ intro: "DATE函数可以将时间戳转换为日期对象",
259
+ usage: "DATE(时间戳)",
260
+ example: "略",
261
+ },
262
+ {
263
+ name: "DATEDELTA",
264
+ intro: "DATEDELTA函数可以将指定日期加/减指定天数",
265
+ usage: "DATEDELTA(指定日期,需要加减的天数)",
266
+ example: "略",
267
+ },
268
+ {
269
+ name: "DAY",
270
+ intro: "DAY函数可以获取某日期是当月的第几日",
271
+ usage: "DAY(时间戳)",
272
+ example: "略",
273
+ },
274
+ {
275
+ name: "DAYS",
276
+ intro: "DAYS函数可以返回两个日期之间相差的天数。",
277
+ usage: "DAYS(结束日期,开始日期)",
278
+ example: "略",
279
+ },
280
+ {
281
+ name: "HOUR",
282
+ intro: "HOUR函数可以返回某日期的小时数",
283
+ usage: "HOUR(时间戳)",
284
+ example: "略",
285
+ },
286
+ {
287
+ name: "ISOWEEKNUM",
288
+ intro: "ISOWEEKNUM函数可以返回指定日期在全年中的ISO周数",
289
+ usage: "ISOWEEKNUM(指定日期)",
290
+ example: "略",
291
+ },
292
+ {
293
+ name: "MINUTE",
294
+ intro: "MINUTE函数可以返回某日期的分钟数",
295
+ usage: "MINUTE(日期)",
296
+ example: "略",
297
+ },
298
+ {
299
+ name: "MONTH",
300
+ intro: "MONTH返回某日期的月份",
301
+ usage: "MONTH(日期)",
302
+ example: "略",
303
+ },
304
+ {
305
+ name: "NOW",
306
+ intro: "NOW函数可以获取当前时间",
307
+ usage: "NOW()",
308
+ example: "略",
309
+ },
310
+ {
311
+ name: "SECOND",
312
+ intro: "SECOND函数可以返回某日期的秒数",
313
+ usage: "SECOND(日期)",
314
+ example: "略",
315
+ },
316
+ {
317
+ name: "SYSTIME",
318
+ intro: "SYSTIME函数可以获取当前服务器时间",
319
+ usage: "SYSTIME()",
320
+ example: "略",
321
+ },
322
+ {
323
+ name: "TIME",
324
+ intro: "TIME函数可以返回特定时间的十进制数字",
325
+ usage: "TIME(时_数字,分_数字,秒_数字)",
326
+ example: "略",
327
+ },
328
+ {
329
+ name: "TIMESTAMP",
330
+ intro: "TIMESTAMP函数可以将日期对象转换成时间戳。",
331
+ usage: "TIMESTAMP(日期)",
332
+ example: "略",
333
+ },
334
+ {
335
+ name: "TODAY",
336
+ intro: "TODAY函数可以返回今天",
337
+ usage: "TODAY()",
338
+ example: "略",
339
+ },
340
+ {
341
+ name: "WEEKNUM",
342
+ intro: "WEEKNUM函数可以返回指定日期在当年是第几周",
343
+ usage: "WEEKNUM(指定日期)",
344
+ example: "略",
345
+ },
346
+ {
347
+ name: "YEAR",
348
+ intro: "YEAR函数可以返回某日期的年份",
349
+ usage: "YEAR(时间戳)",
350
+ example: "略",
351
+ },
352
+ {
353
+ name: "STRDATE",
354
+ intro: "STRDATE函数可以将字符串转换为日期",
355
+ usage: "STRDATE(年月日)",
356
+ example: 'STRDATE("19860913") 返回1986-09-13',
357
+ },
358
+ {
359
+ name: "DATEMINUS",
360
+ intro: "DATEMINUS函数可以求2个日期相差的年、月、天、小时数",
361
+ usage: "DATEMINUS(开始日期,结束日期,'1')",
362
+ example: 'DATEMINUS("2020-01-01","2021-01-02","3") 返回1,单位为天。第三个参数1为年,2为月,3为天,4为小时',
363
+ },
364
+ ],
365
+ },
366
+ {
367
+ category: "逻辑函数",
368
+ contains: [
369
+ {
370
+ name: "AND",
371
+ intro: "如果所有参数都为真,AND函数返回布尔值true,否则返回布尔值 false",
372
+ usage: "AND(逻辑表达式1,逻辑表达式2,...)",
373
+ example: "AND({语文成绩}>90,{数学成绩}>90,{英语成绩}>90),如果三门课成绩都> 90,返回true,否则返回false",
374
+ },
375
+ {
376
+ name: "FALSE",
377
+ intro: "FALSE函数返回布尔值false",
378
+ usage: "FALSE()",
379
+ example: "略",
380
+ },
381
+ {
382
+ name: "IF",
383
+ intro: "IF函数判断一个条件能否满足;如果满足返回一个值,如果不满足则返回另外一个值",
384
+ usage: "IF(逻辑表达式,为true时返回的值,为false时返回的值)",
385
+ example: 'IF({语文成绩}>60,"及格","不及格"),当语文成绩>60时返回及格,否则返回不及格。',
386
+ },
387
+ {
388
+ name: "NOT",
389
+ intro: "NOT函数返回与指定表达式相反的布尔值。",
390
+ usage: "NOT(逻辑表达式)",
391
+ example: "NOT({语文成绩}>60),如果语文成绩大于60返回false,否则返回true",
392
+ },
393
+ {
394
+ name: "OR",
395
+ intro: "如果任意参数为真,OR 函数返回布尔值true;如果所有参数为假,返回布尔值false。",
396
+ usage: "OR(逻辑表达式1,逻辑表达式2,...)",
397
+ example: "OR({语文成绩}>90,{数学成绩}>90,{英语成绩}>90),任何一门课成绩> 90,返回true,否则返回false",
398
+ },
399
+ {
400
+ name: "TRUE",
401
+ intro: "TRUE函数返回布尔值true",
402
+ usage: "TRUE()",
403
+ example: "略",
404
+ },
405
+ {
406
+ name: "XOR",
407
+ intro: "XOR函数可以返回所有参数的异或值",
408
+ usage: "XOR(逻辑表达式1, 逻辑表达式2,...)",
409
+ example: "XOR({语文成绩}>90,{数学成绩}>90),如果两门成绩都>90,返回false;如果两门成绩都<90,返回false;如果其中一门>90,另外一门<90,返回true",
410
+ },
411
+ ],
412
+ },
413
+ {
414
+ category: "高级函数",
415
+ contains: [
416
+ {
417
+ name: "MAPX",
418
+ intro: "MAPX函数是一个可以用来进行跨表单取数的高级函数",
419
+ usage: "MAPX(operation,map_value,map_field,result_field)",
420
+ example: "略",
421
+ },
422
+ {
423
+ name: "RECNO",
424
+ intro: "RECNO函数依据当前表单被新打开的次数进行不断累计,起始值为1。",
425
+ usage: "RECNO()",
426
+ example: "略",
427
+ },
428
+ {
429
+ name: "UUID",
430
+ intro: "UUID函数随机码生成器。可适用于随机流水号的使用场景等",
431
+ usage: "UUID()",
432
+ example: "略",
433
+ },
434
+ ],
435
+ },
436
+ ];
437
+ FormulaEditor = {
438
+ CONST: {
439
+ NAME_FILED_CLS: "cm-field-name",
440
+ VALUE_FIELD_CLS: "cm-field-value",
441
+ INVALID_FIELD_CLS: "cm-field-invalid",
442
+ DEPRECATE_FIELD_CLS: "cm-deprecate",
443
+ NEGATIVE_FIELD_CLS: "cm-negative",
444
+ FIELD_REG: /^\$({*|_formula_[0-9]{13}|ext|createTime|updateTime|creator|wx_open_id|wx_nickname|wx_gender)/,
445
+ },
446
+ COMMON_REG: {
447
+ VALIDATOR_FORMULA: "(\\$[{0-9a-zA-Z._]+})",
448
+ FORM_FORMULA: "(\\$[{0-9a-zA-Z._}@]+)",
449
+ NEW_LINE: "[\\r\\n]",
450
+ },
451
+ };
452
+ Utils = {};
453
+ Formula = {};
454
+ constructor() {
455
+ let that = this;
456
+ that.Utils = {
457
+ isString: function (a) {
458
+ return "string" == typeof a;
459
+ },
460
+ isNumber: function (b) {
461
+ return this.isNumeric(b);
462
+ },
463
+ isFunction: function (b) {
464
+ return this.isFunction(b);
465
+ },
466
+ isDate: function (a) {
467
+ return a instanceof Date;
468
+ },
469
+ isArray: function (b) {
470
+ return this.isArray(b);
471
+ },
472
+ isEmpty: function (a) {
473
+ return "" === a || this.Utils.isNull(a);
474
+ },
475
+ isBlank: function (a) {
476
+ return this.Utils.isNull(a) || "" === a.trim();
477
+ },
478
+ isNull: function (a) {
479
+ return null == a;
480
+ },
481
+ isObjectEmpty: function (a) {
482
+ if (null == a)
483
+ return !0;
484
+ if (a.length > 0)
485
+ return !1;
486
+ if (0 === a.length)
487
+ return !0;
488
+ for (var b in a) {
489
+ if (this.hasOwnProperty.call(a, b)) {
490
+ return !1;
491
+ }
492
+ return isNaN(a);
493
+ }
494
+ return null;
495
+ },
496
+ isValueWidget: function (a) {
497
+ return !!this.ValueWidgets[a];
498
+ },
499
+ address2Str: function (a, b, c) {
500
+ if (c && a) {
501
+ b = "";
502
+ var d = !0;
503
+ /p/.test(c) &&
504
+ a.province &&
505
+ ((b += a.province), a.province === a.city && (d = !1)),
506
+ /c/.test(c) && a.city && d && (b += a.city),
507
+ /d/.test(c) && a.district && (b += a.district),
508
+ /a/.test(c) && a.detail && (b += a.detail);
509
+ }
510
+ return b;
511
+ },
512
+ num2Str: function (a, b) {
513
+ if (this.Utils.isEmpty(a))
514
+ return "";
515
+ var c = a + "";
516
+ if (this.Utils.isEmpty(b))
517
+ return c;
518
+ var d = /\[Num0\]/;
519
+ if (d.test(b))
520
+ return b.replace(d, c);
521
+ if (((d = /\[Num1\]/), d.test(b)))
522
+ return b.replace(d, this.Utils._num2CN(c, !1));
523
+ if (((d = /\[Num2\]/), d.test(b)))
524
+ return b.replace(d, this.Utils._num2CN(c, !0));
525
+ d = /[#0]+,?[#0]*\.?[#0]*%?/;
526
+ var e = b.match(d);
527
+ if (e && e.length > 0) {
528
+ var f = e[0];
529
+ return (c = this.Utils._numberFormat(a, f)), b.replace(d, c);
530
+ }
531
+ return b;
532
+ },
533
+ _numberFormat: function (a, b) {
534
+ var c = "", d = a + "";
535
+ if (/%$/.test(b)) {
536
+ (c = "%"), (a = 100 * a), (b = b.replace("%", ""));
537
+ var e = d.indexOf(".");
538
+ if (e > -1) {
539
+ var f = d.length - 3 - e;
540
+ (f = f < 0 ? 0 : f > 8 ? 8 : f), (a = parseFloat(a.toFixed(f)));
541
+ }
542
+ d = a + "";
543
+ }
544
+ var g = b.split("."), h = g[0], i = g[1];
545
+ if ("" !== i) {
546
+ var j = i ? i.length : 0;
547
+ d = parseFloat(a).toFixed(j);
548
+ for (var k = d.split(""), l = j; l > 0 && "#" === i.charAt(l - 1); l--) {
549
+ var m = k.pop();
550
+ if ("0" !== m) {
551
+ k.push(m);
552
+ break;
553
+ }
554
+ }
555
+ var n = k.pop();
556
+ "." === n && (n = ""), (d = k.join("") + n);
557
+ }
558
+ var o = d.split("."), p = o[0];
559
+ if (/,/.test(h))
560
+ o[0] = p.replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, "$1,");
561
+ else {
562
+ var q = h.match(/[0]+[0#]*$/);
563
+ q && q.length > 0 && (o[0] = this.Utils.leftPad(p, q[0].length, "0"));
564
+ }
565
+ return o.join(".") + c;
566
+ },
567
+ _num2CN: function (a, b) {
568
+ var c = "〇一二三四五六七八九", d = "个十百千万亿";
569
+ b && ((c = "零壹贰叁肆伍陆柒捌玖"), (d = "个拾佰仟万亿"));
570
+ var e = Math.floor(Math.abs(a)), f = Math.abs(a).toString(), g = f.replace(/\..*$/, ""), h = f.split("."), i = c, j = d, k = "-.", l = i[0], m = new RegExp(i[0] + "*$"), n = new RegExp(i[0] + "+", "g"), o = "", p = "";
571
+ if (((o = a < 0 ? k[0] : ""), h.length >= 2)) {
572
+ var q = h[1];
573
+ if (q) {
574
+ p = k[1];
575
+ for (var r = 0; r < q.length; r++)
576
+ p += i[+q[r]];
577
+ }
578
+ }
579
+ if (1 == g.length)
580
+ return o + i[e] + p;
581
+ if (g.length <= 5) {
582
+ for (var s = "", t = 0, e = g.length; e--;) {
583
+ var u = +g[t];
584
+ (s += this._num2CN(g[t], b) + (u && e ? j[e] : "")), t++;
585
+ }
586
+ return (s = s.replace(n, l)), (s = s.replace(m, "")), o + s + p;
587
+ }
588
+ for (var v = (g.length / 4) >> 0, w = g.length % 4, s = ""; 0 == w || !j[3 + v];)
589
+ (w += 4), v--;
590
+ if (+g.substr(0, w)) {
591
+ s = this._num2CN(g.substr(0, w), b) + j[3 + v];
592
+ var x = g.substr(w);
593
+ "0" === x[0] && (s += i[0]), (s += this._num2CN(x, b));
594
+ }
595
+ else
596
+ s = this._num2CN(g.substr(0, w), b) + this._num2CN(g.substr(w), b);
597
+ return (s = s.replace(n, l)), (s = s.replace(m, "")), o + s + p;
598
+ },
599
+ date2Str: function (a, b) {
600
+ if (!a)
601
+ return "";
602
+ var c = b.length, d = "";
603
+ if (c > 0) {
604
+ for (var e = b.charAt(0), f = 0, g = e, h = 1; h < c; h++) {
605
+ var i = b.charAt(h);
606
+ e !== i
607
+ ? ((d += this.Utils._compileDateFormat({
608
+ char: e,
609
+ str: g,
610
+ len: h - f,
611
+ }, a)),
612
+ (e = i),
613
+ (f = h),
614
+ (g = e))
615
+ : (g += i);
616
+ }
617
+ d += this.Utils._compileDateFormat({
618
+ char: e,
619
+ str: g,
620
+ len: c - f,
621
+ }, a);
622
+ }
623
+ return d;
624
+ },
625
+ _compileDateFormat: function (a, b) {
626
+ var c = a.str, d = a.len, e = a.char;
627
+ switch (e) {
628
+ case "E":
629
+ // c =
630
+ // d > 2
631
+ // ? Date._DN[b.getDay()]
632
+ // : d > 1
633
+ // ? Date._SDN[b.getDay()]
634
+ // : b.getDay() + "";
635
+ break;
636
+ case "y":
637
+ c = d <= 3 ? (b.getFullYear() + "").slice(2, 4) : b.getFullYear();
638
+ break;
639
+ case "M":
640
+ // c =
641
+ // d > 2
642
+ // ? Date._MN[b.getMonth()]
643
+ // : d < 2
644
+ // ? b.getMonth() + 1
645
+ // : this.Utils.leftPad(b.getMonth() + 1 + "", 2, "0");
646
+ break;
647
+ case "d":
648
+ c =
649
+ d > 1 ? this.Utils.leftPad(b.getDate() + "", 2, "0") : b.getDate();
650
+ break;
651
+ case "h":
652
+ var f = b.getHours() % 12;
653
+ 0 === f && (f = 12),
654
+ (c = d > 1 ? this.Utils.leftPad(f + "", 2, "0") : f);
655
+ break;
656
+ case "H":
657
+ c =
658
+ d > 1
659
+ ? this.Utils.leftPad(b.getHours() + "", 2, "0")
660
+ : b.getHours();
661
+ break;
662
+ case "m":
663
+ c =
664
+ d > 1
665
+ ? this.Utils.leftPad(b.getMinutes() + "", 2, "0")
666
+ : b.getMinutes();
667
+ break;
668
+ case "s":
669
+ c =
670
+ d > 1
671
+ ? this.Utils.leftPad(b.getSeconds() + "", 2, "0")
672
+ : b.getSeconds();
673
+ break;
674
+ case "a":
675
+ c = b.getHours() < 12 ? "am" : "pm";
676
+ break;
677
+ default:
678
+ c = a.str;
679
+ }
680
+ return c;
681
+ },
682
+ pick: function (a, b) {
683
+ var c = {};
684
+ return (this.Utils.forEach(b, function (b, d) {
685
+ d in a && (c[d] = a[d]);
686
+ }),
687
+ c);
688
+ },
689
+ applyFunc: function (a, b, c, d) {
690
+ return this.Utils.isFunction(b) ? b.apply(a, c ? c : []) : d;
691
+ },
692
+ forEach(a, b) {
693
+ if (Array.isArray(a))
694
+ for (var c = 0, d = a.length; c < d && b.apply(a[c], [c, a[c]]) !== !1; c++)
695
+ ;
696
+ else if (a && 'object' == typeof a)
697
+ for (var e in a)
698
+ if (a.hasOwnProperty(e) && b.apply(a[e], [e, a[e]]) === !1)
699
+ break;
700
+ },
701
+ flatten: function (a, b, c) {
702
+ if ((c || (c = []), a))
703
+ for (var d = 0, e = a.length; d < e; d++) {
704
+ var f = a[d];
705
+ Array.isArray(f)
706
+ ? this.Utils.flatten(f, b, c)
707
+ : (b && !b(f)) || c.push(f);
708
+ }
709
+ return c;
710
+ },
711
+ applyCss: function (a, b) {
712
+ this.Utils.isEmpty(b) ||
713
+ (this.Utils.isString(b) ? a.addClass(b) : a.css(b));
714
+ },
715
+ getServerDate: function (a) {
716
+ if (a && a.getResponseHeader) {
717
+ var b = a.getResponseHeader("date");
718
+ b &&
719
+ ((this.STATIC._st = new Date(b).getTime()),
720
+ (this.STATIC._ct = new Date().getTime()));
721
+ }
722
+ },
723
+ getUrlParameter: function (a) {
724
+ for (var b = window.location.search.substring(1), c = b.split("&"), d = 0; d < c.length; d++) {
725
+ var e = c[d].split("=");
726
+ if (e[0] == a)
727
+ return e[1];
728
+ }
729
+ return null;
730
+ },
731
+ validateEmail: function (a) {
732
+ return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(a);
733
+ },
734
+ redirectTo: function (a) {
735
+ window.location.href = a;
736
+ },
737
+ isCanvasSupported: function () {
738
+ var a = document.createElement("canvas");
739
+ return !(!a.getContext || !a.getContext("2d"));
740
+ },
741
+ isFormDataSupported: function () {
742
+ return void 0 !== window.FormData;
743
+ },
744
+ getFileDownloadURL: function (a, b, c) {
745
+ switch (a.bucket) {
746
+ case this.CONST.QN_BUCKET.PUBLIC_IMAGE:
747
+ var d = "", e = a.thumb;
748
+ return (e &&
749
+ (d =
750
+ "?imageView2/" + e.mode + "/w/" + e.width + "/h/" + e.height),
751
+ b(this.CONFIG.HOST.IMAGE_HOST + "/" + a.qnKey + d));
752
+ case this.CONST.OSS_BUCKET.PUBLIC_IMAGE:
753
+ return b(this.CONFIG.HOST.OSS_IMAGE_HOST + "/" + a.ossKey);
754
+ case this.CONST.QN_BUCKET.PRIVATE_FILE:
755
+ default:
756
+ return c();
757
+ }
758
+ },
759
+ evalFormula: function (a) {
760
+ var b = [];
761
+ this.Utils.forEach(Object.keys(this.Formula), function (a, c) {
762
+ b.push(`var ${c}=fml.Formula.${c}`);
763
+ });
764
+ var it = b.join(";") + ";";
765
+ var c = new Function(it + "return " + a)();
766
+ return c;
767
+ },
768
+ createEntryAttributeField: function (b, c) {
769
+ var d = {
770
+ id: c.entryId,
771
+ };
772
+ switch (b) {
773
+ case "ext":
774
+ this.extend(d, {
775
+ name: "ext",
776
+ type: "text",
777
+ text: "扩展字段",
778
+ items: c.extParams,
779
+ });
780
+ break;
781
+ case "createTime":
782
+ this.extend(d, {
783
+ name: "createTime",
784
+ type: "datetime",
785
+ format: "yyyy-MM-dd HH:mm:ss",
786
+ text: "提交时间",
787
+ });
788
+ break;
789
+ case "updateTime":
790
+ this.extend(d, {
791
+ name: "updateTime",
792
+ type: "datetime",
793
+ format: "yyyy-MM-dd HH:mm:ss",
794
+ text: "更新时间",
795
+ });
796
+ break;
797
+ case "creator":
798
+ this.extend(d, {
799
+ name: "creator",
800
+ type: "text",
801
+ text: "提交人",
802
+ });
803
+ break;
804
+ case "flowState":
805
+ this.extend(d, {
806
+ name: "flowState",
807
+ type: "flowState",
808
+ text: "流程状态",
809
+ });
810
+ break;
811
+ case "chargers":
812
+ this.extend(d, {
813
+ name: "chargers",
814
+ type: "chargers",
815
+ text: "当前节点/负责人",
816
+ });
817
+ break;
818
+ case "deleter":
819
+ this.extend(d, {
820
+ name: "deleter",
821
+ type: "text",
822
+ text: "删除人",
823
+ });
824
+ break;
825
+ case "deleteTime":
826
+ this.extend(d, {
827
+ name: "deleteTime",
828
+ type: "datetime",
829
+ format: "yyyy-MM-dd HH:mm:ss",
830
+ text: "删除时间",
831
+ });
832
+ break;
833
+ default:
834
+ return null;
835
+ }
836
+ return d;
837
+ },
838
+ createWidgetName: function () {
839
+ return "{" + this.STATIC.IDBase++;
840
+ },
841
+ formatFileSize: function (a) {
842
+ return this.Utils.isNumber(a)
843
+ ? a >= 1e9
844
+ ? (a / 1e9).toFixed(2) + " GB"
845
+ : a >= 1e6
846
+ ? (a / 1e6).toFixed(2) + " MB"
847
+ : (a / 1e3).toFixed(2) + " KB"
848
+ : "未知";
849
+ },
850
+ chunkArray: function (a, b) {
851
+ var c = [];
852
+ if (!b || !a.length)
853
+ return c;
854
+ for (var d = 0, e = a.length; d < e; d += b) {
855
+ var f = a.slice(d, d + b);
856
+ c.push(f);
857
+ }
858
+ return c;
859
+ },
860
+ UUID: function (a) {
861
+ return null;
862
+ },
863
+ GCD: function (a, b) {
864
+ return b ? this.GCD(b, a % b) : a;
865
+ },
866
+ LCM: function (a, b) {
867
+ return (a * b) / this.GCD(a, b);
868
+ },
869
+ fixDecimalPrecision: function (a, b) {
870
+ let c = null;
871
+ if ((b || (b = 8), !this.isEmpty(a))) {
872
+ let d = parseFloat(a);
873
+ if (!isNaN(d)) {
874
+ let e = (d + "").split(".")[1];
875
+ c == e && e.length > b ? parseFloat(d.toFixed(b)) : d,
876
+ b > 6 &&
877
+ Math.abs(c) < 1 &&
878
+ /e-/.test(c + "") &&
879
+ (c = parseFloat(d.toFixed(6)));
880
+ }
881
+ }
882
+ return c;
883
+ },
884
+ getSelectionText: function () {
885
+ // return window.getSelection
886
+ // ? window.getSelection().toString()
887
+ // : document.selection && document.selection.createRange
888
+ // ? document.selection.createRange().text
889
+ // : "";
890
+ return null;
891
+ },
892
+ getCorpType: function (a) {
893
+ return a
894
+ ? ((a = a.toLowerCase()),
895
+ /^ding/.test(a) ? "dingtalk" : /^w/.test(a) ? "wechat" : "internal")
896
+ : null;
897
+ },
898
+ isCorpSuiteAdmin: function (a) {
899
+ return a && ("dingtalk" === a || "wechat" === a);
900
+ },
901
+ getWeekStartDate: function (a) {
902
+ var b = a.getDay();
903
+ return (0 === b && (b = 7),
904
+ new Date(a.getFullYear(), a.getMonth(), a.getDate() - (b - 1)));
905
+ },
906
+ getWeekEndDate: function (a) {
907
+ var b = a.getDay();
908
+ return (0 === b && (b = 7),
909
+ new Date(a.getFullYear(), a.getMonth(), a.getDate() + (7 - b)));
910
+ },
911
+ getMonthStartDate: function (a) {
912
+ return new Date(a.getFullYear(), a.getMonth(), 1);
913
+ },
914
+ getMonthEndDate: function (a) {
915
+ return new Date(a.getFullYear(), a.getMonth() + 1, 0);
916
+ },
917
+ setPageTitle: function (a) {
918
+ this.Utils.isEmpty(a) || (document.title = a);
919
+ },
920
+ createMask: function (b, c) {
921
+ var d = this('<div class="x-window-mask"/>'), e = c || {};
922
+ if ((e.isModal && d.addClass("modal"),
923
+ e.isLight ? d.addClass("light") : e.isDark && d.addClass("dark"),
924
+ e.hasLoader)) {
925
+ var f = !e.isDark;
926
+ this.createLoadIcon(d, f);
927
+ }
928
+ return (b &&
929
+ d
930
+ .css({
931
+ "z-index": this.STATIC.zIndex++,
932
+ })
933
+ .appendTo(b),
934
+ d);
935
+ },
936
+ createLoadIcon: function (b, c) {
937
+ var d = this('<div class="x-loader-icon"/>').appendTo(b);
938
+ return c && d.addClass("colorful"), this("<div/>").appendTo(d), d;
939
+ },
940
+ doPrint: function (b, c) {
941
+ this("body").children("div").addClass("x-ui-notprint");
942
+ var d = this("#x-printer").removeClass().empty();
943
+ 0 === d.length && (d = this('<div id="x-printer"/>').appendTo("body")),
944
+ b && d.append(b),
945
+ (c = this.Utils.isNull(c) ? 0 : c),
946
+ setTimeout(function () {
947
+ window.print();
948
+ }, c);
949
+ },
950
+ cancelPrint: function () {
951
+ this("body").children(".x-ui-notprint").removeClass("x-ui-notprint"),
952
+ this("#x-printer").remove();
953
+ },
954
+ copyToClipboard: function (a, b) {
955
+ if (a && a.length) {
956
+ var c = document.createElement("textarea");
957
+ (c.style.background = "transparent"),
958
+ (c.style.color = "transparent"),
959
+ (c.value = a),
960
+ document.body.appendChild(c),
961
+ c.select();
962
+ var d;
963
+ try {
964
+ d = document.execCommand("copy");
965
+ }
966
+ catch (a) {
967
+ d = !1;
968
+ }
969
+ document.body.removeChild(c),
970
+ d && this.Utils.applyFunc(this, b, [], !1);
971
+ }
972
+ },
973
+ getColorNumber: function (a) {
974
+ return this.Utils.isEmpty(a)
975
+ ? 1
976
+ : (parseInt(a.toString().substring(0, 8), 16) % 6) + 1;
977
+ },
978
+ getFieldAttr: function (b, c) {
979
+ if (!this.Utils.isValueWidget(b.widget.type))
980
+ return null;
981
+ if (c && c.indexOf(b.widget.type) < 0)
982
+ return null;
983
+ var d = {
984
+ id: b.formId,
985
+ text: b.label,
986
+ name: b.widget.widgetName,
987
+ type: b.widget.type,
988
+ };
989
+ switch (b.widget.type) {
990
+ case "subform":
991
+ var e = [];
992
+ this.Utils.forEach(b.widget.items, function (d, f) {
993
+ this.extend(f, {
994
+ formId: b.formId,
995
+ });
996
+ var g = this.Utils.getFieldAttr(f, c);
997
+ g &&
998
+ (this.extend(g, {
999
+ subform: b.widget.widgetName,
1000
+ }),
1001
+ e.push(g));
1002
+ }),
1003
+ this.extend(d, {
1004
+ items: e,
1005
+ });
1006
+ break;
1007
+ case "linkdata":
1008
+ this.extend(d, {
1009
+ linkForm: b.widget.linkForm,
1010
+ linkFields: b.widget.linkFields,
1011
+ refAppId: b.widget.refAppId,
1012
+ });
1013
+ break;
1014
+ case "combo":
1015
+ case "combocheck":
1016
+ case "radiogroup":
1017
+ case "checkboxgroup":
1018
+ this.extend(d, {
1019
+ async: b.widget.async,
1020
+ items: b.widget.items,
1021
+ });
1022
+ break;
1023
+ case "datetime":
1024
+ this.extend(d, {
1025
+ format: b.widget.format,
1026
+ });
1027
+ }
1028
+ return d;
1029
+ },
1030
+ leftPad: function (a, b, c) {
1031
+ var d = String(a);
1032
+ for (c || (c = " "); d.length < b;)
1033
+ d = c + d;
1034
+ return d.toString();
1035
+ },
1036
+ startWith: function (a, b) {
1037
+ var c = a.length;
1038
+ return (!(null == b || "" == b || 0 === c || b.length > c) &&
1039
+ a.substr(0, b.length) == b);
1040
+ },
1041
+ getFieldInfoByFormula: function (a) {
1042
+ var b = {}, c = a + "", d = c.match(/(\$[0-9a-zA-Z\._]+)(#[0-9a-f]+)?(@[0-9a-f]+)?/), e = ["", "field", "entryId", "appId"];
1043
+ return (this.Utils.forEach(d, function (a, c) {
1044
+ 0 !== a && c && (b[e[a]] = c.substr(1));
1045
+ }),
1046
+ b);
1047
+ },
1048
+ getFieldInfoById: function (a) {
1049
+ var b = {};
1050
+ a = "#" + a;
1051
+ var c = a.match(/(#[0-9a-f]+)(@[0-9a-f]+)?/), d = ["", "entryId", "appId"];
1052
+ return (this.Utils.forEach(c, function (a, c) {
1053
+ 0 !== a && c && (b[d[a]] = c.substr(1));
1054
+ }),
1055
+ b);
1056
+ },
1057
+ isWpsWebView: function () {
1058
+ return /wpscloudform/.test(navigator.userAgent);
1059
+ },
1060
+ callWPSAPI: function (a) {
1061
+ // var b = "jsAsynCall(" + JSON.stringify(a) + ")";
1062
+ // window.cefQuery &&
1063
+ // window.cefQuery({
1064
+ // request: b,
1065
+ // });
1066
+ },
1067
+ onWPSPageUnload: function (a, b) {
1068
+ a
1069
+ ? this.Msg.alert({
1070
+ type: "warning",
1071
+ msg: "当前页面未保存,是否确定离开?",
1072
+ text4Ok: "离开",
1073
+ text4Cancel: "取消",
1074
+ onOk: function () {
1075
+ this.Utils.applyFunc(this, b, [], !1);
1076
+ },
1077
+ })
1078
+ : this.Utils.applyFunc(this, b, [], !1);
1079
+ },
1080
+ fileDownload: function (a, b) {
1081
+ // if (this.Utils.isWpsWebView()) {
1082
+ // var c = {
1083
+ // method: "downloadUrl",
1084
+ // url: a,
1085
+ // filename: b,
1086
+ // },
1087
+ // d = b && b.split(".").pop();
1088
+ // (c.filter = "(*." + (d || "*") + ")"), fml.Utils.callWPSAPI(c);
1089
+ // } else fml.Utils.redirectTo(a);
1090
+ },
1091
+ isSupportPdf: function () {
1092
+ return "undefined" != typeof navigator.mimeTypes["application/pdf"];
1093
+ },
1094
+ dt: function (a, b) {
1095
+ if (a) {
1096
+ var c = ["e=" + a, "t=" + new Date().getTime()];
1097
+ this.Utils.isEmpty(b) || c.push("ext=" + b),
1098
+ this.STATIC.user &&
1099
+ this.STATIC.user.username &&
1100
+ c.push("u=" + this.STATIC.user.username);
1101
+ var d = new Image();
1102
+ d.src = this.CONFIG.HOST.TRACK_HOST + "/log?" + c.join("&");
1103
+ }
1104
+ },
1105
+ };
1106
+ this.Formula = {
1107
+ AND: function () {
1108
+ for (var a = this.Utils.flatten(arguments), b = 0, c = a.length; b < c; b++)
1109
+ if (!a[b])
1110
+ return !1;
1111
+ return !0;
1112
+ },
1113
+ OR: function () {
1114
+ for (var a = this.Utils.flatten(arguments), b = 0, c = a.length; b < c; b++)
1115
+ if (a[b])
1116
+ return !0;
1117
+ return !1;
1118
+ },
1119
+ FALSE: function () {
1120
+ return !1;
1121
+ },
1122
+ TRUE: function () {
1123
+ return !0;
1124
+ },
1125
+ IF: function (a, b, c) {
1126
+ return a ? b : c;
1127
+ },
1128
+ NOT: function (a) {
1129
+ return !a;
1130
+ },
1131
+ XOR: function () {
1132
+ for (var a = 0, b = this.Utils.flatten(arguments), c = 0, d = b.length; c < d; c++)
1133
+ b[c] && a++;
1134
+ return !!(1 & Math.floor(Math.abs(a)));
1135
+ },
1136
+ CONCATENATE: function () {
1137
+ for (var a = this.Utils.flatten(arguments), b = 0; (b = a.indexOf(!0)) > -1;)
1138
+ a[b] = "TRUE";
1139
+ for (var c = 0; (c = a.indexOf(!1)) > -1;)
1140
+ a[c] = "FALSE";
1141
+ return a.join("");
1142
+ },
1143
+ EXACT: function (a, b) {
1144
+ return a === b;
1145
+ },
1146
+ LEFT: function (a, b) {
1147
+ return (b = this.Utils.isEmpty(b) ? 1 : b), a ? a.substring(0, b) : "";
1148
+ },
1149
+ LEN: function (a) {
1150
+ return this.Utils.isString(a)
1151
+ ? a
1152
+ ? a.length
1153
+ : 0
1154
+ : a && a.length
1155
+ ? a.length
1156
+ : 0;
1157
+ },
1158
+ SUBSTRING: function (a, b, c) {
1159
+ return ((a = a || ""),
1160
+ this.Utils.isNumber(b) && this.Utils.isNumber(c)
1161
+ ? a.substr(b - 1, c)
1162
+ : a);
1163
+ },
1164
+ LOWER: function (a) {
1165
+ return this.Utils.isString(a) ? (a ? a.toLowerCase() : a) : "";
1166
+ },
1167
+ REPLACE: function (a, b, c, d) {
1168
+ return this.Utils.isNumber(b) && this.Utils.isNumber(c)
1169
+ ? ((a = a || ""),
1170
+ (d = d || ""),
1171
+ a.substr(0, b - 1) + d + a.substr(b - 1 + c))
1172
+ : a;
1173
+ },
1174
+ REPT: function (a, b) {
1175
+ return (b = b || 0), new Array(b + 1).join(a);
1176
+ },
1177
+ RIGHT: function (a, b) {
1178
+ return (b = void 0 === b ? 1 : b), a ? a.substring(a.length - b) : "";
1179
+ },
1180
+ SEARCH: function (a, b, c) {
1181
+ var d;
1182
+ return this.Utils.isString(a) && this.Utils.isString(b)
1183
+ ? ((c = this.Utils.isNull(c) ? 0 : c),
1184
+ (d = b.toLowerCase().indexOf(a.toLowerCase(), c - 1) + 1))
1185
+ : 0;
1186
+ },
1187
+ SPLIT: function (a, b) {
1188
+ return this.Utils.isString(a) ? a.split(b) : [];
1189
+ },
1190
+ TRIM: function (a) {
1191
+ return this.Utils.isString(a) ? a.replace(/ +/g, " ").trim() : "";
1192
+ },
1193
+ UPPER: function (a) {
1194
+ return this.Utils.isString(a) ? a.toUpperCase() : "";
1195
+ },
1196
+ MID: function (a, b, c) {
1197
+ return ((a = a || ""),
1198
+ this.Utils.isNumber(b) && this.Utils.isNumber(c)
1199
+ ? a.substr(b - 1, c)
1200
+ : a);
1201
+ },
1202
+ AVERAGE: function () {
1203
+ for (var a = this.Utils.flatten(arguments, function (a) {
1204
+ return this.Utils.isNumber(a);
1205
+ }), b = a.length, c = 0, d = 0, e = 0; e < b; e++)
1206
+ (c += a[e]), (d += 1);
1207
+ return c / d;
1208
+ },
1209
+ COUNT: function () {
1210
+ return this.Utils.flatten(arguments).length;
1211
+ },
1212
+ COUNTIF: function () {
1213
+ var arr = arguments[0], condition = arguments[1];
1214
+ var len = 0;
1215
+ if (condition.indexOf(">") == -1 &&
1216
+ condition.indexOf("=") == -1 &&
1217
+ condition.indexOf("<") == -1) {
1218
+ for (var i = 0; i < arr.length; i++) {
1219
+ var a = arr[i];
1220
+ if (a == condition) {
1221
+ len++;
1222
+ }
1223
+ }
1224
+ return len;
1225
+ }
1226
+ else {
1227
+ for (var i = 0; i < arr.length; i++) {
1228
+ var a = arr[i];
1229
+ if (typeof a == "number" &&
1230
+ !!new Function("return " + a + condition)()) {
1231
+ len++;
1232
+ }
1233
+ }
1234
+ return len;
1235
+ }
1236
+ },
1237
+ LARGE: function (a, b) {
1238
+ return ((a = this.Utils.flatten(a, function (a) {
1239
+ return this.Utils.isNumber(a);
1240
+ })),
1241
+ a.sort(function (a, b) {
1242
+ return b - a;
1243
+ })[b - 1]);
1244
+ },
1245
+ MAX: function () {
1246
+ var a = this.Utils.flatten(arguments, function (a) {
1247
+ return this.Utils.isNumber(a);
1248
+ });
1249
+ return 0 === a.length ? 0 : Math.max.apply(Math, a);
1250
+ },
1251
+ MIN: function () {
1252
+ var a = this.Utils.flatten(arguments, function (a) {
1253
+ return this.Utils.isNumber(a);
1254
+ });
1255
+ return 0 === a.length ? 0 : Math.min.apply(Math, a);
1256
+ },
1257
+ SMALL: function (a, b) {
1258
+ return ((a = this.Utils.flatten(a, function (a) {
1259
+ return this.Utils.isNumber(a);
1260
+ })),
1261
+ a.sort(function (a, b) {
1262
+ return a - b;
1263
+ })[b - 1]);
1264
+ },
1265
+ ABS: function (a) {
1266
+ return this.Utils.isNumber(a) ? Math.abs(a) : 0;
1267
+ },
1268
+ ROUND: function (a, b) {
1269
+ return Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
1270
+ },
1271
+ CEILING: function (a, b) {
1272
+ if (0 === b)
1273
+ return 0;
1274
+ var c = b < 0 ? -1 : 0;
1275
+ b = Math.abs(b);
1276
+ var d = b - Math.floor(b), e = 0;
1277
+ return (d > 0 && (e = -Math.floor(Math.log(d) / Math.log(10))),
1278
+ a >= 0
1279
+ ? this.Formula.ROUND(Math.ceil(a / b) * b, e)
1280
+ : 0 === c
1281
+ ? -this.Formula.ROUND(Math.floor(Math.abs(a) / b) * b, e)
1282
+ : -this.Formula.ROUND(Math.ceil(Math.abs(a) / b) * b, e));
1283
+ },
1284
+ FLOOR: function (a, b) {
1285
+ if (0 === b)
1286
+ return 0;
1287
+ if (!((a > 0 && b > 0) || (a < 0 && b < 0)))
1288
+ return 0;
1289
+ b = Math.abs(b);
1290
+ var c = b - Math.floor(b), d = 0;
1291
+ return (c > 0 && (d = -Math.floor(Math.log(c) / Math.log(10))),
1292
+ a >= 0
1293
+ ? this.Formula.ROUND(Math.floor(a / b) * b, d)
1294
+ : -this.Formula.ROUND(Math.floor(Math.abs(a) / b) * b, d));
1295
+ },
1296
+ INT: function (a) {
1297
+ return this.Utils.isNumber(a) ? Math.floor(a) : 0;
1298
+ },
1299
+ LOG: function (a, b) {
1300
+ return ((b = void 0 === b ? 10 : b),
1301
+ this.Utils.isNumber(b) ? Math.log(a) / Math.log(b) : 0);
1302
+ },
1303
+ MOD: function (a, b) {
1304
+ if (0 === b)
1305
+ return 0;
1306
+ var c = Math.abs(a % b);
1307
+ return b > 0 ? c : -c;
1308
+ },
1309
+ POWER: function (a, b) {
1310
+ var c = Math.pow(a, b);
1311
+ return isNaN(c) ? 0 : c;
1312
+ },
1313
+ PRODUCT: function () {
1314
+ for (var a = this.Utils.flatten(arguments, function (a) {
1315
+ return this.Utils.isNumber(a);
1316
+ }), b = 1, c = 0; c < a.length; c++)
1317
+ b *= a[c];
1318
+ return b;
1319
+ },
1320
+ SQRT: function (a) {
1321
+ return a < 0 ? 0 : Math.sqrt(a);
1322
+ },
1323
+ SUM: function () {
1324
+ for (var a = 0, b = this.Utils.flatten(arguments, function (a) {
1325
+ return this.Utils.isNumber(a);
1326
+ }), c = 0, d = b.length; c < d; ++c)
1327
+ a += b[c];
1328
+ return a;
1329
+ },
1330
+ SUMPRODUCT: function () {
1331
+ for (var a = 0, b = [], c = -1, d = 0; d < arguments.length; d++)
1332
+ arguments[d] instanceof Array &&
1333
+ ((c = c < 0 ? arguments[d].length : Math.min(arguments[d].length, c)),
1334
+ b.push(arguments[d]));
1335
+ for (var e, f, g, h = 0; h < c; h++) {
1336
+ for (e = 1, f = 0; f < b.length; f++)
1337
+ (g = parseFloat(b[f][h])), isNaN(g) && (g = 0), (e *= g);
1338
+ a += e;
1339
+ }
1340
+ return a;
1341
+ },
1342
+ FIXED: function (a, b) {
1343
+ return ((b = void 0 === b ? 0 : b),
1344
+ this.Utils.isNumber(b) && b >= 0 ? Number(a).toFixed(b) : "");
1345
+ },
1346
+ DATE: function () {
1347
+ return 6 === arguments.length
1348
+ ? new Date(parseInt(arguments[0], 10), parseInt(arguments[1], 10) - 1, parseInt(arguments[2], 10), parseInt(arguments[3], 10), parseInt(arguments[4], 10), parseInt(arguments[5], 10))
1349
+ : 3 === arguments.length
1350
+ ? new Date(parseInt(arguments[0], 10), parseInt(arguments[1], 10) - 1, parseInt(arguments[2], 10))
1351
+ : new Date(arguments[0]);
1352
+ },
1353
+ TIME: function (a, b, c) {
1354
+ return (3600 * a + 60 * b + c) / 86400;
1355
+ },
1356
+ TIMESTAMP: function (a) {
1357
+ return this.Utils.isDate(a) ? a.getTime() : 0;
1358
+ },
1359
+ TODAY: function () {
1360
+ return new Date();
1361
+ },
1362
+ NOW: function () {
1363
+ return new Date();
1364
+ },
1365
+ SYSTIME: function () {
1366
+ var a = this.STATIC._st, b = new Date().getTime() - this.STATIC._ct;
1367
+ return b > 0 && b < 36e5 && (a += b), new Date(a);
1368
+ },
1369
+ DAY: function (a) {
1370
+ return a.getDate();
1371
+ },
1372
+ MONTH: function (a) {
1373
+ return a.getMonth() + 1;
1374
+ },
1375
+ YEAR: function (a) {
1376
+ return a.getFullYear();
1377
+ },
1378
+ HOUR: function (a) {
1379
+ return a.getHours();
1380
+ },
1381
+ MINUTE: function (a) {
1382
+ return a.getMinutes();
1383
+ },
1384
+ SECOND: function (a) {
1385
+ return a.getSeconds();
1386
+ },
1387
+ DAYS: function (a, b) {
1388
+ var c = new Date(a.getFullYear(), a.getMonth(), a.getDate()), d = new Date(b.getFullYear(), b.getMonth(), b.getDate());
1389
+ return null; //(c - d) / 864e5
1390
+ },
1391
+ DATEMINUS: function (a, b, c) {
1392
+ var d, e, f = b.getMonth(), g = a.getMonth();
1393
+ if (c)
1394
+ (d = 31 === b.getDate() ? 30 : b.getDate()),
1395
+ (e = 31 === a.getDate() ? 30 : a.getDate());
1396
+ else {
1397
+ var h = new Date(b.getFullYear(), f + 1, 0).getDate(), i = new Date(a.getFullYear(), g + 1, 0).getDate();
1398
+ (d = b.getDate() === h ? 30 : b.getDate()),
1399
+ a.getDate() === i
1400
+ ? d < 30
1401
+ ? (g++, (e = 1))
1402
+ : (e = 30)
1403
+ : (e = a.getDate());
1404
+ }
1405
+ return 360 * (a.getFullYear() - b.getFullYear()) + 30 * (g - f) + (e - d);
1406
+ },
1407
+ DATEDELTA: function (a, b) {
1408
+ return (this.Utils.isNumber(b) || (b = 0), new Date(a.getTime() + 864e5 * b));
1409
+ },
1410
+ ISOWEEKNUM: function (a) {
1411
+ a.setHours(0, 0, 0), a.setDate(a.getDate() + 4 - (a.getDay() || 7));
1412
+ var b = new Date(a.getFullYear(), 0, 1);
1413
+ //return Math.ceil(((a - b) / 864e5 + 1) / 7);
1414
+ return null;
1415
+ },
1416
+ WEEKNUM: function (a, b) {
1417
+ var c = 2 === b ? 1 : 0, d = new Date(a.getFullYear(), 0, 1), e = (c + 7 - d.getDay()) % 7, f = e > 0 ? 1 : 0, g = d.getTime() + 24 * e * 60 * 60 * 1e3;
1418
+ return Math.floor((a.getTime() - g) / 864e5 / 7 + 1) + f;
1419
+ },
1420
+ STRDATE: function (a) {
1421
+ return a.getFullYear() + "-" + a.getMonth() + 1 + '-' + a.getDate();
1422
+ },
1423
+ TEXT: function (a, b) {
1424
+ return this.Utils.isNull(a)
1425
+ ? ""
1426
+ : this.Utils.isDate(a) && !this.Utils.isEmpty(b)
1427
+ ? this.Utils.date2Str(a, b)
1428
+ : this.Utils.num2Str(a, b);
1429
+ },
1430
+ VALUE: function (a) {
1431
+ return this.Utils.isEmpty(a) ? 0 : isNaN(a) ? 0 : parseFloat(a);
1432
+ },
1433
+ UUID: function () {
1434
+ return this.Utils.UUID();
1435
+ },
1436
+ RECNO: function () {
1437
+ //需修改
1438
+ // return this.Utils.isNull(this.STATIC.EntryRecNo) ? this.STATIC.APPID && this.STATIC.ENTRYID ? (this.Utils.dataAjax({
1439
+ // url: "/data/formula/recno",
1440
+ // async: !1,
1441
+ // data: {
1442
+ // appId: fml.STATIC.APPID,
1443
+ // formId: fml.STATIC.ENTRYID,
1444
+ // hasIncLock: fml.STATIC.RecnoLock
1445
+ // }
1446
+ // }, function (a) {
1447
+ // fml.STATIC.EntryRecNo = a.incId
1448
+ // }), fml.STATIC.EntryRecNo) : "" : fml.STATIC.EntryRecNo
1449
+ return null;
1450
+ },
1451
+ ISEMPTY: function (a) {
1452
+ return this.Utils.isObjectEmpty(a);
1453
+ },
1454
+ MAPX: function (a, b, c, d) {
1455
+ var e = null;
1456
+ if (this.Utils.isEmpty(a) || this.Utils.isObjectEmpty(b))
1457
+ return e;
1458
+ // a = a.toLowerCase();
1459
+ // var f = this.Utils.getFieldInfoByFormula(c),
1460
+ // g = this.Utils.getFieldInfoByFormula(d);
1461
+ // if (/^sum|avg|max|min|count|first|last$/.test(a) && f.entryId && f.entryId === g.entryId) {
1462
+ // var h = this.Utils.isDate(b),
1463
+ // i = h ? b.getTime() : b;
1464
+ // fml.Utils.dataAjax({
1465
+ // url: "/data/formula/aggregate",
1466
+ // async: !1,
1467
+ // data: {
1468
+ // op: a,
1469
+ // formId: f.entryId,
1470
+ // lookup_value: i,
1471
+ // lookup_field: f.field,
1472
+ // result_field: g.field,
1473
+ // date_type: h,
1474
+ // refAppId: f.appId
1475
+ // }
1476
+ // }, function (a) {
1477
+ // a.result && a.result[0] && (e = a.result[0].result)
1478
+ // })
1479
+ // }
1480
+ return e;
1481
+ },
1482
+ MAP: function (a, b, c) {
1483
+ // var d = [];
1484
+ // if (fml.Utils.isObjectEmpty(a))
1485
+ // return d;
1486
+ // var e = fml.Utils.getFieldInfoByFormula(b),
1487
+ // f = fml.Utils.getFieldInfoByFormula(c);
1488
+ // return e.entryId && e.entryId === f.entryId && fml.Utils.dataAjax({
1489
+ // url: "/data/formula/map",
1490
+ // async: !1,
1491
+ // data: {
1492
+ // formId: e.entryId,
1493
+ // lookup_value: a,
1494
+ // lookup_field: e.field,
1495
+ // result_field: f.field,
1496
+ // refAppId: e.appId
1497
+ // }
1498
+ // }, function (a) {
1499
+ // fml.Utils.forEach(a.result, function (a, b) {
1500
+ // d.push(b[f.field])
1501
+ // })
1502
+ // }, function () {}),
1503
+ // d
1504
+ return [];
1505
+ },
1506
+ GETUSERNAME: function () {
1507
+ //需修改
1508
+ return this.STATIC.user ? this.STATIC.user.nickname : "";
1509
+ },
1510
+ };
1511
+ }
1512
+ }
1513
+
1514
+ /**
1515
+ * 根据关键字匹配变量
1516
+ * @param key
1517
+ * @param fieldVariable
1518
+ */
1519
+ function searchVariable(key, fieldVariable) {
1520
+ let result = [];
1521
+ if (key != null && key !== "") {
1522
+ if (fieldVariable.formFields &&
1523
+ fieldVariable.formFields !== null &&
1524
+ fieldVariable.formFields.length > 0) {
1525
+ fieldVariable.formFields.forEach((item) => {
1526
+ if (item.label.indexOf(key) > -1) {
1527
+ result.push(item);
1528
+ }
1529
+ });
1530
+ }
1531
+ if (fieldVariable.tableList &&
1532
+ fieldVariable.tableList !== null &&
1533
+ fieldVariable.tableList.length > 0) {
1534
+ fieldVariable.tableList.forEach((table) => {
1535
+ table.fields.forEach((item) => {
1536
+ if (item.label.indexOf(key) > -1) {
1537
+ result.push(item);
1538
+ }
1539
+ });
1540
+ });
1541
+ }
1542
+ }
1543
+ return result;
1544
+ }
1545
+ /**
1546
+ * 根据关键字匹配变量 fieldVariable 为数组
1547
+ * @param key
1548
+ * @param fieldVariable
1549
+ */
1550
+ function searchArrayVariable(key, groupArray) {
1551
+ let result = [];
1552
+ groupArray.map((group) => {
1553
+ const tableList = searchVariable(key, group);
1554
+ if (tableList.length > 0) {
1555
+ result = [...result, ...tableList];
1556
+ }
1557
+ });
1558
+ return result;
1559
+ }
1560
+ /**
1561
+ * 根据关键字匹配函数
1562
+ * @param key
1563
+ */
1564
+ function searchUsageFun(key, formulaUsage) {
1565
+ let result = [];
1566
+ if (key != null && key !== "") {
1567
+ let fml = new Formula();
1568
+ formulaUsage.forEach((usage) => {
1569
+ usage.contains.forEach((item) => {
1570
+ if (item.name.toUpperCase().indexOf(key.toUpperCase()) > -1) {
1571
+ result.push(item);
1572
+ }
1573
+ });
1574
+ });
1575
+ }
1576
+ return result;
1577
+ }
1578
+
1579
+ class GramCodemirrorComponent {
1580
+ _differs;
1581
+ _ngZone;
1582
+ el;
1583
+ message;
1584
+ nzConfigService;
1585
+ fmlService;
1586
+ itemTitle = {};
1587
+ set options(value) {
1588
+ if (value) {
1589
+ this._options = value;
1590
+ if (!this._differ && value) {
1591
+ this._differ = this._differs.find(value).create();
1592
+ }
1593
+ }
1594
+ }
1595
+ /**
1596
+ * 可用变量对象
1597
+ * {
1598
+ * formFields:[],tableList:[]
1599
+ * }
1600
+ */
1601
+ set fieldData(value) {
1602
+ this._fieldData = value;
1603
+ if (Array.isArray(value) && value.length > 0) {
1604
+ value.forEach((t) => {
1605
+ if (Array.isArray(t.listField) && t.listField.length > 0) {
1606
+ t.listField.forEach((f) => {
1607
+ this.labelMap['$' + `{${f.key}}`] = f.label;
1608
+ });
1609
+ }
1610
+ });
1611
+ }
1612
+ }
1613
+ get fieldData() {
1614
+ return this._fieldData;
1615
+ }
1616
+ /**
1617
+ * 黑名单 值为函数名数组
1618
+ */
1619
+ blacklist;
1620
+ /**
1621
+ * 启用默认黑名单
1622
+ * 默认黑名单与blackList合并
1623
+ */
1624
+ enableDefaultBlack = true;
1625
+ /**
1626
+ * 显示的公式 值显示列表内指定公式
1627
+ */
1628
+ showList;
1629
+ get dateType() {
1630
+ const t = Array.isArray(this.fieldData);
1631
+ return t ? "array" : "object";
1632
+ }
1633
+ set variableSearch(value) {
1634
+ let variableSearchList;
1635
+ if ("array" === this.dateType) {
1636
+ variableSearchList = searchArrayVariable(value, this.fieldData);
1637
+ }
1638
+ else {
1639
+ variableSearchList = searchVariable(value, this.fieldData);
1640
+ }
1641
+ this.variableSearchList = variableSearchList;
1642
+ this._variableSearch = value;
1643
+ }
1644
+ get variableSearch() {
1645
+ return this._variableSearch;
1646
+ }
1647
+ set usageFunSearch(value) {
1648
+ // TODO 只显示当前公式编辑器支持的函数
1649
+ this.usageFunSearchList = searchUsageFun(value, this.FormulaUsage);
1650
+ this._usageFunSearch = value;
1651
+ }
1652
+ get usageFunSearch() {
1653
+ return this._usageFunSearch;
1654
+ }
1655
+ /**
1656
+ * 所有支持函数分组信息
1657
+ * name 分组名称 string
1658
+ * code 分组code string
1659
+ * items 函数名集合 string[]
1660
+ */
1661
+ get globalCategorys() {
1662
+ var info = [];
1663
+ _.forEach(this.fml.FormulaUsage, function (item) {
1664
+ info.push({
1665
+ // name 分组名称 string
1666
+ name: item.category,
1667
+ // code 分组code string
1668
+ code: item.categoryCode,
1669
+ // items 函数名集合 string[]
1670
+ items: _.flatMap(item.contains, function (c) {
1671
+ return c.name;
1672
+ }),
1673
+ });
1674
+ });
1675
+ return info;
1676
+ }
1677
+ /**
1678
+ * 获取全局CodeMirror
1679
+ */
1680
+ get codeMirrorGlobal() {
1681
+ if (this._codeMirror) {
1682
+ return this._codeMirror;
1683
+ }
1684
+ this._codeMirror =
1685
+ typeof CodeMirror !== "undefined" ? CodeMirror : require("codemirror");
1686
+ return this._codeMirror;
1687
+ }
1688
+ // fml = new Formula();
1689
+ name = "codemirror";
1690
+ title = "";
1691
+ autoFocus = false;
1692
+ /**
1693
+ * 函数显示类型
1694
+ * 班次 attendance 所有 // attendance-items 精度 进位规则
1695
+ *
1696
+ * 与categorys互斥,有type时使用type
1697
+ */
1698
+ type = "";
1699
+ /**
1700
+ * 显示的函数组
1701
+ * 与type 互斥,如果type有值,当前参数无效。
1702
+ */
1703
+ categorys;
1704
+ /**
1705
+ * 自定义公式
1706
+ */
1707
+ formulaClass;
1708
+ typeList = {
1709
+ "attendance-items": [
1710
+ "MANHOURS",
1711
+ "CalendarDay",
1712
+ "PRECISION",
1713
+ "DepartmentScope",
1714
+ "AND",
1715
+ "OR",
1716
+ "IF",
1717
+ "IN",
1718
+ "AttendanceType",
1719
+ "MinusSupport",
1720
+ ],
1721
+ Daycalculation: [
1722
+ "Daycalculation",
1723
+ "Hourcalculation",
1724
+ "SUM",
1725
+ "Daycompute",
1726
+ "PositionHeadcount",
1727
+ ],
1728
+ };
1729
+ preserveScrollPosition = false;
1730
+ labelMap = {};
1731
+ _fieldData = null;
1732
+ cursorActivity = new EventEmitter();
1733
+ focusChange = new EventEmitter();
1734
+ scroll = new EventEmitter();
1735
+ drop = new EventEmitter();
1736
+ textChange = new EventEmitter();
1737
+ ref;
1738
+ fml;
1739
+ value = "";
1740
+ disabled = false;
1741
+ isFocused = false;
1742
+ codeMirror;
1743
+ /**
1744
+ * 存放匹配的变量集合
1745
+ */
1746
+ variableSearchList = [];
1747
+ /**
1748
+ * 存放匹配的函数集合
1749
+ */
1750
+ usageFunSearchList = [];
1751
+ FormulaUsage = [];
1752
+ /**
1753
+ * 查询可用变量
1754
+ */
1755
+ _variableSearch = null;
1756
+ /**
1757
+ * 查询可用函数
1758
+ */
1759
+ _usageFunSearch = null;
1760
+ /**
1761
+ * 函数描述
1762
+ */
1763
+ usageDescription = `
1764
+ <ul class="intro-wrapper default">
1765
+ <li>从左侧面板选择字段名和函数,或输入函数</li>
1766
+ <li>公式编辑举例:
1767
+ <span class="formula-name">AVERAGE</span>
1768
+ (
1769
+ <span class="formula-field">语文成绩</span>
1770
+ ,
1771
+ <span class="formula-field">数学成绩</span>
1772
+ )
1773
+ </li>
1774
+ </ul>
1775
+ `;
1776
+ _codeMirror;
1777
+ _differ;
1778
+ _options = {
1779
+ autoCloseBrackets: true,
1780
+ keywords: [],
1781
+ textWrapping: true,
1782
+ lineWrapping: true,
1783
+ lineNumbers: false,
1784
+ matchBrackets: true,
1785
+ specialChars: /[\u0000-\u001f\u007f\u00ad\u200c-\u200f\u2028\u2029\ufeff]/,
1786
+ mode: "text/fx-formula",
1787
+ labelMap: null,
1788
+ };
1789
+ _fomulaContext;
1790
+ /**
1791
+ * 默认公式
1792
+ */
1793
+ defaultFml;
1794
+ constructor(_differs, _ngZone, el, message, nzConfigService, fmlService) {
1795
+ this._differs = _differs;
1796
+ this._ngZone = _ngZone;
1797
+ this.el = el;
1798
+ this.message = message;
1799
+ this.nzConfigService = nzConfigService;
1800
+ this.fmlService = fmlService;
1801
+ this.defaultFml = _.cloneDeep({
1802
+ FormulaUsage: fmlService.FormulaUsage,
1803
+ Formula: fmlService.Formula,
1804
+ });
1805
+ this.fml = fmlService;
1806
+ }
1807
+ ngOnInit() {
1808
+ this.nzConfigService.set("message", {
1809
+ nzMaxStack: 1,
1810
+ nzAnimate: false,
1811
+ });
1812
+ }
1813
+ /**
1814
+ * 根据黑名单过滤公式
1815
+ */
1816
+ filterUsageByBlackList(formulaUsage) {
1817
+ let FormulaUsageList = [];
1818
+ formulaUsage.forEach((el) => {
1819
+ el.contains.forEach((formula) => {
1820
+ // 黑名单列表内的Index。
1821
+ const blackIndex = _.indexOf(this.blacklist, formula.name);
1822
+ if (blackIndex < 0) {
1823
+ if (FormulaUsageList.findIndex((ele) => ele.category === el.category) >
1824
+ -1) {
1825
+ let index = FormulaUsageList.findIndex((ele) => ele.category === el.category);
1826
+ FormulaUsageList[index].contains.push(formula);
1827
+ }
1828
+ else {
1829
+ let item = {
1830
+ category: el.category,
1831
+ contains: [],
1832
+ };
1833
+ item.contains.push(formula);
1834
+ FormulaUsageList.push(item);
1835
+ }
1836
+ }
1837
+ });
1838
+ });
1839
+ return FormulaUsageList;
1840
+ }
1841
+ /**
1842
+ * 组装显示的函数
1843
+ */
1844
+ resolveDisplayFormula() {
1845
+ let displayFormula = [];
1846
+ if (this.showList) {
1847
+ return _.cloneDeep(this.showList);
1848
+ }
1849
+ if (this.type && !_.isEmpty(this.type)) {
1850
+ displayFormula = this.typeList[this.type];
1851
+ return displayFormula || [];
1852
+ }
1853
+ /**
1854
+ * this.categorys 显示的函数组
1855
+ * 与this.type 互斥,this.type优先级最高。
1856
+ */
1857
+ if (this.categorys && Array.isArray(this.categorys)) {
1858
+ // 显示函数组数组转对象
1859
+ const displayCategory = _.keyBy(this.categorys, function (o) {
1860
+ return o;
1861
+ });
1862
+ // 过滤出需显示的函数
1863
+ this.globalCategorys.map((c) => {
1864
+ if (c.items && displayCategory[c.code]) {
1865
+ displayFormula = displayFormula.concat(c.items);
1866
+ }
1867
+ });
1868
+ }
1869
+ return displayFormula || [];
1870
+ }
1871
+ /**
1872
+ * 组装FomulaContext
1873
+ */
1874
+ resolveFomulaContext() {
1875
+ const fomlaArray = [];
1876
+ if (!this.FormulaUsage) {
1877
+ return fomlaArray;
1878
+ }
1879
+ this.FormulaUsage.map((usage) => {
1880
+ const contains = _.flatMap(usage.contains, function (c) {
1881
+ return c.name;
1882
+ });
1883
+ fomlaArray.push(...contains);
1884
+ });
1885
+ this._fomulaContext = fomlaArray;
1886
+ return fomlaArray;
1887
+ }
1888
+ /**
1889
+ * 组装 this.FormulaUsage
1890
+ */
1891
+ setFormulaUsage() {
1892
+ var FormulaUsage = _.cloneDeep(this.fml.FormulaUsage);
1893
+ this.FormulaUsage = FormulaUsage;
1894
+ }
1895
+ ngAfterViewInit() {
1896
+ this.setFormulaUsage();
1897
+ if (!this.ref) {
1898
+ return;
1899
+ }
1900
+ this._ngZone.runOutsideAngular(() => {
1901
+ this.codeMirror = this.codeMirrorGlobal.fromTextArea(this.ref.nativeElement, this._options);
1902
+ this.codeMirror.on("cursorActivity", (cm) => this._ngZone.run(() => this.cursorActive(cm)));
1903
+ this.codeMirror.on("scroll", this.scrollChanged.bind(this));
1904
+ this.codeMirror.on("blur", () => this._ngZone.run(() => this.focusChanged(false)));
1905
+ this.codeMirror.on("focus", () => this._ngZone.run(() => this.focusChanged(true)));
1906
+ this.codeMirror.on("change", (cm, change) => {
1907
+ this._ngZone.run(() => this.codemirrorValueChanged(cm, change));
1908
+ });
1909
+ this.codeMirror.on("drop", (cm, e) => {
1910
+ this._ngZone.run(() => this.dropFiles(cm, e));
1911
+ });
1912
+ this.codeMirror.setValue(this.value);
1913
+ CodeMirror.fomulaContext = Object.keys(this.fml.Formula);
1914
+ this.codeMirror.setOption("mode", "text/fx-formula");
1915
+ });
1916
+ }
1917
+ ngOnChanges(changes) {
1918
+ if (changes && changes["formulaClass"]) {
1919
+ const change = changes["formulaClass"];
1920
+ if (change && (change.currentValue || change.previousValue)) {
1921
+ this.setFormulaClass(change.currentValue);
1922
+ this.setFormulaUsage();
1923
+ }
1924
+ }
1925
+ }
1926
+ ngDoCheck() {
1927
+ if (!this._differ) {
1928
+ return;
1929
+ }
1930
+ const changes = this._differ.diff(this._options);
1931
+ if (changes) {
1932
+ changes.forEachChangedItem((option) => this.setOptionIfChanged(option.key, option.currentValue));
1933
+ changes.forEachAddedItem((option) => this.setOptionIfChanged(option.key, option.currentValue));
1934
+ changes.forEachRemovedItem((option) => this.setOptionIfChanged(option.key, option.currentValue));
1935
+ }
1936
+ }
1937
+ ngOnDestroy() {
1938
+ if (this.codeMirror) {
1939
+ this.codeMirror.toTextArea();
1940
+ }
1941
+ }
1942
+ /**
1943
+ * set FormulaClass
1944
+ * @param formulaCalss
1945
+ */
1946
+ setFormulaClass(formulaCalss) {
1947
+ const fml = new formulaCalss(this.fml);
1948
+ const { FormulaUsage, Formula } = fml;
1949
+ if (Formula) {
1950
+ this._ngZone.runOutsideAngular(() => {
1951
+ Object.keys(Formula).forEach((key) => {
1952
+ this.fml.Formula[key] = Formula[key].bind(this.fml);
1953
+ });
1954
+ // CodeMirror.fomulaContext = this.resolveFomulaContext();
1955
+ CodeMirror.fomulaContext = Object.keys(this.fml.Formula);
1956
+ });
1957
+ }
1958
+ if (FormulaUsage) {
1959
+ const oldIndexs = {};
1960
+ this.fml.FormulaUsage.forEach((category, index) => {
1961
+ oldIndexs[category.categoryCode] = index;
1962
+ });
1963
+ const newCategorys = {};
1964
+ FormulaUsage.forEach((category) => {
1965
+ newCategorys[category.categoryCode] = category;
1966
+ });
1967
+ Object.keys(newCategorys).forEach((categoryCode) => {
1968
+ const oldIndex = _.get(oldIndexs, categoryCode, undefined);
1969
+ const newCategory = newCategorys[categoryCode];
1970
+ if (undefined === oldIndex) {
1971
+ // 新增分类
1972
+ this.fml.FormulaUsage.push(newCategorys[categoryCode]);
1973
+ }
1974
+ else {
1975
+ // 已有分类 添加新函数
1976
+ let oldContains = this.fml.FormulaUsage[oldIndex].contains;
1977
+ oldContains = oldContains.concat(newCategory.contains);
1978
+ oldContains.reverse();
1979
+ _.uniqWith(oldContains, (a, b) => {
1980
+ return a.name === b.name;
1981
+ });
1982
+ this.fml.FormulaUsage[oldIndex].contains = oldContains.reverse();
1983
+ }
1984
+ });
1985
+ }
1986
+ }
1987
+ codemirrorValueChanged(cm, change) {
1988
+ if (change.origin !== "complete") {
1989
+ cm.showHint({
1990
+ hint: CodeMirror.hint.formula,
1991
+ completeSingle: false,
1992
+ shown: function () { },
1993
+ select: function (cpt, ele) { },
1994
+ pick: function (item) { },
1995
+ });
1996
+ }
1997
+ else {
1998
+ this.insertBarcket();
1999
+ }
2000
+ setTimeout(() => {
2001
+ this.getValue();
2002
+ }, 0);
2003
+ }
2004
+ setOptionIfChanged(optionName, newValue) {
2005
+ if (!this.codeMirror) {
2006
+ return;
2007
+ }
2008
+ this.codeMirror.setOption(optionName, newValue);
2009
+ }
2010
+ focusChanged(focused) {
2011
+ this.onTouched();
2012
+ this.isFocused = focused;
2013
+ // CodeMirror.fomulaContext = this._fomulaContext;
2014
+ this.focusChange.emit(focused);
2015
+ }
2016
+ scrollChanged(cm) {
2017
+ this.scroll.emit(cm.getScrollInfo());
2018
+ }
2019
+ cursorActive(cm) {
2020
+ this.cursorActivity.emit(cm);
2021
+ }
2022
+ dropFiles(cm, e) {
2023
+ this.drop.emit([cm, e]);
2024
+ }
2025
+ writeValue(value) {
2026
+ if (value === null || value === undefined) {
2027
+ if (this.codeMirror) {
2028
+ this.codeMirror.setValue("");
2029
+ }
2030
+ return;
2031
+ }
2032
+ this.value = value;
2033
+ this.setValue();
2034
+ }
2035
+ registerOnChange(fn) {
2036
+ this.onChange = fn;
2037
+ }
2038
+ registerOnTouched(fn) {
2039
+ this.onTouched = fn;
2040
+ }
2041
+ setDisabledState(isDisabled) {
2042
+ this.disabled = isDisabled;
2043
+ this.setOptionIfChanged("readOnly", this.disabled);
2044
+ }
2045
+ /**
2046
+ * 函数鼠标滑动时事件
2047
+ * @param e
2048
+ */
2049
+ usageMouseover(e) {
2050
+ let usage = e.usage ? `<li class="usage"> 用法:${e.usage} </li>` : "";
2051
+ this.usageDescription = `
2052
+ <div class="formula-title">${e.name}</div>
2053
+ <ul class="intro-wrapper">
2054
+ <li class="intro">
2055
+ ${e.intro}
2056
+ </li>
2057
+ ${usage}
2058
+ <li class="example">示例:${e.example}</li>
2059
+ </ul>
2060
+ `;
2061
+ }
2062
+ /**
2063
+ * 插入函数
2064
+ * @param e
2065
+ */
2066
+ insertUsageFun(e) {
2067
+ if (this.codeMirror && this.codeMirror !== null) {
2068
+ let c = this.codeMirror.getCursor();
2069
+ this.codeMirror.replaceSelection(`${e.name}`);
2070
+ let d = this.codeMirror.getCursor();
2071
+ this.insertBarcket();
2072
+ this.getValue();
2073
+ }
2074
+ }
2075
+ /**
2076
+ * 插入可用变量
2077
+ * @param event
2078
+ */
2079
+ insertField(event) {
2080
+ if (this.codeMirror && this.codeMirror !== null) {
2081
+ let c = this.codeMirror.getCursor();
2082
+ this.codeMirror.replaceSelection("" + event.label + "");
2083
+ let d = this.codeMirror.getCursor();
2084
+ let e = {
2085
+ from: c,
2086
+ to: d,
2087
+ key: '$' + `{${event.key}}`, // 工作项ID
2088
+ label: event.label,
2089
+ };
2090
+ this.markField(e);
2091
+ this.codeMirror.focus();
2092
+ this.getValue();
2093
+ }
2094
+ }
2095
+ /**
2096
+ * 复制
2097
+ */
2098
+ btnCopy() {
2099
+ if (!!`${this.value}`) {
2100
+ let value = _.cloneDeep(this.value).replace("↵", "");
2101
+ localStorage.setItem("codemirror", value);
2102
+ this.message.success(`复制成功`);
2103
+ }
2104
+ else {
2105
+ this.message.warning(`公式为空,请配置公式后复制`);
2106
+ }
2107
+ }
2108
+ /**
2109
+ * 粘贴
2110
+ */
2111
+ btnPaste() {
2112
+ if (!!localStorage.getItem("codemirror")) {
2113
+ if (!this.value) {
2114
+ this.value = localStorage.getItem("codemirror");
2115
+ }
2116
+ else {
2117
+ this.value = `${this.value}${localStorage.getItem("codemirror")}`;
2118
+ }
2119
+ this.setValue();
2120
+ this.message.success(`粘贴成功`);
2121
+ }
2122
+ else {
2123
+ this.message.warning(`没有需要粘贴的数据,请先复制`);
2124
+ }
2125
+ }
2126
+ /**
2127
+ * 清空
2128
+ */
2129
+ btnClear() {
2130
+ this.value = null;
2131
+ if (this.codeMirror) {
2132
+ this.codeMirror.setValue("");
2133
+ }
2134
+ this.message.success(`清空成功`);
2135
+ }
2136
+ onChange = (_) => { };
2137
+ onTouched = () => { };
2138
+ markField(e) {
2139
+ if (this.codeMirror && this.codeMirror !== null) {
2140
+ let node = document.createElement("span");
2141
+ node.innerHTML = e.label;
2142
+ node.className = "cm-field cm-field-value";
2143
+ node.setAttribute("field-key", e.key);
2144
+ this.codeMirror.markText(e.from, e.to, {
2145
+ handleMouseEvents: !0,
2146
+ atomic: !0,
2147
+ replacedWith: node,
2148
+ });
2149
+ let d = this.codeMirror.getCursor();
2150
+ }
2151
+ }
2152
+ insertBarcket() {
2153
+ if (this.codeMirror && this.codeMirror !== null) {
2154
+ let c = this.codeMirror.getCursor();
2155
+ this.codeMirror.replaceSelection("(");
2156
+ let d = this.codeMirror.getCursor();
2157
+ let c1 = this.codeMirror.getCursor();
2158
+ this.codeMirror.replaceSelection(")");
2159
+ let d1 = this.codeMirror.getCursor();
2160
+ this.codeMirror.setCursor(d);
2161
+ this.codeMirror.focus();
2162
+ }
2163
+ }
2164
+ getValue() {
2165
+ let result = [];
2166
+ let codeContent = this.el.nativeElement.querySelectorAll(".CodeMirror-line");
2167
+ this.fml.Utils.forEach(codeContent, (t, e) => {
2168
+ this.fml.Utils.forEach(e.children, (t1, e1) => {
2169
+ this.fml.Utils.forEach(e1.children, (t2, e2) => {
2170
+ if (e2.getAttribute("cm-text") !== undefined &&
2171
+ e2.getAttribute("cm-text") !== null) {
2172
+ result.push("↵");
2173
+ }
2174
+ else {
2175
+ if (e2.className === "CodeMirror-widget") {
2176
+ this.fml.Utils.forEach(e2.children, (t3, e3) => {
2177
+ if (e3.getAttribute("field-key") !== undefined &&
2178
+ e3.getAttribute("field-key") !== null) {
2179
+ result.push(e3.getAttribute("field-key"));
2180
+ }
2181
+ else {
2182
+ result.push(e3.innerText);
2183
+ }
2184
+ });
2185
+ }
2186
+ else {
2187
+ result.push(e2.innerText);
2188
+ }
2189
+ }
2190
+ });
2191
+ });
2192
+ });
2193
+ if (result[0] === "↵") {
2194
+ result.splice(0, 1);
2195
+ }
2196
+ this.value = result.join("");
2197
+ if (this.codeMirror) {
2198
+ this.textChange.emit(this.codeMirror.getValue());
2199
+ }
2200
+ this.onChange(this.value);
2201
+ }
2202
+ fakeLabel(t) {
2203
+ return t ? t.replace(/[\[\]()'"]/g, " ") : "";
2204
+ }
2205
+ setValue() {
2206
+ if (this.value === undefined || this.value === null || this.value === "") {
2207
+ return;
2208
+ }
2209
+ let e = [];
2210
+ let p = [];
2211
+ let t = this.value.split("\n");
2212
+ this.fml.Utils.forEach(t, (c, t1) => {
2213
+ let d = "", t = t1.split(new RegExp(this.fml.FormulaEditor.COMMON_REG.FORM_FORMULA, "g"));
2214
+ this.fml.Utils.forEach(t, (t, e) => {
2215
+ let i, a, n, s, o, r, l;
2216
+ this.fml.FormulaEditor.CONST.FIELD_REG.test(e)
2217
+ ? ((a = !1),
2218
+ this.labelMap &&
2219
+ (i = this.labelMap[e] ? this.labelMap[e] : " ") &&
2220
+ ((i = this.fakeLabel(i)), (a = !0)),
2221
+ (n = !1),
2222
+ this.fml.Utils.isNull(i) && ((i = 1), (n = !0)),
2223
+ (s = (l = e.replace("$", "").split("}"))[0]),
2224
+ (o = l[1]),
2225
+ (r = CodeMirror.Pos(c, d.length)),
2226
+ (d += i),
2227
+ (l = CodeMirror.Pos(c, d.length)),
2228
+ p.push({
2229
+ from: r,
2230
+ to: l,
2231
+ key: `$${s}}`,
2232
+ label: a ? (this.labelMap[e] ? this.labelMap[e] : "") : null,
2233
+ }))
2234
+ : (d += e);
2235
+ });
2236
+ e.push(d);
2237
+ });
2238
+ if (this.codeMirror) {
2239
+ this.codeMirror.setValue(e.join("\n"));
2240
+ this.fml.Utils.forEach(p, (t, e) => {
2241
+ this.markField(e);
2242
+ });
2243
+ }
2244
+ }
2245
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorComponent, deps: [{ token: i0.KeyValueDiffers }, { token: i0.NgZone }, { token: i0.ElementRef }, { token: i1.NzMessageService }, { token: i2.NzConfigService }, { token: Formula }], target: i0.ɵɵFactoryTarget.Component });
2246
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: GramCodemirrorComponent, isStandalone: true, selector: "deon-codemirror", inputs: { itemTitle: "itemTitle", options: "options", fieldData: "fieldData", blacklist: "blacklist", enableDefaultBlack: "enableDefaultBlack", showList: "showList", name: "name", title: "title", autoFocus: "autoFocus", type: "type", categorys: "categorys", formulaClass: "formulaClass", preserveScrollPosition: "preserveScrollPosition" }, outputs: { cursorActivity: "cursorActivity", focusChange: "focusChange", scroll: "scroll", drop: "drop", textChange: "textChange" }, providers: [
2247
+ {
2248
+ provide: NG_VALUE_ACCESSOR,
2249
+ useExisting: forwardRef(() => GramCodemirrorComponent),
2250
+ multi: true,
2251
+ },
2252
+ Formula
2253
+ ], viewQueries: [{ propertyName: "ref", first: true, predicate: ["ref"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"formula-head\">\r\n <div class=\"formula-title\">\r\n <span class=\"formula-name\">{{ title }}</span><span class=\"formula-equal\">=</span>\r\n </div>\r\n <div class=\"formula-body\">\r\n <textarea [name]=\"name\" autocomplete=\"off\" [autofocus]=\"autoFocus\" #ref>\r\n </textarea>\r\n <div class=\"button-body\">\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnCopy()\">\u590D\u5236</button>\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnPaste()\">\u7C98\u8D34</button>\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnClear()\">\u6E05\u7A7A</button>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"formula-wrapper\">\r\n <div class=\"field-list\">\r\n <div class=\"title\">\u53EF\u7528\u53D8\u91CF</div>\r\n <div class=\"field-wrapper\">\r\n <div class=\"search\">\r\n <input type=\"text\" nz-input placeholder=\"\u641C\u7D22\u53EF\u7528\u53D8\u91CF\" [(ngModel)]=\"variableSearch\" />\r\n </div>\r\n <div class=\"collapse-wrapper\">\r\n <ng-container *ngIf=\"fieldData!! && fieldData.length>0\">\r\n <nz-collapse [nzBordered]=\"false\">\r\n <ng-container *ngFor=\"let item of fieldData\">\r\n <nz-collapse-panel [nzHeader]=\"item.label\">\r\n <div class=\"item\" *ngFor=\"let field of item.listField\" (click)=\"insertField(field)\">\r\n {{ field.label }}\r\n </div>\r\n </nz-collapse-panel>\r\n </ng-container>\r\n </nz-collapse>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"field-list\">\r\n <div class=\"title\">\u51FD\u6570</div>\r\n <div class=\"field-wrapper\">\r\n <div class=\"search\">\r\n <input type=\"text\" nz-input placeholder=\"\u641C\u7D22\u51FD\u6570\" [(ngModel)]=\"usageFunSearch\" />\r\n </div>\r\n <div class=\"collapse-wrapper\">\r\n\r\n <ng-container *ngIf=\"FormulaUsage!! && FormulaUsage.length>0\">\r\n <nz-collapse [nzBordered]=\"false\">\r\n <ng-container *ngFor=\"let item of FormulaUsage\">\r\n <nz-collapse-panel [nzHeader]=\"item.category\">\r\n <div class=\"item\" *ngFor=\"let field of item.contains\" (mouseover)=\"usageMouseover(field)\"\r\n (click)=\"insertUsageFun(field)\">\r\n {{ field.name }}\r\n </div>\r\n </nz-collapse-panel>\r\n </ng-container>\r\n </nz-collapse>\r\n </ng-container>\r\n\r\n\r\n <ng-template #searchPanel>\r\n <ul>\r\n <li *ngFor=\"let item of usageFunSearchList\" (mouseover)=\"usageMouseover(item)\"\r\n (click)=\"insertUsageFun(item)\">\r\n {{ item.name }}\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"formula-intro\" [innerHtml]=\"usageDescription | safeHtml\"></div>\r\n</div>", styles: [":host ::ng-deep{display:flex;flex-direction:column;width:100%}:host ::ng-deep .CodeMirror{height:200px}:host ::ng-deep input::placeholder{font-size:12px!important}:host ::ng-deep .ant-input{font-size:12px!important;border:0!important}:host ::ng-deep .ant-input:focus{box-shadow:none!important}:host ::ng-deep .formula-head{display:flex;flex-direction:column;width:100%;overflow:hidden;font-size:12px;border:1px solid #eaeaea;border-radius:4px}:host ::ng-deep .formula-head .formula-title{display:inline-block;width:100%;padding:8px 12px;background:#f3f8fb}:host ::ng-deep .formula-head .formula-body{padding:12px 12px 0}:host ::ng-deep .formula-head .formula-body .button-body{display:inline-block;width:100%;padding:0 0 10px;text-align:right}:host ::ng-deep .formula-head .formula-body .button-body button{font-size:12px!important}:host ::ng-deep .formula-wrapper{display:flex;flex-direction:row;height:280px;margin-top:10px;font-size:12px}:host ::ng-deep .formula-wrapper .search{border-bottom:1px solid #eaeaea}:host ::ng-deep .formula-wrapper .field-list+.field-list{padding-left:15px}:host ::ng-deep .formula-wrapper .field-list{display:flex;flex-direction:column;width:230px;height:100%}:host ::ng-deep .formula-wrapper .field-list .title{display:inline-block;height:20px}:host ::ng-deep .formula-wrapper .field-list .field-wrapper{display:flex;flex:1;flex-direction:column;width:100%;overflow:auto;border:1px solid #eaeaea;border-radius:2px}:host ::ng-deep .formula-wrapper .field-list .item{padding:3px 0 0;cursor:pointer}:host ::ng-deep .formula-wrapper .collapse-wrapper{flex:1;overflow-x:overlay;overflow-y:overlay}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar{width:8px}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar-thumb{background-color:#94949475;border-radius:7px}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar-track{background-color:#fff}:host ::ng-deep .formula-intro{flex:1;margin:20px 0 0 15px;border:1px solid #eaeaea}:host ::ng-deep .formula-intro ul{margin:0;padding:0}:host ::ng-deep .formula-intro .intro-wrapper{height:240px;margin:0;padding:10px 0 0;color:#5e6d82;overflow-x:overlay;overflow-y:overlay}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar{width:8px}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar-thumb{background-color:#94949475;border-radius:7px}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar-track{background-color:#fff}:host ::ng-deep .formula-intro .intro-wrapper>li{padding:2px 10px;word-wrap:break-word;word-break:break-all;list-style-type:none}:host ::ng-deep .formula-intro .default>li{margin-left:25px;padding:5px 0;list-style-type:disc}:host ::ng-deep .formula-intro .formula-title{height:35px;padding-left:10px;line-height:35px;border-bottom:solid 1px #e0e0e0}:host ::ng-deep .ant-collapse-borderless{background-color:#fff}:host ::ng-deep .ant-collapse-borderless .ant-collapse-item{border-bottom:0}:host ::ng-deep .ant-collapse-header{padding:10px 15px 0 19px!important;font-size:12px}:host ::ng-deep .ant-collapse-header i{top:3px!important;left:5px!important;padding:10px 15px 10px 0!important}:host ::ng-deep .ant-collapse-content-box{padding:0 16px!important;font-size:12px!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: NzInputModule }, { kind: "directive", type: i6.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzSize", "nzStepperless", "nzStatus", "disabled"], exportAs: ["nzInput"] }, { kind: "ngmodule", type: NzCollapseModule }, { kind: "component", type: i7.NzCollapsePanelComponent, selector: "nz-collapse-panel", inputs: ["nzActive", "nzDisabled", "nzShowArrow", "nzExtra", "nzHeader", "nzExpandedIcon"], outputs: ["nzActiveChange"], exportAs: ["nzCollapsePanel"] }, { kind: "component", type: i7.NzCollapseComponent, selector: "nz-collapse", inputs: ["nzAccordion", "nzBordered", "nzGhost", "nzExpandIconPosition"], exportAs: ["nzCollapse"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i8.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i9.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "directive", type: i10.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }, { kind: "ngmodule", type: NzToolTipModule }, { kind: "ngmodule", type: GramPipeModule }, { kind: "pipe", type: i11.SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2254
+ }
2255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorComponent, decorators: [{
2256
+ type: Component,
2257
+ args: [{ selector: "deon-codemirror", providers: [
2258
+ {
2259
+ provide: NG_VALUE_ACCESSOR,
2260
+ useExisting: forwardRef(() => GramCodemirrorComponent),
2261
+ multi: true,
2262
+ },
2263
+ Formula
2264
+ ], preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, ReactiveFormsModule, FormsModule, NzInputModule, NzCollapseModule, NzIconModule, NzButtonModule, NzToolTipModule, GramPipeModule], template: "<div class=\"formula-head\">\r\n <div class=\"formula-title\">\r\n <span class=\"formula-name\">{{ title }}</span><span class=\"formula-equal\">=</span>\r\n </div>\r\n <div class=\"formula-body\">\r\n <textarea [name]=\"name\" autocomplete=\"off\" [autofocus]=\"autoFocus\" #ref>\r\n </textarea>\r\n <div class=\"button-body\">\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnCopy()\">\u590D\u5236</button>\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnPaste()\">\u7C98\u8D34</button>\r\n <button nz-button type=\"button\" nzSize=\"small\" (click)=\"btnClear()\">\u6E05\u7A7A</button>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"formula-wrapper\">\r\n <div class=\"field-list\">\r\n <div class=\"title\">\u53EF\u7528\u53D8\u91CF</div>\r\n <div class=\"field-wrapper\">\r\n <div class=\"search\">\r\n <input type=\"text\" nz-input placeholder=\"\u641C\u7D22\u53EF\u7528\u53D8\u91CF\" [(ngModel)]=\"variableSearch\" />\r\n </div>\r\n <div class=\"collapse-wrapper\">\r\n <ng-container *ngIf=\"fieldData!! && fieldData.length>0\">\r\n <nz-collapse [nzBordered]=\"false\">\r\n <ng-container *ngFor=\"let item of fieldData\">\r\n <nz-collapse-panel [nzHeader]=\"item.label\">\r\n <div class=\"item\" *ngFor=\"let field of item.listField\" (click)=\"insertField(field)\">\r\n {{ field.label }}\r\n </div>\r\n </nz-collapse-panel>\r\n </ng-container>\r\n </nz-collapse>\r\n </ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"field-list\">\r\n <div class=\"title\">\u51FD\u6570</div>\r\n <div class=\"field-wrapper\">\r\n <div class=\"search\">\r\n <input type=\"text\" nz-input placeholder=\"\u641C\u7D22\u51FD\u6570\" [(ngModel)]=\"usageFunSearch\" />\r\n </div>\r\n <div class=\"collapse-wrapper\">\r\n\r\n <ng-container *ngIf=\"FormulaUsage!! && FormulaUsage.length>0\">\r\n <nz-collapse [nzBordered]=\"false\">\r\n <ng-container *ngFor=\"let item of FormulaUsage\">\r\n <nz-collapse-panel [nzHeader]=\"item.category\">\r\n <div class=\"item\" *ngFor=\"let field of item.contains\" (mouseover)=\"usageMouseover(field)\"\r\n (click)=\"insertUsageFun(field)\">\r\n {{ field.name }}\r\n </div>\r\n </nz-collapse-panel>\r\n </ng-container>\r\n </nz-collapse>\r\n </ng-container>\r\n\r\n\r\n <ng-template #searchPanel>\r\n <ul>\r\n <li *ngFor=\"let item of usageFunSearchList\" (mouseover)=\"usageMouseover(item)\"\r\n (click)=\"insertUsageFun(item)\">\r\n {{ item.name }}\r\n </li>\r\n </ul>\r\n </ng-template>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"formula-intro\" [innerHtml]=\"usageDescription | safeHtml\"></div>\r\n</div>", styles: [":host ::ng-deep{display:flex;flex-direction:column;width:100%}:host ::ng-deep .CodeMirror{height:200px}:host ::ng-deep input::placeholder{font-size:12px!important}:host ::ng-deep .ant-input{font-size:12px!important;border:0!important}:host ::ng-deep .ant-input:focus{box-shadow:none!important}:host ::ng-deep .formula-head{display:flex;flex-direction:column;width:100%;overflow:hidden;font-size:12px;border:1px solid #eaeaea;border-radius:4px}:host ::ng-deep .formula-head .formula-title{display:inline-block;width:100%;padding:8px 12px;background:#f3f8fb}:host ::ng-deep .formula-head .formula-body{padding:12px 12px 0}:host ::ng-deep .formula-head .formula-body .button-body{display:inline-block;width:100%;padding:0 0 10px;text-align:right}:host ::ng-deep .formula-head .formula-body .button-body button{font-size:12px!important}:host ::ng-deep .formula-wrapper{display:flex;flex-direction:row;height:280px;margin-top:10px;font-size:12px}:host ::ng-deep .formula-wrapper .search{border-bottom:1px solid #eaeaea}:host ::ng-deep .formula-wrapper .field-list+.field-list{padding-left:15px}:host ::ng-deep .formula-wrapper .field-list{display:flex;flex-direction:column;width:230px;height:100%}:host ::ng-deep .formula-wrapper .field-list .title{display:inline-block;height:20px}:host ::ng-deep .formula-wrapper .field-list .field-wrapper{display:flex;flex:1;flex-direction:column;width:100%;overflow:auto;border:1px solid #eaeaea;border-radius:2px}:host ::ng-deep .formula-wrapper .field-list .item{padding:3px 0 0;cursor:pointer}:host ::ng-deep .formula-wrapper .collapse-wrapper{flex:1;overflow-x:overlay;overflow-y:overlay}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar{width:8px}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar-thumb{background-color:#94949475;border-radius:7px}:host ::ng-deep .formula-wrapper .collapse-wrapper::-webkit-scrollbar-track{background-color:#fff}:host ::ng-deep .formula-intro{flex:1;margin:20px 0 0 15px;border:1px solid #eaeaea}:host ::ng-deep .formula-intro ul{margin:0;padding:0}:host ::ng-deep .formula-intro .intro-wrapper{height:240px;margin:0;padding:10px 0 0;color:#5e6d82;overflow-x:overlay;overflow-y:overlay}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar{width:8px}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar-thumb{background-color:#94949475;border-radius:7px}:host ::ng-deep .formula-intro .intro-wrapper::-webkit-scrollbar-track{background-color:#fff}:host ::ng-deep .formula-intro .intro-wrapper>li{padding:2px 10px;word-wrap:break-word;word-break:break-all;list-style-type:none}:host ::ng-deep .formula-intro .default>li{margin-left:25px;padding:5px 0;list-style-type:disc}:host ::ng-deep .formula-intro .formula-title{height:35px;padding-left:10px;line-height:35px;border-bottom:solid 1px #e0e0e0}:host ::ng-deep .ant-collapse-borderless{background-color:#fff}:host ::ng-deep .ant-collapse-borderless .ant-collapse-item{border-bottom:0}:host ::ng-deep .ant-collapse-header{padding:10px 15px 0 19px!important;font-size:12px}:host ::ng-deep .ant-collapse-header i{top:3px!important;left:5px!important;padding:10px 15px 10px 0!important}:host ::ng-deep .ant-collapse-content-box{padding:0 16px!important;font-size:12px!important}\n"] }]
2265
+ }], ctorParameters: () => [{ type: i0.KeyValueDiffers }, { type: i0.NgZone }, { type: i0.ElementRef }, { type: i1.NzMessageService }, { type: i2.NzConfigService }, { type: Formula }], propDecorators: { itemTitle: [{
2266
+ type: Input
2267
+ }], options: [{
2268
+ type: Input
2269
+ }], fieldData: [{
2270
+ type: Input
2271
+ }], blacklist: [{
2272
+ type: Input
2273
+ }], enableDefaultBlack: [{
2274
+ type: Input
2275
+ }], showList: [{
2276
+ type: Input
2277
+ }], name: [{
2278
+ type: Input
2279
+ }], title: [{
2280
+ type: Input
2281
+ }], autoFocus: [{
2282
+ type: Input
2283
+ }], type: [{
2284
+ type: Input
2285
+ }], categorys: [{
2286
+ type: Input
2287
+ }], formulaClass: [{
2288
+ type: Input
2289
+ }], preserveScrollPosition: [{
2290
+ type: Input
2291
+ }], cursorActivity: [{
2292
+ type: Output
2293
+ }], focusChange: [{
2294
+ type: Output
2295
+ }], scroll: [{
2296
+ type: Output
2297
+ }], drop: [{
2298
+ type: Output
2299
+ }], textChange: [{
2300
+ type: Output
2301
+ }], ref: [{
2302
+ type: ViewChild,
2303
+ args: ["ref", { static: true }]
2304
+ }] } });
2305
+
2306
+ const components = [GramCodemirrorComponent];
2307
+ class GramCodemirrorModule {
2308
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2309
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorModule, imports: [GramCodemirrorComponent], exports: [GramCodemirrorComponent] });
2310
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorModule, imports: [components] });
2311
+ }
2312
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: GramCodemirrorModule, decorators: [{
2313
+ type: NgModule,
2314
+ args: [{
2315
+ exports: [...components],
2316
+ imports: [...components],
2317
+ }]
2318
+ }] });
2319
+
2320
+ // /**
2321
+ // * Public API surface of GramCodemirror
2322
+ // */
2323
+ // // Components
2324
+ // export * from './default/index';
2325
+ // // Module
2326
+ // export * from './index.module';
2327
+ // // Types
2328
+ // export * from './tools/formula'; // Assuming this exists
2329
+
2330
+ /**
2331
+ * Generated bundle index. Do not edit.
2332
+ */
2333
+
2334
+ export { GramCodemirrorComponent, GramCodemirrorModule };
2335
+ //# sourceMappingURL=components.codemirror.mjs.map