tianheng-ui 0.1.27 → 0.1.29
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 +13 -13
- package/package.json +1 -1
- package/packages/FormMaking/FormConfig.vue +4 -18
- package/packages/FormMaking/GenerateForm.vue +2 -2
- package/packages/FormMaking/WidgetConfig.vue +2 -2
- package/packages/FormMaking/custom/config.js +28 -25
- package/packages/FormMaking/index.vue +46 -32
- package/packages/TableMaking/WidgetTools.vue +12 -3
- package/packages/TableMaking/custom/config.js +29 -25
- package/packages/TableMaking/custom/items/search/index.vue +79 -121
- package/packages/TableMaking/custom/items/table/index.vue +41 -0
- package/packages/TableMaking/custom/items/tools/index.vue +21 -15
- package/packages/TableMaking/generateTable.vue +83 -103
- package/packages/TableMaking/index.vue +4 -9
- package/packages/TableMaking/widgetConfig.vue +5 -1
- package/packages/TableMaking/widgetTable.vue +3 -5
@@ -0,0 +1,41 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="generateTable-table">
|
3
|
+
<el-table
|
4
|
+
:style="config.style.table.customStyle"
|
5
|
+
:data="data"
|
6
|
+
:border="config.style.table.border"
|
7
|
+
:height="config.style.table.height"
|
8
|
+
:max-height="config.style.table.maxHeight"
|
9
|
+
>
|
10
|
+
<el-table-column
|
11
|
+
v-for="item in config.options"
|
12
|
+
:key="item.prop"
|
13
|
+
:prop="item.prop"
|
14
|
+
:label="item.label"
|
15
|
+
:width="item.width || 180"
|
16
|
+
>
|
17
|
+
</el-table-column>
|
18
|
+
</el-table>
|
19
|
+
</div>
|
20
|
+
</template>
|
21
|
+
|
22
|
+
<script>
|
23
|
+
export default {
|
24
|
+
props: {
|
25
|
+
data: Array,
|
26
|
+
config: Object
|
27
|
+
},
|
28
|
+
data() {
|
29
|
+
return {};
|
30
|
+
},
|
31
|
+
created() {},
|
32
|
+
mounted() {},
|
33
|
+
methods: {}
|
34
|
+
};
|
35
|
+
</script>
|
36
|
+
|
37
|
+
<style lang="scss" scoped>
|
38
|
+
.generateTable-table {
|
39
|
+
width: 100%;
|
40
|
+
}
|
41
|
+
</style>
|
@@ -1,16 +1,22 @@
|
|
1
1
|
<template>
|
2
|
-
<div class="
|
3
|
-
<el-
|
4
|
-
v-for="
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
<div class="generateTable-tools">
|
3
|
+
<el-form :inline="true">
|
4
|
+
<el-form-item v-for="item in options" :key="item.type">
|
5
|
+
<el-button
|
6
|
+
:style="item.style.customStyle"
|
7
|
+
:type="item.style.type"
|
8
|
+
:icon="item.style.icon"
|
9
|
+
:plain="item.style.plain"
|
10
|
+
:round="item.style.round"
|
11
|
+
:circle="item.style.circle"
|
12
|
+
:size="item.style.size"
|
13
|
+
:disabled="item.style.disabled || disabled[item.act]"
|
14
|
+
:loading="item.style.loading"
|
15
|
+
@click="handleClick(item)"
|
16
|
+
>{{ item.name }}</el-button
|
17
|
+
>
|
18
|
+
</el-form-item>
|
19
|
+
</el-form>
|
14
20
|
</div>
|
15
21
|
</template>
|
16
22
|
|
@@ -36,14 +42,14 @@ export default {
|
|
36
42
|
},
|
37
43
|
methods: {
|
38
44
|
handleClick(item) {
|
39
|
-
this.$emit("
|
45
|
+
this.$emit("click", item);
|
40
46
|
}
|
41
47
|
}
|
42
48
|
};
|
43
49
|
</script>
|
44
50
|
|
45
51
|
<style lang="less" scoped>
|
46
|
-
.
|
47
|
-
|
52
|
+
.generateTable-tools {
|
53
|
+
width: 100%;
|
48
54
|
}
|
49
55
|
</style>
|
@@ -5,8 +5,8 @@
|
|
5
5
|
v-if="searchConfig.show"
|
6
6
|
:data="searchData"
|
7
7
|
:options="searchConfig.options"
|
8
|
-
@
|
9
|
-
@
|
8
|
+
@search="requestListData"
|
9
|
+
@reset="requestListData"
|
10
10
|
/>
|
11
11
|
|
12
12
|
<!-- 菜单栏 -->
|
@@ -17,11 +17,13 @@
|
|
17
17
|
batchDelete: tableSelectionData.length === 0,
|
18
18
|
export: tableSelectionData.length === 0
|
19
19
|
}"
|
20
|
-
@
|
20
|
+
@click="handleToolsClick"
|
21
21
|
/>
|
22
22
|
|
23
|
+
<STable v-if="tableConfig" :data="tableData" :config="tableConfig"></STable>
|
24
|
+
|
23
25
|
<!-- 表格 -->
|
24
|
-
<th-table
|
26
|
+
<!-- <th-table
|
25
27
|
v-if="tableConfig.options.length"
|
26
28
|
ref="tableRef"
|
27
29
|
:data="tableData"
|
@@ -53,7 +55,7 @@
|
|
53
55
|
>
|
54
56
|
</th-table-action>
|
55
57
|
</template>
|
56
|
-
</th-table>
|
58
|
+
</th-table> -->
|
57
59
|
|
58
60
|
<!-- 表单 -->
|
59
61
|
<th-dialog
|
@@ -88,12 +90,13 @@
|
|
88
90
|
<script>
|
89
91
|
import Search from "./custom/items/search";
|
90
92
|
import Tools from "./custom/items/tools";
|
91
|
-
import
|
93
|
+
import STable from "./custom/items/table";
|
92
94
|
import * as Axios from "lib/theme-chalk/js/axios";
|
93
95
|
export default {
|
94
96
|
name: "thTableGenerate",
|
95
|
-
components: { Search, Tools },
|
97
|
+
components: { Search, Tools, STable },
|
96
98
|
props: {
|
99
|
+
config: Object,
|
97
100
|
oauthConfig: {
|
98
101
|
type: Object,
|
99
102
|
default: () => {
|
@@ -135,8 +138,17 @@ export default {
|
|
135
138
|
searchConfig: { show: false, options: [] },
|
136
139
|
searchData: {},
|
137
140
|
toolsConfig: { show: false, options: [] },
|
138
|
-
tableConfig:
|
139
|
-
tableData: [
|
141
|
+
tableConfig: null,
|
142
|
+
tableData: [
|
143
|
+
{ id: 1 },
|
144
|
+
{ id: 2 },
|
145
|
+
{ id: 3 },
|
146
|
+
{ id: 4 },
|
147
|
+
{ id: 5 },
|
148
|
+
{ id: 6 },
|
149
|
+
{ id: 7 },
|
150
|
+
{ id: 8 }
|
151
|
+
],
|
140
152
|
tableSelectionData: [],
|
141
153
|
dialog: { show: false, data: {}, action: {} },
|
142
154
|
formConfig: null,
|
@@ -144,17 +156,25 @@ export default {
|
|
144
156
|
errorMessage: ""
|
145
157
|
};
|
146
158
|
},
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
159
|
+
watch: {
|
160
|
+
config(val) {
|
161
|
+
this.tableJson = val;
|
162
|
+
this.initConfig();
|
163
|
+
},
|
164
|
+
oauthConfig(val) {
|
165
|
+
this.initAxios();
|
166
|
+
}
|
167
|
+
},
|
168
|
+
created() {},
|
169
|
+
mounted() {
|
170
|
+
this.tableJson = this.config;
|
171
|
+
this.initAxios();
|
151
172
|
this.initConfig();
|
152
173
|
},
|
153
|
-
mounted() {},
|
154
174
|
methods: {
|
155
|
-
//
|
156
|
-
|
157
|
-
this.
|
175
|
+
// 初始组件网络
|
176
|
+
initAxios() {
|
177
|
+
this.axios = Axios.init(this.oauthConfig);
|
158
178
|
|
159
179
|
if (this.oauthConfig.token) {
|
160
180
|
const oauthInfo = {
|
@@ -162,11 +182,6 @@ export default {
|
|
162
182
|
baseUrl: this.oauthConfig.baseUrl
|
163
183
|
};
|
164
184
|
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
165
|
-
}
|
166
|
-
|
167
|
-
const info = sessionStorage.getItem("th_oauth_info");
|
168
|
-
if (info) {
|
169
|
-
this.requestConfigData();
|
170
185
|
} else if (this.oauthConfig.oauth) {
|
171
186
|
// 模拟授权认证流程
|
172
187
|
this.axios({
|
@@ -181,93 +196,58 @@ export default {
|
|
181
196
|
};
|
182
197
|
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
183
198
|
// this.axios.defaults.baseURL = this.oauthConfig.baseUrl;
|
184
|
-
this.requestConfigData();
|
185
199
|
});
|
186
|
-
} else {
|
187
|
-
this.requestConfigData();
|
188
200
|
}
|
189
201
|
},
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
// 获取配置信息
|
195
|
-
requestConfigData() {
|
196
|
-
this.axios({
|
197
|
-
url: this.network.page.url,
|
198
|
-
method: this.network.page.method,
|
199
|
-
headers: this.network.page.headers,
|
200
|
-
data: { ...this.network.page.params, moduleId: this.id }
|
201
|
-
})
|
202
|
-
.then(res => {
|
203
|
-
const resultData = res.data;
|
204
|
-
if (!resultData) {
|
205
|
-
this.tableJson = null;
|
206
|
-
return;
|
207
|
-
}
|
208
|
-
this.tableJson = JSON.parse(resultData.pageConfig);
|
209
|
-
// 网络请求
|
210
|
-
this.networkConfig = this.tableJson.network;
|
202
|
+
// 处理配置信息
|
203
|
+
initConfig() {
|
204
|
+
// 网络请求
|
205
|
+
this.networkConfig = this.tableJson.network;
|
211
206
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
});
|
218
|
-
}
|
207
|
+
// 搜索栏
|
208
|
+
this.searchConfig = this.tableJson.search;
|
209
|
+
this.searchConfig.options.map(item => {
|
210
|
+
this.$set(this.searchData, item.prop, item.defaultValue || "");
|
211
|
+
});
|
219
212
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
fixed: "right",
|
236
|
-
actions: []
|
237
|
-
};
|
213
|
+
// table
|
214
|
+
this.tableConfig = this.tableJson.table;
|
215
|
+
if (this.tableConfig.sequence) {
|
216
|
+
this.tableConfig.options.unshift({
|
217
|
+
type: "index",
|
218
|
+
label: "序号"
|
219
|
+
});
|
220
|
+
}
|
221
|
+
const action = {
|
222
|
+
label: "操作",
|
223
|
+
hide: true,
|
224
|
+
slot: "action",
|
225
|
+
fixed: "right",
|
226
|
+
actions: []
|
227
|
+
};
|
238
228
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
}
|
260
|
-
action.width = action.actions.length * 60 + 20;
|
261
|
-
this.tableJson.table.options.push(action);
|
229
|
+
// tools
|
230
|
+
this.toolsConfig = { show: false, options: [] };
|
231
|
+
// 按position处理按钮,1:公共区,2:行内区
|
232
|
+
Object.values(this.tableJson.tools).map(item => {
|
233
|
+
if (!item.show) return;
|
234
|
+
if (item.type === "batchDelete") {
|
235
|
+
this.tableConfig.options.unshift({
|
236
|
+
type: "selection"
|
237
|
+
});
|
238
|
+
}
|
239
|
+
if (item.position === 1 || item.position === "header") {
|
240
|
+
this.toolsConfig.show = true;
|
241
|
+
this.toolsConfig.options.push(item);
|
242
|
+
} else if (item.position === 2 || item.position === "row") {
|
243
|
+
action.hide = false;
|
244
|
+
action.actions.push(item);
|
245
|
+
}
|
246
|
+
});
|
247
|
+
action.width = action.actions.length * 60 + 20;
|
248
|
+
if (!action.hide) this.tableConfig.options.push(action);
|
262
249
|
|
263
|
-
|
264
|
-
this.requestListData();
|
265
|
-
})
|
266
|
-
.catch(err => {
|
267
|
-
this.errorMessage = err.message;
|
268
|
-
this.tableJson = null;
|
269
|
-
this.$emit("error");
|
270
|
-
});
|
250
|
+
// this.requestListData();
|
271
251
|
},
|
272
252
|
requestListData() {
|
273
253
|
if (!this.networkConfig.mounted) return;
|
@@ -418,7 +398,7 @@ export default {
|
|
418
398
|
},
|
419
399
|
handleToolsClick(action) {
|
420
400
|
console.log("handleToolsClick =>", action);
|
421
|
-
switch (action.
|
401
|
+
switch (action.type) {
|
422
402
|
case "add":
|
423
403
|
this.dialog = { show: true, data: {}, action: action };
|
424
404
|
this.requestFormConfigData(action);
|
@@ -30,18 +30,13 @@
|
|
30
30
|
import WidgetTools from "./WidgetTools.vue";
|
31
31
|
import WidgetTable from "./widgetTable.vue";
|
32
32
|
import WidgetConfig from "./widgetConfig.vue";
|
33
|
-
import { deepClone
|
33
|
+
import { deepClone } from "./util/index";
|
34
34
|
import { baseConfig } from "./custom/config";
|
35
35
|
export default {
|
36
36
|
name: "ThTableMaking",
|
37
37
|
components: { WidgetTools, WidgetTable, WidgetConfig },
|
38
38
|
props: {
|
39
|
-
config:
|
40
|
-
type: Object,
|
41
|
-
default: () => {
|
42
|
-
return {};
|
43
|
-
}
|
44
|
-
},
|
39
|
+
config: Object,
|
45
40
|
|
46
41
|
/**
|
47
42
|
* 表单配置列表。
|
@@ -88,7 +83,7 @@ export default {
|
|
88
83
|
data() {
|
89
84
|
this.baseConfig = deepClone(baseConfig);
|
90
85
|
return {
|
91
|
-
tableConfig: this.
|
86
|
+
tableConfig: this.baseConfig,
|
92
87
|
client: "monitor"
|
93
88
|
};
|
94
89
|
},
|
@@ -108,7 +103,7 @@ export default {
|
|
108
103
|
}
|
109
104
|
},
|
110
105
|
mounted() {
|
111
|
-
this.tableConfig = Object.assign(this.baseConfig, this.
|
106
|
+
this.tableConfig = Object.assign(this.baseConfig, this.config);
|
112
107
|
},
|
113
108
|
methods: {
|
114
109
|
handleNetwork() {
|
@@ -490,10 +490,14 @@ export default {
|
|
490
490
|
},
|
491
491
|
watch: {
|
492
492
|
config(val) {
|
493
|
+
this.handleFieldsApiChange(val.table.mounted.api)
|
493
494
|
this.handleFields();
|
494
495
|
},
|
495
496
|
fields(val) {
|
496
497
|
this.handleFields();
|
498
|
+
},
|
499
|
+
apiOptions(){
|
500
|
+
this.handleFieldsApiChange(this.config.table.mounted.api)
|
497
501
|
}
|
498
502
|
},
|
499
503
|
computed: {
|
@@ -602,7 +606,7 @@ export default {
|
|
602
606
|
label: item.note || item.name,
|
603
607
|
alias: item.name,
|
604
608
|
prop: item.name,
|
605
|
-
|
609
|
+
elType: "input",
|
606
610
|
align: "left"
|
607
611
|
};
|
608
612
|
});
|
@@ -31,11 +31,10 @@
|
|
31
31
|
<div class="table-item-custom drag">
|
32
32
|
<i class="iconfont icon-drag drag-widget"></i>
|
33
33
|
</div>
|
34
|
-
<
|
35
|
-
<!-- <div>{{ item.prop }}</div> -->
|
34
|
+
<el-input v-model="item.label" size="mini"></el-input>
|
36
35
|
<div>
|
37
36
|
<el-select
|
38
|
-
v-model="item.
|
37
|
+
v-model="item.elType"
|
39
38
|
placeholder="请选择"
|
40
39
|
size="mini"
|
41
40
|
disabled
|
@@ -103,8 +102,7 @@
|
|
103
102
|
<div class="table-item-custom drag">
|
104
103
|
<i class="iconfont icon-drag drag-widget"></i>
|
105
104
|
</div>
|
106
|
-
<
|
107
|
-
<!-- <div>{{ item.prop }}</div> -->
|
105
|
+
<el-input v-model="item.label" size="mini"></el-input>
|
108
106
|
<div>
|
109
107
|
<el-select v-model="item.align" placeholder="请选择" size="mini">
|
110
108
|
<el-option
|