tianheng-ui 0.0.45 → 0.0.48

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.
@@ -1,5 +1,20 @@
1
1
  <template>
2
- <el-form-item :label="widget.name" :prop="widget.model">
2
+ <el-form-item
3
+ :label="widget.options.hideLabel || hideLabel ? '' : widget.name"
4
+ :label-width="
5
+ widget.options.hideLabel
6
+ ? '0'
7
+ : widget.options.isLabelWidth
8
+ ? `${widget.options.labelWidth}px`
9
+ : ''
10
+ "
11
+ :prop="
12
+ tableInfo
13
+ ? `${tableInfo.data.model}.${tableInfo.index}.${widget.model}`
14
+ : widget.model
15
+ "
16
+ :rules="rules[widget.model]"
17
+ >
3
18
  <template v-if="widget.type == 'input'">
4
19
  <el-input
5
20
  v-if="
@@ -10,7 +25,7 @@
10
25
  type="number"
11
26
  v-model.number="dataModel"
12
27
  :placeholder="widget.options.placeholder"
13
- :style="{ width: widget.options.width }"
28
+ :style="{ width: width ? width : widget.options.width }"
14
29
  :disabled="widget.options.disabled"
15
30
  :readonly="widget.options.readonly"
16
31
  :clearable="widget.options.clearable"
@@ -24,7 +39,7 @@
24
39
  type="text"
25
40
  v-model="dataModel"
26
41
  :placeholder="widget.options.placeholder"
27
- :style="{ width: widget.options.width }"
42
+ :style="{ width: width ? width : widget.options.width }"
28
43
  :disabled="widget.options.disabled"
29
44
  :readonly="widget.options.readonly"
30
45
  :clearable="widget.options.clearable"
@@ -49,7 +64,7 @@
49
64
  v-model="dataModel"
50
65
  :disabled="widget.options.disabled"
51
66
  :placeholder="widget.options.placeholder"
52
- :style="{ width: widget.options.width }"
67
+ :style="{ width: width ? width : widget.options.width }"
53
68
  :maxlength="widget.options.maxlength"
54
69
  :clearable="widget.options.clearable"
55
70
  :show-word-limit="widget.options.showWordLimit"
@@ -63,7 +78,7 @@
63
78
  <template v-if="widget.type == 'number'">
64
79
  <el-input-number
65
80
  v-model="dataModel"
66
- :style="{ width: widget.options.width }"
81
+ :style="{ width: width ? width : widget.options.width }"
67
82
  :step="widget.options.step"
68
83
  :controls-position="widget.options.controlsPosition ? 'right' : ''"
69
84
  :disabled="widget.options.disabled"
@@ -76,7 +91,7 @@
76
91
  <template v-if="widget.type == 'radio'">
77
92
  <el-radio-group
78
93
  v-model="dataModel"
79
- :style="{ width: widget.options.width }"
94
+ :style="{ width: width ? width : widget.options.width }"
80
95
  :disabled="widget.options.disabled"
81
96
  >
82
97
  <template v-if="widget.options.buttonType">
@@ -121,7 +136,7 @@
121
136
  <template v-if="widget.type == 'checkbox'">
122
137
  <el-checkbox-group
123
138
  v-model="dataModel"
124
- :style="{ width: widget.options.width }"
139
+ :style="{ width: width ? width : widget.options.width }"
125
140
  :disabled="widget.options.disabled"
126
141
  :min="widget.options.min"
127
142
  :max="widget.options.max"
@@ -179,7 +194,7 @@
179
194
  :clearable="widget.options.clearable"
180
195
  :arrowControl="widget.options.arrowControl"
181
196
  :value-format="widget.options.format"
182
- :style="{ width: widget.options.width }"
197
+ :style="{ width: width ? width : widget.options.width }"
183
198
  >
184
199
  </el-time-picker>
185
200
  <template v-else>
@@ -195,7 +210,7 @@
195
210
  :editable="widget.options.editable"
196
211
  :clearable="widget.options.clearable"
197
212
  :arrowControl="widget.options.arrowControl"
198
- :style="{ width: widget.options.width }"
213
+ :style="{ width: width ? width : widget.options.width }"
199
214
  :picker-options="widget.options.stretTimePickerOptions"
