tianheng-ui 0.0.43 → 0.0.46
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/lib/03250ed25fc1b305e9980cf7cf0dfb09.js +1 -0
- package/lib/c755e7fc08446566ee8dd3a8aa8fe43f.js +1715 -0
- package/lib/index.js +1 -1
- package/lib/tianheng-ui.js +26 -16
- package/lib/tianheng-ui.js.map +1 -1
- package/package.json +65 -58
- package/packages/formMaking/Container.vue +22 -9
- package/packages/formMaking/FormConfig.vue +12 -3
- package/packages/formMaking/GenerateFormItem.vue +516 -266
- package/packages/formMaking/WidgetConfig.vue +1361 -760
- package/packages/formMaking/WidgetForm.vue +167 -116
- package/packages/formMaking/WidgetFormItem.vue +466 -284
- package/packages/formMaking/componentsConfig.js +402 -332
@@ -1,62 +1,103 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="widget-form-container">
|
3
|
-
<div v-if="data.list.length == 0" class="form-empty"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
<div v-if="data.list.length == 0" class="form-empty">
|
4
|
+
从左侧拖拽来添加字段
|
5
|
+
</div>
|
6
|
+
<el-form
|
7
|
+
:size="data.config.size"
|
8
|
+
label-suffix=":"
|
9
|
+
:label-position="data.config.labelPosition"
|
10
|
+
:label-width="data.config.labelWidth + 'px'"
|
11
|
+
>
|
12
|
+
<draggable
|
13
|
+
class=""
|
14
|
+
v-model="data.list"
|
15
|
+
v-bind="{
|
16
|
+
group: 'people',
|
17
|
+
ghostClass: 'ghost',
|
18
|
+
animation: 200,
|
19
|
+
handle: '.drag-widget'
|
20
|
+
}"
|
9
21
|
@end="handleMoveEnd"
|
10
22
|
@add="handleWidgetAdd"
|
11
23
|
>
|
12
|
-
|
13
24
|
<transition-group name="fade" tag="div" class="widget-form-list">
|
14
25
|
<template v-for="(element, index) in data.list">
|
15
26
|
<template v-if="element.type == 'grid'">
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
27
|
+
<el-row
|
28
|
+
class="widget-col widget-view"
|
29
|
+
v-if="element && element.key"
|
30
|
+
:key="element.key"
|
31
|
+
type="flex"
|
32
|
+
:class="{ active: selectWidget.key == element.key }"
|
33
|
+
:gutter="element.options.gutter ? element.options.gutter : 0"
|
34
|
+
:justify="element.options.justify"
|
35
|
+
:align="element.options.align"
|
36
|
+
@click.native="handleSelectWidget(index)"
|
37
|
+
>
|
38
|
+
<el-col
|
39
|
+
v-for="(col, colIndex) in element.columns"
|
40
|
+
:key="colIndex"
|
41
|
+
:span="col.span ? col.span : 0"
|
42
|
+
>
|
43
|
+
<draggable
|
44
|
+
v-model="col.list"
|
45
|
+
:no-transition-on-drag="true"
|
46
|
+
v-bind="{
|
47
|
+
group: 'people',
|
48
|
+
ghostClass: 'ghost',
|
49
|
+
animation: 200,
|
50
|
+
handle: '.drag-widget'
|
51
|
+
}"
|
52
|
+
@end="handleMoveEnd"
|
53
|
+
@add="handleWidgetColAdd($event, element, colIndex)"
|
54
|
+
>
|
55
|
+
<transition-group
|
56
|
+
name="fade"
|
57
|
+
tag="div"
|
58
|
+
class="widget-col-list"
|
59
|
+
>
|
60
|
+
<template v-for="(el, i) in col.list">
|
61
|
+
<widget-form-item
|
62
|
+
:key="el.key"
|
63
|
+
v-if="el.key"
|
64
|
+
:element="el"
|
65
|
+
:select.sync="selectWidget"
|
66
|
+
:index="i"
|
67
|
+
:data="col"
|
68
|
+
>
|
69
|
+
</widget-form-item>
|
70
|
+
</template>
|
71
|
+
</transition-group>
|
72
|
+
</draggable>
|
73
|
+
</el-col>
|
74
|
+
<div
|
75
|
+
class="widget-view-action widget-col-action"
|
76
|
+
v-if="selectWidget.key == element.key"
|
77
|
+
>
|
78
|
+
<i
|
79
|
+
class="iconfont icon-trash"
|
80
|
+
@click.stop="handleWidgetDelete(index)"
|
81
|
+
></i>
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<div
|
85
|
+
class="widget-view-drag widget-col-drag"
|
86
|
+
v-if="selectWidget.key == element.key"
|
87
|
+
>
|
88
|
+
<i class="iconfont icon-drag drag-widget"></i>
|
89
|
+
</div>
|
90
|
+
</el-row>
|
57
91
|
</template>
|
58
92
|
<template v-else>
|
59
|
-
<widget-form-item
|
93
|
+
<widget-form-item
|
94
|
+
v-if="element && element.key"
|
95
|
+
:key="element.key"
|
96
|
+
:element="element"
|
97
|
+
:select.sync="selectWidget"
|
98
|
+
:index="index"
|
99
|
+
:data="data"
|
100
|
+
></widget-form-item>
|
60
101
|
</template>
|
61
102
|
</template>
|
62
103
|
</transition-group>
|
@@ -66,59 +107,58 @@
|
|
66
107
|
</template>
|
67
108
|
|
68
109
|
<script>
|
69
|
-
import Draggable from
|
70
|
-
import WidgetFormItem from
|
110
|
+
import Draggable from "vuedraggable";
|
111
|
+
import WidgetFormItem from "./WidgetFormItem";
|
71
112
|
|
72
113
|
export default {
|
73
114
|
components: {
|
74
115
|
Draggable,
|
75
116
|
WidgetFormItem
|
76
117
|
},
|
77
|
-
props: [
|
78
|
-
data
|
118
|
+
props: ["data", "select"],
|
119
|
+
data() {
|
79
120
|
return {
|
80
121
|
selectWidget: this.select
|
81
|
-
}
|
122
|
+
};
|
82
123
|
},
|
83
|
-
mounted
|
84
|
-
document.body.ondrop = function
|
85
|
-
let isFirefox = navigator.userAgent.toLowerCase().indexOf(
|
124
|
+
mounted() {
|
125
|
+
document.body.ondrop = function(event) {
|
126
|
+
let isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
|
86
127
|
if (isFirefox) {
|
87
|
-
event.preventDefault()
|
88
|
-
event.stopPropagation()
|
128
|
+
event.preventDefault();
|
129
|
+
event.stopPropagation();
|
89
130
|
}
|
90
|
-
}
|
131
|
+
};
|
91
132
|
},
|
92
133
|
methods: {
|
93
|
-
handleMoveEnd
|
94
|
-
|
95
|
-
|
96
|
-
handleSelectWidget (index) {
|
97
|
-
console.log(index, '#####')
|
98
|
-
this.selectWidget = this.data.list[index]
|
134
|
+
handleMoveEnd({ newIndex, oldIndex }) {},
|
135
|
+
handleSelectWidget(index) {
|
136
|
+
this.selectWidget = this.data.list[index];
|
99
137
|
},
|
100
|
-
handleWidgetAdd
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
const to = evt.to
|
105
|
-
console.log(to)
|
106
|
-
|
138
|
+
handleWidgetAdd(evt) {
|
139
|
+
const newIndex = evt.newIndex;
|
140
|
+
const to = evt.to;
|
141
|
+
|
107
142
|
//为拖拽到容器的元素添加唯一 key
|
108
|
-
const key =
|
143
|
+
const key =
|
144
|
+
Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
|
109
145
|
this.$set(this.data.list, newIndex, {
|
110
146
|
...this.data.list[newIndex],
|
111
147
|
options: {
|
112
148
|
...this.data.list[newIndex].options,
|
113
|
-
remoteFunc:
|
149
|
+
// remoteFunc: "func_" + key
|
114
150
|
},
|
115
151
|
key,
|
116
152
|
// 绑定键值
|
117
|
-
model: this.data.list[newIndex].type +
|
153
|
+
model: this.data.list[newIndex].type + "_" + key,
|
118
154
|
rules: []
|
119
|
-
})
|
155
|
+
});
|
120
156
|
|
121
|
-
if (
|
157
|
+
if (
|
158
|
+
this.data.list[newIndex].type === "radio" ||
|
159
|
+
this.data.list[newIndex].type === "checkbox" ||
|
160
|
+
this.data.list[newIndex].type === "select"
|
161
|
+
) {
|
122
162
|
this.$set(this.data.list, newIndex, {
|
123
163
|
...this.data.list[newIndex],
|
124
164
|
options: {
|
@@ -127,91 +167,102 @@ export default {
|
|
127
167
|
...item
|
128
168
|
}))
|
129
169
|
}
|
130
|
-
})
|
170
|
+
});
|
131
171
|
}
|
132
172
|
|
133
|
-
if (this.data.list[newIndex].type ===
|
173
|
+
if (this.data.list[newIndex].type === "grid") {
|
134
174
|
this.$set(this.data.list, newIndex, {
|
135
175
|
...this.data.list[newIndex],
|
136
|
-
columns: this.data.list[newIndex].columns.map(item => ({...item}))
|
137
|
-
})
|
176
|
+
columns: this.data.list[newIndex].columns.map(item => ({ ...item }))
|
177
|
+
});
|
138
178
|
}
|
139
179
|
|
140
|
-
this.selectWidget = this.data.list[newIndex]
|
180
|
+
this.selectWidget = this.data.list[newIndex];
|
141
181
|
},
|
142
|
-
handleWidgetColAdd
|
143
|
-
console.log(
|
144
|
-
const newIndex = $event.newIndex
|
145
|
-
const oldIndex = $event.oldIndex
|
146
|
-
const item = $event.item
|
182
|
+
handleWidgetColAdd($event, row, colIndex) {
|
183
|
+
console.log("coladd", $event, row, colIndex);
|
184
|
+
const newIndex = $event.newIndex;
|
185
|
+
const oldIndex = $event.oldIndex;
|
186
|
+
const item = $event.item;
|
147
187
|
|
148
188
|
// 防止布局元素的嵌套拖拽
|
149
|
-
if (item.className.indexOf(
|
150
|
-
|
189
|
+
if (item.className.indexOf("data-grid") >= 0) {
|
151
190
|
// 如果是列表中拖拽的元素需要还原到原来位置
|
152
|
-
item.tagName ===
|
191
|
+
item.tagName === "DIV" &&
|
192
|
+
this.data.list.splice(
|
193
|
+
oldIndex,
|
194
|
+
0,
|
195
|
+
row.columns[colIndex].list[newIndex]
|
196
|
+
);
|
153
197
|
|
154
|
-
row.columns[colIndex].list.splice(newIndex, 1)
|
198
|
+
row.columns[colIndex].list.splice(newIndex, 1);
|
155
199
|
|
156
|
-
return false
|
200
|
+
return false;
|
157
201
|
}
|
158
202
|
|
159
|
-
console.log(
|
203
|
+
console.log("from", item);
|
160
204
|
|
161
|
-
const key =
|
205
|
+
const key =
|
206
|
+
Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
|
162
207
|
|
163
208
|
this.$set(row.columns[colIndex].list, newIndex, {
|
164
209
|
...row.columns[colIndex].list[newIndex],
|
165
210
|
options: {
|
166
211
|
...row.columns[colIndex].list[newIndex].options,
|
167
|
-
remoteFunc:
|
212
|
+
// remoteFunc: "func_" + key
|
168
213
|
},
|
169
214
|
key,
|
170
215
|
// 绑定键值
|
171
|
-
model: row.columns[colIndex].list[newIndex].type +
|
216
|
+
model: row.columns[colIndex].list[newIndex].type + "_" + key,
|
172
217
|
rules: []
|
173
|
-
})
|
218
|
+
});
|
174
219
|
|
175
|
-
if (
|
220
|
+
if (
|
221
|
+
row.columns[colIndex].list[newIndex].type === "radio" ||
|
222
|
+
row.columns[colIndex].list[newIndex].type === "checkbox" ||
|
223
|
+
row.columns[colIndex].list[newIndex].type === "select"
|
224
|
+
) {
|
176
225
|
this.$set(row.columns[colIndex].list, newIndex, {
|
177
226
|
...row.columns[colIndex].list[newIndex],
|
178
227
|
options: {
|
179
228
|
...row.columns[colIndex].list[newIndex].options,
|
180
|
-
options: row.columns[colIndex].list[newIndex].options.options.map(
|
181
|
-
|
182
|
-
|
229
|
+
options: row.columns[colIndex].list[newIndex].options.options.map(
|
230
|
+
item => ({
|
231
|
+
...item
|
232
|
+
})
|
233
|
+
)
|
183
234
|
}
|
184
|
-
})
|
235
|
+
});
|
185
236
|
}
|
186
237
|
|
187
|
-
this.selectWidget = row.columns[colIndex].list[newIndex]
|
238
|
+
this.selectWidget = row.columns[colIndex].list[newIndex];
|
188
239
|
},
|
189
|
-
handleWidgetDelete
|
240
|
+
handleWidgetDelete(index) {
|
190
241
|
if (this.data.list.length - 1 === index) {
|
191
242
|
if (index === 0) {
|
192
|
-
this.selectWidget = {}
|
243
|
+
this.selectWidget = {};
|
193
244
|
} else {
|
194
|
-
this.selectWidget = this.data.list[index - 1]
|
245
|
+
this.selectWidget = this.data.list[index - 1];
|
195
246
|
}
|
196
247
|
} else {
|
197
|
-
this.selectWidget = this.data.list[index + 1]
|
248
|
+
this.selectWidget = this.data.list[index + 1];
|
198
249
|
}
|
199
250
|
|
200
251
|
this.$nextTick(() => {
|
201
|
-
this.data.list.splice(index, 1)
|
202
|
-
})
|
203
|
-
}
|
252
|
+
this.data.list.splice(index, 1);
|
253
|
+
});
|
254
|
+
}
|
204
255
|
},
|
205
256
|
watch: {
|
206
|
-
select
|
207
|
-
this.selectWidget = val
|
257
|
+
select(val) {
|
258
|
+
this.selectWidget = val;
|
208
259
|
},
|
209
260
|
selectWidget: {
|
210
|
-
handler
|
211
|
-
this.$emit(
|
261
|
+
handler(val) {
|
262
|
+
this.$emit("update:select", val);
|
212
263
|
},
|
213
264
|
deep: true
|
214
265
|
}
|
215
266
|
}
|
216
|
-
}
|
267
|
+
};
|
217
268
|
</script>
|