tianheng-ui 0.1.48 → 0.1.49
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/tianheng-ui.js +6 -6
- package/package.json +1 -1
- package/packages/FormMaking/GenerateForm.vue +43 -7
- package/packages/FormMaking/WidgetConfig.vue +23 -18
- package/packages/FormMaking/custom/configs/button.vue +3 -3
- package/packages/FormMaking/custom/configs/cascader.vue +3 -2
- package/packages/FormMaking/custom/configs/checkbox.vue +14 -12
- package/packages/FormMaking/custom/configs/radio.vue +14 -12
- package/packages/FormMaking/custom/configs/select.vue +14 -12
- package/packages/FormMaking/custom/configs/tabs.vue +14 -11
- package/packages/FormMaking/custom/configs/upload.vue +5 -2
- package/packages/FormMaking/custom/items/button.vue +23 -22
- package/packages/FormMaking/custom/mixins/index.js +2 -1
- package/packages/FormMaking/util/index.js +31 -0
- package/packages/TableMaking/widgetConfig.vue +18 -14
package/package.json
CHANGED
@@ -63,7 +63,7 @@
|
|
63
63
|
|
64
64
|
<script>
|
65
65
|
import * as Axios from "lib/theme-chalk/js/axios";
|
66
|
-
import { deepClone } from "./util/index";
|
66
|
+
import { deepClone, getProperty, setProperty } from "./util/index";
|
67
67
|
import GenetateFormItem from "./GenerateFormItem";
|
68
68
|
|
69
69
|
export default {
|
@@ -222,7 +222,7 @@ export default {
|
|
222
222
|
if (!item.options.remote) return;
|
223
223
|
if (item.type === "upload" || item.type === "button") return;
|
224
224
|
const api = this.formConfig.config.network[item.options.remoteFunc];
|
225
|
-
if (!api) return this.$message.warning("
|
225
|
+
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
226
226
|
|
227
227
|
const requestConfig = {
|
228
228
|
url: api.url,
|
@@ -231,10 +231,10 @@ export default {
|
|
231
231
|
};
|
232
232
|
const params = {};
|
233
233
|
for (let e of api.inParams) {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
234
|
+
const value =
|
235
|
+
getProperty(this.models, e.pAlias) ||
|
236
|
+
getProperty(this.query, e.pAlias);
|
237
|
+
setProperty(params, e.pAlias, value || null);
|
238
238
|
}
|
239
239
|
if (api.needPage) {
|
240
240
|
params.pageNum = 1;
|
@@ -255,7 +255,43 @@ export default {
|
|
255
255
|
});
|
256
256
|
},
|
257
257
|
handleButtonSubmit(val) {
|
258
|
-
this
|
258
|
+
const api = this.formConfig.config.network[val];
|
259
|
+
if (!api) return this.$message.warning("未知的接口,请检查配置信息");
|
260
|
+
|
261
|
+
const requestConfig = {
|
262
|
+
url: api.url,
|
263
|
+
method: api.method,
|
264
|
+
headers: api.headers
|
265
|
+
};
|
266
|
+
|
267
|
+
let params = {};
|
268
|
+
const inParams = api.inParams;
|
269
|
+
const initParams = list => {
|
270
|
+
list.map(item => {
|
271
|
+
if (item.children) {
|
272
|
+
initParams(item.children);
|
273
|
+
} else {
|
274
|
+
const value = getProperty(this.models, item.pAlias);
|
275
|
+
setProperty(params, item.pAlias, value);
|
276
|
+
}
|
277
|
+
});
|
278
|
+
};
|
279
|
+
initParams(inParams);
|
280
|
+
|
281
|
+
if (api.needPage) {
|
282
|
+
params.pageNum = 1;
|
283
|
+
params.pageSize = 20;
|
284
|
+
}
|
285
|
+
if (["get", "delete"].includes(api.method.toLowerCase()))
|
286
|
+
requestConfig.params = params;
|
287
|
+
else requestConfig.data = params;
|
288
|
+
|
289
|
+
this.$refs.generateForm.validate(valid => {
|
290
|
+
if (!valid) return;
|
291
|
+
this.axios(requestConfig).then(res => {
|
292
|
+
this.$emit("button-submit", requestConfig);
|
293
|
+
});
|
294
|
+
});
|
259
295
|
},
|
260
296
|
getData() {
|
261
297
|
return new Promise((resolve, reject) => {
|
@@ -196,10 +196,10 @@
|
|
196
196
|
<el-select
|
197
197
|
v-model="config.fields.api"
|
198
198
|
style="width:100%"
|
199
|
-
clearable
|
200
199
|
placeholder="请选择"
|
201
|
-
filterable
|
202
200
|
no-data-text="暂无接口,请前往【数据源模块】创建"
|
201
|
+
clearable
|
202
|
+
filterable
|
203
203
|
>
|
204
204
|
<el-option
|
205
205
|
v-for="item in apiOptions"
|
@@ -588,10 +588,12 @@ export default {
|
|
588
588
|
return;
|
589
589
|
}
|
590
590
|
|
591
|
-
const initParams = (paramsList, pAlias) => {
|
591
|
+
const initParams = (paramsList, pAlias, bool) => {
|
592
592
|
paramsList.forEach(item => {
|
593
|
-
|
594
|
-
|
593
|
+
if (bool) {
|
594
|
+
item.elType = "input";
|
595
|
+
item.align = "left";
|
596
|
+
}
|
595
597
|
item.pAlias = pAlias ? `${pAlias}.${item.alias}` : item.alias;
|
596
598
|
if (item.children && item.children.length) {
|
597
599
|
initParams(item.children, item.pAlias);
|
@@ -601,25 +603,28 @@ export default {
|
|
601
603
|
|
602
604
|
if (this.config.fields.remote) {
|
603
605
|
const callback = res => {
|
604
|
-
api.inParams = res.inParams;
|
605
|
-
api.outParams = res.outParams;
|
606
|
+
api.inParams = deepClone(res.inParams);
|
607
|
+
api.outParams = deepClone(res.outParams);
|
608
|
+
initParams(api.inParams, null, false);
|
609
|
+
initParams(api.outParams, null, false);
|
610
|
+
|
606
611
|
if (isFields) {
|
607
612
|
this.fieldsData.inParams = deepClone(res.inParams || []);
|
608
|
-
initParams(this.fieldsData.inParams);
|
613
|
+
initParams(this.fieldsData.inParams, null, true);
|
609
614
|
this.fieldsData.outParams = deepClone(res.outParams || []);
|
610
|
-
initParams(this.fieldsData.outParams);
|
615
|
+
initParams(this.fieldsData.outParams, null, true);
|
611
616
|
}
|
612
617
|
};
|
613
618
|
this.$emit("remote-params", apiId, callback);
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
619
|
+
} else {
|
620
|
+
initParams(api.inParams, null, false);
|
621
|
+
initParams(api.outParams, null, false);
|
622
|
+
if (isFields) {
|
623
|
+
this.fieldsData.inParams = deepClone(api.inParams || []);
|
624
|
+
initParams(this.fieldsData.inParams, null, true);
|
625
|
+
this.fieldsData.outParams = deepClone(api.outParams || []);
|
626
|
+
initParams(this.fieldsData.outParams, null, true);
|
627
|
+
}
|
623
628
|
}
|
624
629
|
},
|
625
630
|
formValidate() {
|
@@ -90,10 +90,10 @@
|
|
90
90
|
<el-select
|
91
91
|
style="width:100%"
|
92
92
|
v-model="widget.options.remoteFunc"
|
93
|
-
|
93
|
+
placeholder="请选择"
|
94
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
94
95
|
clearable
|
95
|
-
|
96
|
-
no-data-text="暂无接口,请前往【接口模块】创建"
|
96
|
+
filterable
|
97
97
|
>
|
98
98
|
<el-option
|
99
99
|
v-for="item in apiOptions"
|
@@ -60,19 +60,21 @@
|
|
60
60
|
<el-form-item label-width="0">
|
61
61
|
<template v-if="widget.options.remote">
|
62
62
|
<el-select
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
style="width:100%"
|
64
|
+
v-model="widget.options.remoteFunc"
|
65
|
+
placeholder="请选择"
|
66
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
67
|
+
clearable
|
68
|
+
filterable
|
69
|
+
>
|
70
|
+
<el-option
|
71
|
+
v-for="item in apiOptions"
|
72
|
+
:key="item.id"
|
73
|
+
:label="item.name"
|
74
|
+
:value="item.id"
|
67
75
|
>
|
68
|
-
|
69
|
-
|
70
|
-
:key="item.id"
|
71
|
-
:label="item.name"
|
72
|
-
:value="item.id"
|
73
|
-
>
|
74
|
-
</el-option>
|
75
|
-
</el-select>
|
76
|
+
</el-option>
|
77
|
+
</el-select>
|
76
78
|
|
77
79
|
<el-input v-model="widget.options.props.value">
|
78
80
|
<div slot="prepend" style="width:50px;">值</div>
|
@@ -48,19 +48,21 @@
|
|
48
48
|
<el-form-item label-width="0">
|
49
49
|
<template v-if="widget.options.remote">
|
50
50
|
<el-select
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
style="width:100%"
|
52
|
+
v-model="widget.options.remoteFunc"
|
53
|
+
placeholder="请选择"
|
54
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
55
|
+
clearable
|
56
|
+
filterable
|
57
|
+
>
|
58
|
+
<el-option
|
59
|
+
v-for="item in apiOptions"
|
60
|
+
:key="item.id"
|
61
|
+
:label="item.name"
|
62
|
+
:value="item.id"
|
55
63
|
>
|
56
|
-
|
57
|
-
|
58
|
-
:key="item.id"
|
59
|
-
:label="item.name"
|
60
|
-
:value="item.id"
|
61
|
-
>
|
62
|
-
</el-option>
|
63
|
-
</el-select>
|
64
|
+
</el-option>
|
65
|
+
</el-select>
|
64
66
|
|
65
67
|
<el-input v-model="widget.options.props.value">
|
66
68
|
<div slot="prepend" style="width:50px;">值</div>
|
@@ -45,19 +45,21 @@
|
|
45
45
|
<el-form-item label-width="0">
|
46
46
|
<template v-if="widget.options.remote">
|
47
47
|
<el-select
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
style="width:100%"
|
49
|
+
v-model="widget.options.remoteFunc"
|
50
|
+
placeholder="请选择"
|
51
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
52
|
+
clearable
|
53
|
+
filterable
|
54
|
+
>
|
55
|
+
<el-option
|
56
|
+
v-for="item in apiOptions"
|
57
|
+
:key="item.id"
|
58
|
+
:label="item.name"
|
59
|
+
:value="item.id"
|
52
60
|
>
|
53
|
-
|
54
|
-
|
55
|
-
:key="item.id"
|
56
|
-
:label="item.name"
|
57
|
-
:value="item.id"
|
58
|
-
>
|
59
|
-
</el-option>
|
60
|
-
</el-select>
|
61
|
+
</el-option>
|
62
|
+
</el-select>
|
61
63
|
|
62
64
|
<el-input v-model="widget.options.props.value">
|
63
65
|
<div slot="prepend" style="width:50px;">值</div>
|
@@ -57,18 +57,21 @@
|
|
57
57
|
<el-form-item label-width="0">
|
58
58
|
<div v-if="widget.options.remote">
|
59
59
|
<el-select
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
style="width:100%"
|
61
|
+
v-model="widget.options.remoteFunc"
|
62
|
+
placeholder="请选择"
|
63
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
64
|
+
clearable
|
65
|
+
filterable
|
66
|
+
>
|
67
|
+
<el-option
|
68
|
+
v-for="item in apiOptions"
|
69
|
+
:key="item.id"
|
70
|
+
:label="item.name"
|
71
|
+
:value="item.id"
|
63
72
|
>
|
64
|
-
|
65
|
-
|
66
|
-
:key="item.id"
|
67
|
-
:label="item.name"
|
68
|
-
:value="item.id"
|
69
|
-
>
|
70
|
-
</el-option>
|
71
|
-
</el-select>
|
73
|
+
</el-option>
|
74
|
+
</el-select>
|
72
75
|
|
73
76
|
<!-- <el-input size="mini" style="" v-model="widget.options.props.value">
|
74
77
|
<template slot="prepend">
|
@@ -75,9 +75,12 @@
|
|
75
75
|
</el-radio-group>
|
76
76
|
<el-select
|
77
77
|
v-if="widget.options.remote"
|
78
|
-
v-model="widget.options.remoteFunc"
|
79
78
|
style="width:100%"
|
80
|
-
|
79
|
+
v-model="widget.options.remoteFunc"
|
80
|
+
placeholder="请选择"
|
81
|
+
no-data-text="暂无数据,请查阅相关文档说明"
|
82
|
+
clearable
|
83
|
+
filterable
|
81
84
|
>
|
82
85
|
<el-option
|
83
86
|
v-for="item in apiOptions"
|
@@ -33,28 +33,29 @@ export default {
|
|
33
33
|
this.axios = Axios.init(JSON.parse(oauthConfig));
|
34
34
|
},
|
35
35
|
methods: {
|
36
|
-
hendleRemoteData() {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
36
|
+
// hendleRemoteData() {
|
37
|
+
// const remoteFunc = this.config.network[this.widget.options.remoteFunc];
|
38
|
+
// console.log(remoteFunc);
|
39
|
+
// const requestConfig = {
|
40
|
+
// url: remoteFunc.url,
|
41
|
+
// method: remoteFunc.method,
|
42
|
+
// headers: remoteFunc.headers
|
43
|
+
// };
|
44
|
+
// let params = { ...remoteFunc.params };
|
45
|
+
// if (remoteFunc.needPage) {
|
46
|
+
// params.pageNum = 1;
|
47
|
+
// params.pageSize = 20;
|
48
|
+
// }
|
49
|
+
// if (remoteFunc.method.toLowerCase() === "get") {
|
50
|
+
// requestConfig.params = params;
|
51
|
+
// } else {
|
52
|
+
// params = Object.assign(params, this.models);
|
53
|
+
// requestConfig.data = params;
|
54
|
+
// }
|
55
|
+
// this.axios(requestConfig).then(res => {
|
56
|
+
// this.$emit("button-submit", requestConfig);
|
57
|
+
// });
|
58
|
+
// }
|
58
59
|
}
|
59
60
|
};
|
60
61
|
</script>
|
@@ -65,3 +65,34 @@ export const deepClone = (obj, clone) => {
|
|
65
65
|
}
|
66
66
|
return clone;
|
67
67
|
};
|
68
|
+
|
69
|
+
// 链式读取对象属性
|
70
|
+
export const getProperty = (obj = {}, str = "") => {
|
71
|
+
let dic = deepClone(obj);
|
72
|
+
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
73
|
+
const keys = props.split(".");
|
74
|
+
for (const key of keys) {
|
75
|
+
dic = dic[key] || "";
|
76
|
+
}
|
77
|
+
return dic;
|
78
|
+
};
|
79
|
+
|
80
|
+
// 链式设置对象属性
|
81
|
+
export const setProperty = (obj = {}, str = "", value = "", isClone) => {
|
82
|
+
let dic = isClone ? deepClone(obj) : obj;
|
83
|
+
let propValue = "";
|
84
|
+
const props = str.replace(/\[(\w+)\]/g, ".$1"); // 处理数组下标
|
85
|
+
const keys = props.split(".");
|
86
|
+
for (let i = 0; i < keys.length; i++) {
|
87
|
+
const key = keys[i];
|
88
|
+
if (keys.length === 1) {
|
89
|
+
dic[key] = value;
|
90
|
+
} else if (i === keys.length - 1) {
|
91
|
+
propValue[key] = value;
|
92
|
+
} else {
|
93
|
+
if (!dic[key]) dic[key] = {};
|
94
|
+
propValue = dic[key];
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return dic;
|
98
|
+
};
|
@@ -802,10 +802,12 @@ export default {
|
|
802
802
|
return;
|
803
803
|
}
|
804
804
|
|
805
|
-
const initParams = (paramsList, pAlias) => {
|
805
|
+
const initParams = (paramsList, pAlias, bool) => {
|
806
806
|
paramsList.forEach(item => {
|
807
|
-
|
808
|
-
|
807
|
+
if (bool) {
|
808
|
+
item.elType = "input";
|
809
|
+
item.align = "left";
|
810
|
+
}
|
809
811
|
item.pAlias = pAlias ? `${pAlias}.${item.alias}` : item.alias;
|
810
812
|
if (item.children && item.children.length) {
|
811
813
|
initParams(item.children, item.pAlias);
|
@@ -817,23 +819,25 @@ export default {
|
|
817
819
|
const callback = res => {
|
818
820
|
api.inParams = res.inParams;
|
819
821
|
api.outParams = res.outParams;
|
822
|
+
initParams(api.inParams, null, false);
|
823
|
+
initParams(api.outParams, null, false);
|
820
824
|
if (isFields) {
|
821
825
|
this.fieldsData.inParams = deepClone(res.inParams || []);
|
822
|
-
initParams(this.fieldsData.inParams);
|
826
|
+
initParams(this.fieldsData.inParams, null, true);
|
823
827
|
this.fieldsData.outParams = deepClone(res.outParams || []);
|
824
|
-
initParams(this.fieldsData.outParams);
|
828
|
+
initParams(this.fieldsData.outParams, null, true);
|
825
829
|
}
|
826
830
|
};
|
827
831
|
this.$emit("remote-params", apiId, callback);
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
832
|
+
} else {
|
833
|
+
initParams(api.inParams, null, false);
|
834
|
+
initParams(api.outParams, null, false);
|
835
|
+
if (isFields) {
|
836
|
+
this.fieldsData.inParams = deepClone(api.inParams || []);
|
837
|
+
initParams(this.fieldsData.inParams, null, true);
|
838
|
+
this.fieldsData.outParams = deepClone(api.outParams || []);
|
839
|
+
initParams(this.fieldsData.outParams, null, true);
|
840
|
+
}
|
837
841
|
}
|
838
842
|
},
|
839
843
|
handleTreeCheckChange(action) {
|