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.
@@ -1,5 +1,21 @@
1
1
  <template>
2
- <el-form-item :label="widget.name" :prop="widget.model">
2
+ <el-form-item
3
+ :class="widget.model"
4
+ :label="widget.options.hideLabel || hideLabel ? '' : widget.name"
5
+ :label-width="
6
+ widget.options.hideLabel
7
+ ? '0'
8
+ : widget.options.isLabelWidth
9
+ ? `${widget.options.labelWidth}px`
10
+ : ''
11
+ "
12
+ :prop="
13
+ tableInfo
14
+ ? `${tableInfo.data.model}.${tableInfo.index}.${widget.model}`
15
+ : widget.model
16
+ "
17
+ :rules="rules[widget.model]"
18
+ >
3
19
  <template v-if="widget.type == 'input'">
4
20
  <el-input
5
21
  v-if="
@@ -10,7 +26,7 @@
10
26
  type="number"
11
27
  v-model.number="dataModel"
12
28
  :placeholder="widget.options.placeholder"
13
- :style="{ width: widget.options.width }"
29
+ :style="{ width: width ? width : widget.options.width }"
14
30
  :disabled="widget.options.disabled"
15
31
  :readonly="widget.options.readonly"
16
32
  :clearable="widget.options.clearable"
@@ -24,7 +40,7 @@
24
40
  type="text"
25
41
  v-model="dataModel"
26
42
  :placeholder="widget.options.placeholder"
27
- :style="{ width: widget.options.width }"
43
+ :style="{ width: width ? width : widget.options.width }"
28
44
  :disabled="widget.options.disabled"
29
45
  :readonly="widget.options.readonly"
30
46
  :clearable="widget.options.clearable"
@@ -49,7 +65,7 @@
49
65
  v-model="dataModel"
50
66
  :disabled="widget.options.disabled"
51
67
  :placeholder="widget.options.placeholder"
52
- :style="{ width: widget.options.width }"
68
+ :style="{ width: width ? width : widget.options.width }"
53
69
  :maxlength="widget.options.maxlength"
54
70
  :clearable="widget.options.clearable"
55
71
  :show-word-limit="widget.options.showWordLimit"
@@ -63,7 +79,7 @@
63
79
  <template v-if="widget.type == 'number'">
64
80
  <el-input-number
65
81
  v-model="dataModel"
66
- :style="{ width: widget.options.width }"
82
+ :style="{ width: width ? width : widget.options.width }"
67
83
  :step="widget.options.step"
68
84
  :controls-position="widget.options.controlsPosition ? 'right' : ''"
69
85
  :disabled="widget.options.disabled"
@@ -76,7 +92,7 @@
76
92
  <template v-if="widget.type == 'radio'">
77
93
  <el-radio-group
78
94
  v-model="dataModel"
79
- :style="{ width: widget.options.width }"
95
+ :style="{ width: width ? width : widget.options.width }"
80
96
  :disabled="widget.options.disabled"
81
97
  >
82
98
  <template v-if="widget.options.buttonType">
@@ -121,7 +137,7 @@
121
137
  <template v-if="widget.type == 'checkbox'">
122
138
  <el-checkbox-group
123
139
  v-model="dataModel"
124
- :style="{ width: widget.options.width }"
140
+ :style="{ width: width ? width : widget.options.width }"
125
141
  :disabled="widget.options.disabled"
126
142
  :min="widget.options.min"
127
143
  :max="widget.options.max"
@@ -179,7 +195,7 @@
179
195
  :clearable="widget.options.clearable"
180
196
  :arrowControl="widget.options.arrowControl"
181
197
  :value-format="widget.options.format"
182
- :style="{ width: widget.options.width }"
198
+ :style="{ width: width ? width : widget.options.width }"
183
199
  >
184
200
  </el-time-picker>
185
201
  <template v-else>
@@ -195,7 +211,7 @@
195
211
  :editable="widget.options.editable"
196
212
  :clearable="widget.options.clearable"
197
213
  :arrowControl="widget.options.arrowControl"
198
- :style="{ width: widget.options.width }"
214
+ :style="{ width: width ? width : widget.options.width }"
199
215
  :picker-options="widget.options.stretTimePickerOptions"
200
216
  @change="e => handleTimePicker(e)"
201
217
  >
@@ -209,7 +225,7 @@
209
225
  :editable="widget.options.editable"
210
226
  :clearable="widget.options.clearable"
211
227
  :arrowControl="widget.options.arrowControl"
