tianheng-ui 0.1.10 → 0.1.12

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.
Files changed (72) hide show
  1. package/lib/theme-chalk/styles/reset.scss +0 -2
  2. package/lib/tianheng-ui.js +13 -14
  3. package/package.json +1 -1
  4. package/packages/FormMaking/GenerateForm.vue +16 -11
  5. package/packages/FormMaking/GenerateFormItem.vue +73 -581
  6. package/packages/FormMaking/GenerateFormItemH5.vue +6 -6
  7. package/packages/FormMaking/Upload/index.vue +0 -1
  8. package/packages/FormMaking/WidgetConfig.vue +100 -77
  9. package/packages/FormMaking/WidgetForm.vue +7 -48
  10. package/packages/FormMaking/WidgetFormItem.vue +41 -65
  11. package/packages/FormMaking/WidgetSelect.vue +160 -0
  12. package/packages/FormMaking/WidgetTools.vue +538 -0
  13. package/packages/FormMaking/config/index.js +6 -0
  14. package/packages/FormMaking/custom/config.js +119 -87
  15. package/packages/FormMaking/custom/configs/button.vue +24 -25
  16. package/packages/FormMaking/custom/configs/cascader.vue +7 -7
  17. package/packages/FormMaking/custom/configs/checkbox.vue +23 -22
  18. package/packages/FormMaking/custom/configs/color.vue +3 -3
  19. package/packages/FormMaking/custom/configs/date.vue +3 -3
  20. package/packages/FormMaking/custom/configs/grid.vue +4 -4
  21. package/packages/FormMaking/custom/configs/input.vue +138 -31
  22. package/packages/FormMaking/custom/configs/number.vue +5 -5
  23. package/packages/FormMaking/custom/configs/radio.vue +23 -19
  24. package/packages/FormMaking/custom/configs/rate.vue +3 -3
  25. package/packages/FormMaking/custom/configs/select.vue +25 -20
  26. package/packages/FormMaking/custom/configs/slider.vue +3 -3
  27. package/packages/FormMaking/custom/configs/switch.vue +3 -3
  28. package/packages/FormMaking/custom/configs/table.vue +2 -2
  29. package/packages/FormMaking/custom/configs/{table_h5.vue → tableH5.vue} +2 -2
  30. package/packages/FormMaking/custom/configs/tabs.vue +18 -23
  31. package/packages/FormMaking/custom/configs/textarea.vue +124 -22
  32. package/packages/FormMaking/custom/configs/time.vue +3 -3
  33. package/packages/FormMaking/custom/configs/upload.vue +5 -5
  34. package/packages/FormMaking/custom/index.js +2 -4
  35. package/packages/FormMaking/custom/items/alliance.vue +30 -29
  36. package/packages/FormMaking/custom/items/blank_pro.vue +14 -0
  37. package/packages/FormMaking/custom/items/button.vue +36 -1
  38. package/packages/FormMaking/custom/items/cascader.vue +6 -2
  39. package/packages/FormMaking/custom/items/cell.vue +0 -2
  40. package/packages/FormMaking/custom/items/checkbox.vue +18 -8
  41. package/packages/FormMaking/custom/items/color.vue +1 -1
  42. package/packages/FormMaking/custom/items/date.vue +1 -1
  43. package/packages/FormMaking/custom/items/editor.vue +1 -1
  44. package/packages/FormMaking/custom/items/{grid.vue → grid_dev.vue} +16 -47
  45. package/packages/FormMaking/custom/items/grid_pro.vue +45 -0
  46. package/packages/FormMaking/custom/items/image.vue +0 -28
  47. package/packages/FormMaking/custom/items/input.vue +15 -9
  48. package/packages/FormMaking/custom/items/number.vue +4 -4
  49. package/packages/FormMaking/custom/items/radio.vue +17 -7
  50. package/packages/FormMaking/custom/items/rate.vue +1 -1
  51. package/packages/FormMaking/custom/items/select.vue +12 -6
  52. package/packages/FormMaking/custom/items/slider.vue +1 -1
  53. package/packages/FormMaking/custom/items/switch.vue +1 -1
  54. package/packages/FormMaking/custom/items/{table_h5.vue → tableH5_dev.vue} +44 -49
  55. package/packages/FormMaking/custom/items/tableH5_pro.vue +113 -0
  56. package/packages/FormMaking/custom/items/{table.vue → table_dev.vue} +21 -41
  57. package/packages/FormMaking/custom/items/table_pro.vue +114 -0
  58. package/packages/FormMaking/custom/items/tabs_dev.vue +101 -0
  59. package/packages/FormMaking/custom/items/tabs_pro.vue +50 -0
  60. package/packages/FormMaking/custom/items/text.vue +1 -1
  61. package/packages/FormMaking/custom/items/textarea.vue +4 -13
  62. package/packages/FormMaking/custom/items/time.vue +3 -3
  63. package/packages/FormMaking/custom/items/upload.vue +15 -14
  64. package/packages/FormMaking/custom/mixins/index.js +28 -6
  65. package/packages/FormMaking/custom/register.js +22 -11
  66. package/packages/FormMaking/index.vue +95 -468
  67. package/packages/FormMaking/styles/index.scss +235 -242
  68. package/packages/FormMaking/util/generateCode.js +3 -3
  69. package/packages/FormMaking/util/index.js +33 -23
  70. package/packages/FormMaking/util/request.js +9 -12
  71. package/packages/FormMaking/custom/items/tabs.vue +0 -145
  72. /package/packages/FormMaking/custom/items/{blank.vue → blank_dev.vue} +0 -0
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <th-row
3
+ :gutter="widget.options.gutter ? widget.options.gutter : 0"
4
+ :justify="widget.options.justify"
5
+ :align="widget.options.align"
6
+ >
7
+ <th-col
8
+ v-for="(column, columnIndex) in widget.options.columns"
9
+ :key="columnIndex"
10
+ :span="column.span"
11
+ >
12
+ <generate-form-item
13
+ v-for="element in column.list"
14
+ :key="element.key"
15
+ :widget="element"
16
+ :models="models"
17
+ :config="config"
18
+ :remote="remote"
19
+ :prop="prop ? `${prop}.${element.model}` : element.model"
20
+ :slotKeys="slotKeys"
21
+ :componentsData="componentsData"
22
+ >
23
+ <template v-for="name in slotKeys" :slot="name">
24
+ <slot :name="name" />
25
+ </template>
26
+ </generate-form-item>
27
+ </th-col>
28
+ </th-row>
29
+ </template>
30
+
31
+ <script>
32
+ import { itemsComponent } from "../mixins/index";
33
+ import GenerateFormItem from "../../GenerateFormItem.vue";
34
+ export default {
35
+ components: { GenerateFormItem },
36
+ mixins: [itemsComponent],
37
+ props: ["models", "remote", "prop", "slotKeys", "componentsData"],
38
+ data() {
39
+ return {};
40
+ },
41
+ methods: {}
42
+ };
43
+ </script>
44
+
45
+ <style></style>
@@ -1,32 +1,4 @@
1
1
  <template>