200
215
  @change="e => handleTimePicker(e)"
201
216
  >
@@ -209,7 +224,7 @@
209
224
  :editable="widget.options.editable"
210
225
  :clearable="widget.options.clearable"
211
226
  :arrowControl="widget.options.arrowControl"
212
- :style="{ width: widget.options.width }"
227
+ :style="{ width: width ? width : widget.options.width }"
213
228
  :picker-options="widget.options.endTimePickerOptions"
214
229
  >
215
230
  </el-time-select>
@@ -228,7 +243,7 @@
228
243
  :disabled="widget.options.disabled"
229
244
  :editable="widget.options.editable"
230
245
  :clearable="widget.options.clearable"
231
- :style="{ width: widget.options.width }"
246
+ :style="{ width: width ? width : widget.options.width }"
232
247
  >
233
248
  </el-date-picker>
234
249
  </template>
@@ -264,7 +279,7 @@
264
279
  :filterable="
265
280
  widget.options.allowCreate ? true : widget.options.filterable
266
281
  "
267
- :style="{ width: widget.options.width }"
282
+ :style="{ width: width ? width : widget.options.width }"
268
283
  >
269
284
  <el-option
270
285
  v-for="item in widget.options.remote
@@ -302,7 +317,10 @@
302
317
  :step="widget.options.step"
303
318
  :show-input="widget.options.showInput"
304
319
  :range="widget.options.range"
305
- :style="{ width: widget.options.width, height: widget.options.height }"
320
+ :style="{
321
+ width: width ? width : widget.options.width,
322
+ height: widget.options.height
323
+ }"
306
324
  :show-tooltip="widget.options.showTooltip"
307
325
  :format-tooltip="
308
326
  val => formatTooltip(val, widget.options.formatTooltip)
@@ -316,7 +334,7 @@
316
334
  <!-- <fm-upload
317
335
  v-model="dataModel"
318
336
  :disabled="widget.options.disabled"
319
- :style="{ width: widget.options.width }"
337
+ :style="{ width: width ? width : widget.options.width }"
320
338
  :width="widget.options.size.width"
321
339
  :height="widget.options.size.height"
322
340
  :token="widget.options.token"
@@ -381,7 +399,7 @@
381
399
  <template v-if="widget.type == 'editor'">
382
400
  <vue-editor
383
401
  v-model="dataModel"
384
- :style="{ width: widget.options.width }"
402
+ :style="{ width: width ? width : widget.options.width }"
385
403
  :disabled="widget.options.disabled"
386
404
  >
387
405
  </vue-editor>
@@ -393,7 +411,10 @@
393
411
  :disabled="widget.options.disabled"
394
412
  :clearable="widget.options.clearable"
395
413
  :placeholder="widget.options.placeholder"
396
- :style="{ width: widget.options.width, height: widget.options.height }"
414
+ :style="{
415
+ width: width ? width : widget.options.width,
416
+ height: widget.options.height
417
+ }"
397
418
  :options="widget.options.remoteOptions"
398
419
  :props="widget.options.props"
399
420
  :show-all-levels="widget.options.showAllLevels ? false : true"
@@ -411,6 +432,147 @@
411
432
  <template v-if="widget.type == 'text'">
412
433
  <span>{{ dataModel }}</span>
413
434
  </template>