212
- :style="{ width: widget.options.width }"
228
+ :style="{ width: width ? width : widget.options.width }"
213
229
  :picker-options="widget.options.endTimePickerOptions"
214
230
  >
215
231
  </el-time-select>
@@ -228,7 +244,7 @@
228
244
  :disabled="widget.options.disabled"
229
245
  :editable="widget.options.editable"
230
246
  :clearable="widget.options.clearable"
231
- :style="{ width: widget.options.width }"
247
+ :style="{ width: width ? width : widget.options.width }"
232
248
  >
233
249
  </el-date-picker>
234
250
  </template>
@@ -264,7 +280,7 @@
264
280
  :filterable="
265
281
  widget.options.allowCreate ? true : widget.options.filterable
266
282
  "
267
- :style="{ width: widget.options.width }"
283
+ :style="{ width: width ? width : widget.options.width }"
268
284
  >
269
285
  <el-option
270
286
  v-for="item in widget.options.remote
@@ -302,7 +318,10 @@
302
318
  :step="widget.options.step"
303
319
  :show-input="widget.options.showInput"
304
320
  :range="widget.options.range"
305
- :style="{ width: widget.options.width, height: widget.options.height }"
321
+ :style="{
322
+ width: width ? width : widget.options.width,
323
+ height: widget.options.height
324
+ }"
306
325
  :show-tooltip="widget.options.showTooltip"
307
326
  :format-tooltip="
308
327
  val => formatTooltip(val, widget.options.formatTooltip)
@@ -316,7 +335,7 @@
316
335
  <!-- <fm-upload
317
336
  v-model="dataModel"
318
337
  :disabled="widget.options.disabled"
319
- :style="{ width: widget.options.width }"
338
+ :style="{ width: width ? width : widget.options.width }"
320
339
  :width="widget.options.size.width"
321
340
  :height="widget.options.size.height"
322
341
  :token="widget.options.token"
@@ -381,7 +400,7 @@
381
400
  <template v-if="widget.type == 'editor'">
382
401
  <vue-editor
383
402
  v-model="dataModel"
384
- :style="{ width: widget.options.width }"
403
+ :style="{ width: width ? width : widget.options.width }"
385
404
  :disabled="widget.options.disabled"
386
405
  >
387
406
  </vue-editor>
@@ -393,7 +412,10 @@
393
412
  :disabled="widget.options.disabled"
394
413
  :clearable="widget.options.clearable"
395
414
  :placeholder="widget.options.placeholder"
396
- :style="{ width: widget.options.width, height: widget.options.height }"
415
+ :style="{
416
+ width: width ? width : widget.options.width,
417
+ height: widget.options.height
418
+ }"
397
419
  :options="widget.options.remoteOptions"
398
420
  :props="widget.options.props"
399
421
  :show-all-levels="widget.options.showAllLevels ? false : true"
@@ -411,6 +433,150 @@
411
433
  <template v-if="widget.type == 'text'">
412
434
  <span>{{ dataModel }}</span>
413
435
  </template>
