tianheng-ui 0.0.47 → 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: {