435
+
436
+ <template v-if="widget.type == 'blank'">
437
+ <slot :name="widget.model" />
438
+ </template>
439
+
440
+ <template v-if="widget.type == 'table'">
441
+ <el-table
442
+ v-if="!widget.options.hidden"
443
+ :data="dataModel"
444
+ style="width: 100%"
445
+ border
446
+ >
447
+ <el-table-column
448
+ v-if="widget.options.isSerial"
449
+ label="序号"
450
+ type="index"
451
+ width="50"
452
+ align="center"
453
+ >
454
+ </el-table-column>
455
+ <el-table-column
456
+ v-for="column in widget.list"
457
+ :key="column.key"
458
+ :label="column.name"
459
+ :prop="column.model"
460
+ :width="column.options.width"
461
+ >
462
+ <template slot-scope="scope">
463
+ <genetate-form-item
464
+ :models.sync="dataModel[scope.$index]"
465
+ :widget="column"
466
+ :remote="remote"
467
+ :rules="rules"
468
+ :hideLabel="true"
469
+ :tableInfo="{ index: scope.$index, data: widget }"
470
+ width="100%"
471
+ :slotKeys="slotKeys"
472
+ >
473
+ <template v-for="name in slotKeys" :slot="name">
474
+ <slot :name="name" />
475
+ </template>
476
+ </genetate-form-item>
477
+ </template>
478
+ </el-table-column>
479
+ <el-table-column
480
+ v-if="widget.options.isDelete"
481
+ fixed="right"
482
+ label="操作"
483
+ width="60"
484
+ align="center"
485
+ >
486
+ <template slot-scope="scope">
487
+ <el-button
488
+ style="color:#F56C6C"
489
+ type="text"
490
+ size="small"
491
+ @click.native.prevent="handleTableDelete(scope.$index)"
492
+ >
493
+ 移除
494
+ </el-button>
495
+ </template>
496
+ </el-table-column>
497
+ <template v-if="widget.options.isAdd" slot="append">
498
+ <div
499
+ style="text-align: center;"
500
+ :style="{
501
+ borderTop:
502
+ dataModel && dataModel.length != 0 ? '' : '1px solid #EBEEF5'
503
+ }"
504
+ >
505
+ <el-button
506
+ type="text"
507
+ :disabled="widget.options.disabled"
508
+ @click="handleTableAdd"
509
+ >新增</el-button
510
+ >
511
+ </div>
512
+ </template>
513
+ </el-table>
514
+ </template>
515
+
516
+ <template v-if="widget.type == 'grid'">
517
+ <el-row
518
+ type="flex"
519
+ :gutter="widget.options.gutter ? widget.options.gutter : 0"
520
+ :justify="widget.options.justify"
521
+ :align="widget.options.align"
522
+ >
523
+ <el-col
524
+ v-for="(col, colIndex) in widget.columns"
525
+ :key="colIndex"
526
+ :span="col.span"
527
+ >
528
+ <genetate-form-item
529
+ v-for="el in col.list"
530
+ :key="el.key"
531
+ :models="models"
532
+ :rules="rules"
533
+ :remote="remote"
534
+ :slotKeys="slotKeys"
535
+ :widget="el"
536
+ >
537
+ <template v-for="name in slotKeys" :slot="name">
538
+ <slot :name="name" />
539
+ </template>
540
+ </genetate-form-item>
541
+ </el-col>
542
+ </el-row>
543
+ </template>
544
+
545
+ <template v-if="widget.type == 'tabs'">
546
+ <el-tabs v-model="widget.options.defaultValue">
547
+ <el-tab-pane
548
+ v-for="tabItem in widget.tabs"
549
+ :key="tabItem.value"
550
+ :label="tabItem.label"
551
+ :name="tabItem.value"
552
+ >
553
+ <genetate-form-item
554
+ v-for="el in tabItem.list"
555
+ :key="el.key"
556
+ :models="dataModel[tabItem.value]"
557
+ :rules="rules"
558
+ :remote="remote"
559
+ :slotKeys="slotKeys"
560
+ :widget="el"
561
+ >
562
+ <template v-for="name in slotKeys" :slot="name">
563
+ <slot :name="name" />
564
+ </template>
565
+ </genetate-form-item>
566
+ </el-tab-pane>
567
+ </el-tabs>
568
+ </template>
569
+
570
+ <template v-if="widget.type == 'divider'">
571
+ <el-divider :content-position="widget.options.contentPosition">
572
+ {{ widget.name }}
573
+ </el-divider>
574
+ </template>
575
+
414
576
  <el-dialog :visible.sync="dialogVisible" append-to-body>
415
577
  <img width="100%" :src="dialogImageUrl" alt="" />
416
578
  </el-dialog>
@@ -421,7 +583,17 @@
421
583
  import FmUpload from "./Upload";
422
584
  import { VueEditor } from "vue2-editor";