436
+
437
+ <template v-if="widget.type == 'blank'">
438
+ <slot :name="widget.model" />
439
+ </template>
440
+
441
+ <template v-if="widget.type == 'table'">
442
+ <el-table
443
+ v-if="!widget.options.hidden"
444
+ :data="dataModel"
445
+ style="width: 100%"
446
+ border
447
+ >
448
+ <el-table-column
449
+ v-if="widget.options.isSerial"
450
+ label="序号"
451
+ type="index"
452
+ width="50"
453
+ align="center"
454
+ >
455
+ </el-table-column>
456
+ <el-table-column
457
+ v-for="column in widget.list"
458
+ :key="column.key"
459
+ :label="column.name"
460
+ :prop="column.model"
461
+ :width="column.options.width"
462
+ >
463
+ <template slot-scope="scope">
464
+ <genetate-form-item
465
+ :models.sync="dataModel[scope.$index]"
466
+ :widget="column"
467
+ :remote="remote"
468
+ :rules="rules"
469
+ :hideLabel="true"
470
+ :tableInfo="{ index: scope.$index, data: widget }"
471
+ width="100%"
472
+ :slotKeys="slotKeys"
473
+ >
474
+ <template v-for="name in slotKeys" :slot="name">
475
+ <slot :name="name" />
476
+ </template>
477
+ </genetate-form-item>
478
+ </template>
479
+ </el-table-column>
480
+ <el-table-column
481
+ v-if="widget.options.isDelete"
482
+ fixed="right"
483
+ label="操作"
484
+ width="60"
485
+ align="center"
486
+ >
487
+ <template slot-scope="scope">
488
+ <el-button
489
+ style="color:#F56C6C"
490
+ type="text"
491
+ size="small"
492
+ @click.native.prevent="handleTableDelete(scope.$index)"
493
+ >
494
+ 移除
495
+ </el-button>
496
+ </template>
497
+ </el-table-column>
498
+ <template v-if="widget.options.isAdd" slot="append">
499
+ <div
500
+ style="text-align: center;"
501
+ :style="{
502
+ borderTop:
503
+ dataModel && dataModel.length != 0 ? '' : '1px solid #EBEEF5'
504
+ }"
505
+ >
506
+ <el-button
507
+ type="text"
508
+ :disabled="widget.options.disabled"
509
+ @click="handleTableAdd"
510
+ >新增</el-button
511
+ >
512
+ </div>
513
+ </template>
514
+ </el-table>
515
+ </template>
516
+
517
+ <template v-if="widget.type == 'grid'">
518
+ <el-row
519
+ type="flex"
520
+ :gutter="widget.options.gutter ? widget.options.gutter : 0"
521
+ :justify="widget.options.justify"
522
+ :align="widget.options.align"
523
+ >
524
+ <el-col
525
+ v-for="(col, colIndex) in widget.columns"
526
+ :key="colIndex"
527
+ :span="col.span"
528
+ >
529
+ <genetate-form-item
530
+ v-for="el in col.list"
531
+ :key="el.key"
532
+ :models="models"
533
+ :rules="rules"
534
+ :remote="remote"
535
+ :slotKeys="slotKeys"
536
+ :widget="el"
537
+ >
538
+ <template v-for="name in slotKeys" :slot="name">
539
+ <slot :name="name" />
540
+ </template>
541
+ </genetate-form-item>
542
+ </el-col>
543
+ </el-row>
544
+ </template>
545
+
546
+ <template v-if="widget.type == 'tabs'">
547
+ <el-tabs v-model="widget.options.defaultValue">
548
+ <el-tab-pane
549
+ v-for="tabItem in widget.tabs"
550
+ :key="tabItem.value"
551
+ :label="tabItem.label"
552
+ :name="tabItem.value"
553
+ >
554
+ <genetate-form-item
555
+ v-for="el in tabItem.list"
556
+ :key="el.key"
557
+ :models="dataModel[tabItem.value]"
558
+ :rules="rules"
559
+ :remote="remote"
560
+ :slotKeys="slotKeys"
561
+ :widget="el"
562
+ >
563
+ <template v-for="name in slotKeys" :slot="name">
564
+ <slot :name="name" />
565
+ </template>
566
+ </genetate-form-item>
567
+ </el-tab-pane>
568
+ </el-tabs>
569
+ </template>
570
+
571
+ <template v-if="widget.type == 'divider'">
572
+ <el-divider
573
+ :content-position="widget.options.contentPosition"
574
+ :style="{ height: `${widget.options.height}px` }"
575
+ >
576
+ {{ widget.name }}
577
+ </el-divider>
578
+ </template>
579
+
414
580
  <el-dialog :visible.sync="dialogVisible" append-to-body>
415
581
  <img width="100%" :src="dialogImageUrl" alt="" />
416
582
  </el-dialog>
@@ -421,7 +587,17 @@
421
587
  import FmUpload from "./Upload";
422
588
  import { VueEditor } from "vue2-editor";
423
589
  export default {
424
- props: ["widget", "models", "rules", "remote"],
590
+ name: "genetate-form-item",
591
+ props: [
592
+ "widget",
593
+ "models",
594
+ "rules",
595
+ "remote",
596
+ "hideLabel",
597
+ "width",
598
+ "tableInfo",
599
+ "slotKeys"
600
+ ],
425
601
  components: {
426
602
  FmUpload,
427
603
  VueEditor
@@ -491,6 +667,16 @@ export default {
491
667
  },
492
668
  handleAvatarError() {
493
669
  console.log("上传失败!");
670
+ },
671
+ handleTableAdd() {
672
+ let dic = {};
673
+ this.widget.list.forEach(item => {
674
+ dic[item.model] = item.options.defaultValue;
675
+ });
676
+ this.dataModel.push(dic);
677
+ },
678
+ handleTableDelete(index) {
679
+ this.dataModel.splice(index, 1);
494
680
  }
495
681
  },
496
682
  watch: {