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
@@ -81,27 +81,54 @@
81
81
  </el-form-item>
82
82
 
83
83
  <el-form-item label="校验">
84
- <el-checkbox v-model="widget.options.required">必填</el-checkbox>
85
- <el-select style="width:100%" v-model="widget.options.dataType">
86
- <el-option value="string" label="字符串"></el-option>
87
- <el-option value="number" label="数字"></el-option>
88
- <el-option value="boolean" label="布尔值"></el-option>
89
- <el-option value="integer" label="整数"></el-option>
90
- <el-option value="float" label="浮点数"></el-option>
91
- <el-option value="url" label="URL地址"></el-option>
92
- <el-option value="email" label="邮箱地址"></el-option>
93
- <el-option value="hex" label="十六进制"></el-option>
94
- </el-select>
84
+ <div class="flexView">
85
+ <el-checkbox v-model="widget.options.required">必填</el-checkbox>
86
+ <el-select
87
+ style="flex: 1;margin-left:10px;"
88
+ v-model="widget.options.dataType"
89
+ @change="handleInputTypeChange"
90
+ >
91
+ <el-option
92
+ v-for="rule in Object.values(rulesOptions)"
93
+ :key="rule.value"
94
+ :value="rule.value"
95
+ :label="rule.label"
96
+ ></el-option>
97
+ </el-select>
98
+ </div>
95
99
 
96
- <el-input
97
- class="config-pattern-input"
98
- style=" width: 100%;"
99
- v-model.lazy="widget.options.pattern"
100
- placeholder="填写正则表达式"
100
+ <div
101
+ v-for="(rule, index) in widget.rules"
102
+ class="flexView"
103
+ :key="rule.id"
101
104
  >
102
- <template slot="prepend">/</template>
103
- <template slot="append">/</template>
104
- </el-input>
105
+ <el-input
106
+ class="config-pattern-input"
107
+ style="flex: 1;margin-right:10px;"
108
+ v-model="rule.patternStr"
109
+ placeholder="填写正则表达式"
110
+ clearable
111
+ >
112
+ <template slot="prepend">/</template>
113
+ <template slot="append">/</template>
114
+ </el-input>
115
+ <el-button
116
+ v-if="index === widget.rules.length - 1"
117
+ type="primary"
118
+ icon="el-icon-plus"
119
+ size="mini"
120
+ @click="
121
+ widget.rules.push({ id: new Date().getTime(), patternStr: '' })
122
+ "
123
+ ></el-button>
124
+ <el-button
125
+ v-else
126
+ type="danger"
127
+ icon="el-icon-delete"
128
+ size="mini"
129
+ @click="widget.rules.splice(index, 1)"
130
+ ></el-button>
131
+ </div>
105
132
  </el-form-item>
106
133
 
107
134
  <el-form-item>
@@ -125,9 +152,9 @@
125
152
  >
126
153
  <el-option
127
154
  v-for="item in config.eventScript"
128
- :key="item.key"
129
- :label="item.name"
130
- :value="item.key"
155
+ :key="item.id"
156
+ :label="item.label"
157
+ :value="item.id"
131
158
  >
132
159
  </el-option>
133
160
  </el-select>
@@ -153,12 +180,87 @@ export default {
153
180
  },
154
181
  props: {},
155
182
  mixins: [configComponent],
