tianheng-ui 0.0.47 → 0.0.50
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/README.md +11 -11
- package/lib/iconfont.svg +155 -155
- package/lib/index.js +3 -3
- package/lib/tianheng-ui.js +3 -3
- package/package.json +1 -1
- package/packages/dialog/index.vue +4 -1
- package/packages/formMaking/Container.vue +591 -601
- package/packages/formMaking/CusDialog.vue +134 -134
- package/packages/formMaking/FormConfig.vue +40 -40
- package/packages/formMaking/GenerateForm.vue +176 -184
- package/packages/formMaking/GenerateFormItem.vue +203 -17
- package/packages/formMaking/Upload/index.vue +572 -572
- package/packages/formMaking/WidgetConfig.vue +212 -34
- package/packages/formMaking/WidgetForm.vue +134 -268
- package/packages/formMaking/WidgetFormItem.vue +382 -30
- package/packages/formMaking/componentsConfig.js +159 -14
- package/packages/formMaking/generateCode.js +163 -155
- package/packages/formMaking/iconfont/demo.css +539 -539
- package/packages/formMaking/iconfont/demo_index.html +1159 -1159
- package/packages/formMaking/iconfont/iconfont.css +189 -189
- package/packages/formMaking/iconfont/iconfont.svg +155 -155
- package/packages/formMaking/index.js +77 -77
- package/packages/formMaking/lang/en-US.js +187 -187
- package/packages/formMaking/lang/zh-CN.js +187 -187
- package/packages/formMaking/styles/cover.scss +3 -3
- package/packages/formMaking/styles/index.scss +768 -746
- package/packages/formMaking/util/index.js +32 -32
- package/packages/formMaking/util/request.js +28 -28
- package/packages/table/search.vue +46 -37
@@ -1,601 +1,591 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="fm-style">
|
3
|
-
<el-container class="fm2-container">
|
4
|
-
<el-main class="fm2-main">
|
5
|
-
<el-container>
|
6
|
-
<el-aside width="250px">
|
7
|
-
<div class="components-list">
|
8
|
-
<template v-if="basicFields.length">
|
9
|
-
<div class="widget-cate">
|
10
|
-
基础字段
|
11
|
-
</div>
|
12
|
-
<draggable
|
13
|
-
tag="ul"
|
14
|
-
:list="basicComponents"
|
15
|
-
v-bind="{
|
16
|
-
group: { name: 'people', pull: 'clone', put: false },
|
17
|
-
sort: false,
|
18
|
-
ghostClass: 'ghost'
|
19
|
-
}"
|
20
|
-
@end="handleMoveEnd"
|
21
|
-
@start="handleMoveStart"
|
22
|
-
:move="handleMove"
|
23
|
-
>
|
24
|
-
<template v-for="(item, index) in basicComponents">
|
25
|
-
<li
|
26
|
-
v-if="basicFields.indexOf(item.type) >= 0"
|
27
|
-
class="form-edit-widget-label"
|
28
|
-
:class="{ 'no-put': item.type == 'divider' }"
|
29
|
-
:key="index"
|
30
|
-
>
|
31
|
-
<a>
|
32
|
-
<i class="icon iconfont" :class="item.icon"></i>
|
33
|
-
<span>{{ item.name }}</span>
|
34
|
-
</a>
|
35
|
-
</li>
|
36
|
-
</template>
|
37
|
-
</draggable>
|
38
|
-
</template>
|
39
|
-
<template v-if="advanceFields.length">
|
40
|
-
<div class="widget-cate">
|
41
|
-
高级字段
|
42
|
-
</div>
|
43
|
-
<draggable
|
44
|
-
tag="ul"
|
45
|
-
:list="advanceComponents"
|
46
|
-
v-bind="{
|
47
|
-
group: { name: 'people', pull: 'clone', put: false },
|
48
|
-
sort: false,
|
49
|
-
ghostClass: 'ghost'
|
50
|
-
}"
|
51
|
-
@end="handleMoveEnd"
|
52
|
-
@start="handleMoveStart"
|
53
|
-
:move="handleMove"
|
54
|
-
>
|
55
|
-
<template v-for="(item, index) in advanceComponents">
|
56
|
-
<li
|
57
|
-
v-if="advanceFields.indexOf(item.type) >= 0"
|
58
|
-
class="form-edit-widget-label"
|
59
|
-
:class="{ 'no-put': item.type == 'table' }"
|
60
|
-
:key="index"
|
61
|
-
>
|
62
|
-
<a>
|
63
|
-
<i class="icon iconfont" :class="item.icon"></i>
|
64
|
-
<span>{{ item.name }}</span>
|
65
|
-
</a>
|
66
|
-
</li>
|
67
|
-
</template>
|
68
|
-
</draggable>
|
69
|
-
</template>
|
70
|
-
|
71
|
-
<template v-if="layoutFields.length">
|
72
|
-
<div class="widget-cate">
|
73
|
-
布局字段
|
74
|
-
</div>
|
75
|
-
<draggable
|
76
|
-
tag="ul"
|
77
|
-
:list="layoutComponents"
|
78
|
-
v-bind="{
|
79
|
-
group: { name: 'people', pull: 'clone', put: false },
|
80
|
-
sort: false,
|
81
|
-
ghostClass: 'ghost'
|
82
|
-
}"
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
>
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
>
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
form
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
:
|
201
|
-
:
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
import
|
303
|
-
import "
|
304
|
-
import "
|
305
|
-
import
|
306
|
-
|
307
|
-
import
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
import
|
313
|
-
import
|
314
|
-
import
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
"
|
361
|
-
"
|
362
|
-
"
|
363
|
-
"
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
//
|
453
|
-
|
454
|
-
|
455
|
-
//
|
456
|
-
//
|
457
|
-
//
|
458
|
-
//
|
459
|
-
//
|
460
|
-
//
|
461
|
-
//
|
462
|
-
//
|
463
|
-
//
|
464
|
-
//
|
465
|
-
//
|
466
|
-
//
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
},
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
this.
|
528
|
-
this.$nextTick(() => {
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
this.
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
this.
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
},
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
handler: function(val) {
|
593
|
-
// console.log(this.$refs.widgetForm);
|
594
|
-
}
|
595
|
-
},
|
596
|
-
$lang: function(val) {
|
597
|
-
this._loadComponents();
|
598
|
-
}
|
599
|
-
}
|
600
|
-
};
|
601
|
-
</script>
|
1
|
+
<template>
|
2
|
+
<div class="fm-style">
|
3
|
+
<el-container class="fm2-container">
|
4
|
+
<el-main class="fm2-main">
|
5
|
+
<el-container>
|
6
|
+
<el-aside width="250px">
|
7
|
+
<div class="components-list">
|
8
|
+
<template v-if="basicFields.length">
|
9
|
+
<div class="widget-cate">
|
10
|
+
基础字段
|
11
|
+
</div>
|
12
|
+
<draggable
|
13
|
+
tag="ul"
|
14
|
+
:list="basicComponents"
|
15
|
+
v-bind="{
|
16
|
+
group: { name: 'people', pull: 'clone', put: false },
|
17
|
+
sort: false,
|
18
|
+
ghostClass: 'ghost'
|
19
|
+
}"
|
20
|
+
@end="handleMoveEnd"
|
21
|
+
@start="handleMoveStart"
|
22
|
+
:move="handleMove"
|
23
|
+
>
|
24
|
+
<template v-for="(item, index) in basicComponents">
|
25
|
+
<li
|
26
|
+
v-if="basicFields.indexOf(item.type) >= 0"
|
27
|
+
class="form-edit-widget-label"
|
28
|
+
:class="{ 'no-put': item.type == 'divider' }"
|
29
|
+
:key="index"
|
30
|
+
>
|
31
|
+
<a>
|
32
|
+
<i class="icon iconfont" :class="item.icon"></i>
|
33
|
+
<span>{{ item.name }}</span>
|
34
|
+
</a>
|
35
|
+
</li>
|
36
|
+
</template>
|
37
|
+
</draggable>
|
38
|
+
</template>
|
39
|
+
<template v-if="advanceFields.length">
|
40
|
+
<div class="widget-cate">
|
41
|
+
高级字段
|
42
|
+
</div>
|
43
|
+
<draggable
|
44
|
+
tag="ul"
|
45
|
+
:list="advanceComponents"
|
46
|
+
v-bind="{
|
47
|
+
group: { name: 'people', pull: 'clone', put: false },
|
48
|
+
sort: false,
|
49
|
+
ghostClass: 'ghost'
|
50
|
+
}"
|
51
|
+
@end="handleMoveEnd"
|
52
|
+
@start="handleMoveStart"
|
53
|
+
:move="handleMove"
|
54
|
+
>
|
55
|
+
<template v-for="(item, index) in advanceComponents">
|
56
|
+
<li
|
57
|
+
v-if="advanceFields.indexOf(item.type) >= 0"
|
58
|
+
class="form-edit-widget-label"
|
59
|
+
:class="{ 'no-put': item.type == 'table' }"
|
60
|
+
:key="index"
|
61
|
+
>
|
62
|
+
<a>
|
63
|
+
<i class="icon iconfont" :class="item.icon"></i>
|
64
|
+
<span>{{ item.name }}</span>
|
65
|
+
</a>
|
66
|
+
</li>
|
67
|
+
</template>
|
68
|
+
</draggable>
|
69
|
+
</template>
|
70
|
+
|
71
|
+
<template v-if="layoutFields.length">
|
72
|
+
<div class="widget-cate">
|
73
|
+
布局字段
|
74
|
+
</div>
|
75
|
+
<draggable
|
76
|
+
tag="ul"
|
77
|
+
:list="layoutComponents"
|
78
|
+
v-bind="{
|
79
|
+
group: { name: 'people', pull: 'clone', put: false },
|
80
|
+
sort: false,
|
81
|
+
ghostClass: 'ghost'
|
82
|
+
}"
|
83
|
+
>
|
84
|
+
<template v-for="(item, index) in layoutComponents">
|
85
|
+
<li
|
86
|
+
v-if="layoutFields.indexOf(item.type) >= 0"
|
87
|
+
class="form-edit-widget-label no-put"
|
88
|
+
:key="index"
|
89
|
+
>
|
90
|
+
<a>
|
91
|
+
<i class="icon iconfont" :class="item.icon"></i>
|
92
|
+
<span>{{ item.name }}</span>
|
93
|
+
</a>
|
94
|
+
</li>
|
95
|
+
</template>
|
96
|
+
</draggable>
|
97
|
+
</template>
|
98
|
+
</div>
|
99
|
+
</el-aside>
|
100
|
+
<el-container class="center-container" direction="vertical">
|
101
|
+
<el-header class="btn-bar" style="height: 45px;">
|
102
|
+
<slot name="action"> </slot>
|
103
|
+
<el-button
|
104
|
+
v-if="upload"
|
105
|
+
type="text"
|
106
|
+
size="medium"
|
107
|
+
icon="el-icon-upload2"
|
108
|
+
@click="handleUpload"
|
109
|
+
>导入JSON</el-button
|
110
|
+
>
|
111
|
+
<el-button
|
112
|
+
v-if="clearable"
|
113
|
+
type="text"
|
114
|
+
size="medium"
|
115
|
+
icon="el-icon-delete"
|
116
|
+
@click="handleClear"
|
117
|
+
>清空</el-button
|
118
|
+
>
|
119
|
+
<el-button
|
120
|
+
v-if="preview"
|
121
|
+
type="text"
|
122
|
+
size="medium"
|
123
|
+
icon="el-icon-view"
|
124
|
+
@click="handlePreview"
|
125
|
+
>预览</el-button
|
126
|
+
>
|
127
|
+
<el-button
|
128
|
+
v-if="generateJson"
|
129
|
+
type="text"
|
130
|
+
size="medium"
|
131
|
+
icon="el-icon-tickets"
|
132
|
+
@click="handleGenerateJson"
|
133
|
+
>生成JSON</el-button
|
134
|
+
>
|
135
|
+
<el-button
|
136
|
+
v-if="generateCode"
|
137
|
+
type="text"
|
138
|
+
size="medium"
|
139
|
+
icon="el-icon-document"
|
140
|
+
@click="handleGenerateCode"
|
141
|
+
>生成代码</el-button
|
142
|
+
>
|
143
|
+
</el-header>
|
144
|
+
<el-main :class="{ 'widget-empty': widgetForm.list.length == 0 }">
|
145
|
+
<widget-form
|
146
|
+
v-if="!resetJson"
|
147
|
+
ref="widgetForm"
|
148
|
+
:data="widgetForm"
|
149
|
+
:select.sync="widgetFormSelect"
|
150
|
+
>
|
151
|
+
</widget-form>
|
152
|
+
</el-main>
|
153
|
+
</el-container>
|
154
|
+
|
155
|
+
<el-aside class="widget-config-container">
|
156
|
+
<el-container>
|
157
|
+
<el-header height="45px">
|
158
|
+
<div
|
159
|
+
class="config-tab"
|
160
|
+
:class="{ active: configTab == 'widget' }"
|
161
|
+
@click="handleConfigSelect('widget')"
|
162
|
+
>
|
163
|
+
字段属性
|
164
|
+
</div>
|
165
|
+
<div
|
166
|
+
class="config-tab"
|
167
|
+
:class="{ active: configTab == 'form' }"
|
168
|
+
@click="handleConfigSelect('form')"
|
169
|
+
>
|
170
|
+
表单属性
|
171
|
+
</div>
|
172
|
+
</el-header>
|
173
|
+
<el-main class="config-content">
|
174
|
+
<widget-config
|
175
|
+
v-show="configTab == 'widget'"
|
176
|
+
:data="widgetFormSelect"
|
177
|
+
:remoteApis="remoteApis"
|
178
|
+
></widget-config>
|
179
|
+
<form-config
|
180
|
+
v-show="configTab == 'form'"
|
181
|
+
:data="widgetForm.config"
|
182
|
+
></form-config>
|
183
|
+
</el-main>
|
184
|
+
</el-container>
|
185
|
+
</el-aside>
|
186
|
+
|
187
|
+
<cus-dialog
|
188
|
+
:visible="previewVisible"
|
189
|
+
@on-close="previewVisible = false"
|
190
|
+
ref="widgetPreview"
|
191
|
+
width="1000px"
|
192
|
+
form
|
193
|
+
>
|
194
|
+
<generate-form
|
195
|
+
insite="true"
|
196
|
+
@on-change="handleDataChange"
|
197
|
+
v-if="previewVisible"
|
198
|
+
:data="widgetForm"
|
199
|
+
:value="widgetModels"
|
200
|
+
:remote="remoteFuncs"
|
201
|
+
:slotKeys="slotKeys"
|
202
|
+
ref="generateForm"
|
203
|
+
>
|
204
|
+
<template v-for="name in slotKeys" :slot="name">
|
205
|
+
<slot :name="name" />
|
206
|
+
</template>
|
207
|
+
</generate-form>
|
208
|
+
|
209
|
+
<template slot="action">
|
210
|
+
<el-button type="primary" @click="handleTest">获取数据</el-button>
|
211
|
+
<el-button @click="handleReset">重置</el-button>
|
212
|
+
</template>
|
213
|
+
</cus-dialog>
|
214
|
+
|
215
|
+
<cus-dialog
|
216
|
+
:visible="uploadVisible"
|
217
|
+
@on-close="uploadVisible = false"
|
218
|
+
@on-submit="handleUploadJson"
|
219
|
+
ref="uploadJson"
|
220
|
+
width="800px"
|
221
|
+
form
|
222
|
+
>
|
223
|
+
<el-alert
|
224
|
+
type="info"
|
225
|
+
title="JSON格式如下,直接复制生成的json覆盖此处代码点击确定即可"
|
226
|
+
></el-alert>
|
227
|
+
<div id="uploadeditor" style="height: 400px;width: 100%;">
|
228
|
+
{{ jsonEg }}
|
229
|
+
</div>
|
230
|
+
</cus-dialog>
|
231
|
+
|
232
|
+
<cus-dialog
|
233
|
+
:visible="jsonVisible"
|
234
|
+
@on-close="jsonVisible = false"
|
235
|
+
ref="jsonPreview"
|
236
|
+
width="800px"
|
237
|
+
form
|
238
|
+
>
|
239
|
+
<div id="jsoneditor" style="height: 400px;width: 100%;">
|
240
|
+
{{ jsonTemplate }}
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<template slot="action">
|
244
|
+
<el-button
|
245
|
+
type="primary"
|
246
|
+
class="json-btn"
|
247
|
+
:data-clipboard-text="jsonCopyValue"
|
248
|
+
>复制数据</el-button
|
249
|
+
>
|
250
|
+
</template>
|
251
|
+
</cus-dialog>
|
252
|
+
|
253
|
+
<cus-dialog
|
254
|
+
:visible="codeVisible"
|
255
|
+
@on-close="codeVisible = false"
|
256
|
+
ref="codePreview"
|
257
|
+
width="800px"
|
258
|
+
form
|
259
|
+
:action="false"
|
260
|
+
>
|
261
|
+
<!-- <div id="codeeditor" style="height: 500px; width: 100%;">{{htmlTemplate}}</div> -->
|
262
|
+
<el-tabs
|
263
|
+
type="border-card"
|
264
|
+
style="box-shadow: none;"
|
265
|
+
v-model="codeActiveName"
|
266
|
+
>
|
267
|
+
<el-tab-pane label="Vue Component" name="vue">
|
268
|
+
<div id="vuecodeeditor" style="height: 500px; width: 100%;">
|
269
|
+
{{ vueTemplate }}
|
270
|
+
</div>
|
271
|
+
</el-tab-pane>
|
272
|
+
<el-tab-pane label="HTML" name="html">
|
273
|
+
<div id="codeeditor" style="height: 500px; width: 100%;">
|
274
|
+
{{ htmlTemplate }}
|
275
|
+
</div>
|
276
|
+
</el-tab-pane>
|
277
|
+
</el-tabs>
|
278
|
+
</cus-dialog>
|
279
|
+
</el-container>
|
280
|
+
</el-main>
|
281
|
+
<!-- <el-footer height="30px" style="font-weight: 600;"
|
282
|
+
>Powered by
|
283
|
+
<a target="_blank" href="https://github.com/GavinZhuLei/vue-form-making"
|
284
|
+
>vue-form-making</a
|
285
|
+
></el-footer
|
286
|
+
> -->
|
287
|
+
</el-container>
|
288
|
+
</div>
|
289
|
+
</template>
|
290
|
+
|
291
|
+
<script>
|
292
|
+
import ace from "ace-builds";
|
293
|
+
import "ace-builds/src-min-noconflict/mode-json";
|
294
|
+
import "ace-builds/src-min-noconflict/mode-html";
|
295
|
+
import htmlWorkerUrl from "file-loader!ace-builds/src-min-noconflict/worker-html";
|
296
|
+
ace.config.setModuleUrl("ace/mode/html_worker", htmlWorkerUrl);
|
297
|
+
import jsonWorkerUrl from "file-loader!ace-builds/src-noconflict/worker-json";
|
298
|
+
ace.config.setModuleUrl("ace/mode/json_worker", jsonWorkerUrl);
|
299
|
+
|
300
|
+
import Draggable from "vuedraggable";
|
301
|
+
import Clipboard from "clipboard";
|
302
|
+
import WidgetConfig from "./WidgetConfig";
|
303
|
+
import FormConfig from "./FormConfig";
|
304
|
+
import WidgetForm from "./WidgetForm";
|
305
|
+
import CusDialog from "./CusDialog";
|
306
|
+
import GenerateForm from "./GenerateForm";
|
307
|
+
import {
|
308
|
+
basicComponents,
|
309
|
+
advanceComponents,
|
310
|
+
layoutComponents
|
311
|
+
} from "./componentsConfig.js";
|
312
|
+
// import {loadJs, loadCss} from '../util/index.js'
|
313
|
+
import request from "./util/request";
|
314
|
+
import generateCode from "./generateCode.js";
|
315
|
+
|
316
|
+
export default {
|
317
|
+
name: "fm-making-form",
|
318
|
+
components: {
|
319
|
+
Draggable,
|
320
|
+
WidgetConfig,
|
321
|
+
FormConfig,
|
322
|
+
WidgetForm,
|
323
|
+
CusDialog,
|
324
|
+
GenerateForm
|
325
|
+
},
|
326
|
+
props: {
|
327
|
+
preview: {
|
328
|
+
type: Boolean,
|
329
|
+
default: false
|
330
|
+
},
|
331
|
+
generateCode: {
|
332
|
+
type: Boolean,
|
333
|
+
default: false
|
334
|
+
},
|
335
|
+
generateJson: {
|
336
|
+
type: Boolean,
|
337
|
+
default: false
|
338
|
+
},
|
339
|
+
upload: {
|
340
|
+
type: Boolean,
|
341
|
+
default: false
|
342
|
+
},
|
343
|
+
clearable: {
|
344
|
+
type: Boolean,
|
345
|
+
default: false
|
346
|
+
},
|
347
|
+
basicFields: {
|
348
|
+
type: Array,
|
349
|
+
default: () => [
|
350
|
+
"input",
|
351
|
+
"textarea",
|
352
|
+
"number",
|
353
|
+
"radio",
|
354
|
+
"checkbox",
|
355
|
+
"time",
|
356
|
+
"date",
|
357
|
+
"rate",
|
358
|
+
"color",
|
359
|
+
"select",
|
360
|
+
"switch",
|
361
|
+
"slider",
|
362
|
+
"text",
|
363
|
+
"button"
|
364
|
+
]
|
365
|
+
},
|
366
|
+
advanceFields: {
|
367
|
+
type: Array,
|
368
|
+
default: () => ["blank", "imgupload", "editor", "cascader", "table"]
|
369
|
+
},
|
370
|
+
layoutFields: {
|
371
|
+
type: Array,
|
372
|
+
default: () => ["grid", "tabs", "divider"]
|
373
|
+
},
|
374
|
+
remoteApis: {
|
375
|
+
type: Array,
|
376
|
+
default: () => []
|
377
|
+
}
|
378
|
+
},
|
379
|
+
data() {
|
380
|
+
return {
|
381
|
+
basicComponents,
|
382
|
+
layoutComponents,
|
383
|
+
advanceComponents,
|
384
|
+
resetJson: false,
|
385
|
+
widgetForm: {
|
386
|
+
list: [],
|
387
|
+
config: {
|
388
|
+
labelWidth: 100,
|
389
|
+
labelPosition: "right",
|
390
|
+
size: "small"
|
391
|
+
}
|
392
|
+
},
|
393
|
+
configTab: "widget",
|
394
|
+
widgetFormSelect: null,
|
395
|
+
previewVisible: false,
|
396
|
+
jsonVisible: false,
|
397
|
+
codeVisible: false,
|
398
|
+
uploadVisible: false,
|
399
|
+
remoteFuncs: {
|
400
|
+
func_test(resolve) {
|
401
|
+
setTimeout(() => {
|
402
|
+
const options = [
|
403
|
+
{ id: "1", name: "1111" },
|
404
|
+
{ id: "2", name: "2222" },
|
405
|
+
{ id: "3", name: "3333" }
|
406
|
+
];
|
407
|
+
|
408
|
+
resolve(options);
|
409
|
+
}, 2000);
|
410
|
+
},
|
411
|
+
funcGetToken(resolve) {
|
412
|
+
request
|
413
|
+
.get("http://tools-server.making.link/api/uptoken")
|
414
|
+
.then(res => {
|
415
|
+
resolve(res.uptoken);
|
416
|
+
});
|
417
|
+
},
|
418
|
+
upload_callback(response, file, fileList) {
|
419
|
+
console.log("callback", response, file, fileList);
|
420
|
+
}
|
421
|
+
},
|
422
|
+
widgetModels: { table: [{ name: "这是" }] },
|
423
|
+
blank: "",
|
424
|
+
htmlTemplate: "",
|
425
|
+
vueTemplate: "",
|
426
|
+
jsonTemplate: "",
|
427
|
+
uploadEditor: null,
|
428
|
+
jsonCopyValue: "",
|
429
|
+
jsonClipboard: null,
|
430
|
+
jsonEg: `
|
431
|
+
{
|
432
|
+
"list": [],
|
433
|
+
"config": {
|
434
|
+
"labelWidth": 100,
|
435
|
+
"labelPosition": "top",
|
436
|
+
"size": "small"
|
437
|
+
}
|
438
|
+
}`,
|
439
|
+
codeActiveName: "vue",
|
440
|
+
slotKeys: []
|
441
|
+
};
|
442
|
+
},
|
443
|
+
mounted() {
|
444
|
+
// this._loadComponents();
|
445
|
+
},
|
446
|
+
methods: {
|
447
|
+
// _loadComponents() {
|
448
|
+
// this.basicComponents = this.basicComponents.map(item => {
|
449
|
+
// return {
|
450
|
+
// ...item,
|
451
|
+
// name: this.$t(`fm.components.fields.${item.type}`)
|
452
|
+
// };
|
453
|
+
// });
|
454
|
+
// this.advanceComponents = this.advanceComponents.map(item => {
|
455
|
+
// return {
|
456
|
+
// ...item,
|
457
|
+
// name: this.$t(`fm.components.fields.${item.type}`)
|
458
|
+
// };
|
459
|
+
// });
|
460
|
+
// this.layoutComponents = this.layoutComponents.map(item => {
|
461
|
+
// return {
|
462
|
+
// ...item,
|
463
|
+
// name: this.$t(`fm.components.fields.${item.type}`)
|
464
|
+
// };
|
465
|
+
// });
|
466
|
+
// },
|
467
|
+
handleConfigSelect(value) {
|
468
|
+
this.configTab = value;
|
469
|
+
},
|
470
|
+
handleMoveEnd(evt) {
|
471
|
+
// console.log("end", evt);
|
472
|
+
},
|
473
|
+
handleMoveStart({ oldIndex }) {
|
474
|
+
// console.log("start", oldIndex, this.basicComponents);
|
475
|
+
},
|
476
|
+
handleMove() {
|
477
|
+
return true;
|
478
|
+
},
|
479
|
+
handlePreview() {
|
480
|
+
// console.log(this.widgetForm);
|
481
|
+
this.slotKeys = Object.keys(this.$slots);
|
482
|
+
this.previewVisible = true;
|
483
|
+
},
|
484
|
+
handleTest() {
|
485
|
+
this.$refs.generateForm
|
486
|
+
.getData()
|
487
|
+
.then(data => {
|
488
|
+
this.$alert(data, "").catch(e => {});
|
489
|
+
this.$refs.widgetPreview.end();
|
490
|
+
})
|
491
|
+
.catch(e => {
|
492
|
+
this.$refs.widgetPreview.end();
|
493
|
+
});
|
494
|
+
},
|
495
|
+
handleReset() {
|
496
|
+
this.$refs.generateForm.reset();
|
497
|
+
},
|
498
|
+
handleGenerateJson() {
|
499
|
+
this.jsonVisible = true;
|
500
|
+
this.jsonTemplate = this.widgetForm;
|
501
|
+
this.$nextTick(() => {
|
502
|
+
const editor = ace.edit("jsoneditor");
|
503
|
+
editor.session.setMode("ace/mode/json");
|
504
|
+
|
505
|
+
if (!this.jsonClipboard) {
|
506
|
+
this.jsonClipboard = new Clipboard(".json-btn");
|
507
|
+
this.jsonClipboard.on("success", e => {
|
508
|
+
this.$message.success("复制成功");
|
509
|
+
});
|
510
|
+
}
|
511
|
+
this.jsonCopyValue = JSON.stringify(this.widgetForm);
|
512
|
+
});
|
513
|
+
},
|
514
|
+
handleGenerateCode() {
|
515
|
+
this.codeVisible = true;
|
516
|
+
this.htmlTemplate = generateCode(JSON.stringify(this.widgetForm), "html");
|
517
|
+
this.vueTemplate = generateCode(JSON.stringify(this.widgetForm), "vue");
|
518
|
+
this.$nextTick(() => {
|
519
|
+
const editor = ace.edit("codeeditor");
|
520
|
+
editor.session.setMode("ace/mode/html");
|
521
|
+
|
522
|
+
const vueeditor = ace.edit("vuecodeeditor");
|
523
|
+
vueeditor.session.setMode("ace/mode/html");
|
524
|
+
});
|
525
|
+
},
|
526
|
+
handleUpload() {
|
527
|
+
this.uploadVisible = true;
|
528
|
+
this.$nextTick(() => {
|
529
|
+
this.uploadEditor = ace.edit("uploadeditor");
|
530
|
+
this.uploadEditor.session.setMode("ace/mode/json");
|
531
|
+
});
|
532
|
+
},
|
533
|
+
handleUploadJson() {
|
534
|
+
try {
|
535
|
+
this.setJSON(JSON.parse(this.uploadEditor.getValue()));
|
536
|
+
this.uploadVisible = false;
|
537
|
+
} catch (e) {
|
538
|
+
this.$message.error(e.message);
|
539
|
+
this.$refs.uploadJson.end();
|
540
|
+
}
|
541
|
+
},
|
542
|
+
handleClear() {
|
543
|
+
this.widgetForm = {
|
544
|
+
list: [],
|
545
|
+
config: {
|
546
|
+
labelWidth: 100,
|
547
|
+
labelPosition: "right",
|
548
|
+
size: "small",
|
549
|
+
customClass: ""
|
550
|
+
}
|
551
|
+
};
|
552
|
+
|
553
|
+
this.widgetFormSelect = {};
|
554
|
+
},
|
555
|
+
clear() {
|
556
|
+
this.handleClear();
|
557
|
+
},
|
558
|
+
getJSON() {
|
559
|
+
return this.widgetForm;
|
560
|
+
},
|
561
|
+
getHtml() {
|
562
|
+
return generateCode(JSON.stringify(this.widgetForm));
|
563
|
+
},
|
564
|
+
setJSON(json) {
|
565
|
+
this.widgetForm = json;
|
566
|
+
|
567
|
+
if (json.list.length > 0) {
|
568
|
+
this.widgetFormSelect = json.list[0];
|
569
|
+
}
|
570
|
+
},
|
571
|
+
handleInput(val) {
|
572
|
+
// console.log(val);
|
573
|
+
this.blank = val;
|
574
|
+
},
|
575
|
+
handleDataChange(field, value, data) {
|
576
|
+
// console.log(field, value, data);
|
577
|
+
}
|
578
|
+
},
|
579
|
+
watch: {
|
580
|
+
widgetForm: {
|
581
|
+
deep: true,
|
582
|
+
handler: function(val) {
|
583
|
+
// console.log(this.$refs.widgetForm);
|
584
|
+
}
|
585
|
+
},
|
586
|
+
$lang: function(val) {
|
587
|
+
this._loadComponents();
|
588
|
+
}
|
589
|
+
}
|
590
|
+
};
|
591
|
+
</script>
|