2
- <!-- <div>
3
- <th-image
4
- v-if="!widget.options.remote"
5
- :src="widget.options.defaultValue"
6
- :height="widget.options.height"
7
- :width="widget.options.width"
8
- :fit="widget.options.fit"
9
- :border-radius="widget.options.borderRadius"
10
- :display-style="widget.options.displayStyle"
11
- :error-src="widget.options.errorSrc"
12
- :is-loding="widget.options.isLoding"
13
- ></th-image>
14
- <div v-for="item in widget.options.defaultValueArr" :key="item.url">
15
- <th-image
16
- v-if="widget.options.remote"
17
- :src="item"
18
- src-key="url"
19
- :height="widget.options.height"
20
- :width="widget.options.width"
21
- :fit="widget.options.fit"
22
- :border-radius="widget.options.borderRadius"
23
- :preview-list="widget.options.defaultValueArr"
24
- :display-style="widget.options.displayStyle"
25
- :error-src="widget.options.errorSrc"
26
- :is-loding="widget.options.isLoding"
27
- ></th-image>
28
- </div>
29
- </div> -->
30
2
  <div>
31
3
  <el-image
32
4
  v-for="(item, index) in widget.options.defaultValue"
@@ -1,32 +1,38 @@
1
1
  <template>
2
2
  <el-input
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
+ :type="inputTypeDict(widget.options.dataType)"
4
5
  :style="{ width: widget.options.width }"