183
+ data(){
184
+ return {
185
+ rulesOptions: {
186
+ string: { label: "字符串", value: "string", pattern: "" },
187
+ number: { label: "数字", value: "number", pattern: "^[0-9]*$" },
188
+ numberOrAlphabet: {
189
+ label: "数字和大小写英文字母",
190
+ value: "numberOrAlphabet",
191
+ pattern: "^[A-Za-z0-9]+$"
192
+ },
193
+ integer: {
194
+ label: "正整数",
195
+ value: "integer",
196
+ pattern: "^[1-9]+[0-9]*$"
197
+ },
198
+ url: { label: "URL地址", value: "url", pattern: "" },
199
+ email: { label: "邮箱地址", value: "email", pattern: "" },
200
+ chineseName: {
201
+ label: "中文名(2-16位)",
202
+ value: "chineseName",
203
+ pattern: "^(?:[\\u4e00-\\u9fa5·]{2,16})$"
204
+ },
205
+ englishName: {
206
+ label: "英文名(2-22位)",
207
+ value: "englishName",
208
+ pattern: "(^[a-zA-Z]{1}[a-zA-Z\\s]{0,20}[a-zA-Z]{1}$)"
209
+ },
210
+ tel: { label: "手机号", value: "tel", pattern: "^1\\d{10}$" },
211
+ specialPlane: {
212
+ label: "座机号(xxx-xxxxxxxx)",
213
+ value: "specialPlane",
214
+ pattern: "^\\d{3}-\\d{8}$|^\\d{4}-\\d{7}$"
215
+ },
216
+ idCard: {
217
+ label: "身份证(18位)",
218
+ value: "idCard",
219
+ pattern: "^\\d{17}(\\d|X)$"
220
+ },
221
+ bankCard: {
222
+ label: "银行卡号",
223
+ value: "bankCard",
224
+ pattern: "^[1-9]\\d{9,29}$"
225
+ },
226
+ creditCode: {
227
+ label: "统一社会信用代码",
228
+ value: "creditCode",
229
+ pattern: "^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$"
230
+ }
231
+ }
232
+ }
233
+ },
156
234
  mounted() {},
157
235
  methods: {
158
236
  handleInputNumberChange() {
159
237
  if (this.widget.options.minRows > this.widget.options.maxRows) {
160
238
  this.widget.options.maxRows = this.widget.options.minRows;
161
239
  }
240
+ },
241
+ handleInputTypeChange() {
242
+ const ruleType = this.widget.options.dataType;
243
+ if (this.rulesOptions[ruleType].pattern) {
244
+ let isNew = true;
245
+ this.widget.rules.forEach(rule => {
246
+ if (rule.name) {
247
+ rule.name = ruleType;
248
+ rule.patternStr = this.rulesOptions[ruleType].pattern;
249
+ isNew = false;
250
+ }
251
+ });
252
+ if (isNew) {
253
+ this.widget.rules.unshift({
254
+ id: new Date().getTime(),
255
+ name: ruleType,
256
+ patternStr: this.rulesOptions[ruleType].pattern
257
+ });
258
+ }
259
+ } else {
260
+ this.widget.rules = this.widget.rules.filter(rule => {
261
+ return !rule.name;
262
+ });
263
+ }
162
264
  }
163
265
  }
164
266
  };
@@ -109,9 +109,9 @@
109
109
  >
110
110
  <el-option
111
111
  v-for="item in config.eventScript"
112
- :key="item.key"
113
- :label="item.name"
114
- :value="item.key"
112
+ :key="item.id"
113
+ :label="item.label"
114
+ :value="item.id"
115
115
  >
116
116
  </el-option>
117
117
  </el-select>
@@ -71,15 +71,15 @@
71
71
  </el-radio-group>
72
72
  <el-select
73
73
  v-if="widget.options.remote"
74
- style="width:100%"
75
74
  v-model="widget.options.remoteFunc"
76
- value-key="api"
75
+ style="width:100%"
76
+ :value-key="config.remoteFuncs.props.key"
77
77
  placeholder="请选择远端方法"
78
78
  >
79
79
  <el-option
80
- v-for="item in remoteApis"
81
- :key="item.api"
82
- :label="item.name"
80
+ v-for="item in config.remoteFuncs.options"
81
+ :key="item[config.remoteFuncs.props.key]"
82
+ :label="item[config.remoteFuncs.props.label]"
83
83
  :value="item"
84
84
  >
85
85
  </el-option>
