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