5
6
  :placeholder="widget.options.placeholder"
6
7
  :disabled="widget.options.disabled"
8
+ :readonly="widget.options.readonly"
9
+ :clearable="widget.options.clearable"
7
10
  :maxlength="widget.options.maxlength"
8
11
  :show-word-limit="widget.options.showWordLimit"
9
12
  :show-password="widget.options.showPassword"
10
- :clearable="widget.options.clearable"
11
13
  :suffix-icon="widget.options.suffixIcon"
12
14
  :prefix-icon="widget.options.prefixIcon"
13
15
  @input="handleEventAction(widget.events.onChange)"
14
16
  @focus="handleEventAction(widget.events.onFocus)"
15
17
  @blur="handleEventAction(widget.events.onBlur)"
16
18
  >
17
- <template v-if="widget.options.prepend" slot="prepend">
18
- <span v-html="widget.options.prepend"></span>
19
- </template>
20
- <template v-if="widget.options.append" slot="append">
21
- <span v-html="widget.options.append"></span>
22
- </template>
19
+ <template v-if="widget.options.prepend" slot="prepend">{{
20
+ widget.options.prepend
21
+ }}</template>
22
+ <template v-if="widget.options.append" slot="append">{{
23
+ widget.options.append
24
+ }}</template>
23
25
  </el-input>
24
26
  </template>
25
27
 
26
28
  <script>
29
+ import { inputTypeDict } from "../../util/index";
27
30
  import { itemsComponent } from "../mixins/index";
28
31
  export default {
29
- mixins: [itemsComponent]
32
+ mixins: [itemsComponent],
33
+ methods: {
34
+ inputTypeDict
35
+ }
30
36
  };
31
37
  </script>
32
38
 
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <el-input-number
3
- v-model="widget.options.defaultValue"
4
- :disabled="widget.options.disabled"
5
- :controls-position="widget.options.controlsPosition ? 'right' : ''"
3
+ v-model="dataModel"
6
4
  :style="{ width: widget.options.width }"
5
+ :step="widget.options.step"
6
+ :controls-position="widget.options.controlsPosition ? 'right' : ''"
7
+ :disabled="widget.options.disabled"
7
8
  :min="widget.options.min"
8
9
  :max="widget.options.max"
9
- :step="widget.options.step"
10
10
  :precision="widget.options.precision"
11
11
  @change="handleEventAction(widget.events.onChange)"
12
12
  @focus="handleEventAction(widget.events.onFocus)"
@@ -1,21 +1,26 @@
1
1
  <template>
2
2
  <el-radio-group
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :style="{ width: widget.options.width }"
5
5
  :disabled="widget.options.disabled"
6
6
  @change="handleEventAction(widget.events.onChange)"
7
7
  >
8
8
  <template v-if="widget.options.buttonType">
9
9
  <el-radio-button
10
- v-for="(item, index) in widget.options.options"
11
- :key="`radio_${index}_${item.value}`"
12
10
  :style="{
13
11
  display: widget.options.inline ? 'inline-block' : 'block'
14
12
  }"