@@ -12,17 +12,15 @@ const basicComponents = [
12
12
  "color",
13
13
  "switch",
14
14
  "button",
15
- "slider",
16
15
  "number",
16
+ "slider",
17
17
  "rate",
18
18
  "image",
19
19
  "upload",
20
20
  "editor",
21
21
  "cascader"
22
22
  ];
23
-
24
- const advanceComponents = ["table", "table_h5", "tabs", "blank"];
25
-
23
+ const advanceComponents = ["table", "tableH5", "tabs", "blank"];
26
24
  const layoutComponents = ["grid", "alliance", "filler", "divider"];
27
25
 
28
26
  module.exports = {
@@ -19,7 +19,7 @@
19
19
  :key="element.key"
20
20
  :widget="element"
21
21
  :widgetIndex="elementIndex"
22
- :widgetArray="column"
22
+ :widgetArray="column.list"
23
23
  :select.sync="selectWidget"
24
24
  :config="config"
25
25
  ></widget-form-item>
@@ -61,13 +61,13 @@ export default {
61
61
  if (item.className.indexOf("alliance") >= 0) {
62
62
  // 如果是列表中拖拽的元素需要还原到原来位置
63
63
  item.tagName === "DIV" &&
64
- this.widgetArray.list.splice(
64
+ this.widgetArray.splice(
65
65
  oldIndex,
66
66
  0,
67
- row.tabs[colIndex].list[newIndex]
67
+ row.options.columns[colIndex].list[newIndex]
68
68
  );
69
69
 
70
- row.tabs[colIndex].list.splice(newIndex, 1);
70
+ row.options.columns[colIndex].list.splice(newIndex, 1);
71
71
 
72
72
  return false;
73
73
  }
@@ -75,58 +75,59 @@ export default {
75
75
  const key =
76
76
  Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
77
77
 
78
- this.$set(row.tabs[colIndex].list, newIndex, {
79
- ...row.tabs[colIndex].list[newIndex],
78
+ this.$set(row.options.columns[colIndex].list, newIndex, {
79
+ ...row.options.columns[colIndex].list[newIndex],
80
80
  options: {
81
- ...row.tabs[colIndex].list[newIndex].options
81
+ ...row.options.columns[colIndex].list[newIndex].options
82
82
  // remoteFunc: "func_" + key
83
83
  },
84
84
  key,
85
85
  // 绑定键值
86
- model: row.tabs[colIndex].list[newIndex].type + "_" + key,
86
+ model: row.options.columns[colIndex].list[newIndex].type + "_" + key,
87
87
  rules: []
88
88
  });
89
89
 
90
90
  if (
91
- row.tabs[colIndex].list[newIndex].type === "radio" ||
92
- row.tabs[colIndex].list[newIndex].type === "checkbox" ||
93
- row.tabs[colIndex].list[newIndex].type === "select"
91
+ row.options.columns[colIndex].list[newIndex].type === "radio" ||
92
+ row.options.columns[colIndex].list[newIndex].type === "checkbox" ||
93
+ row.options.columns[colIndex].list[newIndex].type === "select"
94
94
  ) {
95
- this.$set(row.tabs[colIndex].list, newIndex, {
96
- ...row.tabs[colIndex].list[newIndex],
95
+ this.$set(row.options.columns[colIndex].list, newIndex, {
96
+ ...row.options.columns[colIndex].list[newIndex],
97
97
  options: {
98
- ...row.tabs[colIndex].list[newIndex].options,
99
- options: row.tabs[colIndex].list[newIndex].options.options.map(
100
- item => ({
101
- ...item
102
- })
103
- )
98
+ ...row.options.columns[colIndex].list[newIndex].options,
99
+ options: row.options.columns[colIndex].list[
100
+ newIndex
101
+ ].options.options.map(item => ({
102
+ ...item
103
+ }))
104
104
  }
105
105
  });
106
106
  }
107
107
 
108
- if (row.tabs[colIndex].list[newIndex].type === "grid") {
108
+ if (row.options.columns[colIndex].list[newIndex].type === "grid") {
109
109
  this.$set(
110
- row.tabs[colIndex].list,
110
+ row.options.columns[colIndex].list,
111
111
  newIndex,
112
- JSON.parse(JSON.stringify(row.tabs[colIndex].list[newIndex]))
112
+ JSON.parse(
113
+ JSON.stringify(row.options.columns[colIndex].list[newIndex])
114
+ )
113
115
  );
114
116
  }
115
117
 
116
- if (row.tabs[colIndex].list[newIndex].type === "table") {
117
- this.$set(row.tabs[colIndex].list, newIndex, {
118
- ...row.tabs[colIndex].list[newIndex],
119
- list: row.tabs[colIndex].list[newIndex].list.map(item => ({
118
+ if (row.options.columns[colIndex].list[newIndex].type === "table") {
119
+ this.$set(row.options.columns[colIndex].list, newIndex, {
120
+ ...row.options.columns[colIndex].list[newIndex],
121
+ list: row.options.columns[colIndex].list[newIndex].list.map(item => ({
120
122
  ...item
121
123
  }))
122
124
  });
123
125
  }
124
126
 
125
- this.selectWidget = row.tabs[colIndex].list[newIndex];
127
+ this.selectWidget = row.options.columns[colIndex].list[newIndex];
126
128
  }
127
129
  }
128
130
  };
129
131
  </script>
130
132
 
131
- <style lang="scss" scoped>
132
- </style>
133
+ <style lang="scss" scoped></style>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <div>
3
+ <slot :name="widget.model" />
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import { itemsComponent } from "../mixins/index";
9
+ export default {
10
+ mixins: [itemsComponent]
11
+ };
12
+ </script>
13
+
14
+ <style></style>
@@ -12,6 +12,7 @@
12
12
  :loading="widget.options.loading"
13
13
  :disabled="widget.options.disabled"
14
14
  :icon="widget.options.buttonIcon"
15
+ @click="handleEventAction(widget.events.onClick)"
15
16
  >
16
17
  {{ widget.options.defaultValue }}
17
18
  </th-button>
@@ -19,8 +20,42 @@
19
20
 
20
21
  <script>
21
22
  import { itemsComponent } from "../mixins/index";
23
+ import * as Axios from "lib/theme-chalk/js/axios";
22
24
  export default {
23
- mixins: [itemsComponent]
25
+ mixins: [itemsComponent],
26
+ data() {
27
+ return {
28
+ axios: null
29
+ };
30
+ },
31
+ created() {
32
+ const oauthConfig = localStorage.getItem("TH_OauthConfig") || "{}";
33
+ this.axios = Axios.init(JSON.parse(oauthConfig));
34
+ },
35
+ methods: {
36
+ hendleRemoteData() {
37
+ const remoteFunc = this.widget.options.remoteFunc;
38
+ const requestConfig = {
39
+ url: remoteFunc.url,
40
+ method: remoteFunc.method,
41
+ headers: remoteFunc.headers
42
+ };
43
+ let params = { ...remoteFunc.params };
44
+ if (remoteFunc.needPage) {
45
+ params.pageNum = 1;
46
+ params.pageSize = 20;
47
+ }
48
+ if (remoteFunc.method.toLowerCase() === "get") {
49
+ requestConfig.params = params;
50
+ } else {
51
+ params = Object.assign(params, this.models);
52
+ requestConfig.data = params;
53
+ }
54
+ this.axios(requestConfig).then(res => {
55
+ this.$emit("button-submit", requestConfig);
56
+ });
57
+ }
58
+ }
24
59
  };
25
60
  </script>
26
61
 
@@ -1,14 +1,18 @@
1
1
  <template>
2
2
  <el-cascader
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :disabled="widget.options.disabled"
5
5
  :clearable="widget.options.clearable"
6
6
  :placeholder="widget.options.placeholder"
7
- :style="{ width: widget.options.width }"
7
+ :style="{
8
+ width: widget.options.width,
9
+ height: widget.options.height
10
+ }"
8
11
  :options="widget.options.remoteOptions"
9
12
  :props="widget.options.props"
10
13
  :show-all-levels="widget.options.showAllLevels ? false : true"
11
14
  :collapse-tags="widget.options.collapseTags"
15
+ :filterable="widget.options.filterable"
12
16
  @change="handleEventAction(widget.events.onChange)"
13
17
  >
14
18
  <template slot-scope="{ data }">
@@ -8,9 +8,7 @@
8
8
 
9
9
  <script>
10
10
  import { itemsComponent } from "../mixins/index";
11
- import ThCell from "ui/Cell/index.vue";
12
11
  export default {
13
- components: { ThCell },
14
12
  mixins: [itemsComponent]
15
13
  };
16
14
  </script>
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <el-checkbox-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
  :min="widget.options.min"
7
- :max="widget.options.max"
7
+ :max="widget.options.max || 99999"
8
8
  @change="handleEventAction(widget.events.onChange)"
9
9
  >
10
10
  <template v-if="widget.options.buttonType">
@@ -14,10 +14,15 @@
14
14
  }"
15
15
  :label="item.value"
16
16
  :border="widget.options.border"
17
- v-for="(item, index) in widget.options.options"
18
- :key="`checkbox_${index}_${item.value}`"
17
+ v-for="(item, index) in widget.options.remote
18
+ ? widget.options.remoteOptions
19
+ : widget.options.options"
20
+ :key="index"
19
21
  >
20
- {{ widget.options.showLabel ? item.label : item.value }}
22
+ <template v-if="widget.options.remote">{{ item.label }}</template>
23
+ <template v-else>{{
24
+ widget.options.showLabel ? item.label : item.value
25
+ }}</template>
21
26
  </el-checkbox-button>
22
27
  </template>
23
28
  <template v-else>
@@ -27,10 +32,15 @@
27
32
  }"
28
33
  :label="item.value"
29
34
  :border="widget.options.border"
30
- v-for="(item, index) in widget.options.options"
31
- :key="`checkbox_${index}_${item.value}`"
35
+ v-for="(item, index) in widget.options.remote
36
+ ? widget.options.remoteOptions
37
+ : widget.options.options"
38
+ :key="index"
32
39
  >
33
- {{ widget.options.showLabel ? item.label : item.value }}
40
+ <template v-if="widget.options.remote">{{ item.label }}</template>
41
+ <template v-else>{{
42
+ widget.options.showLabel ? item.label : item.value
43
+ }}</template>
34
44
  </el-checkbox>
35
45
  </template>
36
46
  </el-checkbox-group>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-color-picker
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :disabled="widget.options.disabled"
5
5
  :show-alpha="widget.options.showAlpha"
6
6
  :color-format="widget.options.showAlpha ? 'rgb' : 'hex'"
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-date-picker
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :style="{ width: widget.options.width }"
5
5
  :type="widget.options.type"
6
6
  :is-range="widget.options.isRange"
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <vue-editor
3
- v-model="widget.options.defaultValue"
3
+ v-model="dataModel"
4
4
  :style="{
5
5
  width: widget.options.width,
6
6
  height: widget.options.height
@@ -1,5 +1,4 @@
1
1
  <template>
2
- <!-- widget.key -->
3
2
  <th-row
4
3
  :class="{ active: selectWidget.model == widget.model }"
5
4
  :gutter="widget.options.gutter ? widget.options.gutter : 0"
@@ -7,7 +6,7 @@
7
6
  :align="widget.options.align"
8
7
  >
9
8
  <th-col
10
- v-for="(column, columnIndex) in widget.columns"
9
+ v-for="(column, columnIndex) in widget.options.columns"
11
10
  :key="`grid_${columnIndex}`"
12
11
  :span="column.span ? column.span : 0"
13
12
  >
@@ -20,7 +19,7 @@
20
19
  animation: 200,
21
20
  handle: '.drag-widget'
22
21
  }"
23
- @add="handleWidgetColAdd($event, widget, columnIndex)"
22
+ @add="handleWidgetAdd($event, widget, columnIndex)"
24
23
  >
25
24
  <transition-group name="fade" tag="div" class="widget-col-list">
26
25
  <widget-form-item
@@ -29,8 +28,8 @@
29
28
  })"
30
29
  :key="element.key"
31
30
  :widget="element"
31
+ :widgetArray="column.list"
32
32
  :widgetIndex="elementIndex"
33
- :widgetArray="column"
34
33
  :select.sync="selectWidget"
35
34
  :config="config"
36
35
  >
@@ -45,10 +44,9 @@
45
44
  import { itemsComponent } from "../mixins/index";
46
45
  import Draggable from "vuedraggable";
47
46
  import WidgetFormItem from "../../WidgetFormItem.vue";
48
- import ThRow from "ui/Row/index.vue";
49
- import ThCol from "ui/Col/index.vue";
47
+
50
48
  export default {
51
- components: { Draggable, WidgetFormItem, ThRow, ThCol },
49
+ components: { Draggable, WidgetFormItem },
52
50
  mixins: [itemsComponent],
53
51
  data() {
54
52
  return {
@@ -67,61 +65,32 @@ export default {
67
65
  }
68
66
  },
69
67
  methods: {
70
- handleWidgetColAdd($event, row, colIndex) {
68
+ handleWidgetAdd($event, row, colIndex) {
71
69
  const newIndex = $event.newIndex;
72
70
  const oldIndex = $event.oldIndex;
73
71
  const item = $event.item;
72
+ const newComponent = JSON.parse(
73
+ JSON.stringify(row.options.columns[colIndex].list[newIndex])
74
+ );
74
75
 
75
76
  // 防止布局元素的嵌套拖拽
76
77
  if (item.className.indexOf("data-grid") >= 0) {
77
78
  // 如果是列表中拖拽的元素需要还原到原来位置
78
79
  item.tagName === "DIV" &&
79
- this.widgetArray.list.splice(
80
- oldIndex,
81
- 0,
82
- row.columns[colIndex].list[newIndex]
83
- );
84
-
85
- row.columns[colIndex].list.splice(newIndex, 1);
80
+ this.widgetArray.splice(oldIndex, 0, newComponent);
86
81
 
82
+ row.options.columns[colIndex].list.splice(newIndex, 1);
87
83
  return false;
88
84
  }
89
85
 
90
86
  const key =
91
87
  Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
92
-
93
- this.$set(row.columns[colIndex].list, newIndex, {
94
- ...row.columns[colIndex].list[newIndex],
95
- options: {
96
- ...row.columns[colIndex].list[newIndex].options
97
- // remoteFunc: "func_" + key
98
- },
99
- key,
100
- // 绑定键值
101
- model: row.columns[colIndex].list[newIndex].type + "_" + key,
102
- rules: []
103
- });
104
-
105
- if (
106
- row.columns[colIndex].list[newIndex].type === "radio" ||
107
- row.columns[colIndex].list[newIndex].type === "checkbox" ||
108
- row.columns[colIndex].list[newIndex].type === "select"
109
- ) {
110
- this.$set(row.columns[colIndex].list, newIndex, {
111
- ...row.columns[colIndex].list[newIndex],
112
- options: {
113
- ...row.columns[colIndex].list[newIndex].options,
114
- options: row.columns[colIndex].list[newIndex].options.options.map(
115
- item => ({
116
- ...item
117
- })
118
- )
119
- }
120
- });
88
+ if (!newComponent.model) {
89
+ newComponent.key = key;
90
+ newComponent.model = `${newComponent.type}_${key}`;
121
91
  }
122
-
123
- // this.$emit("update:select", row.columns[colIndex].list[newIndex]);
124
- this.selectWidget = row.columns[colIndex].list[newIndex];
92
+ this.$set(row.options.columns[colIndex].list, newIndex, newComponent);
93
+ this.selectWidget = newComponent;
125
94
  }
126
95
  }
127
96
  };