tianheng-ui 0.1.64 → 0.1.65
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/theme-chalk/index.scss +1 -1
- package/lib/theme-chalk/styles/feature.scss +1 -0
- package/lib/tianheng-ui.js +13 -13
- package/package.json +1 -1
- package/packages/CodeEditor/index.vue +41 -19
- package/packages/FormMaking/GenerateForm.vue +59 -65
- package/packages/FormMaking/WidgetConfig.vue +1 -1
- package/packages/FormMaking/WidgetForm.vue +11 -5
- package/packages/FormMaking/WidgetFormItem.vue +11 -4
- package/packages/FormMaking/WidgetGuide.vue +0 -0
- package/packages/FormMaking/WidgetTools.vue +2 -2
- package/packages/FormMaking/custom/config.js +320 -76
- package/packages/FormMaking/custom/configs/blank.vue +1 -1
- package/packages/FormMaking/custom/configs/button.vue +2 -2
- package/packages/FormMaking/custom/configs/cascader.vue +71 -34
- package/packages/FormMaking/custom/configs/cell.vue +1 -1
- package/packages/FormMaking/custom/configs/checkbox.vue +95 -64
- package/packages/FormMaking/custom/configs/color.vue +1 -1
- package/packages/FormMaking/custom/configs/date.vue +1 -1
- package/packages/FormMaking/custom/configs/descriptions.vue +314 -0
- package/packages/FormMaking/custom/configs/divider.vue +1 -1
- package/packages/FormMaking/custom/configs/editor.vue +1 -1
- package/packages/FormMaking/custom/configs/filler.vue +1 -1
- package/packages/FormMaking/custom/configs/grid.vue +33 -22
- package/packages/FormMaking/custom/configs/image.vue +1 -1
- package/packages/FormMaking/custom/configs/input.vue +1 -1
- package/packages/FormMaking/custom/configs/number.vue +1 -1
- package/packages/FormMaking/custom/configs/radio.vue +84 -53
- package/packages/FormMaking/custom/configs/rate.vue +1 -1
- package/packages/FormMaking/custom/configs/select.vue +157 -158
- package/packages/FormMaking/custom/configs/slider.vue +1 -1
- package/packages/FormMaking/custom/configs/switch.vue +1 -1
- package/packages/FormMaking/custom/configs/table.vue +1 -1
- package/packages/FormMaking/custom/configs/tableH5.vue +1 -1
- package/packages/FormMaking/custom/configs/tabs.vue +1 -1
- package/packages/FormMaking/custom/configs/text.vue +1 -1
- package/packages/FormMaking/custom/configs/textarea.vue +1 -1
- package/packages/FormMaking/custom/configs/time.vue +1 -1
- package/packages/FormMaking/custom/configs/upload.vue +1 -1
- package/packages/FormMaking/custom/configs/workflow.vue +494 -0
- package/packages/FormMaking/custom/index.js +4 -2
- package/packages/FormMaking/custom/items/cascader.vue +2 -2
- package/packages/FormMaking/custom/items/checkbox.vue +6 -10
- package/packages/FormMaking/custom/items/descriptions.vue +75 -0
- package/packages/FormMaking/custom/items/grid_dev.vue +2 -2
- package/packages/FormMaking/custom/items/list_dev.vue +10 -22
- package/packages/FormMaking/custom/items/radio.vue +5 -9
- package/packages/FormMaking/custom/items/select.vue +2 -4
- package/packages/FormMaking/custom/items/tableH5_dev.vue +9 -18
- package/packages/FormMaking/custom/items/table_dev.vue +13 -3
- package/packages/FormMaking/custom/items/tabs_dev.vue +3 -2
- package/packages/FormMaking/custom/items/workflow.vue +131 -0
- package/packages/FormMaking/custom/register.js +15 -1
- package/packages/FormMaking/index.vue +61 -27
- package/packages/FormMaking/styles/index.scss +156 -478
- package/packages/TableMaking/index.vue +4 -1
- package/packages/TableMaking/widgetGuide.vue +96 -0
- package/packages/TableMaking/widgetTable.vue +0 -7
- package/packages/Workflow/index.vue +0 -31
- package/packages/FormMaking/GenerateFormItemH5.vue +0 -825
package/package.json
CHANGED
@@ -46,7 +46,7 @@ export default {
|
|
46
46
|
},
|
47
47
|
props: {
|
48
48
|
// 编辑器内容
|
49
|
-
value: String,
|
49
|
+
value: [String, Object, Array],
|
50
50
|
// 默认语言
|
51
51
|
language: {
|
52
52
|
type: String,
|
@@ -76,17 +76,32 @@ export default {
|
|
76
76
|
data() {
|
77
77
|
return {
|
78
78
|
editor: null,
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
editorValue: this.value,
|
80
|
+
generateId: `id_${Math.random()
|
81
|
+
.toString(36)
|
82
|
+
.substr(2, 4)}`,
|
83
|
+
dataType: ""
|
84
84
|
};
|
85
85
|
},
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
watch: {
|
87
|
+
value(val) {
|
88
|
+
this.dataType = val.constructor;
|
89
|
+
if (this.dataType === Object || this.dataType === Array)
|
90
|
+
this.editorValue = JSON.stringify(val, null, 2);
|
91
|
+
else this.editorValue = val;
|
92
|
+
},
|
93
|
+
editorValue(val) {
|
94
|
+
if (this.dataType === Object || this.dataType === Array)
|
95
|
+
try {
|
96
|
+
this.$emit("change", JSON.parse(val));
|
97
|
+
} catch (error) {}
|
98
|
+
else this.$emit("change", val);
|
99
|
+
|
100
|
+
if (this.editor.getValue() !== val) {
|
101
|
+
this.editor.setValue(val);
|
102
|
+
this.editor.clearSelection();
|
103
|
+
}
|
104
|
+
}
|
90
105
|
},
|
91
106
|
computed: {
|
92
107
|
selfStyle() {
|
@@ -102,24 +117,25 @@ export default {
|
|
102
117
|
return style;
|
103
118
|
}
|
104
119
|
},
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
this.editor.clearSelection();
|
110
|
-
}
|
111
|
-
}
|
120
|
+
mounted() {
|
121
|
+
// 初始化
|
122
|
+
this.initEditor();
|
123
|
+
this.setCompleteData();
|
112
124
|
},
|
113
125
|
methods: {
|
114
126
|
// 初始化
|
115
127
|
initEditor() {
|
128
|
+
this.dataType = this.editorValue.constructor;
|
116
129
|
// 创建实例
|
117
130
|
this.editor = ace.edit(this.$refs[this.generateId], {
|
118
131
|
mode: `ace/mode/${this.language}`,
|
119
132
|
theme: `ace/theme/${this.theme}`,
|
120
133
|
fontSize: 14,
|
121
134
|
tabSize: 2,
|
122
|
-
value:
|
135
|
+
value:
|
136
|
+
this.dataType === Object || this.dataType === Array
|
137
|
+
? JSON.stringify(this.editorValue, null, 2)
|
138
|
+
: this.editorValue,
|
123
139
|
selectionStyle: "text",
|
124
140
|
maxLines: this.maxLines,
|
125
141
|
readOnly: this.readonly,
|
@@ -138,7 +154,7 @@ export default {
|
|
138
154
|
});
|
139
155
|
// 设置值改变监听
|
140
156
|
this.editor.on("change", () => {
|
141
|
-
this
|
157
|
+
this.editorValue = this.editor.getValue();
|
142
158
|
});
|
143
159
|
},
|
144
160
|
setCompleteData() {
|
@@ -169,6 +185,12 @@ export default {
|
|
169
185
|
this.editor.destroy();
|
170
186
|
this.editor = null;
|
171
187
|
}
|
188
|
+
},
|
189
|
+
setValue(val) {
|
190
|
+
if (this.editor) {
|
191
|
+
this.editor.setValue(val);
|
192
|
+
this.editor.clearSelection();
|
193
|
+
}
|
172
194
|
}
|
173
195
|
},
|
174
196
|
beforeDestroy() {
|
@@ -24,7 +24,7 @@
|
|
24
24
|
:slotKeys="slotKeys"
|
25
25
|
:config="formConfig.config"
|
26
26
|
:componentsData="componentsData"
|
27
|
-
@input-change="
|
27
|
+
@input-change="handleInputChange"
|
28
28
|
@button-submit="handleButtonSubmit"
|
29
29
|
>
|
30
30
|
<template v-for="name in slotKeys" :slot="name">
|
@@ -32,32 +32,6 @@
|
|
32
32
|
</template>
|
33
33
|
</genetate-form-item>
|
34
34
|
</el-form>
|
35
|
-
<!-- <van-form
|
36
|
-
v-else
|
37
|
-
class="generateForm"
|
38
|
-
:class="{ 'form-hideLabel': formConfig.config.hideLabel }"
|
39
|
-
:style="{ width: formWidth }"
|
40
|
-
style="margin: 0 auto;"
|
41
|
-
:label-align="formConfig.config.labelPosition"
|
42
|
-
:label-width="formConfig.config.labelWidth + 'px'"
|
43
|
-
ref="generateForm"
|
44
|
-
>
|
45
|
-
<genetate-form-item-h5
|
46
|
-
v-for="item in formConfig.list"
|
47
|
-
:key="item.key"
|
48
|
-
:models.sync="models"
|
49
|
-
:widget="item"
|
50
|
-
:slotKeys="slotKeys"
|
51
|
-
:config="formConfig.config"
|
52
|
-
:prop="item.type === 'grid' ? '' : item.model"
|
53
|
-
:componentsData="componentsData"
|
54
|
-
@input-change="onInputChange"
|
55
|
-
>
|
56
|
-
<template v-for="name in slotKeys" :slot="name">
|
57
|
-
<slot :name="name" />
|
58
|
-
</template>
|
59
|
-
</genetate-form-item-h5>
|
60
|
-
</van-form> -->
|
61
35
|
</div>
|
62
36
|
</template>
|
63
37
|
|
@@ -118,6 +92,7 @@ export default {
|
|
118
92
|
},
|
119
93
|
value(val) {
|
120
94
|
if (val) this.models = val;
|
95
|
+
console.log("watch models =>", this.models);
|
121
96
|
}
|
122
97
|
},
|
123
98
|
created() {
|
@@ -126,6 +101,7 @@ export default {
|
|
126
101
|
},
|
127
102
|
mounted() {
|
128
103
|
this.generateModle(this.formConfig.list, this.models);
|
104
|
+
console.log("mounted models =>", this.models);
|
129
105
|
this.handleMountedRemotData();
|
130
106
|
this.showForm = true;
|
131
107
|
},
|
@@ -203,9 +179,15 @@ export default {
|
|
203
179
|
},
|
204
180
|
// 获取组件的远端数据
|
205
181
|
hendleElementRemoteData(item) {
|
206
|
-
if (!item.options.remote) return;
|
182
|
+
if (!item.options.remote || !item.options.remote.open) return;
|
207
183
|
if (item.type === "upload" || item.type === "button") return;
|
208
|
-
|
184
|
+
|
185
|
+
let api = "";
|
186
|
+
if (item.options.remote.api.constructor === String) {
|
187
|
+
api = this.formConfig.config.network[item.options.remote.api];
|
188
|
+
} else {
|
189
|
+
api = deepClone(item.options.remote.api);
|
190
|
+
}
|
209
191
|
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
210
192
|
|
211
193
|
const requestConfig = {
|
@@ -230,33 +212,43 @@ export default {
|
|
230
212
|
else requestConfig.data = params;
|
231
213
|
|
232
214
|
this.axios(requestConfig).then(res => {
|
233
|
-
const props = {
|
234
|
-
value: item.options.props.value || "value",
|
235
|
-
label: item.options.props.label || "label",
|
236
|
-
children: item.options.props.children || "children"
|
237
|
-
};
|
238
|
-
const initOptions = list => {
|
239
|
-
return list.map(element => {
|
240
|
-
const dic = {
|
241
|
-
value: element[props.value],
|
242
|
-
label: element[props.label]
|
243
|
-
};
|
244
|
-
if (element[props.children] && element[props.children].length) {
|
245
|
-
dic.children = initOptions(element[props.children]);
|
246
|
-
}
|
247
|
-
return dic;
|
248
|
-
});
|
249
|
-
};
|
250
215
|
const resultData = res.data.records ? res.data.records : res.data;
|
251
|
-
item.
|
216
|
+
if (item.type === "descriptions" || item.type === "workflow") {
|
217
|
+
item.options.defaultValue = resultData;
|
218
|
+
} else {
|
219
|
+
const props = {
|
220
|
+
value: item.options.remote.props.value || "value",
|
221
|
+
label: item.options.remote.props.label || "label",
|
222
|
+
children: item.options.remote.props.children || "children"
|
223
|
+
};
|
224
|
+
const initOptions = list => {
|
225
|
+
return list.map(element => {
|
226
|
+
const dic = {
|
227
|
+
value: element[props.value],
|
228
|
+
label: element[props.label]
|
229
|
+
};
|
230
|
+
if (element[props.children] && element[props.children].length) {
|
231
|
+
dic.children = initOptions(element[props.children]);
|
232
|
+
}
|
233
|
+
return dic;
|
234
|
+
});
|
235
|
+
};
|
236
|
+
item.options.options = initOptions(resultData);
|
237
|
+
}
|
252
238
|
});
|
253
239
|
},
|
254
240
|
handleMountedRemotData() {
|
255
241
|
if (!this.formConfig.config.mounted.api) return;
|
256
242
|
|
257
|
-
|
258
|
-
|
259
|
-
|
243
|
+
let api = "";
|
244
|
+
if (this.formConfig.config.mounted.api.constructor === String) {
|
245
|
+
api = this.formConfig.config.network[
|
246
|
+
this.formConfig.config.mounted.api
|
247
|
+
];
|
248
|
+
} else {
|
249
|
+
api = deepClone(this.formConfig.config.mounted.api);
|
250
|
+
}
|
251
|
+
|
260
252
|
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
261
253
|
|
262
254
|
const requestConfig = {
|
@@ -286,11 +278,20 @@ export default {
|
|
286
278
|
});
|
287
279
|
},
|
288
280
|
handleButtonSubmit(element) {
|
289
|
-
|
281
|
+
if (!element.options.remote.api)
|
282
|
+
return this.$emit("button-submit", element);
|
283
|
+
|
284
|
+
let api = "";
|
285
|
+
if (element.options.remote.api.constructor === String) {
|
286
|
+
api = this.formConfig.config.network[element.options.remote.api];
|
287
|
+
} else {
|
288
|
+
api = deepClone(element.options.remote.api);
|
289
|
+
}
|
290
|
+
|
290
291
|
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
291
292
|
|
292
293
|
let params = {};
|
293
|
-
const inParams = api.inParams;
|
294
|
+
const inParams = api.inParams || [];
|
294
295
|
const initParams = list => {
|
295
296
|
list.map(item => {
|
296
297
|
if (item.children) {
|
@@ -332,6 +333,12 @@ export default {
|
|
332
333
|
});
|
333
334
|
});
|
334
335
|
},
|
336
|
+
handleInputChange(value, field) {
|
337
|
+
this.$emit("change", field, value, this.models);
|
338
|
+
},
|
339
|
+
reset() {
|
340
|
+
this.$refs.generateForm.resetFields();
|
341
|
+
},
|
335
342
|
getData() {
|
336
343
|
return new Promise((resolve, reject) => {
|
337
344
|
this.$refs.generateForm.validate(valid => {
|
@@ -343,12 +350,6 @@ export default {
|
|
343
350
|
});
|
344
351
|
});
|
345
352
|
},
|
346
|
-
reset() {
|
347
|
-
this.$refs.generateForm.resetFields();
|
348
|
-
},
|
349
|
-
onInputChange(value, field) {
|
350
|
-
this.$emit("change", field, value, this.models);
|
351
|
-
},
|
352
353
|
setConfig(json) {
|
353
354
|
this.formConfig = json;
|
354
355
|
this.generateModle(this.formConfig.list, this.models);
|
@@ -379,13 +380,6 @@ export default {
|
|
379
380
|
}
|
380
381
|
}
|
381
382
|
|
382
|
-
.widget-form-list-filler {
|
383
|
-
margin-bottom: 0 !important;
|
384
|
-
}
|
385
|
-
.widget-form-list-image {
|
386
|
-
margin-bottom: 0 !important;
|
387
|
-
}
|
388
|
-
|
389
383
|
.tableH5 {
|
390
384
|
// 操作按钮布局
|
391
385
|
.tableH5-item > div {
|
@@ -338,7 +338,7 @@
|
|
338
338
|
<div class="list-item-title">Function</div>
|
339
339
|
<div class="list-item-value">{{ item.label }}</div>
|
340
340
|
<el-popconfirm
|
341
|
-
:title="
|
341
|
+
:title="`是否确定删除 ${item.label}`"
|
342
342
|
confirm-button-text="删除"
|
343
343
|
confirm-button-type="danger"
|
344
344
|
@confirm="handleEventDialogDelete(item, index)"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<template>
|
2
|
-
<div class="
|
2
|
+
<div class="widgetForm" ref="formContainer">
|
3
3
|
<th-empty
|
4
4
|
v-if="data.list.length == 0"
|
5
5
|
class="form-empty"
|
@@ -21,9 +21,9 @@
|
|
21
21
|
v-model="data.list"
|
22
22
|
v-bind="{
|
23
23
|
group: 'people',
|
24
|
-
ghostClass: 'ghost',
|
25
24
|
animation: 200,
|
26
|
-
handle: '.drag-widget'
|
25
|
+
handle: '.drag-widget',
|
26
|
+
ghostClass: 'draggable-ghost'
|
27
27
|
}"
|
28
28
|
@add="handleWidgetAdd"
|
29
29
|
>
|
@@ -117,11 +117,11 @@ export default {
|
|
117
117
|
</script>
|
118
118
|
|
119
119
|
<style lang="scss" scoped>
|
120
|
-
.
|
120
|
+
.widgetForm {
|
121
121
|
position: relative;
|
122
122
|
width: 100%;
|
123
123
|
height: calc(100% - 45px);
|
124
|
-
overflow-y:
|
124
|
+
overflow-y: overlay;
|
125
125
|
|
126
126
|
.form-empty {
|
127
127
|
position: absolute;
|
@@ -136,5 +136,11 @@ export default {
|
|
136
136
|
font-size: 20px;
|
137
137
|
}
|
138
138
|
}
|
139
|
+
.draggable {
|
140
|
+
height: 100%;
|
141
|
+
.draggable-list {
|
142
|
+
min-height: 100%;
|
143
|
+
}
|
144
|
+
}
|
139
145
|
}
|
140
146
|
</style>
|
@@ -2,14 +2,14 @@
|
|
2
2
|
<el-form-item
|
3
3
|
class="widgetFormItem"
|
4
4
|
:class="{
|
5
|
-
|
6
|
-
isRequired: widget.options.required,
|
5
|
+
isActive: selectWidget.model == widget.model,
|
7
6
|
isLayout: layoutElements.includes(widget.type),
|
8
7
|
[`widget-form-list-${widget.type}`]: true,
|
9
8
|
[widget.model]: true
|
10
9
|
}"
|
11
10
|
:label="widget.options.hideLabel ? '' : widget.name"
|
12
11
|
:label-width="labelWidth"
|
12
|
+
:required="widget.options.required"
|
13
13
|
:ref="widget.model"
|
14
14
|
@click.native.stop="selectWidget = widget"
|
15
15
|
>
|
@@ -30,8 +30,15 @@
|
|
30
30
|
}"
|
31
31
|
>
|
32
32
|
<div class="actions">
|
33
|
-
<
|
34
|
-
|
33
|
+
<div class="clone">
|
34
|
+
<i
|
35
|
+
class="iconfont icon-icon_clone"
|
36
|
+
@click.stop="handleWidgetClone"
|
37
|
+
></i>
|
38
|
+
</div>
|
39
|
+
<div class="trash">
|
40
|
+
<i class="iconfont icon-trash" @click.stop="handleWidgetDelete"></i>
|
41
|
+
</div>
|
35
42
|
</div>
|
36
43
|
|
37
44
|
<div class="drag">
|
File without changes
|
@@ -480,8 +480,8 @@ export default {
|
|
480
480
|
});
|
481
481
|
} else if (item.type === "table" || item.type === "tableH5") {
|
482
482
|
initList(item.options.columns);
|
483
|
-
} else if (item.options.remote || item.options.
|
484
|
-
fieldsApi[item.model] = item.options.
|
483
|
+
} else if (item.options.remote?.open || item.options.remote?.api) {
|
484
|
+
fieldsApi[item.model] = item.options.remote.api;
|
485
485
|
}
|
486
486
|
}
|
487
487
|
};
|