13
+ v-for="(item, index) in widget.options.remote
14
+ ? widget.options.remoteOptions
15
+ : widget.options.options"
16
+ :key="index"
15
17
  :label="item.value"
16
18
  :border="widget.options.border"
17
19
  >
18
- {{ widget.options.showLabel ? item.label : item.value }}
20
+ <template v-if="widget.options.remote">{{ item.label }}</template>
21
+ <template v-else>{{
22
+ widget.options.showLabel ? item.label : item.value
23
+ }}</template>
19
24
  </el-radio-button>
20
25
  </template>
21
26
  <template v-else>
@@ -25,10 +30,15 @@
25
30
  }"
26
31
  :label="item.value"
27
32
  :border="widget.options.border"
28
- v-for="(item, index) in widget.options.options"
29
- :key="`radio_${index}_${item.value}`"
33
+ v-for="(item, index) in widget.options.remote
34
+ ? widget.options.remoteOptions
35
+ : widget.options.options"
36
+ :key="index"
30
37
  >
31
- {{ widget.options.showLabel ? item.label : item.value }}
38
+ <template v-if="widget.options.remote">{{ item.label }}</template>
39
+ <template v-else>{{
40
+ widget.options.showLabel ? item.label : item.value
41
+ }}</template>
32
42
  </el-radio>
33
43
  </template>
34
44
  </el-radio-group>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-rate
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :max="widget.options.max"
5
5
  :disabled="widget.options.disabled"
6
6
  :allow-half="widget.options.allowHalf"
@@ -1,23 +1,29 @@
1
1
  <template>
2
2
  <el-select
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :style="{ width: widget.options.width }"
5
5
  :disabled="widget.options.disabled"
6
6
  :multiple="widget.options.multiple"
7
- :collapseTags="widget.options.collapseTags"
8
- :allowCreate="widget.options.allowCreate"
9
7
  :clearable="widget.options.clearable"
10
8
  :placeholder="widget.options.placeholder"
9
+ :collapseTags="widget.options.collapseTags"
10
+ :allowCreate="widget.options.allowCreate"
11
11
  :filterable="widget.options.allowCreate ? true : widget.options.filterable"
12
12
  @change="handleEventAction(widget.events.onChange)"
13
13
  @focus="handleEventAction(widget.events.onFocus)"
14
14
  @blur="handleEventAction(widget.events.onBlur)"
15
15
  >
16
16
  <el-option
17
- v-for="(item, index) in widget.options.options"
18
- :key="`select_${index}_${item.value}`"
17
+ v-for="item in widget.options.remote
18
+ ? widget.options.remoteOptions
19
+ : widget.options.options"
20
+ :key="item.value"
19
21
  :value="item.value"
20
- :label="widget.options.showLabel ? item.label : item.value"
22
+ :label="
23
+ widget.options.showLabel || widget.options.remote
24
+ ? item.label
25
+ : item.value
26
+ "
21
27
  ></el-option>
22
28
  </el-select>
23
29
  </template>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-slider
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :min="widget.options.min"
5
5
  :max="widget.options.max"
6
6
  :disabled="widget.options.disabled"
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-switch
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :width="widget.options.width - 20"
5
5
  :disabled="widget.options.disabled"
6
6
  :inactive-text="widget.options.switchInactiveText"
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div>
2
+ <div class="tableH5">
3
3
  <draggable
4
- v-model="widget.list"
4
+ v-model="widget.options.columns"
5
5
  :no-transition-on-drag="true"
6
6
  v-bind="{
7
7
  group: 'people',
@@ -9,29 +9,24 @@
9
9
  animation: 200,
10
10
  handle: '.drag-widget'
11
11
  }"
12
- @add="handleWidgetTableAdd($event, widget)"
12
+ @add="handleWidgetAdd($event)"
13
13
  >
