tianheng-ui 0.0.91 → 0.0.93
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 +8 -8
- package/package.json +1 -1
- package/packages/FormMaking/GenerateForm.vue +32 -1
- package/packages/FormMaking/GenerateFormItem.vue +23 -27
- package/packages/FormMaking/custom/config.js +28 -32
- package/packages/FormMaking/custom/configs/button.vue +29 -1
- package/packages/FormMaking/custom/configs/cascader.vue +12 -19
- package/packages/FormMaking/custom/configs/checkbox.vue +18 -21
- package/packages/FormMaking/custom/configs/radio.vue +19 -23
- package/packages/FormMaking/custom/configs/select.vue +17 -25
- package/packages/FormMaking/custom/configs/upload.vue +20 -0
- package/packages/FormMaking/custom/items/upload.vue +25 -6
- package/packages/FormMaking/index.vue +33 -8
- package/packages/TableMaking/generateTable.vue +169 -84
- package/packages/TableMaking/index.vue +2 -2
- package/packages/TableMaking/util/index.js +4 -3
- package/packages/TableMaking/widgetConfig.vue +5 -6
- package/packages/TableMaking/widgetTable.vue +10 -5
@@ -264,6 +264,7 @@
|
|
264
264
|
v-if="dialog.preview.visible"
|
265
265
|
:data="widgetFormData"
|
266
266
|
:value="widgetValue"
|
267
|
+
:oauthConfig="oauthConfig"
|
267
268
|
:remote="remoteFuncs"
|
268
269
|
:slotKeys="slotKeys"
|
269
270
|
:client="client"
|
@@ -402,6 +403,12 @@ export default {
|
|
402
403
|
return {};
|
403
404
|
}
|
404
405
|
},
|
406
|
+
oauthConfig: {
|
407
|
+
type: Object,
|
408
|
+
default: () => {
|
409
|
+
return {};
|
410
|
+
}
|
411
|
+
},
|
405
412
|
tools: {
|
406
413
|
type: Array,
|
407
414
|
default: () => {
|
@@ -535,6 +542,7 @@ export default {
|
|
535
542
|
}
|
536
543
|
},
|
537
544
|
created() {
|
545
|
+
this.initConfig();
|
538
546
|
this.widgetFormData.config = Object.assign(
|
539
547
|
this.baseConfig,
|
540
548
|
this.widgetFormData.config
|
@@ -543,15 +551,32 @@ export default {
|
|
543
551
|
this.widgetFormSelect = this.widgetFormData.list[0];
|
544
552
|
}
|
545
553
|
},
|
546
|
-
mounted() {
|
547
|
-
// if (this.data && this.data.config) {
|
548
|
-
// this.widgetFormData.config = Object.assign(
|
549
|
-
// this.widgetFormData.config,
|
550
|
-
// this.data.config
|
551
|
-
// );
|
552
|
-
// }
|
553
|
-
},
|
554
|
+
mounted() {},
|
554
555
|
methods: {
|
556
|
+
// 初始化组件配置
|
557
|
+
initConfig() {
|
558
|
+
if (this.oauthConfig.token) {
|
559
|
+
const oauthInfo = {
|
560
|
+
token: this.oauthConfig.token,
|
561
|
+
baseUrl: this.oauthConfig.baseUrl
|
562
|
+
};
|
563
|
+
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
564
|
+
} else if (this.oauthConfig.oauth) {
|
565
|
+
// 模拟授权认证流程
|
566
|
+
this.axios({
|
567
|
+
url: this.oauthConfig.oauth.url,
|
568
|
+
method: this.oauthConfig.oauth.method,
|
569
|
+
data: this.oauthConfig.oauth.params,
|
570
|
+
headers: this.oauthConfig.oauth.headers
|
571
|
+
}).then(res => {
|
572
|
+
const oauthInfo = {
|
573
|
+
token: res.data,
|
574
|
+
baseUrl: this.oauthConfig.baseUrl
|
575
|
+
};
|
576
|
+
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
577
|
+
});
|
578
|
+
}
|
579
|
+
},
|
555
580
|
// 读取excel file
|
556
581
|
readExcelFile(file) {
|
557
582
|
//文件读取
|
@@ -73,29 +73,55 @@
|
|
73
73
|
</th-form-generate>
|
74
74
|
</th-dialog>
|
75
75
|
</div>
|
76
|
-
<
|
77
|
-
v-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
<div v-else>
|
77
|
+
<slot v-if="$slots.empty" name="empty"></slot>
|
78
|
+
<th-empty
|
79
|
+
v-else
|
80
|
+
:image="require('@/assets/images/notData.png')"
|
81
|
+
:description="errorMessage || empty.description"
|
82
|
+
>
|
83
|
+
<th-button type="primary" @click="initConfig">刷新</th-button>
|
84
|
+
</th-empty>
|
85
|
+
</div>
|
82
86
|
</template>
|
83
87
|
|
84
88
|
<script>
|
85
89
|
import Search from "./custom/items/search";
|
86
90
|
import Tools from "./custom/items/tools";
|
87
|
-
import { toolsItemConfig
|
91
|
+
import { toolsItemConfig } from "./util/index";
|
88
92
|
import * as Axios from "lib/theme-chalk/js/axios";
|
89
93
|
export default {
|
90
94
|
name: "thTableGenerate",
|
91
95
|
components: { Search, Tools },
|
92
96
|
props: {
|
93
|
-
|
97
|
+
oauthConfig: {
|
98
|
+
type: Object,
|
99
|
+
default: () => {
|
100
|
+
return {};
|
101
|
+
}
|
102
|
+
},
|
103
|
+
empty: {
|
94
104
|
type: Object,
|
95
105
|
default: () => {
|
96
106
|
return {
|
97
|
-
|
98
|
-
|
107
|
+
description: "暂无数据"
|
108
|
+
};
|
109
|
+
}
|
110
|
+
},
|
111
|
+
network: {
|
112
|
+
type: Object,
|
113
|
+
default: () => {
|
114
|
+
return {
|
115
|
+
page: {
|
116
|
+
url: "/viewManage/getViewManageDetailById",
|
117
|
+
method: "POST",
|
118
|
+
params: {}
|
119
|
+
},
|
120
|
+
form: {
|
121
|
+
url: "/formManage/getFormDetailById",
|
122
|
+
method: "POST",
|
123
|
+
params: {}
|
124
|
+
}
|
99
125
|
};
|
100
126
|
}
|
101
127
|
}
|
@@ -177,10 +203,12 @@ export default {
|
|
177
203
|
updateTime: null
|
178
204
|
}
|
179
205
|
]
|
180
|
-
}
|
206
|
+
},
|
207
|
+
errorMessage: ""
|
181
208
|
};
|
182
209
|
},
|
183
210
|
created() {
|
211
|
+
this.axios = Axios.init(this.oauthConfig);
|
184
212
|
const code = this.$route.path.split("/").pop();
|
185
213
|
this.id = code;
|
186
214
|
this.initConfig();
|
@@ -189,105 +217,142 @@ export default {
|
|
189
217
|
methods: {
|
190
218
|
// 初始化组件配置
|
191
219
|
initConfig() {
|
192
|
-
this.
|
220
|
+
this.initData();
|
193
221
|
const info = sessionStorage.getItem("th_oauth_info");
|
194
222
|
if (info) {
|
195
223
|
this.requestConfigData();
|
196
|
-
} else if (this.
|
224
|
+
} else if (this.oauthConfig.token) {
|
197
225
|
const oauthInfo = {
|
198
|
-
token: this.
|
199
|
-
baseUrl: this.
|
226
|
+
token: this.oauthConfig.token,
|
227
|
+
baseUrl: this.oauthConfig.baseUrl
|
200
228
|
};
|
201
229
|
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
202
230
|
this.requestConfigData();
|
203
|
-
} else if (this.
|
231
|
+
} else if (this.oauthConfig.oauth) {
|
204
232
|
// 模拟授权认证流程
|
205
233
|
this.axios({
|
206
|
-
url: this.
|
207
|
-
method: this.
|
208
|
-
data: this.
|
209
|
-
headers: this.
|
234
|
+
url: this.oauthConfig.oauth.url,
|
235
|
+
method: this.oauthConfig.oauth.method,
|
236
|
+
data: this.oauthConfig.oauth.params,
|
237
|
+
headers: this.oauthConfig.oauth.headers
|
210
238
|
}).then(res => {
|
211
|
-
const oauthInfo = { token: res.data, baseUrl: this.
|
239
|
+
const oauthInfo = { token: res.data, baseUrl: this.oauthConfig.baseUrl };
|
212
240
|
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
213
|
-
// this.axios.defaults.baseURL = this.
|
241
|
+
// this.axios.defaults.baseURL = this.oauthConfig.baseUrl;
|
214
242
|
this.requestConfigData();
|
215
243
|
});
|
244
|
+
} else {
|
245
|
+
this.requestConfigData();
|
216
246
|
}
|
217
247
|
},
|
248
|
+
initData() {
|
249
|
+
this.tableJson = {};
|
250
|
+
this.errorMessage = "";
|
251
|
+
},
|
218
252
|
// 获取配置信息
|
219
253
|
requestConfigData() {
|
220
|
-
this.
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
254
|
+
this.axios({
|
255
|
+
url: this.network.page.url,
|
256
|
+
method: this.network.page.method,
|
257
|
+
headers: this.network.page.headers,
|
258
|
+
data: { ...this.network.page.params, moduleId: this.id }
|
259
|
+
})
|
260
|
+
.then(res => {
|
261
|
+
const resultData = res.data.viewManage;
|
262
|
+
if (!resultData) {
|
263
|
+
this.tableJson = null;
|
264
|
+
return;
|
265
|
+
}
|
266
|
+
this.tableJson = JSON.parse(resultData.pageConfig);
|
267
|
+
// 网络请求
|
268
|
+
this.networkConfig = this.tableJson.network;
|
234
269
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
}
|
243
|
-
const action = { label: "操作", hide: true, slot: "action", actions: [] };
|
270
|
+
// 搜索栏
|
271
|
+
this.searchConfig = this.tableJson.search;
|
272
|
+
if (this.searchConfig.show) {
|
273
|
+
this.searchConfig.options.map(item => {
|
274
|
+
this.$set(this.searchData, item.prop, item.defaultValue || "");
|
275
|
+
});
|
276
|
+
}
|
244
277
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
if (
|
278
|
+
// table
|
279
|
+
for (let i = 0; i < this.tableJson.table.options.length; i++) {
|
280
|
+
const element = this.tableJson.table.options[i];
|
281
|
+
delete element.type;
|
282
|
+
}
|
283
|
+
if (this.tableJson.table.sequence) {
|
251
284
|
this.tableJson.table.options.unshift({
|
252
|
-
type: "
|
285
|
+
type: "index",
|
286
|
+
label: "序号"
|
253
287
|
});
|
254
288
|
}
|
255
|
-
const
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
}
|
261
|
-
|
262
|
-
|
289
|
+
const action = {
|
290
|
+
label: "操作",
|
291
|
+
hide: true,
|
292
|
+
slot: "action",
|
293
|
+
actions: []
|
294
|
+
};
|
295
|
+
|
296
|
+
// 按position处理按钮,1:公共区,2:行内区
|
297
|
+
for (const key in this.tableJson.tools) {
|
298
|
+
if (Object.hasOwnProperty.call(this.tableJson.tools, key)) {
|
299
|
+
const element = this.tableJson.tools[key];
|
300
|
+
if (!element.show) continue;
|
301
|
+
if (key === "batchDelete") {
|
302
|
+
this.tableJson.table.options.unshift({
|
303
|
+
type: "selection"
|
304
|
+
});
|
305
|
+
}
|
306
|
+
const dic = toolsItemConfig(key, element);
|
307
|
+
dic.form = element.form;
|
308
|
+
if (element.position === 1) {
|
309
|
+
this.toolsConfig.show = true;
|
310
|
+
this.toolsConfig.options.push(dic);
|
311
|
+
} else if (element.position === 2) {
|
312
|
+
action.hide = false;
|
313
|
+
action.actions.push(dic);
|
314
|
+
}
|
315
|
+
}
|
263
316
|
}
|
264
|
-
|
265
|
-
|
266
|
-
action.width = action.actions.length * 60 + 20;
|
267
|
-
this.tableJson.table.options.push(action);
|
317
|
+
action.width = action.actions.length * 60 + 20;
|
318
|
+
this.tableJson.table.options.push(action);
|
268
319
|
|
269
|
-
|
270
|
-
|
320
|
+
this.tableConfig = this.tableJson.table;
|
321
|
+
this.requestListData();
|
322
|
+
})
|
323
|
+
.catch(err => {
|
324
|
+
this.errorMessage = err.message;
|
325
|
+
this.tableJson = null;
|
326
|
+
this.$emit("error");
|
327
|
+
});
|
271
328
|
},
|
272
329
|
requestListData() {
|
273
330
|
if (!this.networkConfig.mounted) return;
|
274
331
|
this.tableConfig.loading.show = true;
|
275
332
|
const apiInfo = this.networkConfig.mounted;
|
276
333
|
const params = {
|
277
|
-
current: this.tableConfig.pageInfo.options.currentPage,
|
278
|
-
size: this.tableConfig.pageInfo.options.pageSize,
|
279
334
|
...this.searchData
|
280
335
|
};
|
336
|
+
if (this.tableConfig.pageInfo.show) {
|
337
|
+
params.current = this.tableConfig.pageInfo.options.currentPage;
|
338
|
+
params.size = this.tableConfig.pageInfo.options.pageSize;
|
339
|
+
}
|
281
340
|
this.axios({
|
282
341
|
url: apiInfo.api,
|
283
342
|
method: apiInfo.method,
|
343
|
+
headers: apiInfo.headers,
|
284
344
|
data: params
|
285
345
|
})
|
286
346
|
.then(res => {
|
287
|
-
const data = res.data.records;
|
288
|
-
this.tableData = data;
|
289
347
|
this.tableConfig.loading.show = false;
|
290
|
-
|
348
|
+
let data = [];
|
349
|
+
if (this.tableConfig.pageInfo.show) {
|
350
|
+
data = res.data.records;
|
351
|
+
this.tableConfig.pageInfo.options.total = Number(res.data.total);
|
352
|
+
} else {
|
353
|
+
data = res.data;
|
354
|
+
}
|
355
|
+
this.tableData = data;
|
291
356
|
})
|
292
357
|
.catch(err => {
|
293
358
|
this.tableConfig.loading.show = false;
|
@@ -300,7 +365,8 @@ export default {
|
|
300
365
|
this.axios({
|
301
366
|
url: apiInfo.api,
|
302
367
|
method: apiInfo.method,
|
303
|
-
|
368
|
+
headers: apiInfo.headers,
|
369
|
+
data: { ...apiInfo.params, ...data }
|
304
370
|
})
|
305
371
|
.then(res => {
|
306
372
|
this.dialog.action.loading = false;
|
@@ -317,7 +383,8 @@ export default {
|
|
317
383
|
this.axios({
|
318
384
|
url: apiInfo.api,
|
319
385
|
method: apiInfo.method,
|
320
|
-
|
386
|
+
headers: apiInfo.headers,
|
387
|
+
data: { ...apiInfo.params, ...data }
|
321
388
|
})
|
322
389
|
.then(res => {
|
323
390
|
this.dialog.action.loading = false;
|
@@ -334,7 +401,8 @@ export default {
|
|
334
401
|
this.axios({
|
335
402
|
url: apiInfo.api,
|
336
403
|
method: apiInfo.method,
|
337
|
-
|
404
|
+
headers: apiInfo.headers,
|
405
|
+
data: { ...apiInfo.params, ids: this.dialog.data.id }
|
338
406
|
})
|
339
407
|
.then(res => {
|
340
408
|
callback(true);
|
@@ -362,7 +430,8 @@ export default {
|
|
362
430
|
this.axios({
|
363
431
|
url: apiInfo.api,
|
364
432
|
method: apiInfo.method,
|
365
|
-
|
433
|
+
headers: apiInfo.headers,
|
434
|
+
data: { ...apiInfo.params, ...data }
|
366
435
|
})
|
367
436
|
.then(res => {
|
368
437
|
callback(true);
|
@@ -375,12 +444,28 @@ export default {
|
|
375
444
|
})
|
376
445
|
.catch(() => {});
|
377
446
|
},
|
378
|
-
requestFormConfigData() {
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
this.
|
383
|
-
|
447
|
+
requestFormConfigData(action) {
|
448
|
+
this.axios({
|
449
|
+
url: this.network.form.url,
|
450
|
+
method: this.network.form.method,
|
451
|
+
headers: this.network.form.headers,
|
452
|
+
// data: { id: action.form.id }
|
453
|
+
data: { ...this.network.page.params, id: this.id }
|
454
|
+
})
|
455
|
+
.then(res => {
|
456
|
+
const data = res.data;
|
457
|
+
data.forEach(item => {
|
458
|
+
if (item.type === "0" && action.act === "add") {
|
459
|
+
this.formConfig = JSON.parse(item.pageConfig);
|
460
|
+
return;
|
461
|
+
}
|
462
|
+
if (item.type === "1" && action.act === "edit") {
|
463
|
+
this.formConfig = JSON.parse(item.pageConfig);
|
464
|
+
return;
|
465
|
+
}
|
466
|
+
});
|
467
|
+
})
|
468
|
+
.catch(err => {});
|
384
469
|
},
|
385
470
|
handleSearchSubmit(val) {
|
386
471
|
this.requestListData();
|
@@ -393,7 +478,7 @@ export default {
|
|
393
478
|
switch (action.act) {
|
394
479
|
case "add":
|
395
480
|
this.dialog = { show: true, data: {}, action: action };
|
396
|
-
this.requestFormConfigData();
|
481
|
+
this.requestFormConfigData(action);
|
397
482
|
break;
|
398
483
|
case "batchDelete":
|
399
484
|
this.dialog = { show: false, data: {}, action: action };
|
@@ -419,11 +504,11 @@ export default {
|
|
419
504
|
switch (action.act) {
|
420
505
|
case "edit":
|
421
506
|
this.dialog = { show: true, data: item, action: action };
|
422
|
-
this.requestFormConfigData();
|
507
|
+
this.requestFormConfigData(action);
|
423
508
|
break;
|
424
509
|
case "detail":
|
425
510
|
this.dialog = { show: true, data: item, action: action };
|
426
|
-
this.requestFormConfigData();
|
511
|
+
this.requestFormConfigData(action);
|
427
512
|
break;
|
428
513
|
case "delete":
|
429
514
|
this.dialog = { show: false, data: item, action: action };
|
@@ -13,7 +13,7 @@
|
|
13
13
|
>
|
14
14
|
桌面端
|
15
15
|
</el-button>
|
16
|
-
<el-button
|
16
|
+
<!-- <el-button
|
17
17
|
:class="{ active: client === 'mobile' }"
|
18
18
|
type="text"
|
19
19
|
size="medium"
|
@@ -21,7 +21,7 @@
|
|
21
21
|
@click="client = 'mobile'"
|
22
22
|
>
|
23
23
|
移动端
|
24
|
-
</el-button>
|
24
|
+
</el-button> -->
|
25
25
|
</div>
|
26
26
|
<slot name="action"></slot>
|
27
27
|
</el-header>
|
@@ -59,9 +59,10 @@ const toolsConfig = {
|
|
59
59
|
};
|
60
60
|
|
61
61
|
export const toolsItemConfig = (key, data) => {
|
62
|
-
|
62
|
+
let config = toolsConfig[key] || {};
|
63
|
+
config = JSON.parse(JSON.stringify(config));
|
63
64
|
config.name = data.name;
|
64
|
-
return
|
65
|
+
return config;
|
65
66
|
};
|
66
67
|
|
67
68
|
const formConfig = {
|
@@ -224,7 +225,7 @@ const formConfig = {
|
|
224
225
|
]
|
225
226
|
}
|
226
227
|
},
|
227
|
-
|
228
|
+
"2": {}
|
228
229
|
};
|
229
230
|
|
230
231
|
export const formItemConfig = key => {
|
@@ -68,10 +68,10 @@
|
|
68
68
|
clearable
|
69
69
|
>
|
70
70
|
<el-option
|
71
|
-
v-for="item in
|
72
|
-
:key="item.
|
71
|
+
v-for="item in fields"
|
72
|
+
:key="item.prop"
|
73
73
|
:label="item.label"
|
74
|
-
:value="item.
|
74
|
+
:value="item.prop"
|
75
75
|
>
|
76
76
|
</el-option>
|
77
77
|
</el-select>
|
@@ -233,7 +233,7 @@ export default {
|
|
233
233
|
sizes: [10, 20, 30, 50, 100]
|
234
234
|
}
|
235
235
|
},
|
236
|
-
sort: { type: "1", key: "
|
236
|
+
sort: { type: "1", key: "create_time" },
|
237
237
|
loading: { show: false, text: "加载中", image: "" },
|
238
238
|
empty: { show: true, text: "暂无数据", image: "" },
|
239
239
|
sequence: true //是否显示序号
|
@@ -248,8 +248,7 @@ export default {
|
|
248
248
|
import: { show: false, name: "导入", position: 1 }
|
249
249
|
},
|
250
250
|
network: {}
|
251
|
-
}
|
252
|
-
sortFieldOptions: [{ label: "创建时间", value: "createTime" }]
|
251
|
+
}
|
253
252
|
};
|
254
253
|
},
|
255
254
|
mounted() {},
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<div class="table-header">
|
6
6
|
<div>拖动</div>
|
7
7
|
<div>列名</div>
|
8
|
-
<div>字段</div>
|
8
|
+
<!-- <div>字段</div> -->
|
9
9
|
<div>类型</div>
|
10
10
|
<div>默认值</div>
|
11
11
|
<div>数据来源</div>
|
@@ -30,9 +30,14 @@
|
|
30
30
|
<i class="iconfont icon-drag drag-widget"></i>
|
31
31
|
</div>
|
32
32
|
<div>{{ item.label }}</div>
|
33
|
-
<div>{{ item.prop }}</div>
|
33
|
+
<!-- <div>{{ item.prop }}</div> -->
|
34
34
|
<div>
|
35
|
-
<el-select
|
35
|
+
<el-select
|
36
|
+
v-model="item.type"
|
37
|
+
placeholder="请选择"
|
38
|
+
size="mini"
|
39
|
+
disabled
|
40
|
+
>
|
36
41
|
<el-option
|
37
42
|
v-for="item in componentOptions"
|
38
43
|
:key="item.value"
|
@@ -65,7 +70,7 @@
|
|
65
70
|
<div class="table-header">
|
66
71
|
<div>拖动</div>
|
67
72
|
<div>列名</div>
|
68
|
-
<div>字段</div>
|
73
|
+
<!-- <div>字段</div> -->
|
69
74
|
<div>排序</div>
|
70
75
|
<div>对齐</div>
|
71
76
|
<div>宽度</div>
|
@@ -90,7 +95,7 @@
|
|
90
95
|
<i class="iconfont icon-drag drag-widget"></i>
|
91
96
|
</div>
|
92
97
|
<div>{{ item.label }}</div>
|
93
|
-
<div>{{ item.prop }}</div>
|
98
|
+
<!-- <div>{{ item.prop }}</div> -->
|
94
99
|
<div><el-checkbox v-model="item.sortable"></el-checkbox></div>
|
95
100
|
<div>
|
96
101
|
<el-select v-model="item.align" placeholder="请选择" size="mini">
|