@wibetter/json-utils 7.0.0 → 7.0.1

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.
Files changed (49) hide show
  1. package/dist/index.esm.js +753 -355
  2. package/dist/index.esm.min.js +1469 -1
  3. package/dist/index.js +1659 -1
  4. package/dist/index.js.LICENSE.txt +2 -2
  5. package/dist/types/data/TypeDataList.d.ts +112 -112
  6. package/dist/types/data/initSchemaEntity/Api.d.ts +38 -38
  7. package/dist/types/data/initSchemaEntity/Array.d.ts +11 -11
  8. package/dist/types/data/initSchemaEntity/Boolean.d.ts +4 -4
  9. package/dist/types/data/initSchemaEntity/BoxStyle.d.ts +20 -20
  10. package/dist/types/data/initSchemaEntity/Cascader.d.ts +15 -15
  11. package/dist/types/data/initSchemaEntity/Checkbox.d.ts +8 -8
  12. package/dist/types/data/initSchemaEntity/CodeArea.d.ts +5 -5
  13. package/dist/types/data/initSchemaEntity/Color.d.ts +4 -4
  14. package/dist/types/data/initSchemaEntity/DataSource.d.ts +58 -58
  15. package/dist/types/data/initSchemaEntity/Date.d.ts +5 -5
  16. package/dist/types/data/initSchemaEntity/DateTime.d.ts +5 -5
  17. package/dist/types/data/initSchemaEntity/DynamicData.d.ts +86 -86
  18. package/dist/types/data/initSchemaEntity/EmptyArray.d.ts +7 -7
  19. package/dist/types/data/initSchemaEntity/EmptyObject.d.ts +4 -4
  20. package/dist/types/data/initSchemaEntity/Event.d.ts +74 -74
  21. package/dist/types/data/initSchemaEntity/FuncBody.d.ts +5 -5
  22. package/dist/types/data/initSchemaEntity/HtmlArea.d.ts +5 -5
  23. package/dist/types/data/initSchemaEntity/IMG.d.ts +7 -7
  24. package/dist/types/data/initSchemaEntity/Input.d.ts +5 -5
  25. package/dist/types/data/initSchemaEntity/InputImage.d.ts +5 -5
  26. package/dist/types/data/initSchemaEntity/JSONSchema.d.ts +45 -45
  27. package/dist/types/data/initSchemaEntity/Json.d.ts +4 -4
  28. package/dist/types/data/initSchemaEntity/Number.d.ts +6 -6
  29. package/dist/types/data/initSchemaEntity/Object.d.ts +12 -12
  30. package/dist/types/data/initSchemaEntity/PaddingMargin.d.ts +26 -26
  31. package/dist/types/data/initSchemaEntity/Quantity.d.ts +22 -22
  32. package/dist/types/data/initSchemaEntity/Radio.d.ts +7 -7
  33. package/dist/types/data/initSchemaEntity/Select.d.ts +7 -7
  34. package/dist/types/data/initSchemaEntity/TextEditor.d.ts +5 -5
  35. package/dist/types/data/initSchemaEntity/Textarea.d.ts +5 -5
  36. package/dist/types/data/initSchemaEntity/Time.d.ts +5 -5
  37. package/dist/types/data/initSchemaEntity/URL.d.ts +5 -5
  38. package/dist/types/function/getJsonDataByKeyRoute.d.ts +5 -1
  39. package/dist/types/function/getSchemaByIndexRoute.d.ts +5 -1
  40. package/dist/types/function/getSchemaByKeyRoute.d.ts +5 -1
  41. package/dist/types/function/indexRoute2keyRoute.d.ts +4 -1
  42. package/dist/types/function/json2treeData.d.ts +8 -2
  43. package/dist/types/function/keyRoute2indexRoute.d.ts +4 -1
  44. package/dist/types/function/metaElemAnalyzer.d.ts +4 -1
  45. package/dist/types/function/schema2conditionValue.d.ts +4 -1
  46. package/dist/types/utils/index.d.ts +8 -2
  47. package/dist/types/utils/jsonData.d.ts +3 -1
  48. package/dist/types/utils/jsonSchema.d.ts +21 -6
  49. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -1,4 +1,8 @@
1
- import { isEqual as isEqual$1, cloneDeep, truncate as truncate$1 } from 'lodash';
1
+ import {
2
+ isEqual as isEqual$1,
3
+ cloneDeep,
4
+ truncate as truncate$1,
5
+ } from 'lodash';
2
6
  import qs from 'qs';
3
7
 