14
- <transition-group name="fade" tag="div" class="tableH5">
14
+ <transition-group name="fade" tag="div" class="tableH5-list">
15
15
  <div
16
- class="tableH5-item"
17
- v-for="(element, elementIndex) in widget.list.filter(item => {
18
- return item.key;
19
- })"
16
+ v-for="(element, elementIndex) in widget.options.columns"
17
+ class="tableH5-list-item"
20
18
  :key="element.key"
19
+ @click.stop="selectWidget = element"
21
20
  >
22
21
  <widget-form-item
23
- class="tableH5-item-widget"
24
22
  :widget="element"
23
+ :widgetArray="widget.options.columns"
25
24
  :widgetIndex="elementIndex"
26
- :widgetArray="widget"
27
25
  :select.sync="selectWidget"
28
26
  :config="config"
29
27
  >
30
28
  </widget-form-item>
31
- <div
32
- v-if="widget.options.isDelete && elementIndex === 0"
33
- class="actions"
34
- >
29
+ <div v-if="widget.options.isDelete && elementIndex === 0">
35
30
  <el-button type="danger">{{
36
31
  widget.options.deleteButtonText
37
32
  }}</el-button>
@@ -39,7 +34,7 @@
39
34
  </div>
40
35
  </transition-group>
41
36
  </draggable>
42
- <div v-if="widget.options.isAdd" style="text-align: center;">
37
+ <div v-if="widget.options.isAdd" class="footer">
43
38
  <el-button type="text" :disabled="widget.options.disabled">{{
44
39
  widget.options.addButtonText
45
40
  }}</el-button>
@@ -71,56 +66,56 @@ export default {
71
66
  }
72
67
  },
