tianheng-ui 0.1.63 → 0.1.65
Sign up to get free protection for your applications and to get access to all the features.
- 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 +67 -71
- 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
|
|
@@ -70,6 +44,8 @@ export default {
|
|
70
44
|
name: "thFormGenerate",
|
71
45
|
components: { GenetateFormItem },
|
72
46
|
props: {
|
47
|
+
formId: String,
|
48
|
+
query: Object,
|
73
49
|
oauthConfig: {
|
74
50
|
type: Object,
|
75
51
|
default: () => {
|
@@ -99,7 +75,6 @@ export default {
|
|
99
75
|
return {
|
100
76
|
formConfig: this.config,
|
101
77
|
models: this.value,
|
102
|
-
query: {},
|
103
78
|
componentsData: [],
|
104
79
|
axios: null,
|
105
80
|
showForm: false
|
@@ -117,15 +92,16 @@ export default {
|
|
117
92
|
},
|
118
93
|
value(val) {
|
119
94
|
if (val) this.models = val;
|
95
|
+
console.log("watch models =>", this.models);
|
120
96
|
}
|
121
97
|
},
|
122
98
|
created() {
|
123
|
-
this.query = this.$route.query || {};
|
124
99
|
localStorage.setItem("_TH_OauthConfig", JSON.stringify(this.oauthConfig));
|
125
100
|
this.axios = Axios.init(this.oauthConfig);
|
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 = {
|
@@ -218,8 +200,8 @@ export default {
|
|
218
200
|
const params = {};
|
219
201
|
for (let e of api.inParams) {
|
220
202
|
const value =
|
221
|
-
e.defaultValue || getProperty(this.query, e.
|
222
|
-
setProperty(params, e.
|
203
|
+
e.defaultValue || getProperty(this.query, e.pAlias) || null;
|
204
|
+
setProperty(params, e.pAlias, value);
|
223
205
|
}
|
224
206
|
if (api.needPage) {
|
225
207
|
params.pageNum = params.pageNum || 1;
|
@@ -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,12 +278,20 @@ export default {
|
|
286
278
|
});
|
287
279
|
},
|
288
280
|
handleButtonSubmit(element) {
|
289
|
-
|
290
|
-
|
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
|
+
|
291
291
|
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
292
292
|
|
293
293
|
let params = {};
|
294
|
-
const inParams = api.inParams;
|
294
|
+
const inParams = api.inParams || [];
|
295
295
|
const initParams = list => {
|
296
296
|
list.map(item => {
|
297
297
|
if (item.children) {
|
@@ -311,7 +311,10 @@ export default {
|
|
311
311
|
const requestConfig = {
|
312
312
|
url: api.url,
|
313
313
|
method: api.method,
|
314
|
-
headers:
|
314
|
+
headers: {
|
315
|
+
...api.headers,
|
316
|
+
formId: this.formId
|
317
|
+
}
|
315
318
|
};
|
316
319
|
if (["get", "delete"].includes(api.method.toLowerCase()))
|
317
320
|
requestConfig.params = params;
|
@@ -330,6 +333,12 @@ export default {
|
|
330
333
|
});
|
331
334
|
});
|
332
335
|
},
|
336
|
+
handleInputChange(value, field) {
|
337
|
+
this.$emit("change", field, value, this.models);
|
338
|
+
},
|
339
|
+
reset() {
|
340
|
+
this.$refs.generateForm.resetFields();
|
341
|
+
},
|
333
342
|
getData() {
|
334
343
|
return new Promise((resolve, reject) => {
|
335
344
|
this.$refs.generateForm.validate(valid => {
|
@@ -341,12 +350,6 @@ export default {
|
|
341
350
|
});
|
342
351
|
});
|
343
352
|
},
|
344
|
-
reset() {
|
345
|
-
this.$refs.generateForm.resetFields();
|
346
|
-
},
|
347
|
-
onInputChange(value, field) {
|
348
|
-
this.$emit("change", field, value, this.models);
|
349
|
-
},
|
350
353
|
setConfig(json) {
|
351
354
|
this.formConfig = json;
|
352
355
|
this.generateModle(this.formConfig.list, this.models);
|
@@ -377,13 +380,6 @@ export default {
|
|
377
380
|
}
|
378
381
|
}
|
379
382
|
|
380
|
-
.widget-form-list-filler {
|
381
|
-
margin-bottom: 0 !important;
|
382
|
-
}
|
383
|
-
.widget-form-list-image {
|
384
|
-
margin-bottom: 0 !important;
|
385
|
-
}
|
386
|
-
|
387
383
|
.tableH5 {
|
388
384
|
// 操作按钮布局
|
389
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
|
};
|