4
8
  /** 新版JSONSchema一级字段项
@@ -27,10 +31,10 @@ var initJSONSchemaData = {
27
31
  // 字段项的说明和描述
28
32
  placeholder: '',
29
33
  // 输入提示
30
- isRequired: false
31
- }
34
+ isRequired: false,
35
+ },
32
36
  },
33
- propertyOrder: ['a']
37
+ propertyOrder: ['a'],
34
38
  },
35
39
  style: {
36
40
  type: 'object',
@@ -43,10 +47,10 @@ var initJSONSchemaData = {
43
47
  // 默认值
44
48
  description: '',
45
49
  // 字段项的说明和描述
46
- placeholder: '' // 输入提示
47
- }
50
+ placeholder: '', // 输入提示
51
+ },
48
52
  },
49
- propertyOrder: ['b']
53
+ propertyOrder: ['b'],
50
54
  },
51
55
  data: {
52
56
  type: 'data',
@@ -61,13 +65,13 @@ var initJSONSchemaData = {
61
65
  // 字段项的说明和描述
62
66
  placeholder: '',
63
67
  // 输入提示
64
- isRequired: false
65
- }
68
+ isRequired: false,
69
+ },
66
70
  },
67
- propertyOrder: ['c']
68
- }
71
+ propertyOrder: ['c'],
72
+ },
69
73
  },
70
- propertyOrder: ['func', 'style', 'data']
74
+ propertyOrder: ['func', 'style', 'data'],
71
75
  };
72
76
 
73
77
  /* input类型字段
@@ -87,7 +91,7 @@ var initInputData = {
87
91
  // 默认值
88
92
  description: '',
89
93
  // 字段项的说明和描述
90
- placeholder: '' // 输入提示
94
+ placeholder: '', // 输入提示
91
95
  };
92
96
 
93
97
  /* boolean类型字段
@@ -104,7 +108,7 @@ var initBooleanData = {
104
108
  title: '布尔值',
105
109
  default: false,
106
110
  // 默认值
107
- description: '' // 字段项的说明和描述
111
+ description: '', // 字段项的说明和描述
108
112
  };
109
113
 
110
114
  /* textarea类型字段
@@ -124,7 +128,7 @@ var initTextareaData = {
124
128
  // 默认值
125
129
  description: '',
126
130
  // 字段项的说明和描述
127
- placeholder: '' // 输入提示
131
+ placeholder: '', // 输入提示
128
132
  };
129
133
 
130
134
  /* 富文本类型字段
@@ -144,7 +148,7 @@ var initTextEditorData = {
144
148
  // 默认值
145
149
  description: '',
146
150
  // 字段项的说明和描述
147
- placeholder: '' // 输入提示
151
+ placeholder: '', // 输入提示
148
152
  };
149
153
 
150
154
  /* number类型字段
@@ -167,7 +171,7 @@ var initNumberData = {
167
171
  // 在高级设置中配置
168
172
  maximum: 1000,
169
173
  // 在高级设置中配置
170
- description: '' // 字段项的说明和描述
174
+ description: '', // 字段项的说明和描述
171
175
  };
172
176
 
173
177
  /* radio类型字段
@@ -182,18 +186,22 @@ var initNumberData = {
182
186
  var initRadioData = {
183
187
  type: 'radio',
184
188
  title: '单选',
185
- options: [{
186
- label: '选项a',
187
- value: 'a'
188
- }, {
189
- label: '选项b',
190
- value: 'b'
191
- }, {
192
- label: '选项c',
193
- value: 'c'
194
- }],
189
+ options: [
190
+ {
191
+ label: '选项a',
192
+ value: 'a',
193
+ },
194
+ {
195
+ label: '选项b',
196
+ value: 'b',
197
+ },
198
+ {
199
+ label: '选项c',
200
+ value: 'c',
201
+ },
202
+ ],
195
203
  // default: 'a',
196
- description: ''
204
+ description: '',
197
205
  };
198
206
 
199
207
  /* Select下拉类型字段
@@ -208,18 +216,22 @@ var initRadioData = {
208
216
  var initSelectData = {
209
217
  type: 'select',
210
218
  title: '下拉选择',
211
- options: [{
212
- label: '选项a',
213
- value: 'a'
214
- }, {
215
- label: '选项b',
216
- value: 'b'
217
- }, {
218
- label: '选项c',
219
- value: 'c'
220
- }],
219
+ options: [
220
+ {
221
+ label: '选项a',
222
+ value: 'a',
223
+ },
224
+ {
225
+ label: '选项b',
226
+ value: 'b',
227
+ },
228
+ {
229
+ label: '选项c',
230
+ value: 'c',
231
+ },
232
+ ],
221
233
  // default: 'a',
222
- description: ''
234
+ description: '',
223
235
  };
224
236
 
225
237
  /* checkboxes元素
@@ -234,18 +246,22 @@ var initSelectData = {
234
246
  var initCheckboxSchema = {
235
247
  type: 'checkboxes',
236
248
  title: '多选',
237
- options: [{
238
- label: '选项a',
239
- value: 'a'
240
- }, {
241
- label: '选项b',
242
- value: 'b'
243
- }, {
244
- label: '选项c',
245
- value: 'c'
246
- }],
249
+ options: [
250
+ {
251
+ label: '选项a',
252
+ value: 'a',
253
+ },
254
+ {
255
+ label: '选项b',
256
+ value: 'b',
257
+ },
258
+ {
259
+ label: '选项c',
260
+ value: 'c',
261
+ },
262
+ ],
247
263
  default: ['a'],
248
- description: ''
264
+ description: '',
249
265
  };
250
266
 
251
267
  /* Cascader 级联选择
@@ -260,33 +276,44 @@ var initCheckboxSchema = {
260
276
  var initCascaderSchema = {
261
277
  type: 'cascader',
262
278
  title: '级联选择',
263
- options: [{
264
- value: 'zhejiang',
265
- label: 'Zhejiang',
266
- children: [{
267
- value: 'hangzhou',
268
- label: 'Hangzhou',
269
- children: [{
270
- value: 'xihu',
271
- label: 'West Lake'
272
- }]
273
- }]
274
- }, {
275
- value: 'jiangsu',
276
- label: 'Jiangsu',
277
- children: [{
278
- value: 'nanjing',
279
- label: 'Nanjing',
280
- children: [{
281
- value: 'zhonghuamen',
282
- label: 'Zhong Hua Men'
283
- }]
284
- }]
285
- }],
279
+ options: [
280
+ {
281
+ value: 'zhejiang',
282
+ label: 'Zhejiang',
283
+ children: [
284
+ {
285
+ value: 'hangzhou',
286
+ label: 'Hangzhou',
287
+ children: [
288
+ {
289
+ value: 'xihu',
290
+ label: 'West Lake',
291
+ },
292
+ ],
293
+ },
294
+ ],
295
+ },
296
+ {
297
+ value: 'jiangsu',
298
+ label: 'Jiangsu',
299
+ children: [
300
+ {
301
+ value: 'nanjing',
302
+ label: 'Nanjing',
303
+ children: [
304
+ {
305
+ value: 'zhonghuamen',
306
+ label: 'Zhong Hua Men',
307
+ },
308
+ ],
309
+ },
310
+ ],
311
+ },
312
+ ],
286
313
  default: 'a',
287
314
  description: '',
288
315
  showSearch: true,
289
- allowClear: true
316
+ allowClear: true,
290
317
  };
291
318
 
292
319
  /* DateTime类型字段
@@ -306,7 +333,7 @@ var initDateTimeData = {
306
333
  // 默认值
307
334
  description: '',
308
335
  // 字段项的说明和描述
309
- placeholder: '' // 输入提示
336
+ placeholder: '', // 输入提示
310
337
  };
311
338
 
312
339
  /* Date类型字段
@@ -326,7 +353,7 @@ var initDateData = {
326
353
  // 默认值
327
354
  description: '',
328
355
  // 字段项的说明和描述
329
- placeholder: '' // 输入提示
356
+ placeholder: '', // 输入提示
330
357
  };
331
358
 
332
359
  /* Time类型字段
@@ -346,7 +373,7 @@ var initTimeData = {
346
373
  // 默认值
347
374
  description: '',
348
375
  // 字段项的说明和描述
349
- placeholder: '' // 输入提示
376
+ placeholder: '', // 输入提示
350
377
  };
351
378
 
352
379
  /* color类型字段
@@ -363,7 +390,7 @@ var initColorData = {
363
390
  title: '颜色color',
364
391
  default: '#ffffff',
365
392
  // 默认值
366
- description: '' // 字段项的说明和描述
393
+ description: '', // 字段项的说明和描述
367
394
  };
368
395
 
369
396
  /* URL类型字段
@@ -383,7 +410,7 @@ var initURLData = {
383
410
  // 默认值
384
411
  description: '',
385
412
  // 字段项的说明和描述
386
- placeholder: '' // 输入提示
413
+ placeholder: '', // 输入提示
387
414
  };
388
415
 
389
416
  /** image图片类型字段
@@ -400,7 +427,7 @@ var initIMGData = {
400
427
  // 图片默认的宽度,单位默认px
401
428
  imgHeight: 200,
402
429
  // 图片默认的高度,单位默认px
403
- imgRatioReadOnly: true // 图片宽高比例是否可调整
430
+ imgRatioReadOnly: true, // 图片宽高比例是否可调整
404
431
  };
405
432
 
406
433
  /* input类型字段
@@ -418,7 +445,7 @@ var initInputImageData = {
418
445
  description: '',
419
446
  // 字段项的说明和描述
420
447
  accept: '.jpeg,.jpg,.png',
421
- multiple: true
448
+ multiple: true,
422
449
  };
423
450
 
424
451
  /* array类型字段
@@ -449,11 +476,11 @@ var initArrayData = {
449
476
  // 默认值
450
477
  description: '',
451
478
  // 字段项的说明和描述
452
- placeholder: '' // 输入提示
453
- }
479
+ placeholder: '', // 输入提示
480
+ },
454
481
  },
455
- propertyOrder: ['name']
456
- }
482
+ propertyOrder: ['name'],
483
+ },
457
484
  };
458
485
 
459
486
  /** Object字段项
@@ -478,10 +505,10 @@ var initObjectData = {
478
505
  // 默认值
479
506
  description: '',
480
507
  // 字段项的说明和描述
481
- placeholder: '' // 输入提示
482
- }
508
+ placeholder: '', // 输入提示
509
+ },
483
510
  },
484
- propertyOrder: ['a']
511
+ propertyOrder: ['a'],
485
512
  };
486
513
 
487
514
  // 空数组的schema数据
@@ -494,8 +521,8 @@ var EmptyArray = {
494
521
  type: 'object',
495
522
  title: '数组项',
496
523
  description: '',
497
- properties: {}
498
- }
524
+ properties: {},
525
+ },
499
526
  };
500
527
 
501
528
  // 空对象的schema数据
@@ -503,7 +530,7 @@ var EmptyObject = {
503
530
  type: 'object',
504
531
  title: '对象Object',
505
532
  description: '',
506
- properties: {}
533
+ properties: {},
507
534
  };
508
535
 
509
536
  /** quantity字段项
@@ -529,29 +556,34 @@ var initQuantityData = {
529
556
  // 在高级设置中配置
530
557
  maximum: 1000,
531
558
  // 在高级设置中配置
532
- description: '' // 字段项的说明和描述
559
+ description: '', // 字段项的说明和描述
533
560
  },
534
561
  quantity: {
535
562
  type: 'select',
536
563
  // 选择列表
537
564
  default: 'px',
538
- options: [{
539
- label: 'px',
540
- value: 'px'
541
- }, {
542
- label: 'rem',
543
- value: 'rem'
544
- }, {
545
- label: 'em',
546
- value: 'em'
547
- }, {
548
- label: '%',
549
- value: '%'
550
- }],
551
- title: '单位类型'
552
- }
565
+ options: [
566
+ {
567
+ label: 'px',
568
+ value: 'px',
569
+ },
570
+ {
571
+ label: 'rem',
572
+ value: 'rem',
573
+ },
574
+ {
575
+ label: 'em',
576
+ value: 'em',
577
+ },
578
+ {
579
+ label: '%',
580
+ value: '%',
581
+ },
582
+ ],
583
+ title: '单位类型',
584
+ },
553
585
  },
554
- propertyOrder: ['unit', 'quantity']
586
+ propertyOrder: ['unit', 'quantity'],
555
587
  };
556
588
 
557
589
  /** box-style字段项
@@ -573,29 +605,34 @@ var initBoxStyleData = {
573
605
  type: 'input',
574
606
  default: '0',
575
607
  // 默认值为'0':'0px 0px 0px 0px';为'5px': '5px 5px 5px 5px'
576
- description: '' // 字段项的说明和描述
608
+ description: '', // 字段项的说明和描述
577
609
  },
578
610
  quantity: {
579
611
  type: 'select',
580
612
  // 选择列表
581
613
  default: 'px',
582
- options: [{
583
- label: 'px',
584
- value: 'px'
585
- }, {
586
- label: 'rem',
587
- value: 'rem'
588
- }, {
589
- label: 'em',
590
- value: 'em'
591
- }, {
592
- label: '%',
593
- value: '%'
594
- }],
595
- title: '单位类型'
596
- }
614
+ options: [
615
+ {
616
+ label: 'px',
617
+ value: 'px',
618
+ },
619
+ {
620
+ label: 'rem',
621
+ value: 'rem',
622
+ },
623
+ {
624
+ label: 'em',
625
+ value: 'em',
626
+ },
627
+ {
628
+ label: '%',
629
+ value: '%',
630
+ },
631
+ ],
632
+ title: '单位类型',
633
+ },
597
634
  },
598
- propertyOrder: ['unit', 'quantity']
635
+ propertyOrder: ['unit', 'quantity'],
599
636
  };
600
637
 
601
638
  /** padding-margin 字段项
@@ -617,35 +654,40 @@ var initPaddingMarginData = {
617
654
  type: 'input',
618
655
  default: '0',
619
656
  // 默认值为'0':'0px 0px 0px 0px';为'5px': '5px 5px 5px 5px'
620
- description: ''
657
+ description: '',
621
658
  },
622
659
  padding: {
623
660
  title: '内边距',
624
661
  type: 'input',
625
662
  default: '0',
626
- description: ''
663
+ description: '',
627
664
  },
628
665
  quantity: {
629
666
  type: 'select',
630
667
  // 选择列表
631
668
  default: 'px',
632
- options: [{
633
- label: 'px',
634
- value: 'px'
635
- }, {
636
- label: 'rem',
637
- value: 'rem'
638
- }, {
639
- label: 'em',
640
- value: 'em'
641
- }, {
642
- label: '%',
643
- value: '%'
644
- }],
645
- title: '单位类型'
646
- }
669
+ options: [
670
+ {
671
+ label: 'px',
672
+ value: 'px',
673
+ },
674
+ {
675
+ label: 'rem',
676
+ value: 'rem',
677
+ },
678
+ {
679
+ label: 'em',
680
+ value: 'em',
681
+ },
682
+ {
683
+ label: '%',
684
+ value: '%',
685
+ },
686
+ ],
687
+ title: '单位类型',
688
+ },
647
689
  },
648
- propertyOrder: ['margin', 'padding', 'quantity']
690
+ propertyOrder: ['margin', 'padding', 'quantity'],
649
691
  };
650
692
 
651
693
  /* json类型字段
@@ -663,7 +705,7 @@ var initJsonData = {
663
705
  type: 'json',
664
706
  default: '{}',
665
707
  // 默认值
666
- description: '' // 字段项的说明和描述
708
+ description: '', // 字段项的说明和描述
667
709
  };
668
710
 
669
711
  /* CodeArea类型字段
@@ -683,7 +725,7 @@ var initCodeAreaData = {
683
725
  // 输入提示
684
726
  default: 'function func() { console.log("hello, world!"); }',
685
727
  // 默认值
686
- description: '用于定义函数方法' // 字段项的说明和描述
728
+ description: '用于定义函数方法', // 字段项的说明和描述
687
729
  };
688
730
 
689
731
  /* HtmlArea类型字段
@@ -702,7 +744,7 @@ var initHtmlAreaData = {
702
744
  placeholder: '请输入html代码片段',
703
745
  default: '<p>hello,world!</p>',
704
746
  // 默认值
705
- description: '用于放置html代码片段' // 字段项的说明和描述
747
+ description: '用于放置html代码片段', // 字段项的说明和描述
706
748
  };
707
749
 
708
750
  /** event字段项
@@ -725,31 +767,34 @@ var initEventData = {
725
767
  type: {
726
768
  default: 'emit',
727
769
  type: 'select',
728
- options: [{
729
- label: 'on',
730
- value: 'on'
731
- }, {
732
- label: 'emit',
733
- value: 'emit'
734
- }],
735
- title: '事件类型'
770
+ options: [
771
+ {
772
+ label: 'on',
773
+ value: 'on',
774
+ },
775
+ {
776
+ label: 'emit',
777
+ value: 'emit',
778
+ },
779
+ ],
780
+ title: '事件类型',
736
781
  },
737
782
  trigger: {
738
783
  type: 'input',
739
784
  default: 'eventName',
740
785
  title: '触发事件',
741
786
  description: '用于输入触发事件的名称',
742
- placeholder: '请输入触发事件的名称'
787
+ placeholder: '请输入触发事件的名称',
743
788
  },
744
789
  eventData: {
745
790
  title: '事件数据',
746
791
  type: 'json',
747
792
  default: '{}',
748
793
  // 默认值
749
- description: '传递给触发事件的数据对象' // 字段项的说明和描述
750
- }
794
+ description: '传递给触发事件的数据对象', // 字段项的说明和描述
795
+ },
751
796
  },
752
- propertyOrder: ['type', 'trigger', 'eventData']
797
+ propertyOrder: ['type', 'trigger', 'eventData'],
753
798
  };
754
799
  /** 新版EventData
755
800
  * type: on 的默认数据 */