73
68
  methods: {
74
- handleWidgetTableAdd($event, row) {
69
+ handleWidgetAdd($event) {
75
70
  const newIndex = $event.newIndex;
76
71
  const oldIndex = $event.oldIndex;
72
+ const newComponent = JSON.parse(
73
+ JSON.stringify(this.widget.options.columns[newIndex])
74
+ );
77
75
  const item = $event.item;
78
76
  // 防止布局元素的嵌套拖拽
79
77
  if (item.className.indexOf("no-put") >= 0) {
80
78
  // 如果是列表中拖拽的元素需要还原到原来位置
81
79
  item.tagName === "DIV" &&
82
- this.widgetArray.list.splice(oldIndex, 0, row.list[newIndex]);
83
-
84
- row.list.splice(newIndex, 1);
80
+ this.widgetArray.splice(oldIndex, 0, newComponent);
85
81
 
82
+ this.widget.options.columns.splice(newIndex, 1);
86
83
  return false;
87
84
  }
88
85
 
89
86
  const key =
90
87
  Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
91
-
92
- this.$set(row.list, newIndex, {
93
- ...row.list[newIndex],
94
- options: {
95
- ...row.list[newIndex].options
96
- // remoteFunc: "func_" + key
97
- },
98
- key,
99
- // 绑定键值
100
- model: row.list[newIndex].type + "_" + key,
101
- rules: []
102
- });
103
-
104
- if (
105
- row.list[newIndex].type === "radio" ||
106
- row.list[newIndex].type === "checkbox" ||
107
- row.list[newIndex].type === "select"
108
- ) {
109
- this.$set(row.list, newIndex, {
110
- ...row.list[newIndex],
111
- options: {
112
- ...row.list[newIndex].options,
113
- options: row.list[newIndex].options.options.map(item => ({
114
- ...item
115
- }))
116
- }
117
- });
88
+ if (!newComponent.model) {
89
+ newComponent.key = key;
90
+ newComponent.model = `${newComponent.type}_${key}`;
118
91
  }
119
-
120
- this.selectWidget = row.list[newIndex];
92
+ this.$set(this.widget.options.columns, newIndex, newComponent);
93
+ this.selectWidget = newComponent;
121
94
  }
122
95
  }
123
96
  };
124
97
  </script>
125
98
 
126
- <style></style>
99
+ <style lang="scss" scoped>
100
+ .tableH5 {
101
+ background: #fff;
102
+
103
+ .tableH5-list {
104
+ min-height: 50px;
105
+ border: 1px dashed #ccc;
106
+ .tableH5-list-item {
107
+ width: 100%;
108
+ }
109
+ .tableH5-list-item:nth-child(1) {
110
+ display: flex;
111
+ > div:first-child {
112
+ flex: 1;
113
+ }
114
+ }
115
+ }
116
+
117
+ .footer {
118
+ text-align: center;
119
+ }
120
+ }
121
+ </style>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <div class="tableH5">
3
+ <div
4
+ v-for="(column, columnIndex) in dataModel"
5
+ class="tableH5-list"
6
+ :key="`tableH5_${columnIndex}`"
7
+ >
8
+ <div
9
+ v-for="(element, elementIndex) in widget.options.columns"
10
+ class="tableH5-list-item"
11
+ :key="`tableH5_${columnIndex}_${element.key}`"
12
+ >
13
+ <generate-form-item
14
+ style="flex:1;"
15
+ :models.sync="column"
16
+ :widget="element"
17
+ :remote="remote"
18
+ :config="config"
19
+ :prop="
20
+ element.type === 'grid'
21
+ ? `${prop}.${columnIndex}`
22
+ : `${prop}.${columnIndex}.${element.model}`
23
+ "
24
+ :slotKeys="slotKeys"
25
+ :componentsData="componentsData"
26
+ >
27
+ <template v-for="name in slotKeys" :slot="name">
28
+ <slot :name="name" />
29
+ </template>
30
+ </generate-form-item>
31
+ <div
32
+ v-if="
33
+ widget.options.isDelete &&
34
+ elementIndex === 0 &&
35
+ columnIndex >= widget.options.deleteIndex
36
+ "
37
+ class="actions"
38
+ >
39
+ <el-button
40
+ type="danger"
41
+ @click.native.prevent="dataModel.splice(columnIndex, 1)"
42
+ >{{ widget.options.deleteButtonText }}</el-button
43
+ >
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <div v-if="widget.options.isAdd" style="text-align: center;">
49
+ <el-button
50
+ type="text"
51
+ :disabled="widget.options.disabled"
52
+ @click="handleTableAdd"
53
+ >{{ widget.options.addButtonText }}</el-button
54
+ >
55
+ </div>
56
+ </div>
57
+ </template>
58
+
59
+ <script>
60
+ import { itemsComponent } from "../mixins/index";
61
+ import GenerateFormItem from "../../GenerateFormItem.vue";
62
+ export default {
63
+ components: { GenerateFormItem },
64
+ mixins: [itemsComponent],
65
+ props: ["models", "remote", "prop", "slotKeys", "componentsData"],
66
+ data() {
67
+ return {};
68
+ },
69
+
70
+ methods: {
71
+ handleTableAdd() {
72
+ let dic = {};
73
+ this.widget.options.columns.forEach(item => {
74
+ if (item.type === "grid") {
75
+ for (let i = 0; i < item.options.columns.length; i++) {
76
+ const element = item.options.columns[i];
77
+ for (let j = 0; j < element.options.columns.length; j++) {
78
+ const element2 = element.options.columns[j];
79
+ dic[element2.model] = element2.options.defaultValue;
80
+ }
81
+ }
82
+ } else {
83
+ dic[item.model] = item.options.defaultValue;
84
+ }
85
+ });
86
+ this.dataModel.push(dic);
87
+ }
88
+ }
89
+ };
90
+ </script>
91
+
92
+ <style lang="scss" scoped>
93
+ .tableH5 {
94
+ background: #fff;
95
+
96
+ .tableH5-list {
97
+ .tableH5-list-item {
98
+ width: 100%;
99
+ }
100
+ .tableH5-list-item:nth-child(1) {
101
+ display: flex;
102
+ > div:first-child {
103
+ flex: 1;
104
+ margin-right: 10px;
105
+ }
106
+ }
107
+ }
108
+
109
+ .footer {
110
+ text-align: center;
111
+ }
112
+ }
113
+ </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <draggable
3
- v-model="widget.list"
3
+ v-model="widget.options.columns"
4
4
  :no-transition-on-drag="true"
5
5
  v-bind="{
6
6
  group: 'people',
@@ -8,17 +8,19 @@
8
8
  animation: 200,
9
9
  handle: '.drag-widget'
10
10
  }"