423
585
  export default {
424
- props: ["widget", "models", "rules", "remote"],
586
+ name: "genetate-form-item",
587
+ props: [
588
+ "widget",
589
+ "models",
590
+ "rules",
591
+ "remote",
592
+ "hideLabel",
593
+ "width",
594
+ "tableInfo",
595
+ "slotKeys"
596
+ ],
425
597
  components: {
426
598
  FmUpload,
427
599
  VueEditor
@@ -430,7 +602,7 @@ export default {
430
602
  return {
431
603
  dataModel: this.models[this.widget.model],
432
604
  dialogVisible: false,
433
- dialogImageUrl: ""
605
+ dialogImageUrl: "",
434
606
  };
435
607
  },
436
608
  created() {
@@ -491,6 +663,16 @@ export default {
491
663
  },
492
664
  handleAvatarError() {
493
665
  console.log("上传失败!");
666
+ },
667
+ handleTableAdd() {
668
+ let dic = {};
669
+ this.widget.list.forEach(item => {
670
+ dic[item.model] = item.options.defaultValue;
671
+ });
672
+ this.dataModel.push(dic);
673
+ },
674
+ handleTableDelete(index) {
675
+ this.dataModel.splice(index, 1);
494
676
  }
495
677
  },
496
678
  watch: {
@@ -16,6 +16,21 @@
16
16
  <el-input v-model="data.options.width"></el-input>
17
17
  </el-form-item>
18
18
 
19
+ <el-form-item
20
+ label="标签宽度"
21
+ v-if="Object.keys(data.options).indexOf('labelWidth') >= 0"
22
+ >
23
+ <div style="display: flex;">
24
+ <el-checkbox v-model="data.options.isLabelWidth">自定义</el-checkbox>
25
+ <el-input-number
26
+ v-model="data.options.labelWidth"
27
+ :min="0"
28
+ :max="200"
29
+ :disabled="!data.options.isLabelWidth"
30
+ ></el-input-number>
31
+ </div>
32
+ </el-form-item>
33
+
19
34
  <el-form-item
20
35
  label="高度"
21
36
  v-if="Object.keys(data.options).indexOf('height') >= 0"
@@ -54,6 +69,17 @@
54
69
  ></el-input>
55
70
  </el-form-item>
56
71
 
72
+ <el-form-item
73
+ label="对齐方式"
74
+ v-if="Object.keys(data.options).indexOf('contentPosition') >= 0"
75
+ >
76
+ <el-radio-group v-model="data.options.contentPosition">
77
+ <el-radio-button label="left">左对齐</el-radio-button>
78
+ <el-radio-button label="center">居中对齐</el-radio-button>
79
+ <el-radio-button label="right">右对齐</el-radio-button>
80
+ </el-radio-group>
81
+ </el-form-item>
82
+
57
83
  <el-form-item label="文件列表样式" v-if="data.type == 'imgupload'">
58
84
  <el-select
59
85
  v-model="data.options.listType"
@@ -163,7 +189,7 @@
163
189
  >
164
190
  <el-radio-group v-model="data.options.controlsPosition">
165
191
  <el-radio-button :label="false">两边</el-radio-button>
166
- <el-radio-button :label="true">right</el-radio-button>
192
+ <el-radio-button :label="true">右边</el-radio-button>
167
193
  </el-radio-group>
168
194
  </el-form-item>
169
195
 
@@ -794,7 +820,7 @@
794
820
  </template>
795
821
 
796
822
  <template v-else>
797
- <el-form-item label="图片上传" :required="true">
823
+ <el-form-item label="文件上传" :required="true">
798
824
  <el-select
799
825
  class="remoteApis"
800
826
  v-model="data.options.remoteFunc"
@@ -879,7 +905,7 @@
879
905
  </li>
880
906
  </draggable>
881
907
  <div style="margin-left: 22px;">
882
- <el-button type="text" @click="handleAddColumn">添加列</el-button>
908
+ <el-button type="text" @click="handleAddOption">添加列</el-button>
883
909
  </div>
884
910
  </el-form-item>
885
911
 
@@ -902,6 +928,121 @@
902
928
  </el-form-item>
903
929
  </template>
904
930
 
931
+ <template v-if="data.type == 'tabs'">
932
+ <el-form-item label="标签对齐方式">
933
+ <el-radio-group v-model="data.options.type" size="mini">
934
+ <el-radio-button label="">默认</el-radio-button>
935
+ <el-radio-button label="card">选项卡</el-radio-button>
936
+ <el-radio-button label="border-card">卡片化</el-radio-button>
937
+ </el-radio-group>
938
+ </el-form-item>
939
+ <el-form-item label="选项卡位置">
940
+ <el-radio-group v-model="data.options.tabPosition" size="mini">
941
+ <el-radio-button label="top">顶部</el-radio-button>
942
+ <el-radio-button label="right">右侧</el-radio-button>
943
+ <el-radio-button label="bottom">底部</el-radio-button>
944
+ <el-radio-button label="left">左侧</el-radio-button>
945
+ </el-radio-group>
946
+ </el-form-item>
947
+ <el-form-item label="选项">
948
+ <el-radio-group
949
+ v-model="data.options.remote"
950
+ size="mini"
951
+ style="margin-bottom:10px;"
952
+ >
953
+ <el-radio-button :label="false">静态数据</el-radio-button>
954
+ <el-radio-button :label="true">远端数据</el-radio-button>
955
+ </el-radio-group>
956
+ <div v-if="data.options.remote">
957
+ <el-select
958
+ class="remoteApis"
959
+ size="mini"
960
+ v-model="data.options.remoteFunc"
961
+ placeholder="请选择远端方法"
962
+ >
963
+ <template slot="prefix">
964
+ <div style="width:70px;">接口名</div>
965
+ </template>
966
+ <el-option-group
967
+ v-for="group in remoteApis"
968
+ :key="group.label"
969
+ :label="group.label"
970
+ >
971
+ <el-option
972
+ v-for="item in group.options"
973
+ :key="item.value"
974
+ :label="item.label"
975
+ :value="item.value"
976
+ >
977
+ </el-option>
978
+ </el-option-group>
979
+ </el-select>
980
+
981
+ <el-input size="mini" style="" v-model="data.options.props.value">
982
+ <template slot="prepend">
983
+ <div style="width:30px;">值</div>
984
+ </template>
985
+ </el-input>
986
+ <el-input size="mini" style="" v-model="data.options.props.label">
987
+ <template slot="prepend">
988
+ <div style="width:30px;">标签</div>
989
+ </template>
990
+ </el-input>
991
+ </div>
992
+ <template v-else>
993
+ <el-radio-group v-model="data.options.defaultValue">
994
+ <draggable
995
+ tag="ul"
996
+ :list="data.tabs"
997
+ v-bind="{
998
+ group: { name: 'tabs' },
999
+ ghostClass: 'ghost',
1000
+ handle: '.drag-item'
1001
+ }"
1002
+ handle=".drag-item"
1003
+ >
1004
+ <li v-for="(item, index) in data.tabs" :key="index">
1005
+ <el-radio :label="item.value" style="margin-right: 5px;">
1006
+ <el-input
1007
+ v-model="item.value"
1008
+ style="width:90px;"
1009
+ size="mini"
1010
+ placeholder="value"
1011
+ ></el-input>
1012
+ <el-input
1013
+ v-model="item.label"
1014
+ style="width:90px;"
1015
+ size="mini"
1016
+ placeholder="label"
1017
+ ></el-input>
1018
+ </el-radio>
1019
+ <i
1020
+ class="drag-item"
1021
+ style="font-size: 16px;margin: 0 5px;cursor: move;"
1022
+ ><i class="iconfont icon-icon_bars"></i
1023
+ ></i>
1024
+ <el-button
1025
+ @click="handleOptionsRemove(index)"
1026
+ circle
1027
+ plain
1028
+ type="danger"
1029
+ size="mini"
1030
+ icon="el-icon-minus"
1031
+ style="padding: 4px;margin-left: 5px;"
1032
+ ></el-button>
1033
+ </li>
1034
+ </draggable>
1035
+ </el-radio-group>
1036
+
1037
+ <div style="margin-left: 22px;">
1038
+ <el-button type="text" @click="handleAddOption"
1039
+ >添加选项</el-button
1040
+ >
1041
+ </div>
1042
+ </template>
1043
+ </el-form-item>
1044
+ </template>
1045
+
905
1046
  <template v-if="data.type != 'grid'">
906
1047
  <el-form-item label="带入icon" v-if="data.type == 'input'">
907
1048
  <el-input
@@ -1045,6 +1186,16 @@
1045
1186
  v-if="Object.keys(data.options).indexOf('readonly') >= 0"
1046
1187
  >完全只读</el-checkbox
1047
1188
  >
1189
+ <el-checkbox
1190
+ v-model="data.options.hidden"
1191
+ v-if="Object.keys(data.options).indexOf('hidden') >= 0"
1192
+ >隐藏
1193
+ </el-checkbox>
1194
+ <el-checkbox
1195
+ v-model="data.options.hideLabel"
1196
+ v-if="Object.keys(data.options).indexOf('hideLabel') >= 0"
1197
+ >隐藏标签
1198
+ </el-checkbox>
1048
1199
  <el-checkbox
1049
1200
  v-model="data.options.disabled"
1050
1201
  v-if="Object.keys(data.options).indexOf('disabled') >= 0"
@@ -1065,16 +1216,26 @@
1065
1216
  v-if="Object.keys(data.options).indexOf('arrowControl') >= 0"
1066
1217
  >使用箭头进行时间选择</el-checkbox
1067
1218
  >
1219
+ <el-checkbox
1220
+ v-model="data.options.isAdd"
1221
+ v-if="Object.keys(data.options).indexOf('isAdd') >= 0"
1222
+ >可新增</el-checkbox
1223
+ >
1068
1224
  <el-checkbox
1069
1225
  v-model="data.options.isDelete"
1070
1226
  v-if="Object.keys(data.options).indexOf('isDelete') >= 0"
1071
- >删除</el-checkbox
1227
+ >可删除</el-checkbox
1072
1228
  >
1073
1229
  <el-checkbox
1074
1230
  v-model="data.options.isEdit"
1075
1231
  v-if="Object.keys(data.options).indexOf('isEdit') >= 0"
1076
1232
  >编辑</el-checkbox
1077
1233
  >
1234
+ <el-checkbox
1235
+ v-model="data.options.isSerial"
1236
+ v-if="Object.keys(data.options).indexOf('isSerial') >= 0"
1237
+ >显示序号</el-checkbox
1238
+ >
1078
1239
  <el-checkbox
1079
1240
  v-model="data.options.border"
1080
1241
  v-if="Object.keys(data.options).indexOf('border') >= 0"
@@ -1201,30 +1362,43 @@ export default {
1201
1362
  this.data.columns.splice(index, 1);
1202
1363
  } else if (this.data.type === "rate") {
1203
1364
  this.data.options.auxiliaryValue.splice(index, 1);
1365
+ } else if (this.data.type === "tabs") {
1366
+ this.data.tabs.splice(index, 1);
1204
1367
  } else {
1205
1368
  this.data.options.options.splice(index, 1);
1206
1369
  }
1207
1370
  },
1208
1371
  handleAddOption() {
1372
+ if (this.data.type === "grid") {
1373
+ this.data.columns.push({
1374
+ span: "",
1375
+ list: []
1376
+ });
1377
+ return;
1378
+ }
1379
+ if (this.data.type === "tabs") {
1380
+ this.data.tabs.push({
1381
+ label: `选项${this.data.tabs.length + 1}`,
1382
+ value: `tab_${this.data.tabs.length + 1}`,
1383
+ list: []
1384
+ });
1385
+ return;
1386
+ }
1209
1387
  if (this.data.type === "rate") {
1210
1388
  this.data.options.auxiliaryValue.push("新选项");
1211
1389
  return;
1212
1390
  }
1391
+
1213
1392
  if (this.data.options.showLabel) {
1214
1393
  this.data.options.options.push({
1215
1394
  value: "新选项",
1216
1395
  label: "新选项"
1217
1396
  });
1218
- } else {
1219
- this.data.options.options.push({
1220
- value: "新选项"
1221
- });
1397
+ return;
1222
1398
  }
1223
- },
1224
- handleAddColumn() {
1225
- this.data.columns.push({
1226
- span: "",
1227
- list: []
1399
+
1400
+ this.data.options.options.push({
1401
+ value: "新选项"
1228
1402
  });
1229
1403
  },
1230
1404
  generateRule() {