@@ -761,31 +806,34 @@ var initEventDataTypeON = {
761
806
  type: {
762
807
  default: 'on',
763
808
  type: 'select',
764
- options: [{
765
- label: 'on',
766
- value: 'on'
767
- }, {
768
- label: 'emit',
769
- value: 'emit'
770
- }],
771
- title: '事件类型'
809
+ options: [
810
+ {
811
+ label: 'on',
812
+ value: 'on',
813
+ },
814
+ {
815
+ label: 'emit',
816
+ value: 'emit',
817
+ },
818
+ ],
819
+ title: '事件类型',
772
820
  },
773
821
  register: {
774
822
  type: 'input',
775
823
  default: 'eventName',
776
824
  title: '注册事件',
777
825
  description: '用于输入注册事件的名称',
778
- placeholder: '请输入注册事件的名称'
826
+ placeholder: '请输入注册事件的名称',
779
827
  },
780
828
  actionFunc: {
781
829
  title: '执行函数',
782
830
  type: 'codearea',
783
831
  default: '() => {}',
784
832
  // 默认值
785
- description: '' // 字段项的说明和描述
786
- }
833
+ description: '', // 字段项的说明和描述
834
+ },
787
835
  },
788
- propertyOrder: ['type', 'register', 'actionFunc']
836
+ propertyOrder: ['type', 'register', 'actionFunc'],
789
837
  };
790
838
 
791
839
  /** dataSource字段项
@@ -805,14 +853,17 @@ var initDataSourceData = {
805
853
  type: {
806
854
  default: 'local',
807
855
  type: 'select',
808
- options: [{
809
- label: '本地数据',
810
- value: 'local'
811
- }, {
812
- label: '接口数据',
813
- value: 'remote'
814
- }],
815
- title: '数据源类型'
856
+ options: [
857
+ {
858
+ label: '本地数据',
859
+ value: 'local',
860
+ },
861
+ {
862
+ label: '接口数据',
863
+ value: 'remote',
864
+ },
865
+ ],
866
+ title: '数据源类型',
816
867
  },
817
868
  data: {
818
869
  title: '本地json数据',
@@ -822,17 +873,17 @@ var initDataSourceData = {
822
873
  default: '{}',
823
874
  // 默认值
824
875
  description: '用于设置本地的静态json数据',
825
- isRequired: true
876
+ isRequired: true,
826
877
  },
827
878
  filter: {
828
879
  title: '过滤器',
829
880
  type: 'codearea',
830
881
  default: '() => {}',
831
882
  description: '用于定义过滤当前数据的函数',
832
- isRequired: true
833
- }
883
+ isRequired: true,
884
+ },
834
885
  },
835
- propertyOrder: ['type', 'data', 'filter']
886
+ propertyOrder: ['type', 'data', 'filter'],
836
887
  };
837
888
  // 默认是用于展示local本地数据源的,如果展示远程数据源使用initDataSourceDataV2
838
889
  var initDataSourceDataV2 = {
@@ -843,14 +894,17 @@ var initDataSourceDataV2 = {
843
894
  type: {
844
895
  type: 'select',
845
896
  default: 'remote',
846
- options: [{
847
- label: '本地数据',
848
- value: 'local'
849
- }, {
850
- label: '接口数据',
851
- value: 'remote'
852
- }],
853
- title: '数据源类型'
897
+ options: [
898
+ {
899
+ label: '本地数据',
900
+ value: 'local',
901
+ },
902
+ {
903
+ label: '接口数据',
904
+ value: 'remote',
905
+ },
906
+ ],
907
+ title: '数据源类型',
854
908
  },
855
909
  data: {
856
910
  type: 'url',
@@ -860,17 +914,17 @@ var initDataSourceDataV2 = {
860
914
  default: 'http://xxx',
861
915
  // 默认值
862
916
  isRequired: true,
863
- description: '用于设置获取元素数据的请求地址'
917
+ description: '用于设置获取元素数据的请求地址',
864
918
  },
865
919
  filter: {
866
920
  type: 'codearea',
867
921
  title: '过滤器',
868
922
  default: '() => {}',
869
923
  description: '用于定义过滤当前数据的函数',
870
- isRequired: true
871
- }
924
+ isRequired: true,
925
+ },
872
926
  },
873
- propertyOrder: ['type', 'data', 'filter']
927
+ propertyOrder: ['type', 'data', 'filter'],
874
928
  };
875
929
 
876
930
  /** dynamic-data: 动态数据
@@ -890,14 +944,17 @@ var initDynamicData = {
890
944
  type: {
891
945
  default: 'local',
892
946
  type: 'select',
893
- options: [{
894
- label: '本地数据',
895
- value: 'local'
896
- }, {
897
- label: '接口数据',
898
- value: 'remote'
899
- }],
900
- title: '数据类型'
947
+ options: [
948
+ {
949
+ label: '本地数据',
950
+ value: 'local',
951
+ },
952
+ {
953
+ label: '接口数据',
954
+ value: 'remote',
955
+ },
956
+ ],
957
+ title: '数据类型',
901
958
  },
902
959
  config: {
903
960
  title: '接口配置',
@@ -910,65 +967,75 @@ var initDynamicData = {
910
967
  title: '请求地址',
911
968
  default: '',
912
969
  description: 'API 的 URL',
913
- isRequired: true
970
+ isRequired: true,
914
971
  },
915
972
  method: {
916
973
  type: 'select',
917
974
  title: '请求方式',
918
975
  default: 'get',
919
- options: [{
920
- label: 'GET',
921
- value: 'get'
922
- }, {
923
- label: 'POST',
924
- value: 'post'
925
- }, {
926
- label: 'PUT',
927
- value: 'put'
928
- }, {
929
- label: 'PATCH',
930
- value: 'patch'
931
- }, {
932
- label: 'DELETE',
933
- value: 'delete'
934
- }],
935
- isRequired: true
976
+ options: [
977
+ {
978
+ label: 'GET',
979
+ value: 'get',
980
+ },
981
+ {
982
+ label: 'POST',
983
+ value: 'post',
984
+ },
985
+ {
986
+ label: 'PUT',
987
+ value: 'put',
988
+ },
989
+ {
990
+ label: 'PATCH',
991
+ value: 'patch',
992
+ },
993
+ {
994
+ label: 'DELETE',
995
+ value: 'delete',
996
+ },
997
+ ],
998
+ isRequired: true,
936
999
  },
937
1000
  headers: {
938
1001
  type: 'json',
939
1002
  title: '请求头',
940
1003
  default: '{}',
941
- description: '请求头对象'
1004
+ description: '请求头对象',
942
1005
  },
943
1006
  data: {
944
1007
  type: 'json',
945
1008
  title: '请求参数',
946
1009
  default: '{}',
947
- description: '请求体或查询参数'
1010
+ description: '请求体或查询参数',
948
1011
  },
949
1012
  dataType: {
950
1013
  type: 'select',
951
1014
  title: '数据格式',
952
1015
  default: 'json',
953
- options: [{
954
- label: 'JSON',
955
- value: 'json'
956
- }, {
957
- label: 'FormData',
958
- value: 'form-data'
959
- }, {
960
- label: 'Form',
961
- value: 'form'
962
- }]
1016
+ options: [
1017
+ {
1018
+ label: 'JSON',
1019
+ value: 'json',
1020
+ },
1021
+ {
1022
+ label: 'FormData',
1023
+ value: 'form-data',
1024
+ },
1025
+ {
1026
+ label: 'Form',
1027
+ value: 'form',
1028
+ },
1029
+ ],
963
1030
  },
964
1031
  cache: {
965
1032
  type: 'number',
966
1033
  title: '缓存时间',
967
1034
  default: undefined,
968
- description: '缓存时间(ms),不设置则不缓存'
969
- }
1035
+ description: '缓存时间(ms),不设置则不缓存',
1036
+ },
970
1037
  },
971
- propertyOrder: ['url', 'method', 'headers', 'data', 'dataType', 'cache']
1038
+ propertyOrder: ['url', 'method', 'headers', 'data', 'dataType', 'cache'],
972
1039
  },
973
1040
  data: {
974
1041
  title: '数据内容',
@@ -976,17 +1043,17 @@ var initDynamicData = {
976
1043
  default: '{}',
977
1044
  // 默认值
978
1045
  description: '用于存放DynamicData的数据内容',
979
- isRequired: true
1046
+ isRequired: true,
980
1047
  },
981
1048
  localFilter: {
982
1049
  title: '过滤器',
983
1050
  type: 'codearea',
984
1051
  default: 'return data;',
985
1052
  description: '用于定义过滤本地数据',
986
- isRequired: true
987
- }
1053
+ isRequired: true,
1054
+ },
988
1055
  },
989
- propertyOrder: ['type', 'config', 'data', 'localFilter']
1056
+ propertyOrder: ['type', 'config', 'data', 'localFilter'],
990
1057
  };
991
1058
  // 动态数据对应的空json数据内容
992
1059
  var EmptyDynamicDataCont = {
@@ -996,11 +1063,11 @@ var EmptyDynamicDataCont = {
996
1063
  method: 'get',
997
1064
  headers: {},
998
1065
  data: {},
999
- dataType: 'json'
1066
+ dataType: 'json',
1000
1067
  },
1001
1068
  data: '{}',
1002
1069
  // 用于存储结果数据
1003
- localFilter: 'return data;'
1070
+ localFilter: 'return data;',
1004
1071
  };
1005
1072
 
1006
1073
  // Define the schema for API configuration
@@ -1014,41 +1081,46 @@ var initApiData = {
1014
1081
  title: '请求地址',
1015
1082
  default: '',
1016
1083
  description: 'API 的 URL',
1017
- isRequired: true
1084
+ isRequired: true,
1018
1085
  },
1019
1086
  method: {
1020
1087
  type: 'select',
1021
1088
  title: '请求方式',
1022
1089
  default: 'get',
1023
- options: [{
1024
- label: 'GET',
1025
- value: 'get'
1026
- }, {
1027
- label: 'POST',
1028
- value: 'post'
1029
- }, {
1030
- label: 'PUT',
1031
- value: 'put'
1032
- }, {
1033
- label: 'DELETE',
1034
- value: 'delete'
1035
- }],
1036
- isRequired: true
1090
+ options: [
1091
+ {
1092
+ label: 'GET',
1093
+ value: 'get',
1094
+ },
1095
+ {
1096
+ label: 'POST',
1097
+ value: 'post',
1098
+ },
1099
+ {
1100
+ label: 'PUT',
1101
+ value: 'put',
1102
+ },
1103
+ {
1104
+ label: 'DELETE',
1105
+ value: 'delete',
1106
+ },
1107
+ ],
1108
+ isRequired: true,
1037
1109
  },
1038
1110
  headers: {
1039
1111
  type: 'json',
1040
1112
  title: '请求头',
1041
1113
  default: '{}',
1042
- description: '请求头对象'
1114
+ description: '请求头对象',
1043
1115
  },
1044
1116
  data: {
1045
1117
  type: 'json',
1046
1118
  title: '请求参数',
1047
1119
  default: '{}',
1048
- description: '请求体或查询参数'
1049
- }
1120
+ description: '请求体或查询参数',
1121
+ },
1050
1122
  },
1051
- propertyOrder: ['url', 'method', 'headers', 'data']
1123
+ propertyOrder: ['url', 'method', 'headers', 'data'],
1052
1124
  };
1053
1125
 
1054
1126
  // 类型数据清单
@@ -1083,17 +1155,17 @@ var TypeDataList = {
1083
1155
  'dynamic-data': initDynamicData,
1084
1156
  datasource: initDataSourceData,
1085
1157
  event: initEventData,
1086
- api: initApiData
1158
+ api: initApiData,
1087
1159
  };
1088
1160
  // 事件类型数据
1089
1161
  var EventTypeDataList = {
1090
1162
  on: initEventDataTypeON,
1091
- emit: initEventData
1163
+ emit: initEventData,
1092
1164
  };
1093
1165
  // 数据源类型
1094
1166
  var DataSourceTypeList = {
1095
1167
  local: initDataSourceData,
1096
- remote: initDataSourceDataV2
1168
+ remote: initDataSourceDataV2,
1097
1169
  };
1098
1170
 
1099
1171
  // 判断是否是URL地址类型
@@ -1106,7 +1178,10 @@ function isString(o) {
1106
1178
  }
1107
1179
  // 判断是否是数字类型
1108
1180
  function isNumber(value) {
1109
- return typeof value === 'number' || Object.prototype.toString.call(value) === '[object Number]';
1181
+ return (
1182
+ typeof value === 'number' ||
1183
+ Object.prototype.toString.call(value) === '[object Number]'
1184
+ );
1110
1185
  }
1111
1186
  // 判断是否是Boolean类型
1112
1187
  function isBoolean(o) {
@@ -1118,7 +1193,10 @@ function isDateStr(dateStr) {
1118
1193
  }
1119
1194
  // 判断是否是年月日时分的时间类型
1120
1195
  function isDateTimeStr(dateStr) {
1121
- return /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/.test(dateStr) || /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(dateStr);
1196
+ return (
1197
+ /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/.test(dateStr) ||
1198
+ /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(dateStr)
1199
+ );
1122
1200
  }
1123
1201
  // 判断是否是时分的时间类型
1124
1202
  function isTimeStr(dateStr) {
@@ -1168,7 +1246,11 @@ function isQuantity(val) {
1168
1246
  var _TypeDataList$quantit;
1169
1247
  var isObject = false;
1170
1248
  // 获取当前计量单位元素可选的单位类型
1171
- var quantityList = ((_TypeDataList$quantit = TypeDataList.quantity.properties.quantity) === null || _TypeDataList$quantit === void 0 ? void 0 : _TypeDataList$quantit.enum) || [];
1249
+ var quantityList =
1250
+ ((_TypeDataList$quantit = TypeDataList.quantity.properties.quantity) ===
1251
+ null || _TypeDataList$quantit === void 0
1252
+ ? void 0
1253
+ : _TypeDataList$quantit.enum) || [];
1172
1254
  if (quantityList.indexOf(val) >= 0) {
1173
1255
  isObject = true;
1174
1256
  }
@@ -1222,14 +1304,27 @@ function objClone(targetObj) {
1222
1304
  }
1223
1305
  /** 对比两个json数据是否相等 */
