tianheng-ui 0.1.40 → 0.1.41

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.1.40",
4
+ "version": "0.1.41",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -85,17 +85,16 @@ export default {
85
85
  grid: "grid_pro",
86
86
  table: "table_pro",
87
87
  tableH5: "tableH5_pro",
88
+ list: "list_pro",
88
89
  tabs: "tabs_pro",
89
90
  blank: "blank_pro"
90
91
  };
91
92
  const keys = Object.keys(this.compsData);
92
93
  for (const key of keys) {
94
+ const element = this.compsData[key];
93
95
  if (proComponentsPath[key])
94
- this.compsData[
95
- key
96
- ].content = require(`./custom/items/${proComponentsPath[key]}`).default;
97
- else
98
- this.compsData[key].content = require(`./custom/items/${key}`).default;
96
+ element.content = require(`./custom/items/${proComponentsPath[key]}`).default;
97
+ else element.content = require(`./custom/items/${key}`).default;
99
98
  }
100
99
  },
101
100
  mounted() {
@@ -507,11 +507,11 @@
507
507
  <div
508
508
  class="tableH5-item"
509
509
  v-for="(column, columnIndex) in dataModel"
510
- :key="`table_h5_${columnIndex}`"
510
+ :key="`tableH5_${columnIndex}`"
511
511
  >
512
512
  <div
513
513
  v-for="(element, elementIndex) in widget.list"
514
- :key="`table_h5_${columnIndex}_${element.key}`"
514
+ :key="`tableH5_${columnIndex}_${element.key}`"
515
515
  >
516
516
  <genetate-form-item
517
517
  style="flex:1;"
@@ -3,9 +3,9 @@
3
3
  <div class="tabs th-sticky_top">
4
4
  <div
5
5
  v-for="(item, index) in tabsMenus"
6
- :key="index"
7
6
  class="tabs-item"
8
7
  :class="{ 'tabs-item__active': activeTab.value === item.value }"
8
+ :key="index"
9
9
  @click="activeTab = item"
10
10
  >
11
11
  {{ item.title }}
@@ -133,7 +133,7 @@
133
133
  </el-collapse-item>
134
134
  </el-collapse>
135
135
  </el-form>
136
- <th-empty v-else description="请左侧拖拽来添加字段"></th-empty>
136
+ <th-empty v-else description="请从左侧拖拽来添加字段"></th-empty>
137
137
  </div>
138
138
  <div v-if="activeTab.value === 'form'">
139
139
  <el-form
@@ -267,11 +267,24 @@
267
267
  </el-form>
268
268
  </div>
269
269
  <div v-if="activeTab.value === 'css'">
270
- <th-empty description="开发中,敬请期待..."></th-empty>
270
+ <el-form
271
+ :model="config"
272
+ label-position="left"
273
+ label-width="80px"
274
+ size="small"
275
+ :rules="formRules"
276
+ ref="formRef"
277
+ >
278
+ <el-collapse v-model="collapseValue">
279
+ <el-collapse-item title="form 样式" name="group-style_form">
280
+ </el-collapse-item>
281
+ </el-collapse>
282
+ </el-form>
283
+ <!-- <th-empty description="开发中,敬请期待..."></th-empty> -->
271
284
  </div>
272
285
 
273
286
  <th-dialog
274
- v-model="eventsDialog.visible"
287
+ v-model="dialog.show"
275
288
  title="动作设置"
276
289
  :modal-append-to-body="false"
277
290
  @on-fullscreen="$refs.codeEditor && $refs.codeEditor.resize()"
@@ -289,14 +302,14 @@
289
302
  >
290
303
  </div>
291
304
  <div
292
- v-for="(item, index) in eventsDialog.eventScript"
305
+ v-for="(item, index) in dialog.data"
293
306
  class="list-item th-is_hover"
294
307
  :class="{
295
308
  'th-is_active':
296
- eventsDialog.active && eventsDialog.active.label === item.label
309
+ dialog.active && dialog.active.label === item.label
297
310
  }"
298
311
  :key="item.key"
299
- @click="eventsDialog.active = item"
312
+ @click="dialog.active = item"
300
313
  >
301
314
  <div class="list-item-title">Function</div>
302
315
  <div class="list-item-value">{{ item.label }}</div>
@@ -310,16 +323,16 @@
310
323
  </el-popconfirm>
311
324
  </div>
312
325
  </div>
