tianheng-ui 0.0.92 → 0.0.94
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 +33 -2
- package/packages/FormMaking/GenerateFormItem.vue +26 -28
- 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 +40 -10
- package/packages/TableMaking/generateTable.vue +173 -84
- package/packages/TableMaking/util/index.js +4 -3
- package/packages/TableMaking/widgetConfig.vue +28 -6
@@ -1,6 +1,6 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="fm-container">
|
3
|
-
<el-container v-if="widgetFormData.config" class="container-box">
|
3
|
+
<el-container v-if="Object.keys(widgetFormData.config).length" class="container-box">
|
4
4
|
<el-main>
|
5
5
|
<el-container>
|
6
6
|
<!-- 左侧字段区 -->
|
@@ -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"
|
@@ -397,6 +398,12 @@ export default {
|
|
397
398
|
},
|
398
399
|
props: {
|
399
400
|
data: {
|
401
|
+
type: Object,
|
402
|
+
default: () => {
|
403
|
+
return { config: {}, list: [] };
|
404
|
+
}
|
405
|
+
},
|
406
|
+
oauthConfig: {
|
400
407
|
type: Object,
|
401
408
|
default: () => {
|
402
409
|
return {};
|
@@ -535,23 +542,46 @@ 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
|
541
549
|
);
|
542
|
-
if (
|
550
|
+
if (
|
551
|
+
this.widgetFormData.list &&
|
552
|
+
this.widgetFormData.list.length
|
553
|
+
) {
|
543
554
|
this.widgetFormSelect = this.widgetFormData.list[0];
|
555
|
+
}else {
|
556
|
+
this.widgetFormData.list = []
|
544
557
|
}
|
545
558
|
},
|
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
|
-
},
|
559
|
+
mounted() {},
|
554
560
|
methods: {
|
561
|
+
// 初始化组件配置
|
562
|
+
initConfig() {
|
563
|
+
if (this.oauthConfig.token) {
|
564
|
+
const oauthInfo = {
|
565
|
+
token: this.oauthConfig.token,
|
566
|
+
baseUrl: this.oauthConfig.baseUrl
|
567
|
+
};
|
568
|
+
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
569
|
+
} else if (this.oauthConfig.oauth) {
|
570
|
+
// 模拟授权认证流程
|
571
|
+
this.axios({
|
572
|
+
url: this.oauthConfig.oauth.url,
|
573
|
+
method: this.oauthConfig.oauth.method,
|
574
|
+
data: this.oauthConfig.oauth.params,
|
575
|
+
headers: this.oauthConfig.oauth.headers
|
576
|
+
}).then(res => {
|
577
|
+
const oauthInfo = {
|
578
|
+
token: res.data,
|
579
|
+
baseUrl: this.oauthConfig.baseUrl
|
580
|
+
};
|
581
|
+
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
582
|
+
});
|
583
|
+
}
|
584
|
+
},
|
555
585
|
// 读取excel file
|
556
586
|
readExcelFile(file) {
|
557
587
|
//文件读取
|
@@ -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,146 @@ 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 = {
|
239
|
+
const oauthInfo = {
|
240
|
+
token: res.data,
|
241
|
+
baseUrl: this.oauthConfig.baseUrl
|
242
|
+
};
|
212
243
|
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
213
|
-
// this.axios.defaults.baseURL = this.
|
244
|
+
// this.axios.defaults.baseURL = this.oauthConfig.baseUrl;
|
214
245
|
this.requestConfigData();
|
215
246
|
});
|
247
|
+
} else {
|
248
|
+
this.requestConfigData();
|
216
249
|
}
|
217
250
|
},
|
251
|
+
initData() {
|
252
|
+
this.tableJson = {};
|
253
|
+
this.errorMessage = "";
|
254
|
+
},
|
218
255
|
// 获取配置信息
|
219
256
|
requestConfigData() {
|
220
|
-
this.
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
257
|
+
this.axios({
|
258
|
+
url: this.network.page.url,
|
259
|
+
method: this.network.page.method,
|
260
|
+
headers: this.network.page.headers,
|
261
|
+
data: { ...this.network.page.params, moduleId: this.id }
|
262
|
+
})
|
263
|
+
.then(res => {
|
264
|
+
const resultData = res.data.viewManage;
|
265
|
+
if (!resultData) {
|
266
|
+
this.tableJson = null;
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
this.tableJson = JSON.parse(resultData.pageConfig);
|
270
|
+
// 网络请求
|
271
|
+
this.networkConfig = this.tableJson.network;
|
234
272
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
}
|
243
|
-
const action = { label: "操作", hide: true, slot: "action", actions: [] };
|
273
|
+
// 搜索栏
|
274
|
+
this.searchConfig = this.tableJson.search;
|
275
|
+
if (this.searchConfig.show) {
|
276
|
+
this.searchConfig.options.map(item => {
|
277
|
+
this.$set(this.searchData, item.prop, item.defaultValue || "");
|
278
|
+
});
|
279
|
+
}
|
244
280
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
if (
|
281
|
+
// table
|
282
|
+
for (let i = 0; i < this.tableJson.table.options.length; i++) {
|
283
|
+
const element = this.tableJson.table.options[i];
|
284
|
+
delete element.type;
|
285
|
+
}
|
286
|
+
if (this.tableJson.table.sequence) {
|
251
287
|
this.tableJson.table.options.unshift({
|
252
|
-
type: "
|
288
|
+
type: "index",
|
289
|
+
label: "序号"
|
253
290
|
});
|
254
291
|
}
|
255
|
-
const
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
292
|
+
const action = {
|
293
|
+
label: "操作",
|
294
|
+
hide: true,
|
295
|
+
slot: "action",
|
296
|
+
fixed: "right",
|
297
|
+
actions: []
|
298
|
+
};
|
299
|
+
|
300
|
+
// 按position处理按钮,1:公共区,2:行内区
|
301
|
+
for (const key in this.tableJson.tools) {
|
302
|
+
if (Object.hasOwnProperty.call(this.tableJson.tools, key)) {
|
303
|
+
const element = this.tableJson.tools[key];
|
304
|
+
if (!element.show) continue;
|
305
|
+
if (key === "batchDelete") {
|
306
|
+
this.tableJson.table.options.unshift({
|
307
|
+
type: "selection"
|
308
|
+
});
|
309
|
+
}
|
310
|
+
const dic = toolsItemConfig(key, element);
|
311
|
+
dic.form = element.form;
|
312
|
+
if (element.position === 1) {
|
313
|
+
this.toolsConfig.show = true;
|
314
|
+
this.toolsConfig.options.push(dic);
|
315
|
+
} else if (element.position === 2) {
|
316
|
+
action.hide = false;
|
317
|
+
action.actions.push(dic);
|
318
|
+
}
|
319
|
+
}
|
263
320
|
}
|
264
|
-
|
265
|
-
|
266
|
-
action.width = action.actions.length * 60 + 20;
|
267
|
-
this.tableJson.table.options.push(action);
|
321
|
+
action.width = action.actions.length * 60 + 20;
|
322
|
+
this.tableJson.table.options.push(action);
|
268
323
|
|
269
|
-
|
270
|
-
|
324
|
+
this.tableConfig = this.tableJson.table;
|
325
|
+
this.requestListData();
|
326
|
+
})
|
327
|
+
.catch(err => {
|
328
|
+
this.errorMessage = err.message;
|
329
|
+
this.tableJson = null;
|
330
|
+
this.$emit("error");
|
331
|
+
});
|
271
332
|
},
|
272
333
|
requestListData() {
|
273
334
|
if (!this.networkConfig.mounted) return;
|
274
335
|
this.tableConfig.loading.show = true;
|
275
336
|
const apiInfo = this.networkConfig.mounted;
|
276
337
|
const params = {
|
277
|
-
current: this.tableConfig.pageInfo.options.currentPage,
|
278
|
-
size: this.tableConfig.pageInfo.options.pageSize,
|
279
338
|
...this.searchData
|
280
339
|
};
|
340
|
+
if (this.tableConfig.pageInfo.show) {
|
341
|
+
params.current = this.tableConfig.pageInfo.options.currentPage;
|
342
|
+
params.size = this.tableConfig.pageInfo.options.pageSize;
|
343
|
+
}
|
281
344
|
this.axios({
|
282
345
|
url: apiInfo.api,
|
283
346
|
method: apiInfo.method,
|
347
|
+
headers: apiInfo.headers,
|
284
348
|
data: params
|
285
349
|
})
|
286
350
|
.then(res => {
|
287
|
-
const data = res.data.records;
|
288
|
-
this.tableData = data;
|
289
351
|
this.tableConfig.loading.show = false;
|
290
|
-
|
352
|
+
let data = [];
|
353
|
+
if (this.tableConfig.pageInfo.show) {
|
354
|
+
data = res.data.records;
|
355
|
+
this.tableConfig.pageInfo.options.total = Number(res.data.total);
|
356
|
+
} else {
|
357
|
+
data = res.data;
|
358
|
+
}
|
359
|
+
this.tableData = data;
|
291
360
|
})
|
292
361
|
.catch(err => {
|
293
362
|
this.tableConfig.loading.show = false;
|
@@ -300,7 +369,8 @@ export default {
|
|
300
369
|
this.axios({
|
301
370
|
url: apiInfo.api,
|
302
371
|
method: apiInfo.method,
|
303
|
-
|
372
|
+
headers: apiInfo.headers,
|
373
|
+
data: { ...apiInfo.params, ...data }
|
304
374
|
})
|
305
375
|
.then(res => {
|
306
376
|
this.dialog.action.loading = false;
|
@@ -317,7 +387,8 @@ export default {
|
|
317
387
|
this.axios({
|
318
388
|
url: apiInfo.api,
|
319
389
|
method: apiInfo.method,
|
320
|
-
|
390
|
+
headers: apiInfo.headers,
|
391
|
+
data: { ...apiInfo.params, ...data }
|
321
392
|
})
|
322
393
|
.then(res => {
|
323
394
|
this.dialog.action.loading = false;
|
@@ -334,7 +405,8 @@ export default {
|
|
334
405
|
this.axios({
|
335
406
|
url: apiInfo.api,
|
336
407
|
method: apiInfo.method,
|
337
|
-
|
408
|
+
headers: apiInfo.headers,
|
409
|
+
data: { ...apiInfo.params, ids: this.dialog.data.id }
|
338
410
|
})
|
339
411
|
.then(res => {
|
340
412
|
callback(true);
|
@@ -362,7 +434,8 @@ export default {
|
|
362
434
|
this.axios({
|
363
435
|
url: apiInfo.api,
|
364
436
|
method: apiInfo.method,
|
365
|
-
|
437
|
+
headers: apiInfo.headers,
|
438
|
+
data: { ...apiInfo.params, ...data }
|
366
439
|
})
|
367
440
|
.then(res => {
|
368
441
|
callback(true);
|
@@ -375,12 +448,28 @@ export default {
|
|
375
448
|
})
|
376
449
|
.catch(() => {});
|
377
450
|
},
|
378
|
-
requestFormConfigData() {
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
this.
|
383
|
-
|
451
|
+
requestFormConfigData(action) {
|
452
|
+
this.axios({
|
453
|
+
url: this.network.form.url,
|
454
|
+
method: this.network.form.method,
|
455
|
+
headers: this.network.form.headers,
|
456
|
+
// data: { id: action.form.id }
|
457
|
+
data: { ...this.network.page.params, id: this.id }
|
458
|
+
})
|
459
|
+
.then(res => {
|
460
|
+
const data = res.data;
|
461
|
+
data.forEach(item => {
|
462
|
+
if (item.type === "0" && action.act === "add") {
|
463
|
+
this.formConfig = JSON.parse(item.pageConfig);
|
464
|
+
return;
|
465
|
+
}
|
466
|
+
if (item.type === "1" && action.act === "edit") {
|
467
|
+
this.formConfig = JSON.parse(item.pageConfig);
|
468
|
+
return;
|
469
|
+
}
|
470
|
+
});
|
471
|
+
})
|
472
|
+
.catch(err => {});
|
384
473
|
},
|
385
474
|
handleSearchSubmit(val) {
|
386
475
|
this.requestListData();
|
@@ -393,7 +482,7 @@ export default {
|
|
393
482
|
switch (action.act) {
|
394
483
|
case "add":
|
395
484
|
this.dialog = { show: true, data: {}, action: action };
|
396
|
-
this.requestFormConfigData();
|
485
|
+
this.requestFormConfigData(action);
|
397
486
|
break;
|
398
487
|
case "batchDelete":
|
399
488
|
this.dialog = { show: false, data: {}, action: action };
|
@@ -419,11 +508,11 @@ export default {
|
|
419
508
|
switch (action.act) {
|
420
509
|
case "edit":
|
421
510
|
this.dialog = { show: true, data: item, action: action };
|
422
|
-
this.requestFormConfigData();
|
511
|
+
this.requestFormConfigData(action);
|
423
512
|
break;
|
424
513
|
case "detail":
|
425
514
|
this.dialog = { show: true, data: item, action: action };
|
426
|
-
this.requestFormConfigData();
|
515
|
+
this.requestFormConfigData(action);
|
427
516
|
break;
|
428
517
|
case "delete":
|
429
518
|
this.dialog = { show: false, data: item, action: action };
|
@@ -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 => {
|
@@ -109,7 +109,18 @@
|
|
109
109
|
</el-select>
|
110
110
|
</el-form-item>
|
111
111
|
</el-collapse-item> -->
|
112
|
-
<el-collapse-item
|
112
|
+
<el-collapse-item name="3">
|
113
|
+
<template slot="title">
|
114
|
+
<div class="collapse-title">
|
115
|
+
<div>按钮配置</div>
|
116
|
+
<div
|
117
|
+
class="collapse-title-action"
|
118
|
+
@click.stop="handleActionConfig"
|
119
|
+
>
|
120
|
+
配置
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
</template>
|
113
124
|
<el-form-item label-width="90px">
|
114
125
|
<el-checkbox v-model="tableConfig.tools.add.show" slot="label"
|
115
126
|
>新增</el-checkbox
|
@@ -176,11 +187,6 @@
|
|
176
187
|
></el-input>
|
177
188
|
</el-form-item>
|
178
189
|
</el-collapse-item>
|
179
|
-
<!-- <el-collapse-item title="权限设置" name="4">
|
180
|
-
<div>
|
181
|
-
与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;
|
182
|
-
</div>
|
183
|
-
</el-collapse-item> -->
|
184
190
|
</el-collapse>
|
185
191
|
</el-form>
|
186
192
|
</div>
|
@@ -297,6 +303,7 @@ export default {
|
|
297
303
|
this.table.isIndeterminate = false;
|
298
304
|
this.handleChange();
|
299
305
|
},
|
306
|
+
handleActionConfig() {},
|
300
307
|
getJson() {
|
301
308
|
return JSON.parse(JSON.stringify(this.tableConfig));
|
302
309
|
}
|
@@ -346,6 +353,21 @@ export default {
|
|
346
353
|
|
347
354
|
.tableConfig {
|
348
355
|
height: calc(100% - 45px);
|
356
|
+
|
357
|
+
.collapse-title {
|
358
|
+
display: flex;
|
359
|
+
justify-content: space-between;
|
360
|
+
width: 100%;
|
361
|
+
padding-right: 10px;
|
362
|
+
|
363
|
+
.collapse-title-action {
|
364
|
+
transition: 0.25s;
|
365
|
+
}
|
366
|
+
|
367
|
+
.collapse-title-action:hover {
|
368
|
+
color: #409eff;
|
369
|
+
}
|
370
|
+
}
|
349
371
|
}
|
350
372
|
}
|
351
373
|
</style>
|