1224
1306
  function isEqual(targetObj, nextTargetObj) {
1225
- if (hasProperties(targetObj) && !hasProperties(nextTargetObj) || !hasProperties(targetObj) && hasProperties(nextTargetObj) || typeof targetObj !== typeof nextTargetObj) {
1307
+ if (
1308
+ (hasProperties(targetObj) && !hasProperties(nextTargetObj)) ||
1309
+ (!hasProperties(targetObj) && hasProperties(nextTargetObj)) ||
1310
+ typeof targetObj !== typeof nextTargetObj
1311
+ ) {
1226
1312
  return false;
1227
1313
  }
1228
- if (isObject(targetObj) && (targetObj.id !== nextTargetObj.id || targetObj.lastUpdateTime !== nextTargetObj.lastUpdateTime)) {
1314
+ if (
1315
+ isObject(targetObj) &&
1316
+ (targetObj.id !== nextTargetObj.id ||
1317
+ targetObj.lastUpdateTime !== nextTargetObj.lastUpdateTime)
1318
+ ) {
1229
1319
  return false;
1230
1320
  }
1231
1321
  var curTime = new Date().getTime();
1232
- if (isObject(targetObj) && targetObj.lastUpdateTime && targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime && curTime - targetObj.lastUpdateTime < 500) {
1322
+ if (
1323
+ isObject(targetObj) &&
1324
+ targetObj.lastUpdateTime &&
1325
+ targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime &&
1326
+ curTime - targetObj.lastUpdateTime < 500
1327
+ ) {
1233
1328
  // 当两个对象的时间戳相同,且和当前时间的时间戳数值相差不到500毫秒,则直接认为两者数据相同
1234
1329
  return true;
1235
1330
  }
@@ -1237,18 +1332,36 @@ function isEqual(targetObj, nextTargetObj) {
1237
1332
  }
1238
1333
  // 根据 id 或 lastUpdateTime 判断 数据是否相等
1239
1334
  function isEqualByIdT(targetObj, nextTargetObj) {
1240
- if (hasProperties(targetObj) && !hasProperties(nextTargetObj) || !hasProperties(targetObj) && hasProperties(nextTargetObj) || typeof targetObj !== typeof nextTargetObj) {
1335
+ if (
1336
+ (hasProperties(targetObj) && !hasProperties(nextTargetObj)) ||
1337
+ (!hasProperties(targetObj) && hasProperties(nextTargetObj)) ||
1338
+ typeof targetObj !== typeof nextTargetObj
1339
+ ) {
1241
1340
  return false;
1242
1341
  }
1243
- if (isObject(targetObj) && (targetObj.id !== nextTargetObj.id || targetObj.lastUpdateTime !== nextTargetObj.lastUpdateTime)) {
1342
+ if (
1343
+ isObject(targetObj) &&
1344
+ (targetObj.id !== nextTargetObj.id ||
1345
+ targetObj.lastUpdateTime !== nextTargetObj.lastUpdateTime)
1346
+ ) {
1244
1347
  return false;
1245
1348
  }
1246
1349
  var curTime = new Date().getTime();
1247
- if (isObject(targetObj) && targetObj.lastUpdateTime && targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime && curTime - targetObj.lastUpdateTime < 500) {
1350
+ if (
1351
+ isObject(targetObj) &&
1352
+ targetObj.lastUpdateTime &&
1353
+ targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime &&
1354
+ curTime - targetObj.lastUpdateTime < 500
1355
+ ) {
1248
1356
  // 当两个对象的时间戳相同,且和当前时间的时间戳数值相差不到500毫秒,则直接认为两者数据相同
1249
1357
  return true;
1250
1358
  }
1251
- if (isObject(targetObj) && (hasProperties(targetObj.id) && targetObj.id === nextTargetObj.id || hasProperties(targetObj.lastUpdateTime) && targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime)) {
1359
+ if (
1360
+ isObject(targetObj) &&
1361
+ ((hasProperties(targetObj.id) && targetObj.id === nextTargetObj.id) ||
1362
+ (hasProperties(targetObj.lastUpdateTime) &&
1363
+ targetObj.lastUpdateTime === nextTargetObj.lastUpdateTime))
1364
+ ) {
1252
1365
  return true;
1253
1366
  } else {
1254
1367
  return isEqual$1(targetObj, nextTargetObj);
@@ -1278,12 +1391,20 @@ function truncate(str, paramConfig) {
1278
1391
  function evalExpression(expressionStr, data) {
1279
1392
  var curData = data || {};
1280
1393
  if (!expressionStr) return false;
1281
- var expressionFunc = new Function('data', "with(data) { return (" + expressionStr + ");}");
1394
+ var expressionFunc = new Function(
1395
+ 'data',
1396
+ 'with(data) { return (' + expressionStr + ');}',
1397
+ );
1282
1398
  var expressionResult = '';
1283
1399
  try {
1284
1400
  expressionResult = expressionFunc(curData);
1285
1401
  } catch (error) {
1286
- console.warn("\u8868\u8FBE\u5F0F\u8FD0\u7B97\u51FA\u9519: " + expressionStr + "\uFF0C\u62A5\u9519\u4FE1\u606F\uFF1A", error);
1402
+ console.warn(
1403
+ '\u8868\u8FBE\u5F0F\u8FD0\u7B97\u51FA\u9519: ' +
1404
+ expressionStr +
1405
+ '\uFF0C\u62A5\u9519\u4FE1\u606F\uFF1A',
1406
+ error,
1407
+ );
1287
1408
  return expressionResult;
1288
1409
  }
1289
1410
  return expressionResult;
@@ -1329,11 +1450,21 @@ function getSchemaByIndexRoute(indexRoute, targetJsonSchemaObj, useObjClone) {
1329
1450
  curJsonSchemaObj = objClone(targetJsonSchemaObj); // 进行深拷贝,避免影响原有数据
1330
1451
  }
1331
1452
  if (indexRoute) {
1332
- var indexRouteArr = typeof indexRoute === 'string' ? indexRoute.split('-') : [indexRoute.toString()];
1453
+ var indexRouteArr =
1454
+ typeof indexRoute === 'string'
1455
+ ? indexRoute.split('-')
1456
+ : [indexRoute.toString()];
1333
1457
  for (var index = 0, size = indexRouteArr.length; index < size; index++) {
1334
1458
  // 获取指定路径的json数据对象,需要按以下步骤(备注:确保是符合规则的json格式数据)
1335
1459
  var curIndex = indexRouteArr[index];
1336
- if (curIndex === '0' && (curJsonSchemaObj.type === 'array' || curJsonSchemaObj.type === 'radio' || curJsonSchemaObj.type === 'select' || curJsonSchemaObj.type === 'checkboxes') && (curJsonSchemaObj.options || curJsonSchemaObj.items)) {
1460
+ if (
1461
+ curIndex === '0' &&
1462
+ (curJsonSchemaObj.type === 'array' ||
1463
+ curJsonSchemaObj.type === 'radio' ||
1464
+ curJsonSchemaObj.type === 'select' ||
1465
+ curJsonSchemaObj.type === 'checkboxes') &&
1466
+ (curJsonSchemaObj.options || curJsonSchemaObj.items)
1467
+ ) {
1337
1468
  // 从items中获取数据
1338
1469
  curJsonSchemaObj = curJsonSchemaObj.options || curJsonSchemaObj.items;
1339
1470
  } else if (curIndex) {
@@ -1388,18 +1519,21 @@ function getSchemaByKeyRoute(keyRoute, targetJsonSchemaObj, useObjClone) {
1388
1519
  function indexRoute2keyRoute(indexRoute, targetJsonSchemaObj) {
1389
1520
  var curJsonSchemaObj = targetJsonSchemaObj;
1390
1521
  var curKeyRoute = '';
1391
- var indexRouteArr = typeof indexRoute === 'string' ? indexRoute.split('-') : [indexRoute.toString()];
1522
+ var indexRouteArr =
1523
+ typeof indexRoute === 'string'
1524
+ ? indexRoute.split('-')
1525
+ : [indexRoute.toString()];
1392
1526
  for (var index = 0, size = indexRouteArr.length; index < size; index++) {
1393
1527
  // 获取指定路径的json数据对象,需要按以下步骤(备注:确保是符合规则的json格式数据)
1394
1528
  var curIndex = indexRouteArr[index];
1395
1529
  if (curIndex === '0' && curJsonSchemaObj.items) {
1396
1530
  // 从items中获取数据
1397
1531
  curJsonSchemaObj = curJsonSchemaObj.items; // 对象类型数据引用
1398
- curKeyRoute = curKeyRoute ? curKeyRoute + "-items" : 'items';
1532
+ curKeyRoute = curKeyRoute ? curKeyRoute + '-items' : 'items';
1399
1533
  } else if (curIndex === '0' && curJsonSchemaObj.options) {
1400
1534
  // 从options中获取数据
1401
1535
  curJsonSchemaObj = curJsonSchemaObj.options;
1402
- curKeyRoute = curKeyRoute ? curKeyRoute + "-options" : 'options';
1536
+ curKeyRoute = curKeyRoute ? curKeyRoute + '-options' : 'options';
1403
1537
  } else if (curIndex) {
1404
1538
  // 1、先根据路径值获取key值
1405
1539
  var curKey = '0';
@@ -1412,7 +1546,7 @@ function indexRoute2keyRoute(indexRoute, targetJsonSchemaObj) {
1412
1546
  }
1413
1547
  // 2、根据key值获取对应的json数据对象
1414
1548
  curJsonSchemaObj = curJsonSchemaObj.properties[curKey]; // 对象类型数据引用
1415
- curKeyRoute = curKeyRoute ? curKeyRoute + "-" + curKey : curKey;
1549
+ curKeyRoute = curKeyRoute ? curKeyRoute + '-' + curKey : curKey;
1416
1550
  }
1417
1551
  }
1418
1552
  return curKeyRoute;
@@ -1452,7 +1586,9 @@ function keyRoute2indexRoute(keyRoute, targetJsonSchemaObj) {
1452
1586
  curIndex = 0;
1453
1587
  curJsonSchemaObj = curJsonSchemaObj.options;
1454
1588
  }
1455
- curIndexRoute = curIndexRoute ? curIndexRoute + "-" + curIndex : curIndex.toString();
1589
+ curIndexRoute = curIndexRoute
1590
+ ? curIndexRoute + '-' + curIndex
1591
+ : curIndex.toString();
1456
1592
  }
1457
1593
  }
1458
1594
  return curIndexRoute;
@@ -1531,13 +1667,25 @@ function objectJson2Schema(jsonData) {
1531
1667
  // 远程数据源类型
1532
1668
  curJsonSchema = objClone(DataSourceTypeList.remote);
1533
1669
  }
1534
- } else if (jsonData.trigger && jsonData.eventData && properties.length === 2) {
1670
+ } else if (
1671
+ jsonData.trigger &&
1672
+ jsonData.eventData &&
1673
+ properties.length === 2
1674
+ ) {
1535
1675
  // 触发事件类型(固定格式的Object类型)
1536
1676
  curJsonSchema = objClone(EventTypeDataList.emit);
1537
- } else if (jsonData.register && jsonData.actionFunc && properties.length === 2) {
1677
+ } else if (
1678
+ jsonData.register &&
1679
+ jsonData.actionFunc &&
1680
+ properties.length === 2
1681
+ ) {
1538
1682
  // 注册事件类型(固定格式的Object类型)
1539
1683
  curJsonSchema = objClone(EventTypeDataList.on);
1540
- } else if (jsonData.quantity && isQuantity(jsonData.quantity) && properties.length === 2) {
1684
+ } else if (
1685
+ jsonData.quantity &&
1686
+ isQuantity(jsonData.quantity) &&
1687
+ properties.length === 2
1688
+ ) {
1541
1689
  // 计量单位类型(固定格式的Object类型)
1542
1690
  curJsonSchema = objClone(TypeDataList.quantity);
1543
1691
  } else {
@@ -1570,7 +1718,7 @@ function arrayJson2Schema(jsonData) {
1570
1718
  if (arrLength > enumextraLength) {
1571
1719
  // 如果当前jsonDats的数值个数大于selectSchemaData的选项个数,则需要进行补充
1572
1720
  for (var ind = enumextraLength, size = arrLength; ind < size; ind++) {
1573
- curJsonSchema.items.enumextra.push("\u9009\u9879" + jsonData(ind));
1721
+ curJsonSchema.items.enumextra.push('\u9009\u9879' + jsonData(ind));
1574
1722
  }
1575
1723
  }
1576
1724
  } else {
@@ -1624,7 +1772,7 @@ var valExpectType = {
1624
1772
  textarea: 'string',
1625
1773
  'text-editor': 'string',
1626
1774
  time: 'string',
1627
- url: 'string'
1775
+ url: 'string',
1628
1776
  };
1629
1777
  // 根据type获取对应元素的期望类型值
1630
1778
  function getExpectType(type) {
@@ -1633,7 +1781,13 @@ function getExpectType(type) {
1633
1781
  // 注册新的期望类型值
1634
1782
  function registerExpectType(type, valType) {
1635
1783
  if (valExpectType[type]) {
1636
- console.warn("\u5F53\u524D\u5DF2\u7ECF\u5B58\u5728" + type + "(" + valExpectType[type] + ")\uFF0C\u6682\u65F6\u4E0D\u652F\u6301\u8986\u76D6\u3002");
1784
+ console.warn(
1785
+ '\u5F53\u524D\u5DF2\u7ECF\u5B58\u5728' +
1786
+ type +
1787
+ '(' +
1788
+ valExpectType[type] +
1789
+ ')\uFF0C\u6682\u65F6\u4E0D\u652F\u6301\u8986\u76D6\u3002',
1790
+ );
1637
1791
  return;
1638
1792
  }
1639
1793
  valExpectType[type] = valType;
@@ -1663,7 +1817,11 @@ function registerExpectType(type, valType) {
1663
1817
  * */
1664
1818
  function objectSchema2JsonData$1(jsonSchema, analyzerResult) {
1665
1819
  var curAnalyzerResult = analyzerResult || {};
1666
- if (isObject(jsonSchema) && getExpectType(jsonSchema.type) === 'object' && jsonSchema.properties) {
1820
+ if (
1821
+ isObject(jsonSchema) &&
1822
+ getExpectType(jsonSchema.type) === 'object' &&
1823
+ jsonSchema.properties
1824
+ ) {
1667
1825
  var curPropertyOrder = [];
1668
1826
  if (jsonSchema.propertyOrder) {
1669
1827
  curPropertyOrder = jsonSchema.propertyOrder;
@@ -1685,14 +1843,22 @@ function metaElemAnalyzer(curJsonSchemaObj, analyzerResult) {
1685
1843
  // 根据当前schem数据分析使用到的元数据情况
1686
1844
  if (curJsonSchemaObj && JSON.stringify(curJsonSchemaObj) !== '{}') {
1687
1845
  var curType = curJsonSchemaObj.type;
1688
- if (curType === 'object' || curType === 'func' || curType === 'style' || curType === 'data') {
1846
+ if (
1847
+ curType === 'object' ||
1848
+ curType === 'func' ||
1849
+ curType === 'style' ||
1850
+ curType === 'data'
1851
+ ) {
1689
1852
  // 最外层的schema类型不进行统计
1690
1853
  if (!isFirstAnalyzer && curAnalyzerResult['object']) {
1691
1854
  curAnalyzerResult['object'] += 1;
1692
1855
  } else if (!isFirstAnalyzer) {
1693
1856
  curAnalyzerResult['object'] = 1;
1694
1857
  }
1695
- curAnalyzerResult = objectSchema2JsonData$1(curJsonSchemaObj, curAnalyzerResult);
1858
+ curAnalyzerResult = objectSchema2JsonData$1(
1859
+ curJsonSchemaObj,
1860
+ curAnalyzerResult,
1861
+ );
1696
1862
  } else if (curType === 'array') {
1697
1863
  // 最外层的schema类型不进行统计
1698
1864
  if (!isFirstAnalyzer && curAnalyzerResult['array']) {
@@ -1701,7 +1867,10 @@ function metaElemAnalyzer(curJsonSchemaObj, analyzerResult) {
1701
1867
  curAnalyzerResult['array'] = 1;
1702
1868
  }
1703
1869
  curJsonSchemaObj = curJsonSchemaObj.items;
1704
- curAnalyzerResult = objectSchema2JsonData$1(curJsonSchemaObj, curAnalyzerResult);
1870
+ curAnalyzerResult = objectSchema2JsonData$1(
1871
+ curJsonSchemaObj,
1872
+ curAnalyzerResult,
1873
+ );
1705
1874
  } else {
1706
1875
  if (!isFirstAnalyzer && curAnalyzerResult[curType]) {
1707
1876
  curAnalyzerResult[curType] += 1;
@@ -1730,7 +1899,14 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1730
1899
  newJSONSchema.type = newJSONSchema.format;
1731
1900
  }
1732
1901
  // 3.不需要default属性的类型自动删除
1733
- if ((newJSONSchema.type === 'quantity' || newJSONSchema.type === 'array' || newJSONSchema.type === 'datasource' || newJSONSchema.type === 'event' || newJSONSchema.type === 'object') && hasProperties(newJSONSchema.default)) {
1902
+ if (
1903
+ (newJSONSchema.type === 'quantity' ||
1904
+ newJSONSchema.type === 'array' ||
1905
+ newJSONSchema.type === 'datasource' ||
1906
+ newJSONSchema.type === 'event' ||
1907
+ newJSONSchema.type === 'object') &&
1908
+ hasProperties(newJSONSchema.default)
1909
+ ) {
1734
1910
  delete newJSONSchema.default; // 单位计量输入类型的默认值改放unit属性中
1735
1911
  }
1736
1912
  // 转换旧版的radio类型的数据结构
@@ -1741,7 +1917,7 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1741
1917
  newJSONSchema.items = {
1742
1918
  type: 'string',
1743
1919
  enum: objClone(newJSONSchema.enum),
1744
- enumextra: objClone(newJSONSchema.enumextra)
1920
+ enumextra: objClone(newJSONSchema.enumextra),
1745
1921
  };
1746
1922
  // 删除此前的enum、enumextra
1747
1923
  delete newJSONSchema.enum;
@@ -1752,10 +1928,15 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1752
1928
  if (newJSONSchema.type === 'quantity') {
1753
1929
  var curProperties = newJSONSchema.properties;
1754
1930
  var newQuantitySchema = objClone(TypeDataList.quantity); // 新版quantity的schema数据对象
1755
- if (curProperties.quantity && isObject(curProperties.quantity) && curProperties.quantity.default) {
1931
+ if (
1932
+ curProperties.quantity &&
1933
+ isObject(curProperties.quantity) &&
1934
+ curProperties.quantity.default
1935
+ ) {
1756
1936
  var oldDefault = curProperties.quantity.default;
1757
1937
  // percent 自动转换成 %
1758
- newQuantitySchema.properties.quantity.default = oldDefault === 'percent' ? '%' : oldDefault;
1938
+ newQuantitySchema.properties.quantity.default =
1939
+ oldDefault === 'percent' ? '%' : oldDefault;
1759
1940
  }
1760
1941
  // 融合新版schema数据
1761
1942
  newJSONSchema = newQuantitySchema;
@@ -1769,12 +1950,18 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1769
1950
  var filterProp = _curProperties.filter && _curProperties.filter.default;
1770
1951
  if (typeProp === 'local') {
1771
1952
  newJSONSchema = objClone(DataSourceTypeList.local);
1772
- newJSONSchema.properties.data.default = dataProp ? objClone(dataProp) : '{}';
1953
+ newJSONSchema.properties.data.default = dataProp
1954
+ ? objClone(dataProp)
1955
+ : '{}';
1773
1956
  } else {
1774
1957
  newJSONSchema = objClone(DataSourceTypeList.remote);
1775
- newJSONSchema.properties.data.default = dataProp ? objClone(dataProp) : 'http://xxx';
1958
+ newJSONSchema.properties.data.default = dataProp
1959
+ ? objClone(dataProp)
1960
+ : 'http://xxx';
1776
1961
  }
1777
- newJSONSchema.properties.filter.default = filterProp ? objClone(filterProp) : '() => {}';
1962
+ newJSONSchema.properties.filter.default = filterProp
1963
+ ? objClone(filterProp)
1964
+ : '() => {}';
1778
1965
  }
1779
1966
  // 转换旧版的event类型的数据结构
1780
1967
  if (newJSONSchema.type === 'event') {
@@ -1785,18 +1972,23 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1785
1972
  if (eventType === 'in' || eventType === 'on') {
1786
1973
  // 兼容旧版的'in'和新版的'on'
1787
1974
  // 注册类事件: 新版type改成'on'
1788
- var eventFunc = _curProperties2.filter && _curProperties2.filter.default || '() => {}';
1975
+ var eventFunc =
1976
+ (_curProperties2.filter && _curProperties2.filter.default) ||
1977
+ '() => {}';
1789
1978
  newJSONSchema = objClone(EventTypeDataList.on);
1790
1979
  if (_curProperties2.actionFunc && isObject(_curProperties2.actionFunc)) {
1791
- newJSONSchema.properties.actionFunc.default = _curProperties2.actionFunc.default || objClone(eventFunc);
1980
+ newJSONSchema.properties.actionFunc.default =
1981
+ _curProperties2.actionFunc.default || objClone(eventFunc);
1792
1982
  }
1793
1983
  } else {
1794
1984
  // 其他,则默认为触发事件
1795
1985
  // 注册类事件: 新版type改成'emit'
1796
- var _eventFunc = _curProperties2.filter && _curProperties2.filter.default || '{}';
1986
+ var _eventFunc =
1987
+ (_curProperties2.filter && _curProperties2.filter.default) || '{}';
1797
1988
  newJSONSchema = objClone(EventTypeDataList.emit);
1798
1989
  if (_curProperties2.eventData && isObject(_curProperties2.eventData)) {
1799
- newJSONSchema.properties.eventData.default = _curProperties2.eventData.default || objClone(_eventFunc);
1990
+ newJSONSchema.properties.eventData.default =
1991
+ _curProperties2.eventData.default || objClone(_eventFunc);
1800
1992
  }
1801
1993
  }
1802
1994
  }
@@ -1808,7 +2000,9 @@ function oldSchemaToNewSchemaV1(oldSchema) {
1808
2000
  }
1809
2001
  // 继续遍历properties属性进行转换
1810
2002
  newJSONSchema.propertyOrder.map(function (jsonKey) {
1811
- newJSONSchema.properties[jsonKey] = oldSchemaToNewSchema(newJSONSchema.properties[jsonKey]);
2003
+ newJSONSchema.properties[jsonKey] = oldSchemaToNewSchema(
2004
+ newJSONSchema.properties[jsonKey],
2005
+ );
1812
2006
  });
1813
2007
  }
1814
2008
  // 判断是否有items属性
@@ -1829,17 +2023,32 @@ function oldSchemaToNewSchema(oldSchema) {
1829
2023
  newJSONSchema.type = newJSONSchema.type;
1830
2024
  }
1831
2025
  // 不需要default属性的类型自动删除
1832
- if ((newJSONSchema.type === 'quantity' || newJSONSchema.type === 'array' || newJSONSchema.type === 'datasource' || newJSONSchema.type === 'event' || newJSONSchema.type === 'object') && hasProperties(newJSONSchema.default)) {
2026
+ if (
2027
+ (newJSONSchema.type === 'quantity' ||
2028
+ newJSONSchema.type === 'array' ||
2029
+ newJSONSchema.type === 'datasource' ||
2030
+ newJSONSchema.type === 'event' ||
2031
+ newJSONSchema.type === 'object') &&
2032
+ hasProperties(newJSONSchema.default)
2033
+ ) {
1833
2034
  delete newJSONSchema.default; // 单位计量输入类型的默认值改放unit属性中
1834
2035
  }
1835
2036
  // 转换旧版的选择类型的数据结构
1836
- if (newJSONSchema.type === 'radio' || newJSONSchema.type === 'checkboxes' || newJSONSchema.type === 'select') {
1837
- if (newJSONSchema.items && newJSONSchema.items.enum && newJSONSchema.items.enumextra) {
2037
+ if (
2038
+ newJSONSchema.type === 'radio' ||
2039
+ newJSONSchema.type === 'checkboxes' ||
2040
+ newJSONSchema.type === 'select'
2041
+ ) {
2042
+ if (
2043
+ newJSONSchema.items &&
2044
+ newJSONSchema.items.enum &&
2045
+ newJSONSchema.items.enumextra
2046
+ ) {
1838
2047
  newJSONSchema.options = [];
1839
2048
  newJSONSchema.items.enum.forEach(function (option, optionIndex) {
1840
2049
  newJSONSchema.options.push({
1841
2050
  label: newJSONSchema.items.enumextra[optionIndex] || option,
1842
- value: option
2051
+ value: option,
1843
2052
  });
1844
2053
  });
1845
2054
  // 删除此前的items
@@ -1854,7 +2063,9 @@ function oldSchemaToNewSchema(oldSchema) {
1854
2063
  }
1855
2064
  // 继续遍历properties属性进行转换
1856
2065
  newJSONSchema.propertyOrder.map(function (jsonKey) {
1857
- newJSONSchema.properties[jsonKey] = oldSchemaToNewSchema(newJSONSchema.properties[jsonKey]);
2066
+ newJSONSchema.properties[jsonKey] = oldSchemaToNewSchema(
2067
+ newJSONSchema.properties[jsonKey],
2068
+ );
1858
2069
  });
1859
2070
  }
1860
2071
  if (newJSONSchema.type === 'array' && newJSONSchema.items) {
@@ -1876,13 +2087,29 @@ function isEmptySchema(targetJsonSchema) {
1876
2087
  return isEmpty;
1877
2088
  }
1878
2089
  var curType = targetJsonSchema.type;
1879
- if (curType === 'object' && targetJsonSchema.properties && targetJsonSchema.propertyOrder && targetJsonSchema.propertyOrder.length > 0) {
2090
+ if (
2091
+ curType === 'object' &&
2092
+ targetJsonSchema.properties &&
2093
+ targetJsonSchema.propertyOrder &&
2094
+ targetJsonSchema.propertyOrder.length > 0
2095
+ ) {
1880
2096
  // Object对象类型
1881
2097
  isEmpty = false;
1882
- } else if (curType === 'array' && targetJsonSchema.items && targetJsonSchema.items.properties && targetJsonSchema.items.propertyOrder && targetJsonSchema.items.propertyOrder.length > 0) {
2098
+ } else if (
2099
+ curType === 'array' &&
2100
+ targetJsonSchema.items &&
2101
+ targetJsonSchema.items.properties &&
2102
+ targetJsonSchema.items.propertyOrder &&
2103
+ targetJsonSchema.items.propertyOrder.length > 0
2104
+ ) {
1883
2105
  // Array数组类型
1884
2106
  isEmpty = false;
1885
- } else if (targetJsonSchema.type && targetJsonSchema.type !== 'array' && targetJsonSchema.type !== 'object' || targetJsonSchema.type) {
2107
+ } else if (
2108
+ (targetJsonSchema.type &&
2109
+ targetJsonSchema.type !== 'array' &&
2110
+ targetJsonSchema.type !== 'object') ||
2111
+ targetJsonSchema.type
2112
+ ) {
1886
2113
  // 其他基本类型
1887
2114
  isEmpty = false;
1888
2115
  }
@@ -1911,7 +2138,8 @@ function isNewSchemaData(schemaData) {
1911
2138
  function isContainerSchema(curSchema) {
1912
2139
  var isContainerElem = false;
1913
2140
  var valueType = getExpectType(curSchema.type);
1914
- var isContainer = curSchema.isContainer !== undefined ? curSchema.isContainer : true; // 默认 isContainer 为 true
2141
+ var isContainer =
2142
+ curSchema.isContainer !== undefined ? curSchema.isContainer : true; // 默认 isContainer 为 true
1915
2143
  if (valueType === 'object' && isContainer) {
1916
2144
  isContainerElem = true;
1917
2145
  }
@@ -1923,7 +2151,11 @@ function isContainerSchema(curSchema) {
1923
2151
  function isStructuredSchema(jsonSchema) {
1924
2152
  var isStructured = true;
1925
2153
  var currentType = jsonSchema.type;
1926
- if (currentType !== 'object' || !jsonSchema.propertyOrder || !jsonSchema.properties) {
2154
+ if (
2155
+ currentType !== 'object' ||
2156
+ !jsonSchema.propertyOrder ||
2157
+ !jsonSchema.properties
2158
+ ) {
1927
2159
  isStructured = false;
1928
2160
  } else {
1929
2161
  jsonSchema.propertyOrder.map(function (key) {
@@ -1931,7 +2163,11 @@ function isStructuredSchema(jsonSchema) {
1931
2163
  var curSchemaData = jsonSchema.properties[key];
1932
2164
  /** 2. 判断是否是容器类型元素,如果是则禁止选中 */
1933
2165
  var curType = jsonSchema.type;
1934
- if (curType !== 'object' || !curSchemaData.propertyOrder || !curSchemaData.properties) {
2166
+ if (
2167
+ curType !== 'object' ||
2168
+ !curSchemaData.propertyOrder ||
2169
+ !curSchemaData.properties
2170
+ ) {
1935
2171
  isStructured = false;
1936
2172
  }
1937
2173
  });
@@ -1960,7 +2196,8 @@ function getCurPosition(curIndex, targetIndex) {
1960
2196
  var targetIndexArr = targetIndex.split('-');
1961
2197
  var curPosition = 'before'; // 默认在目标元素的前面
1962
2198
  // 使用短的路径进行遍历(避免空指针)
1963
- var forEachArr = curIndexArr.length > targetIndexArr.length ? targetIndexArr : curIndexArr;
2199
+ var forEachArr =
2200
+ curIndexArr.length > targetIndexArr.length ? targetIndexArr : curIndexArr;
1964
2201
  for (var index = 0, size = forEachArr.length; index < size; index += 1) {
1965
2202
  var curIndexItem = Number(curIndexArr[index]);
1966
2203
  var targetIndexItem = Number(targetIndexArr[index]);
@@ -1974,7 +2211,10 @@ function getCurPosition(curIndex, targetIndex) {
1974
2211
  * 获取父元素的路径值
1975
2212
  */
1976
2213
  function getParentIndexRoute(curIndexRoute) {
1977
- var curIndexArr = typeof curIndexRoute === 'string' ? curIndexRoute.split('-') : [curIndexRoute.toString()];
2214
+ var curIndexArr =
2215
+ typeof curIndexRoute === 'string'
2216
+ ? curIndexRoute.split('-')
2217
+ : [curIndexRoute.toString()];
1978
2218
  curIndexArr.pop();
1979
2219
  return curIndexArr.join('-');
1980
2220
  }
@@ -1982,17 +2222,23 @@ function getParentIndexRoute(curIndexRoute) {
1982
2222
  * 获取下一个兄弟元素的路径值
1983
2223
  */
1984
2224
  function getNextIndexRoute(curIndexRoute) {
1985
- var curIndexArr = typeof curIndexRoute === 'string' ? curIndexRoute.split('-') : [curIndexRoute.toString()];
2225
+ var curIndexArr =
2226
+ typeof curIndexRoute === 'string'
2227
+ ? curIndexRoute.split('-')
2228
+ : [curIndexRoute.toString()];
1986
2229
  var lastIndex = curIndexArr.pop();
1987
2230
  var endIndex = Number(lastIndex) + 1;
1988
- curIndexArr.push("" + endIndex);
2231
+ curIndexArr.push('' + endIndex);
1989
2232
  return curIndexArr.join('-');
1990
2233
  }
1991
2234
  /**
1992
2235
  * 获取父元素的路径值和当前index
1993
2236
  */
1994
2237
  function getParentIndexRoute_CurIndex(curIndexRoute) {
1995
- var curIndexArr = typeof curIndexRoute === 'string' ? curIndexRoute.split('-') : [curIndexRoute.toString()];
2238
+ var curIndexArr =
2239
+ typeof curIndexRoute === 'string'
2240
+ ? curIndexRoute.split('-')
2241
+ : [curIndexRoute.toString()];
1996
2242
  var curIndex = curIndexArr.pop() || '';
1997
2243
  return [curIndexArr.join('-'), curIndex];
1998
2244
  }
@@ -2000,7 +2246,10 @@ function getParentIndexRoute_CurIndex(curIndexRoute) {
2000
2246
  * 将当前路径值向前移动一位
2001
2247
  */
2002
2248
  function moveForward(curIndexRoute) {
2003
- var curIndexArr = typeof curIndexRoute === 'string' ? curIndexRoute.split('-') : [curIndexRoute.toString()];
2249
+ var curIndexArr =
2250
+ typeof curIndexRoute === 'string'
2251
+ ? curIndexRoute.split('-')
2252
+ : [curIndexRoute.toString()];
2004
2253
  var curIndex = curIndexArr.pop();
2005
2254
  curIndexArr.push(Number(curIndex) - 1);
2006
2255
  return curIndexArr.join('-');
@@ -2009,7 +2258,10 @@ function moveForward(curIndexRoute) {
2009
2258
  * 将当前路径值向后移动一位
2010
2259
  */
2011
2260
  function moveBackward(curIndexRoute) {
2012
- var curIndexArr = typeof curIndexRoute === 'string' ? curIndexRoute.split('-') : [curIndexRoute.toString()];
2261
+ var curIndexArr =
2262
+ typeof curIndexRoute === 'string'
2263
+ ? curIndexRoute.split('-')
2264
+ : [curIndexRoute.toString()];
2013
2265
  var curIndex = curIndexArr.pop();
2014
2266
  curIndexArr.push(Number(curIndex) + 1);
2015
2267
  return curIndexArr.join('-');
@@ -2020,7 +2272,10 @@ function moveBackward(curIndexRoute) {
2020
2272
  function getDefaultOptionVal(jsonSchema, multiple) {
2021
2273
  var defaultVal = '';
2022
2274
  var hasOptions = false;
2023
- if (jsonSchema.defaultActiveFirstOption === false || !jsonSchema.defaultActiveFirstOption) {
2275
+ if (
2276
+ jsonSchema.defaultActiveFirstOption === false ||
2277
+ !jsonSchema.defaultActiveFirstOption
2278
+ ) {
2024
2279
  // 当默认不选择第一个数据项时,则不自动生成数值
2025
2280
  return undefined;
2026
2281
  }
@@ -2043,7 +2298,10 @@ function getDefaultOptionVal(jsonSchema, multiple) {
2043
2298
  * */
2044
2299
  // 用于区分 对象 和 数组 类型
2045
2300
  function isEqualByType(value1, value2) {
2046
- return isObject(value1) + "-" + isArray(value1) === isObject(value2) + "-" + isArray(value2);
2301
+ return (
2302
+ isObject(value1) + '-' + isArray(value1) ===
2303
+ isObject(value2) + '-' + isArray(value2)
2304
+ );
2047
2305
  }
2048
2306
  /**
2049
2307
  * 基础类型的schema转jsonData
@@ -2053,7 +2311,12 @@ function isEqualByType(value1, value2) {
2053
2311
  function baseSchema2JsonData(jsonSchema, jsonData) {
2054
2312
  var curJsonData = undefined;
2055
2313
  var oldValue = jsonData;
2056
- if (hasProperties(oldValue) && hasProperties(jsonSchema.default) && (typeof oldValue !== typeof jsonSchema.default || !isEqualByType(oldValue, jsonSchema.default))) {
2314
+ if (
2315
+ hasProperties(oldValue) &&
2316
+ hasProperties(jsonSchema.default) &&
2317
+ (typeof oldValue !== typeof jsonSchema.default ||
2318
+ !isEqualByType(oldValue, jsonSchema.default))
2319
+ ) {
2057
2320
  // 表示当前数据类型发生变化,则丢弃旧版数据
2058
2321
  oldValue = undefined;
2059
2322
  }
@@ -2062,10 +2325,16 @@ function baseSchema2JsonData(jsonSchema, jsonData) {
2062
2325
  switch (jsonSchema.type) {
2063
2326
  case 'select':
2064
2327
  case 'radio':
2065
- curJsonData = curValue !== null && curValue !== void 0 ? curValue : getDefaultOptionVal(jsonSchema);
2328
+ curJsonData =
2329
+ curValue !== null && curValue !== void 0
2330
+ ? curValue
2331
+ : getDefaultOptionVal(jsonSchema);
2066
2332
  break;
2067
2333
  case 'checkboxes':
2068
- curJsonData = curValue !== null && curValue !== void 0 ? curValue : getDefaultOptionVal(jsonSchema, true);
2334
+ curJsonData =
2335
+ curValue !== null && curValue !== void 0
2336
+ ? curValue
2337
+ : getDefaultOptionVal(jsonSchema, true);
2069
2338
  break;
2070
2339
  case 'color':
2071
2340
  if (curValue === '#fff' || curValue === '#FFF') {
@@ -2123,7 +2392,12 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2123
2392
  if (isObject(jsonSchema) && getExpectType(jsonSchema.type) === 'object') {
2124
2393
  var jsonItem = jsonSchema;
2125
2394
  var oldValue = jsonData;
2126
- if (hasProperties(oldValue) && (hasProperties(jsonItem.default) && typeof oldValue !== typeof jsonSchema.default || !isObject(oldValue))) {
2395
+ if (
2396
+ hasProperties(oldValue) &&
2397
+ ((hasProperties(jsonItem.default) &&
2398
+ typeof oldValue !== typeof jsonSchema.default) ||
2399
+ !isObject(oldValue))
2400
+ ) {
2127
2401
  // 表示当前数据类型发生变化,则丢弃旧版数据
2128
2402
  oldValue = undefined;
2129
2403
  }
@@ -2137,11 +2411,16 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2137
2411
  }
2138
2412
  } else if (curType === 'datasource') {
2139
2413
  // 数据源类型(固定格式的Object类型)
2140
- if (jsonItem.properties && jsonItem.properties.type && jsonItem.properties.type.default && jsonItem.properties.type.default === 'local') {
2414
+ if (
2415
+ jsonItem.properties &&
2416
+ jsonItem.properties.type &&
2417
+ jsonItem.properties.type.default &&
2418
+ jsonItem.properties.type.default === 'local'
2419
+ ) {
2141
2420
  // 本地数据源类型
2142
2421
  curJsonData = {
2143
2422
  data: '{}',
2144
- filter: '() => {}'
2423
+ filter: '() => {}',
2145
2424
  };
2146
2425
  // 读取旧值
2147
2426
  if (curValue && curValue.data) {
@@ -2158,7 +2437,7 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2158
2437
  // 远程数据类型
2159
2438
  curJsonData = {
2160
2439
  data: 'http://xxx',
2161
- filter: '() => {}'
2440
+ filter: '() => {}',
2162
2441
  };
2163
2442
  // 读取旧值
2164
2443
  if (curValue && curValue.data) {
@@ -2174,19 +2453,24 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2174
2453
  }
2175
2454
  } else if (curType === 'event') {
2176
2455
  // 事件类型(固定格式的Object类型)
2177
- if (jsonItem.properties && jsonItem.properties.type && jsonItem.properties.type.default && jsonItem.properties.type.default === 'emit') {
2456
+ if (
2457
+ jsonItem.properties &&
2458
+ jsonItem.properties.type &&
2459
+ jsonItem.properties.type.default &&
2460
+ jsonItem.properties.type.default === 'emit'
2461
+ ) {
2178
2462
  // 触发事件类型
2179
2463
  if (curValue && curValue.type === 'out') {
2180
2464
  curJsonData = {
2181
- trigger: curValue && curValue.filter || 'eventName',
2465
+ trigger: (curValue && curValue.filter) || 'eventName',
2182
2466
  // 兼容旧版数据
2183
- eventData: '{}'
2467
+ eventData: '{}',
2184
2468
  };
2185
2469
  } else {
2186
2470
  curJsonData = {
2187
2471
  trigger: 'eventName',
2188
2472
  // 兼容旧版数据
2189
- eventData: '{}'
2473
+ eventData: '{}',
2190
2474
  };
2191
2475
  // 读取旧值
2192
2476
  if (curValue && curValue.trigger) {
@@ -2201,13 +2485,13 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2201
2485
  if (curValue && curValue.type === 'in') {
2202
2486
  curJsonData = {
2203
2487
  register: 'eventName',
2204
- actionFunc: curValue && curValue.filter || '() => {}' // 兼容旧版数据
2488
+ actionFunc: (curValue && curValue.filter) || '() => {}', // 兼容旧版数据
2205
2489
  };
2206
2490
  } else {
2207
2491
  curJsonData = {
2208
2492
  register: 'eventName',
2209
2493
  // 兼容旧版数据
2210
- actionFunc: '() => {}'
2494
+ actionFunc: '() => {}',
2211
2495
  };
2212
2496
  // 读取旧值
2213
2497
  if (curValue && curValue.register) {
@@ -2218,9 +2502,18 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2218
2502
  }
2219
2503
  }
2220
2504
  }
2221
- } else if (jsonSchema.isContainer === false && curValue && isObject(curValue) && JSON.stringify(curValue) !== '{}') {
2505
+ } else if (
2506
+ jsonSchema.isContainer === false &&
2507
+ curValue &&
2508
+ isObject(curValue) &&
2509
+ JSON.stringify(curValue) !== '{}'
2510
+ ) {
2222
2511
  curJsonData = Object.assign(curJsonData, curValue);
2223
- } else if (oldValue === undefined && jsonItem.default && isObject(jsonItem.default)) {
2512
+ } else if (
2513
+ oldValue === undefined &&
2514
+ jsonItem.default &&
2515
+ isObject(jsonItem.default)
2516
+ ) {
2224
2517
  curJsonData = jsonItem.default;
2225
2518
  } else if (jsonSchema.properties) {
2226
2519
  var curPropertyOrder = [];
@@ -2235,15 +2528,24 @@ function objectSchema2JsonData(jsonSchema, jsonData) {
2235
2528
  var curOldValue = jsonData && jsonData[jsonKey];
2236
2529
  switch (getExpectType(curJsonItem.type)) {
2237
2530
  case 'array':
2238
- curJsonData[jsonKey] = arraySchema2JsonData(curJsonItem, curOldValue);
2531
+ curJsonData[jsonKey] = arraySchema2JsonData(
2532
+ curJsonItem,
2533
+ curOldValue,
2534
+ );
2239
2535
  break;
2240
2536
  case 'object':
2241
2537
  // 普通对象类型
2242
- curJsonData[jsonKey] = objectSchema2JsonData(curJsonItem, curOldValue);
2538
+ curJsonData[jsonKey] = objectSchema2JsonData(
2539
+ curJsonItem,
2540
+ curOldValue,
2541
+ );
2243
2542
  break;
2244
2543
  default:
2245
2544
  // 其他基础类型
2246
- curJsonData[jsonKey] = baseSchema2JsonData(curJsonItem, curOldValue);
2545
+ curJsonData[jsonKey] = baseSchema2JsonData(
2546
+ curJsonItem,
2547
+ curOldValue,
2548
+ );
2247
2549
  }
2248
2550
  });
2249
2551
  }
@@ -2261,7 +2563,12 @@ function arraySchema2JsonData(jsonSchema, jsonData) {
2261
2563
  if (jsonSchema && getExpectType(jsonSchema.type) === 'array') {
2262
2564
  // Array数据对象类型
2263
2565
  var oldValue = jsonData;
2264
- if (hasProperties(oldValue) && (hasProperties(jsonSchema.default) && typeof oldValue !== typeof jsonSchema.default || !isArray(oldValue))) {
2566
+ if (
2567
+ hasProperties(oldValue) &&
2568
+ ((hasProperties(jsonSchema.default) &&
2569
+ typeof oldValue !== typeof jsonSchema.default) ||
2570
+ !isArray(oldValue))
2571
+ ) {
2265
2572
  // 表示当前数据类型发生变化,则丢弃旧版数据
2266
2573
  oldValue = undefined;
2267
2574
  }
@@ -2347,9 +2654,9 @@ function dataRoute2dataPath(dataRoute, baseDataPath) {
2347
2654
  var dataRouteArr = dataRoute.split('-');
2348
2655
  dataRouteArr.map(function (path) {
2349
2656
  if (/^\d+$/.test(path)) {
2350
- dataPath = dataPath + "[" + path + "]";
2657
+ dataPath = dataPath + '[' + path + ']';
2351
2658
  } else {
2352
- dataPath = dataPath + "." + path;
2659
+ dataPath = dataPath + '.' + path;
2353
2660
  }
2354
2661
  });
2355
2662
  return dataPath;
@@ -2363,38 +2670,42 @@ function json2treeData(mockData, parentDataRoute) {
2363
2670
  var mockDataProps = Object.keys(mockData);
2364
2671
  mockDataProps.map(function (propKey) {
2365
2672
  var mockDataItem = mockData[propKey];
2366
- var curDataRoute = parentDataRoute ? parentDataRoute + "-" + propKey : propKey;
2673
+ var curDataRoute = parentDataRoute
2674
+ ? parentDataRoute + '-' + propKey
2675
+ : propKey;
2367
2676
  if (isObject(mockDataItem) || isArray(mockDataItem)) {
2368
2677
  treeData.push({
2369
2678
  title: propKey,
2370
2679
  value: curDataRoute,
2371
2680
  key: curDataRoute,
2372
- children: json2treeData(mockDataItem, curDataRoute)
2681
+ children: json2treeData(mockDataItem, curDataRoute),
2373
2682
  });
2374
2683
  } else {
2375
2684
  treeData.push({
2376
2685
  title: propKey,
2377
2686
  value: curDataRoute,
2378
- key: curDataRoute
2687
+ key: curDataRoute,
2379
2688
  });
2380
2689
  }
2381
2690
  });
2382
2691
  } else if (isArray(mockData)) {
2383
2692
  mockData.map(function (mockDataItem, index) {
2384
2693
  var indexStr = index.toString();
2385
- var curDataRoute = parentDataRoute ? parentDataRoute + "-" + index : indexStr;
2694
+ var curDataRoute = parentDataRoute
2695
+ ? parentDataRoute + '-' + index
2696
+ : indexStr;
2386
2697
  if (isObject(mockDataItem) || isArray(mockDataItem)) {
2387
2698
  treeData.push({
2388
2699
  title: indexStr,
2389
2700
  value: curDataRoute,
2390
2701
  key: curDataRoute,
2391
- children: json2treeData(mockDataItem, curDataRoute)
2702
+ children: json2treeData(mockDataItem, curDataRoute),
2392
2703
  });
2393
2704
  } else {
2394
2705
  treeData.push({
2395
2706
  title: indexStr,
2396
2707
  value: curDataRoute,
2397
- key: curDataRoute
2708
+ key: curDataRoute,
2398
2709
  });
2399
2710
  }
2400
2711
  });
@@ -2417,11 +2728,14 @@ function schema2conditionValue(jsonSchema, jsonData) {
2417
2728
  curPropertyOrder.map(function (jsonKey) {
2418
2729
  var curJsonItem = jsonSchema.properties[jsonKey];
2419
2730
  var curConditionValue = jsonData[jsonKey];
2420
- if (getExpectType(curJsonItem.type) !== 'array' || getExpectType(curJsonItem.type) !== 'object') {
2731
+ if (
2732
+ getExpectType(curJsonItem.type) !== 'array' ||
2733
+ getExpectType(curJsonItem.type) !== 'object'
2734
+ ) {
2421
2735
  if (curConditionValue && curJsonItem.isConditionProp) {
2422
2736
  // 仅记录条件字段数值
2423
2737
  if (conditionValue.indexOf('-') > 0) {
2424
- conditionValue += "-" + curConditionValue;
2738
+ conditionValue += '-' + curConditionValue;
2425
2739
  } else {
2426
2740
  conditionValue = curConditionValue;
2427
2741
  }
@@ -2450,6 +2764,90 @@ function getParentKeyRoute_CurKey(curKeyRoute) {
2450
2764
  }
2451
2765
 
2452
2766
  // JSONSchema关键字清单
2453
- var KeyWordList = ['key', 'enum', 'enumextra', 'items', 'input', 'boolean', 'number', 'color', 'url', 'textarea', 'text-editor', 'radio', 'select', 'checkboxes', 'date', 'date-time', 'time', 'json', 'codearea', 'htmlarea', 'quantity', 'box-style', 'dynamic-data', 'datasource', 'event', 'array', 'object'];
2767
+ var KeyWordList = [
2768
+ 'key',
2769
+ 'enum',
2770
+ 'enumextra',
2771
+ 'items',
2772
+ 'input',
2773
+ 'boolean',
2774
+ 'number',
2775
+ 'color',
2776
+ 'url',
2777
+ 'textarea',
2778
+ 'text-editor',
2779
+ 'radio',
2780
+ 'select',
2781
+ 'checkboxes',
2782
+ 'date',
2783
+ 'date-time',
2784
+ 'time',
2785
+ 'json',
2786
+ 'codearea',
2787
+ 'htmlarea',
2788
+ 'quantity',
2789
+ 'box-style',
2790
+ 'dynamic-data',
2791
+ 'datasource',
2792
+ 'event',
2793
+ 'array',
2794
+ 'object',
2795
+ ];
2454
2796
 
2455
- export { DataSourceTypeList, EventTypeDataList, KeyWordList, TypeDataList, dataRoute2dataPath, evalExpression, getCurPosition, getDefaultOptionVal, getExpectType, getJsonDataByKeyRoute, getNextIndexRoute, getParentIndexRoute, getParentIndexRoute_CurIndex, getParentKeyRoute, getParentKeyRoute_CurKey, getSchemaByIndexRoute, getSchemaByKeyRoute, hasProperties, indexRoute2keyRoute, isArray, isBoolean, isColor, isContainerSchema, isDateStr, isDateTimeStr, isEmptySchema, isEqual, isEqualByIdT, isFunction, isNewSchemaData, isNumber, isObject, isQuantity, isSameParent, isSelect, isString, isStructuredSchema, isTimeStr, isURL, json2schema, json2treeData, keyRoute2indexRoute, metaElemAnalyzer, moveBackward, moveForward, objClone, oldSchemaToNewSchema, oldSchemaToNewSchemaV1, registerExpectType, schema2conditionValue, schema2json, schemaMetaList, truncate, urlParse, urlStringify };
2797
+ export {
2798
+ DataSourceTypeList,
2799
+ EventTypeDataList,
2800
+ KeyWordList,
2801
+ TypeDataList,
2802
+ dataRoute2dataPath,
2803
+ evalExpression,
2804
+ getCurPosition,
2805
+ getDefaultOptionVal,
2806
+ getExpectType,
2807
+ getJsonDataByKeyRoute,
2808
+ getNextIndexRoute,
2809
+ getParentIndexRoute,
2810
+ getParentIndexRoute_CurIndex,
2811
+ getParentKeyRoute,
2812
+ getParentKeyRoute_CurKey,
2813
+ getSchemaByIndexRoute,
2814
+ getSchemaByKeyRoute,
2815
+ hasProperties,
2816
+ indexRoute2keyRoute,
2817
+ isArray,
2818
+ isBoolean,
2819
+ isColor,
2820
+ isContainerSchema,
2821
+ isDateStr,
2822
+ isDateTimeStr,
2823
+ isEmptySchema,
2824
+ isEqual,
2825
+ isEqualByIdT,
2826
+ isFunction,
2827
+ isNewSchemaData,
2828
+ isNumber,
2829
+ isObject,
2830
+ isQuantity,
2831
+ isSameParent,
2832
+ isSelect,
2833
+ isString,
2834
+ isStructuredSchema,
2835
+ isTimeStr,
2836
+ isURL,
2837
+ json2schema,
2838
+ json2treeData,
2839
+ keyRoute2indexRoute,
2840
+ metaElemAnalyzer,
2841
+ moveBackward,
2842
+ moveForward,
2843
+ objClone,
2844
+ oldSchemaToNewSchema,
2845
+ oldSchemaToNewSchemaV1,
2846
+ registerExpectType,
2847
+ schema2conditionValue,
2848
+ schema2json,
2849
+ schemaMetaList,
2850
+ truncate,
2851
+ urlParse,
2852
+ urlStringify,
2853
+ };