313
- <div class="detail th-fiex_content" v-if="eventsDialog.active">
326
+ <div class="detail th-fiex_content" v-if="dialog.active">
314
327
  <div>
315
328
  <span>Function Name</span>
316
329
  <el-input
317
- v-model="eventsDialog.active.label"
330
+ v-model="dialog.active.label"
318
331
  placeholder="请输入动作名称"
319
332
  size="small"
320
333
  :disabled="
321
- eventsDialog.active.label === 'mounted' ||
322
- eventsDialog.active.label === 'refresh'
334
+ dialog.active.label === 'mounted' ||
335
+ dialog.active.label === 'refresh'
323
336
  "
324
337
  ></el-input>
325
338
  </div>
@@ -327,8 +340,8 @@
327
340
  <div>
328
341
  function(
329
342
  {{
330
- eventsDialog.active.label !== "mounted" &&
331
- eventsDialog.active.label !== "refresh"
343
+ dialog.active.label !== "mounted" &&
344
+ dialog.active.label !== "refresh"
332
345
  ? "item,value"
333
346
  : ""
334
347
  }}
@@ -359,7 +372,7 @@
359
372
  </div>
360
373
  <th-code-editor
361
374
  style="height:calc(100% - 48px)"
362
- v-model="eventsDialog.active.value"
375
+ v-model="dialog.active.value"
363
376
  :completions="aceCompletions"
364
377
  ref="codeEditor"
365
378
  ></th-code-editor>
@@ -368,7 +381,7 @@
368
381
  </div>
369
382
  </div>
370
383
  <span slot="footer" class="dialog-footer">
371
- <el-button size="small" @click="eventsDialog.visible = false"
384
+ <el-button size="small" @click="dialog.show = false"
372
385
  >取 消</el-button
373
386
  >
374
387
  <el-button type="primary" size="small" @click="handleEventDialogAffirm"
@@ -408,17 +421,20 @@ export default {
408
421
  { title: "样式设置", value: "css" }
409
422
  ],
410
423
  activeTab: {},
411
- validator: {
412
- type: null,
413
- required: null,
414
- pattern: null,
415
- range: null,
416
- length: null
417
- },
418
- eventsDialog: {
419
- visible: false,
420
- eventScript: [],
421
- active: null
424
+ collapseValue: [
425
+ "group-general",
426
+ "group-element",
427
+ "group-action",
428
+ "group-form",
429
+ "group-resultData",
430
+ "group-label",
431
+ "group-attributes",
432
+ "group-style_form"
433
+ ],
434
+ dialog: {
435
+ show: false,
436
+ data: [],
437
+ action: null
422
438
  },
423
439
  aceCompletions: [
424
440
  {
@@ -452,15 +468,6 @@ export default {
452
468
  score: 1
453
469
  }
454
470
  ],
455
- collapseValue: [
456
- "group-general",
457
- "group-element",
458
- "group-action",
459
- "group-form",
460
- "group-resultData",
461
- "group-label",
462
- "group-attributes"
463
- ],
464
471
  formRules: {
465
472
  model: [
466
473
  { required: true, message: "请填选组件字段", trigger: "change" }
@@ -483,9 +490,9 @@ export default {
483
490
  },
484
491
  methods: {
485
492
  handleEventDialogShow() {
486
- this.eventsDialog = {
487
- visible: true,
488
- eventScript: deepClone(this.config.eventScript),
493
+ this.dialog = {
494
+ show: true,
495
+ data: deepClone(this.config.eventScript),
489
496
  active: null
490
497
  };
491
498
  },
@@ -496,34 +503,34 @@ export default {
496
503
  label: key,
497
504
  value: ""
498
505
  };
499
- this.eventsDialog.eventScript.push(dic);
500
- this.eventsDialog.active = dic;
506
+ this.dialog.data.push(dic);
507
+ this.dialog.active = dic;
501
508
  },
502
509
  handleEventDialogAffirm() {
503
- this.config.eventScript = this.eventsDialog.eventScript;
504
- this.eventsDialog = {
505
- visible: false,
506
- eventScript: [],
510
+ this.config.eventScript = this.dialog.data;
511
+ this.dialog = {
512
+ show: false,
513
+ data: [],
507
514
  active: null
508
515
  };
509
516
  },
510
517
  handleEventDialogDelete(item, index) {
511
518
  if (
512
- this.eventsDialog.active &&
513
- item.key === this.eventsDialog.active.key
519
+ this.dialog.active &&
520
+ item.key === this.dialog.active.key
514
521
  ) {
515
- this.eventsDialog.active = null;
522
+ this.dialog.active = null;
516
523
  }
517
- this.eventsDialog.eventScript.splice(index, 1);
524
+ this.dialog.data.splice(index, 1);
518
525
  },
519
526
  handleEventsCollapseClick(eventKey) {
520
527
  const eventScript = deepClone(this.config.eventScript);
521
528
  for (let i = 0; i < eventScript.length; i++) {
522
529
  const event = eventScript[i];
523
- if (event.key === eventKey) {
524
- this.eventsDialog = {
525
- visible: true,
526
- eventScript: eventScript,
530
+ if (event.id === eventKey) {
531
+ this.dialog = {
532
+ show: true,
533
+ data: eventScript,
527
534
  active: event
528
535
  };
529
536
  break;
@@ -4,9 +4,7 @@
4
4
  :class="{
5
5
  active: selectWidget.model == widget.model,
6
6
  isRequired: widget.options.required,
7
- isLayout: ['grid', 'tabs', 'table', 'tableH5', 'alliance'].includes(
8
- widget.type
9
- ),
7
+ isLayout: layoutElements.includes(widget.type),
10
8
  [`widget-form-list-${widget.type}`]: true,
11
9
  [widget.model]: true
12
10
  }"
@@ -28,13 +26,7 @@
28
26
  v-if="selectWidget.model == widget.model"
29
27
  class="widget-actions"
30
28
  :class="{
31
- 'widget-actions-col': [
32
- 'grid',
33
- 'tabs',
34
- 'table',
35
- 'tableH5',
36
- 'alliance'
37
- ].includes(widget.type)
29
+ 'widget-actions-col': layoutElements.includes(widget.type)
38
30
  }"
39
31
  >
40
32
  <div class="actions">
@@ -61,7 +53,8 @@ export default {
61
53
  data() {
62
54
  return {
63
55
  compsData: deepClone(compsData),
64
- selectWidget: this.select
56
+ selectWidget: this.select,
57
+ layoutElements: ["grid", "tabs", "table", "tableH5", "list", "alliance"]
65
58
  };
66
59
  },
67
60
  watch: {
@@ -89,17 +82,16 @@ export default {
89
82
  grid: "grid_dev",
90
83
  table: "table_dev",
91
84
  tableH5: "tableH5_dev",
85
+ list: "list_dev",
92
86
  tabs: "tabs_dev",
93
87
  blank: "blank_dev"
94
88
  };
95
89
  const keys = Object.keys(this.compsData);
96
90
  for (const key of keys) {
91
+ const element = this.compsData[key];
97
92
  if (devComponentsPath[key])
98
- this.compsData[
99
- key
100
- ].content = require(`./custom/items/${devComponentsPath[key]}`).default;
101
- else
102
- this.compsData[key].content = require(`./custom/items/${key}`).default;
93
+ element.content = require(`./custom/items/${devComponentsPath[key]}`).default;
94
+ else element.content = require(`./custom/items/${key}`).default;
103
95
  }
104
96
  },
105
97
  mounted() {},
@@ -489,7 +489,7 @@ export const basicComponents = [
489
489
  {
490
490
  name: "文件",
491
491
  type: "upload",
492
- icon: "icon-tupian",
492
+ icon: "th-icon-upload",
493
493
  options: {
494
494
  width: "",
495
495
  labelWidth: 100,
@@ -583,7 +583,7 @@ export const advanceComponents = [
583
583
  {
584
584
  name: "子表单",
585
585
  type: "table",
586
- icon: "icon-table",
586
+ icon: "th-icon-insertrowabove",
587
587
  options: {
588
588
  height: "",
589
589
  defaultValue: "",
@@ -615,7 +615,36 @@ export const advanceComponents = [
615
615
  {
616
616
  name: "子表单H5",
617
617
  type: "tableH5",
618
- icon: "icon-table",
618
+ icon: "th-icon-insertrowleft",
619
+ options: {
620
+ defaultValue: "",
621
+ columns: [],
622
+ customClass: "",
623
+ labelWidth: 100,
624
+ isLabelWidth: false,
625
+ dataBind: true,
626
+ validatorCheck: false,
627
+ validator: "",
628
+ paging: false,
629
+ pageSize: 5,
630
+ tableColumn: false,
631
+ hidden: false,
632
+ hideLabel: false,
633
+ disabled: false,
634
+ required: false,
635
+ isAdd: true,
636
+ addButtonText: "新增",
637
+ isDelete: true,
638
+ deleteButtonText: "删除",
639
+ deleteIndex: 0 // 可删除的最小索引
640
+ },
641
+ events: {},
642
+ rules: []
643
+ },
644
+ {
645
+ name: "子列表",
646
+ type: "list",
647
+ icon: "th-icon-orderedlist",
619
648
  options: {
620
649
  defaultValue: "",
621
650
  columns: [],
@@ -677,7 +706,7 @@ export const advanceComponents = [
677
706
  {
678
707
  name: "自定义区域",
679
708
  type: "blank",
680
- icon: "icon-zidingyishuju",
709
+ icon: "th-icon-code",
681
710
  options: {
682
711
  defaultType: "String",
683
712
  required: false
@@ -691,7 +720,7 @@ export const layoutComponents = [
691
720
  {
692
721
  name: "栅格布局",
693
722
  type: "grid",
694
- icon: "icon-grid-",
723
+ icon: "th-icon-layout",
695
724
  options: {
696
725
  gutter: 0,
697
726
  justify: "start",
@@ -20,7 +20,7 @@ const basicComponents = [
20
20
  "editor",
21
21
  "cascader"
22
22
  ];
23
- const advanceComponents = ["table", "tableH5", "tabs", "blank"];
23
+ const advanceComponents = ["table", "tableH5", "list", "tabs", "blank"];
24
24
  const layoutComponents = ["grid", "alliance", "filler", "divider"];
25
25
 
26
26
  module.exports = {
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <div class="list">
3
+ <draggable
4
+ v-model="widget.options.columns"
5
+ :no-transition-on-drag="true"
6
+ v-bind="{
7
+ group: 'people',
8
+ ghostClass: 'ghost',
9
+ animation: 200,
10
+ handle: '.drag-widget'
11
+ }"
12
+ @add="handleWidgetAdd($event)"
13
+ >
14
+ <transition-group name="fade" tag="div" class="list">
15
+ <div
16
+ v-for="(element, elementIndex) in widget.options.columns"
17
+ class="list-item"
18
+ :key="element.key"
19
+ @click.stop="selectWidget = element"
20
+ >
21
+ <widget-form-item
22
+ :widget="element"
23
+ :widgetArray="widget.options.columns"
24
+ :widgetIndex="elementIndex"
25
+ :select.sync="selectWidget"
26
+ :config="config"
27
+ >
28
+ </widget-form-item>
29
+ </div>
30
+ </transition-group>
31
+ </draggable>
32
+ <div v-if="widget.options.isDelete" class="tools">
33
+ <el-button type="danger">{{ widget.options.deleteButtonText }}</el-button>
34
+ </div>
35
+ <div v-if="widget.options.isAdd" class="footer">
36
+ <el-button type="text" :disabled="widget.options.disabled">{{
37
+ widget.options.addButtonText
38
+ }}</el-button>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ import { itemsComponent } from "../mixins/index";
45
+ import Draggable from "vuedraggable";
46
+ import WidgetFormItem from "../../WidgetFormItem.vue";
47
+ export default {
48
+ components: { Draggable, WidgetFormItem },
49
+ mixins: [itemsComponent],
50
+ data() {
51
+ return {
52
+ selectWidget: {}
53
+ };
54
+ },
55
+ watch: {
56
+ select(val) {
57
+ this.selectWidget = val;
58
+ },
59
+ selectWidget: {
60
+ handler(val) {
61
+ this.$emit("update:select", val);
62
+ },
63
+ deep: true
64
+ }
65
+ },
66
+ methods: {
67
+ handleWidgetAdd($event) {
68
+ const newIndex = $event.newIndex;
69
+ const oldIndex = $event.oldIndex;
70
+ const newComponent = JSON.parse(
71
+ JSON.stringify(this.widget.options.columns[newIndex])
72
+ );
73
+ const item = $event.item;
74
+ // 防止布局元素的嵌套拖拽
75
+ if (item.className.indexOf("no-put") >= 0) {
76
+ // 如果是列表中拖拽的元素需要还原到原来位置
77
+ item.tagName === "DIV" &&
78
+ this.widgetArray.splice(oldIndex, 0, newComponent);
79
+
80
+ this.widget.options.columns.splice(newIndex, 1);
81
+ return false;
82
+ }
83
+
84
+ if (!newComponent.key) {
85
+ const key =
86
+ Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
87
+ newComponent.key = key;
88
+ newComponent.model = `${newComponent.type}_${key}`;
89
+ }
90
+ this.$set(this.widget.options.columns, newIndex, newComponent);
91
+ this.selectWidget = newComponent;
92
+ }
93
+ }
94
+ };
95
+ </script>
96
+
97
+ <style lang="scss" scoped>
98
+ .list {
99
+ background: #fff;
100
+
101
+ .list {
102
+ min-height: 50px;
103
+ border: 1px dashed #ccc;
104
+ .list-item {
105
+ width: 100%;
106
+ }
107
+ .list-item:nth-child(1) {
108
+ display: flex;
109
+ > div:first-child {
110
+ flex: 1;
111
+ }
112
+ }
113
+ }
114
+
115
+ .tools {
116
+ text-align: right;
117
+ }
118
+ .footer {
119
+ text-align: center;
120
+ }
121
+ }
122
+ </style>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div>
3
+
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ data() {
10
+ return {};
11
+ },
12
+ created() {},
13
+ mounted() {},
14
+ methods: {},
15
+ };
16
+ </script>
17
+
18
+ <style lang="scss" scoped></style>
@@ -69,13 +69,12 @@ export default {
69
69
  methods: {
70
70
  handleTableAdd() {
71
71
  let dic = {};
72
- this.widget.options.columns.forEach(item => {
72
+ this.widget.options.columns.map(item => {
73
73
  if (item.type === "grid") {
74
74
  for (let i = 0; i < item.options.columns.length; i++) {
75
- const element = item.options.columns[i];
76
- for (let j = 0; j < element.options.columns.length; j++) {
77
- const element2 = element.options.columns[j];
78
- dic[element2.model] = element2.options.defaultValue;
75
+ const column = item.options.columns[i];
76
+ for (const element of column.list) {
77
+ dic[element.model] = element.options.defaultValue;
79
78
  }
80
79
  }
81
80
  } else {
@@ -55,7 +55,9 @@
55
55
  v-for="(item, index) in getAdvanceComponents"
56
56
  class="fields-label"
57
57
  :class="{
58
- 'no-put': ['table', 'tableH5', 'tabs'].includes(item.type),
58
+ 'no-put': ['table', 'tableH5', 'list', 'tabs'].includes(
59
+ item.type
60
+ ),
59
61
  [item.type]: true
60
62
  }"
61
63
  :key="index"
@@ -212,7 +214,7 @@ export default {
212
214
  },
213
215
  advanceFields: {
214
216
  type: Array,
215
- default: () => ["table", "tableH5", "tabs", "blank"]
217
+ default: () => ["table", "tableH5", "list", "tabs", "blank"]
216
218
  },
217
219
  layoutFields: {
218
220
  type: Array,
@@ -263,7 +265,7 @@ export default {
263
265
  },
264
266
  config(val) {
265
267
  this.setConfig(val);
266
- this.initApiConfig()
268
+ this.initApiConfig();
267
269
  },
268
270
  apiOptions(val) {
269
271
  this.initApiConfig();
@@ -69,25 +69,25 @@ $primary-background-color: #ecf5ff;
69
69
  // background-color: rgba(69, 90, 100, 0.2);
70
70
  // }
71
71
 
72
- .tableH5 {
73
- min-height: 50px;
74
- border: 1px dashed #ccc;
75
- background: #fff;
76
- white-space: nowrap;
77
- overflow-x: scroll;
78
-
79
- .tableH5-item:nth-child(1) {
80
- display: flex;
72
+ // .tableH5 {
73
+ // min-height: 50px;
74
+ // border: 1px dashed #ccc;
75
+ // background: #fff;
76
+ // white-space: nowrap;
77
+ // overflow-x: scroll;
78
+
79
+ // .tableH5-item:nth-child(1) {
80
+ // display: flex;
81
81
 
82
- .actions {
83
- align-items: center;
84
- justify-content: right;
85
- }
86
- }
87
- .tableH5-item-widget {
88
- width: calc(100% - 5px);
89
- }
90
- }
82
+ // .actions {
83
+ // align-items: center;
84
+ // justify-content: right;
85
+ // }
86
+ // }
87
+ // .tableH5-item-widget {
88
+ // width: calc(100% - 5px);
89
+ // }
90
+ // }
91
91
 
92
92
  .widgetFormItem {
93
93
  min-width: 100px;