11
- @add="handleWidgetTableAdd($event, widget)"
11
+ @add="handleWidgetAdd($event, widget)"
12
12
  >
13
13
  <transition-group name="fade" tag="div" class="widget-table-list">
14
14
  <widget-form-item
15
- v-for="(element, elementIndex) in widget.list.filter(item => {
16
- return item.key;
17
- })"
15
+ v-for="(element, elementIndex) in widget.options.columns.filter(
16
+ item => {
17
+ return item.key;
18
+ }
19
+ )"
18
20
  :key="element.key"
19
21
  :widget="element"
20
22
  :widgetIndex="elementIndex"
21
- :widgetArray="widget"
23
+ :widgetArray="widget.options.columns"
22
24
  :select.sync="selectWidget"
23
25
  :config="config"
24
26
  >
@@ -50,55 +52,33 @@ export default {
50
52
  deep: true
51
53
  }
52
54
  },
53
- methods:{
54
- handleWidgetTableAdd($event, row) {
55
+ methods: {
56
+ handleWidgetAdd($event) {
55
57
  const newIndex = $event.newIndex;
56
58
  const oldIndex = $event.oldIndex;
59
+ const newComponent = JSON.parse(
60
+ JSON.stringify(this.widget.options.columns[newIndex])
61
+ );
57
62
  const item = $event.item;
58
63
  // 防止布局元素的嵌套拖拽
59
64
  if (item.className.indexOf("no-put") >= 0) {
60
65
  // 如果是列表中拖拽的元素需要还原到原来位置
61
66
  item.tagName === "DIV" &&
62
- this.widgetArray.list.splice(oldIndex, 0, row.list[newIndex]);
63
-
64
- row.list.splice(newIndex, 1);
67
+ this.widgetArray.splice(oldIndex, 0, newComponent);
65
68
 
69
+ this.widget.options.columns.splice(newIndex, 1);
66
70
  return false;
67
71
  }
68
72
 
69
73
  const key =
70
74
  Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
71
-
72
- this.$set(row.list, newIndex, {
73
- ...row.list[newIndex],
74
- options: {
75
- ...row.list[newIndex].options
76
- // remoteFunc: "func_" + key
77
- },
78
- key,
79
- // 绑定键值
80
- model: row.list[newIndex].type + "_" + key,
81
- rules: []
82
- });
83
-
84
- if (
85
- row.list[newIndex].type === "radio" ||
86
- row.list[newIndex].type === "checkbox" ||
87
- row.list[newIndex].type === "select"
88
- ) {
89
- this.$set(row.list, newIndex, {
90
- ...row.list[newIndex],
91
- options: {
92
- ...row.list[newIndex].options,
93
- options: row.list[newIndex].options.options.map(item => ({
94
- ...item
95
- }))
96
- }
97
- });
75
+ if (!newComponent.model) {
76
+ newComponent.key = key;
77
+ newComponent.model = `${newComponent.type}_${key}`;
98
78
  }
99
-
100
- this.selectWidget = row.list[newIndex];
101
- },
79
+ this.$set(this.widget.options.columns, newIndex, newComponent);
80
+ this.selectWidget = newComponent;
81
+ }
102
82
  }
103
83
  };
104
84
  </script>