tianheng-ui 0.1.68 → 0.1.70
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/theme-chalk/js/axios.js +1 -1
- package/lib/theme-chalk/styles/dialog.scss +56 -40
- package/lib/theme-chalk/styles/feature.scss +7 -0
- package/lib/theme-chalk/styles/icon.css +8 -2
- package/lib/tianheng-ui.js +13 -13
- package/package.json +1 -1
- package/packages/Dialog/index.vue +18 -9
- package/packages/FormMaking/GenerateForm.vue +40 -49
- package/packages/FormMaking/GenerateFormItem.vue +10 -26
- package/packages/FormMaking/WidgetFormItem.vue +9 -7
- package/packages/FormMaking/WidgetGuide.vue +86 -0
- package/packages/FormMaking/WidgetSelect.vue +2 -2
- package/packages/FormMaking/WidgetTools.vue +10 -7
- package/packages/FormMaking/config/index.js +2 -0
- package/packages/FormMaking/custom/config.js +7 -36
- package/packages/FormMaking/custom/configs/grid.vue +17 -9
- package/packages/FormMaking/custom/configs/list.vue +89 -8
- package/packages/FormMaking/custom/configs/radio.vue +2 -5
- package/packages/FormMaking/custom/configs/table.vue +12 -9
- package/packages/FormMaking/custom/configs/tabs.vue +69 -55
- package/packages/FormMaking/custom/index.js +1 -1
- package/packages/FormMaking/custom/items/grid_dev.vue +5 -8
- package/packages/FormMaking/custom/items/list_dev.vue +19 -23
- package/packages/FormMaking/custom/items/list_pro.vue +109 -6
- package/packages/FormMaking/custom/items/table_dev.vue +13 -12
- package/packages/FormMaking/custom/items/table_pro.vue +5 -5
- package/packages/FormMaking/custom/items/tabs_dev.vue +4 -7
- package/packages/FormMaking/custom/items/tabs_pro.vue +7 -9
- package/packages/FormMaking/custom/items/upload.vue +3 -1
- package/packages/FormMaking/index.vue +72 -78
- package/packages/FormMaking/lang/zh-CN.js +2 -2
- package/packages/FormMaking/network/axios.js +88 -0
- package/packages/FormMaking/styles/index.scss +3 -3
- package/packages/FormMaking/util/Log.js +99 -0
- package/packages/FormMaking/util/generateCode.js +2 -2
- package/packages/TableMaking/config/index.js +8 -0
- package/packages/TableMaking/generateTable.vue +10 -3
- package/packages/TableMaking/index.vue +18 -3
- package/packages/TableMaking/network/axios.js +88 -0
- package/packages/TableMaking/util/Log.js +99 -0
- package/packages/TableMaking/widgetGuide.vue +122 -58
- package/packages/FormMaking/custom/configs/tableH5.vue +0 -98
- package/packages/FormMaking/custom/items/tableH5_dev.vue +0 -112
- package/packages/FormMaking/custom/items/tableH5_pro.vue +0 -119
- package/packages/FormMaking/util/request.js +0 -25
@@ -84,7 +84,8 @@ import Search from "./custom/items/search/index-pc.vue";
|
|
84
84
|
import Tools from "./custom/items/tools/index-pc.vue";
|
85
85
|
import STable from "./custom/items/table/index-pc.vue";
|
86
86
|
import Actions from "./custom/items/actions/index-pc.vue";
|
87
|
-
import * as Axios from "
|
87
|
+
import * as Axios from "./network/axios";
|
88
|
+
import appConfig from "./config/index";
|
88
89
|
import { deepClone } from "../FormMaking/util";
|
89
90
|
export default {
|
90
91
|
name: "thTableGenerate",
|
@@ -169,7 +170,10 @@ export default {
|
|
169
170
|
token: this.oauthConfig.token,
|
170
171
|
baseUrl: this.oauthConfig.baseUrl
|
171
172
|
};
|
172
|
-
sessionStorage.setItem(
|
173
|
+
sessionStorage.setItem(
|
174
|
+
appConfig.storageKeys.oauthConfig,
|
175
|
+
JSON.stringify(oauthInfo)
|
176
|
+
);
|
173
177
|
} else if (this.oauthConfig.oauth) {
|
174
178
|
// 模拟授权认证流程
|
175
179
|
this.axios({
|
@@ -182,7 +186,10 @@ export default {
|
|
182
186
|
token: res.data,
|
183
187
|
baseUrl: this.oauthConfig.baseUrl
|
184
188
|
};
|
185
|
-
sessionStorage.setItem(
|
189
|
+
sessionStorage.setItem(
|
190
|
+
appConfig.storageKeys.oauthConfig,
|
191
|
+
JSON.stringify(oauthInfo)
|
192
|
+
);
|
186
193
|
// this.axios.defaults.baseURL = this.oauthConfig.baseUrl;
|
187
194
|
});
|
188
195
|
}
|
@@ -22,7 +22,14 @@
|
|
22
22
|
ref="configRef"
|
23
23
|
></widget-config>
|
24
24
|
</div>
|
25
|
-
|
25
|
+
|
26
|
+
<th-dialog v-model="showGuide" title="引导配置" :showFooter="false">
|
27
|
+
<widget-guide
|
28
|
+
:config="tableConfig"
|
29
|
+
:apiOptions="apiOptions"
|
30
|
+
@save="showGuide = false"
|
31
|
+
></widget-guide>
|
32
|
+
</th-dialog>
|
26
33
|
</div>
|
27
34
|
</template>
|
28
35
|
|
@@ -79,12 +86,14 @@ export default {
|
|
79
86
|
"generateCode",
|
80
87
|
"generateJson"
|
81
88
|
]
|
82
|
-
}
|
89
|
+
},
|
90
|
+
guide: Boolean
|
83
91
|
},
|
84
92
|
data() {
|
85
93
|
this.baseConfig = deepClone(baseConfig);
|
86
94
|
return {
|
87
|
-
tableConfig: this.baseConfig
|
95
|
+
tableConfig: this.baseConfig,
|
96
|
+
showGuide: this.guide
|
88
97
|
};
|
89
98
|
},
|
90
99
|
watch: {
|
@@ -94,6 +103,12 @@ export default {
|
|
94
103
|
config(val) {
|
95
104
|
this.tableConfig = Object.assign(this.baseConfig, val);
|
96
105
|
this.handleNetworkConfig();
|
106
|
+
},
|
107
|
+
guide(val) {
|
108
|
+
this.showGuide = val;
|
109
|
+
},
|
110
|
+
showGuide(val) {
|
111
|
+
this.$emit("update:guide", val);
|
97
112
|
}
|
98
113
|
},
|
99
114
|
mounted() {
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import axios from "axios";
|
2
|
+
import Log from "../util/Log";
|
3
|
+
import appConfig from "../config/index";
|
4
|
+
import { Notification } from "element-ui";
|
5
|
+
|
6
|
+
export const init = baseConfig => {
|
7
|
+
// 创建axios实例
|
8
|
+
const Axios = axios.create({
|
9
|
+
baseURL: baseConfig.baseUrl,
|
10
|
+
timeout: 60000 // 请求超时时间
|
11
|
+
// withCredentials: true, //允许携带cookie
|
12
|
+
});
|
13
|
+
|
14
|
+
// 添加请求拦截器
|
15
|
+
Axios.interceptors.request.use(
|
16
|
+
config => {
|
17
|
+
const info = sessionStorage.getItem(appConfig.storageKeys.oauthConfig);
|
18
|
+
if (info) {
|
19
|
+
const oauthInfo = JSON.parse(info);
|
20
|
+
config.baseURL = oauthInfo.baseUrl;
|
21
|
+
config.headers["Authorization"] = oauthInfo.token;
|
22
|
+
}
|
23
|
+
if (baseConfig.headers) {
|
24
|
+
config.headers = Object.assign(config.headers, baseConfig.headers);
|
25
|
+
}
|
26
|
+
return config;
|
27
|
+
},
|
28
|
+
error => {
|
29
|
+
Promise.reject(error);
|
30
|
+
}
|
31
|
+
);
|
32
|
+
|
33
|
+
// 添加响应拦截器
|
34
|
+
Axios.interceptors.response.use(
|
35
|
+
response => {
|
36
|
+
const code = response.status;
|
37
|
+
if (code < 200 || code > 300) {
|
38
|
+
Notification.error({
|
39
|
+
title: response.message
|
40
|
+
});
|
41
|
+
return Promise.reject("error");
|
42
|
+
}
|
43
|
+
|
44
|
+
const dataCode = response.data.code;
|
45
|
+
if (dataCode && dataCode !== 200) {
|
46
|
+
Notification.error({
|
47
|
+
title: response.data.message
|
48
|
+
});
|
49
|
+
return Promise.reject("error");
|
50
|
+
}
|
51
|
+
|
52
|
+
if (baseConfig.debug) {
|
53
|
+
Log.prettyPrimary("Request Url:", response.request.responseURL);
|
54
|
+
Log.prettySuccess("Request Res:", response);
|
55
|
+
}
|
56
|
+
|
57
|
+
return response.data;
|
58
|
+
},
|
59
|
+
error => {
|
60
|
+
let code = 0;
|
61
|
+
try {
|
62
|
+
code = error.response.data.status;
|
63
|
+
} catch (e) {
|
64
|
+
if (error.toString().indexOf("Error: timeout") !== -1) {
|
65
|
+
Notification.error({
|
66
|
+
title: "网络请求超时",
|
67
|
+
duration: 5000
|
68
|
+
});
|
69
|
+
return Promise.reject(error);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
if (code) {
|
73
|
+
const errorMsg = error.response.data.message;
|
74
|
+
Notification.error({
|
75
|
+
title: errorMsg || "未知错误",
|
76
|
+
duration: 5000
|
77
|
+
});
|
78
|
+
} else {
|
79
|
+
Notification.error({
|
80
|
+
title: "接口请求失败",
|
81
|
+
duration: 5000
|
82
|
+
});
|
83
|
+
}
|
84
|
+
return Promise.reject(error);
|
85
|
+
}
|
86
|
+
);
|
87
|
+
return Axios;
|
88
|
+
};
|
@@ -0,0 +1,99 @@
|
|
1
|
+
function Log() {}
|
2
|
+
|
3
|
+
Log.prototype.type = ["primary", "success", "warn", "error", "info"];
|
4
|
+
|
5
|
+
Log.prototype.typeColor = function(type) {
|
6
|
+
let color = "";
|
7
|
+
switch (type) {
|
8
|
+
case "primary":
|
9
|
+
color = "#2d8cf0";
|
10
|
+
break;
|
11
|
+
case "success":
|
12
|
+
color = "#19be6b";
|
13
|
+
break;
|
14
|
+
case "info":
|
15
|
+
color = "#909399";
|
16
|
+
break;
|
17
|
+
case "warn":
|
18
|
+
color = "#ff9900";
|
19
|
+
break;
|
20
|
+
case "error":
|
21
|
+
color = "#f03f14";
|
22
|
+
break;
|
23
|
+
default:
|
24
|
+
color = "#35495E";
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
return color;
|
28
|
+
};
|
29
|
+
|
30
|
+
Log.prototype.isArray = function(obj) {
|
31
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
32
|
+
};
|
33
|
+
|
34
|
+
Log.prototype.print = function(text, type = "default", back = false) {
|
35
|
+
if (typeof text === "object") {
|
36
|
+
// 如果是對象則調用打印對象方式
|
37
|
+
this.isArray(text) ? console.table(text) : console.dir(text);
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
if (back) {
|
41
|
+
// 如果是打印帶背景圖的
|
42
|
+
console.log(`%c ${text} `, `background:${this.typeColor(type)}; padding: 2px; border-radius: 4px; color: #fff;`);
|
43
|
+
} else {
|
44
|
+
console.log(
|
45
|
+
`%c ${text} `,
|
46
|
+
`border: 1px solid ${this.typeColor(type)};
|
47
|
+
padding: 2px; border-radius: 4px;
|
48
|
+
color: ${this.typeColor(type)};`
|
49
|
+
);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
Log.prototype.printBack = function(type = "primary", title) {
|
54
|
+
this.print(type, title, true);
|
55
|
+
};
|
56
|
+
|
57
|
+
Log.prototype.pretty = function(type = "primary", title, text) {
|
58
|
+
if (typeof text === "object") {
|
59
|
+
// console.group("Console Group", title);
|
60
|
+
console.log(
|
61
|
+
`%c ${title}`,
|
62
|
+
`background:${this.typeColor(type)};border:1px solid ${this.typeColor(type)};
|
63
|
+
padding: 1px; border-radius: 4px; color: #fff;`
|
64
|
+
);
|
65
|
+
this.isArray(text) ? console.table(text) : console.dir(text);
|
66
|
+
console.groupEnd();
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
console.log(
|
70
|
+
`%c ${title} %c ${text} %c`,
|
71
|
+
`background:${this.typeColor(type)};border:1px solid ${this.typeColor(type)};
|
72
|
+
padding: 1px; border-radius: 4px 0 0 4px; color: #fff;`,
|
73
|
+
`border:1px solid ${this.typeColor(type)};
|
74
|
+
padding: 1px; border-radius: 0 4px 4px 0; color: ${this.typeColor(type)};`,
|
75
|
+
"background:transparent"
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
Log.prototype.prettyPrimary = function(title, ...text) {
|
80
|
+
text.forEach(t => this.pretty("primary", title, t));
|
81
|
+
};
|
82
|
+
|
83
|
+
Log.prototype.prettySuccess = function(title, ...text) {
|
84
|
+
text.forEach(t => this.pretty("success", title, t));
|
85
|
+
};
|
86
|
+
|
87
|
+
Log.prototype.prettyWarn = function(title, ...text) {
|
88
|
+
text.forEach(t => this.pretty("warn", title, t));
|
89
|
+
};
|
90
|
+
|
91
|
+
Log.prototype.prettyError = function(title, ...text) {
|
92
|
+
text.forEach(t => this.pretty("error", title, t));
|
93
|
+
};
|
94
|
+
|
95
|
+
Log.prototype.prettyInfo = function(title, ...text) {
|
96
|
+
text.forEach(t => this.pretty("info", title, t));
|
97
|
+
};
|
98
|
+
|
99
|
+
export default new Log();
|
@@ -1,26 +1,107 @@
|
|
1
1
|
<template>
|
2
|
-
<div
|
3
|
-
<
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
2
|
+
<div class="widgetGuide">
|
3
|
+
<el-steps :active="step" finish-status="success" simple>
|
4
|
+
<el-step title="列表配置" icon="el-icon-s-operation" description="">
|
5
|
+
</el-step>
|
6
|
+
<!-- <el-step
|
7
|
+
title="字段配置"
|
8
|
+
icon="el-icon-c-scale-to-original"
|
9
|
+
description=""
|
10
|
+
></el-step> -->
|
11
|
+
<el-step title="按钮配置" icon="el-icon-set-up" description=""></el-step>
|
12
|
+
</el-steps>
|
13
|
+
<div class="content">
|
14
|
+
<el-form :model="config" label-width="80px" size="small">
|
15
|
+
<div v-show="step === 0">
|
16
|
+
<el-form-item size="small">
|
17
|
+
<el-tooltip
|
18
|
+
slot="label"
|
19
|
+
effect="light"
|
20
|
+
content="字段的配置方式"
|
21
|
+
placement="top"
|
22
|
+
>
|
23
|
+
<span style="color: #409EFF;">字段类型</span>
|
24
|
+
</el-tooltip>
|
25
|
+
<el-radio-group v-model="config.table.fields.type">
|
26
|
+
<el-radio-button label="custom" disabled>自定义</el-radio-button>
|
27
|
+
<el-radio-button label="api">接口导入</el-radio-button>
|
28
|
+
</el-radio-group>
|
29
|
+
</el-form-item>
|
30
|
+
<el-form-item>
|
31
|
+
<el-tooltip
|
32
|
+
slot="label"
|
33
|
+
effect="light"
|
34
|
+
content="开启后,选择数据接口会触发 remote-params 回调,用于从服务器查询字段"
|
35
|
+
placement="top"
|
36
|
+
>
|
37
|
+
<span style="color: #409EFF;">远程字段</span>
|
38
|
+
</el-tooltip>
|
39
|
+
<el-switch v-model="config.table.fields.remote"> </el-switch>
|
40
|
+
</el-form-item>
|
41
|
+
<el-form-item>
|
42
|
+
<el-tooltip
|
43
|
+
slot="label"
|
44
|
+
effect="light"
|
45
|
+
content="列表初始化完成后,调用该接口获取列表数据"
|
46
|
+
placement="top"
|
47
|
+
>
|
48
|
+
<span style="color: #409EFF;">列表接口</span>
|
49
|
+
</el-tooltip>
|
50
|
+
<el-select
|
51
|
+
v-model="config.table.mounted.api"
|
52
|
+
style="width:100%"
|
53
|
+
clearable
|
54
|
+
placeholder="请选择"
|
55
|
+
no-data-text="暂无接口,请前往【接口模块】创建"
|
56
|
+
filterable
|
57
|
+
>
|
58
|
+
<el-option
|
59
|
+
v-for="item in apiOptions"
|
60
|
+
:key="item.id"
|
61
|
+
:label="item.name"
|
62
|
+
:value="item.id"
|
63
|
+
>
|
64
|
+
</el-option>
|
65
|
+
</el-select>
|
66
|
+
</el-form-item>
|
67
|
+
<el-form-item label="列表名称">
|
68
|
+
<el-input
|
69
|
+
v-model="config.table.title"
|
70
|
+
placeholder="请输入"
|
71
|
+
></el-input>
|
72
|
+
</el-form-item>
|
73
|
+
</div>
|
74
|
+
<div v-show="step === 1">
|
75
|
+
<el-form-item label="">
|
76
|
+
<div v-for="item in Object.values(config.tools)" :key="item.type">
|
77
|
+
<el-checkbox v-model="item.show" :label="item.name"></el-checkbox>
|
78
|
+
</div>
|
79
|
+
</el-form-item>
|
23
80
|
</div>
|
81
|
+
</el-form>
|
82
|
+
</div>
|
83
|
+
<div class="footer">
|
84
|
+
<div></div>
|
85
|
+
<div class="stepView">
|
86
|
+
<el-button
|
87
|
+
type="primary"
|
88
|
+
icon="el-icon-back"
|
89
|
+
size="small"
|
90
|
+
:disabled="step === 0"
|
91
|
+
@click="handleBack"
|
92
|
+
>上一步</el-button
|
93
|
+
>
|
94
|
+
<el-button
|
95
|
+
v-if="step !== 1"
|
96
|
+
type="primary"
|
97
|
+
size="small"
|
98
|
+
@click="handleNext"
|
99
|
+
>
|
100
|
+
下一步<i class="el-icon-right el-icon--right"></i>
|
101
|
+
</el-button>
|
102
|
+
<el-button v-else type="success" size="small" @click="handleSave">
|
103
|
+
完 成<i class="el-icon-finished el-icon--right"></i>
|
104
|
+
</el-button>
|
24
105
|
</div>
|
25
106
|
</div>
|
26
107
|
</div>
|
@@ -28,19 +109,16 @@
|
|
28
109
|
|
29
110
|
<script>
|
30
111
|
export default {
|
31
|
-
props: {
|
112
|
+
props: { config: Object, apiOptions: Array },
|
32
113
|
data() {
|
33
114
|
return {
|
34
|
-
|
35
|
-
|
115
|
+
step: 0,
|
116
|
+
formData: {}
|
36
117
|
};
|
37
118
|
},
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
},
|
42
|
-
show(val) {
|
43
|
-
this.$emit("update:visible", val);
|
119
|
+
computed: {
|
120
|
+
getFields() {
|
121
|
+
return [];
|
44
122
|
}
|
45
123
|
},
|
46
124
|
created() {},
|
@@ -51,6 +129,9 @@ export default {
|
|
51
129
|
},
|
52
130
|
handleNext() {
|
53
131
|
this.step++;
|
132
|
+
},
|
133
|
+
handleSave() {
|
134
|
+
this.$emit("save");
|
54
135
|
}
|
55
136
|
}
|
56
137
|
};
|
@@ -58,38 +139,21 @@ export default {
|
|
58
139
|
|
59
140
|
<style lang="scss" scoped>
|
60
141
|
.widgetGuide {
|
61
|
-
position: absolute;
|
62
142
|
width: 100%;
|
63
143
|
height: 100%;
|
64
|
-
display: flex;
|
65
|
-
align-items: center;
|
66
|
-
justify-content: center;
|
67
|
-
background-color: rgba($color: #000000, $alpha: 0.6);
|
68
|
-
z-index: 999;
|
69
144
|
|
70
|
-
.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
.content {
|
81
|
-
height: calc(100% - 100px);
|
82
|
-
}
|
83
|
-
.footer {
|
84
|
-
padding: 10px 20px;
|
85
|
-
height: 50px;
|
86
|
-
display: flex;
|
87
|
-
align-items: center;
|
88
|
-
justify-content: space-between;
|
89
|
-
box-sizing: border-box;
|
145
|
+
.content {
|
146
|
+
height: calc(100% - 96px);
|
147
|
+
padding-top: 10px;
|
148
|
+
}
|
149
|
+
.footer {
|
150
|
+
height: 50px;
|
151
|
+
display: flex;
|
152
|
+
align-items: center;
|
153
|
+
justify-content: space-between;
|
154
|
+
box-sizing: border-box;
|
90
155
|
|
91
|
-
|
92
|
-
}
|
156
|
+
.stepView {
|
93
157
|
}
|
94
158
|
}
|
95
159
|
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="component-config">
|
3
|
-
<el-collapse-item title="组件配置" name="group-element">
|
4
|
-
<el-form-item label="标题">
|
5
|
-
<el-input v-model="widget.name"></el-input>
|
6
|
-
</el-form-item>
|
7
|
-
|
8
|
-
<el-form-item label="标签宽度">
|
9
|
-
<div style="display: flex;">
|
10
|
-
<el-checkbox v-model="widget.options.isLabelWidth"
|
11
|
-
>自定义</el-checkbox
|
12
|
-
>
|
13
|
-
<el-input-number
|
14
|
-
v-model="widget.options.labelWidth"
|
15
|
-
:min="0"
|
16
|
-
:max="200"
|
17
|
-
:disabled="!widget.options.isLabelWidth"
|
18
|
-
>
|
19
|
-
</el-input-number>
|
20
|
-
</div>
|
21
|
-
</el-form-item>
|
22
|
-
|
23
|
-
<el-form-item>
|
24
|
-
<div class="config-header" slot="label">
|
25
|
-
<span class="title">默认值</span>
|
26
|
-
<span class="value" @click="handleAddData">添加数据</span>
|
27
|
-
</div>
|
28
|
-
<code-editor
|
29
|
-
v-model="widget.options.defaultValue"
|
30
|
-
language="json"
|
31
|
-
></code-editor>
|
32
|
-
</el-form-item>
|
33
|
-
|
34
|
-
<el-form-item label="新增按钮文本内容">
|
35
|
-
<el-input v-model.number="widget.options.addButtonText"></el-input>
|
36
|
-
</el-form-item>
|
37
|
-
|
38
|
-
<el-form-item label="删除按钮文本内容">
|
39
|
-
<el-input v-model.number="widget.options.deleteButtonText"></el-input>
|
40
|
-
</el-form-item>
|
41
|
-
|
42
|
-
<el-form-item label="可删除的最小索引">
|
43
|
-
<el-input-number v-model="widget.options.deleteIndex" :min="0">
|
44
|
-
</el-input-number>
|
45
|
-
</el-form-item>
|
46
|
-
|
47
|
-
<el-form-item label="操作属性">
|
48
|
-
<el-checkbox v-model="widget.options.disabled">禁用 </el-checkbox>
|
49
|
-
<el-checkbox v-model="widget.options.hidden">隐藏组件 </el-checkbox>
|
50
|
-
<el-checkbox v-model="widget.options.hideLabel">隐藏标签 </el-checkbox>
|
51
|
-
<el-checkbox v-model="widget.options.isAdd">可新增 </el-checkbox>
|
52
|
-
<el-checkbox v-model="widget.options.isDelete">可删除 </el-checkbox>
|
53
|
-
</el-form-item>
|
54
|
-
|
55
|
-
<el-form-item label="校验">
|
56
|
-
<el-checkbox v-model="widget.options.required">必填</el-checkbox>
|
57
|
-
</el-form-item>
|
58
|
-
</el-collapse-item>
|
59
|
-
</div>
|
60
|
-
</template>
|
61
|
-
|
62
|
-
<script>
|
63
|
-
import Draggable from "vuedraggable";
|
64
|
-
import { configComponent } from "../mixins";
|
65
|
-
import CodeEditor from "ui/CodeEditor/index.vue";
|
66
|
-
export default {
|
67
|
-
components: {
|
68
|
-
Draggable,
|
69
|
-
CodeEditor
|
70
|
-
},
|
71
|
-
props: {},
|
72
|
-
mixins: [configComponent],
|
73
|
-
mounted() {},
|
74
|
-
methods: {
|
75
|
-
handleAddData() {
|
76
|
-
let defaultValue = JSON.parse(this.widget.options.defaultValue || "[]");
|
77
|
-
let dic = {};
|
78
|
-
this.widget.list.forEach(item => {
|
79
|
-
if (item.type === "grid") {
|
80
|
-
for (let i = 0; i < item.options.columns.length; i++) {
|
81
|
-
const element = item.options.columns[i];
|
82
|
-
for (let j = 0; j < element.list.length; j++) {
|
83
|
-
const element2 = element.list[j];
|
84
|
-
dic[element2.model] = element2.options.defaultValue;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
} else {
|
88
|
-
dic[item.model] = item.options.defaultValue;
|
89
|
-
}
|
90
|
-
});
|
91
|
-
defaultValue.push(dic);
|
92
|
-
this.widget.options.defaultValue = JSON.stringify(defaultValue, null, 2);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
};
|
96
|
-
</script>
|
97
|
-
|
98
|
-
<style></style>
|
@@ -1,112 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="component-tableH5">
|
3
|
-
<draggable
|
4
|
-
v-model="widget.options.columns"
|
5
|
-
:no-transition-on-drag="true"
|
6
|
-
v-bind="{
|
7
|
-
group: 'people',
|
8
|
-
ghostClass: 'draggable-ghost',
|
9
|
-
animation: 200,
|
10
|
-
handle: '.drag-widget'
|
11
|
-
}"
|
12
|
-
@add="handleWidgetAdd($event)"
|
13
|
-
>
|
14
|
-
<transition-group name="fade" tag="div" class="draggable-list">
|
15
|
-
<div
|
16
|
-
v-for="(element, elementIndex) in widget.options.columns"
|
17
|
-
class="draggable-list-item"
|
18
|
-
:key="element.key"
|
19
|
-
@click.stop="selectWidget = element"
|
20
|
-
>
|
21
|
-
<widget-form-item
|
22
|
-
:widget="element"
|
23
|
-
:widgetArray="widget.options.columns"
|
24
|
-
:widgetIndex="elementIndex"
|
25
|
-
:select.sync="selectWidget"
|
26
|
-
:config="config"
|
27
|
-
>
|
28
|
-
</widget-form-item>
|
29
|
-
<div v-if="widget.options.isDelete && elementIndex === 0">
|
30
|
-
<el-button type="danger">{{
|
31
|
-
widget.options.deleteButtonText
|
32
|
-
}}</el-button>
|
33
|
-
</div>
|
34
|
-
</div>
|
35
|
-
</transition-group>
|
36
|
-
</draggable>
|
37
|
-
<div v-if="widget.options.isAdd" class="footer">
|
38
|
-
<el-button type="text" :disabled="widget.options.disabled">{{
|
39
|
-
widget.options.addButtonText
|
40
|
-
}}</el-button>
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
</template>
|
44
|
-
|
45
|
-
<script>
|
46
|
-
import { itemsComponent, eventMixin } from "../mixins/index";
|
47
|
-
import Draggable from "vuedraggable";
|
48
|
-
import WidgetFormItem from "../../WidgetFormItem.vue";
|
49
|
-
export default {
|
50
|
-
components: { Draggable, WidgetFormItem },
|
51
|
-
mixins: [itemsComponent, eventMixin],
|
52
|
-
data() {
|
53
|
-
return {
|
54
|
-
selectWidget: {}
|
55
|
-
};
|
56
|
-
},
|
57
|
-
watch: {
|
58
|
-
select(val) {
|
59
|
-
this.selectWidget = val;
|
60
|
-
},
|
61
|
-
selectWidget: {
|
62
|
-
handler(val) {
|
63
|
-
this.$emit("update:select", val);
|
64
|
-
},
|
65
|
-
deep: true
|
66
|
-
}
|
67
|
-
},
|
68
|
-
methods: {
|
69
|
-
handleWidgetAdd($event) {
|
70
|
-
const newIndex = $event.newIndex;
|
71
|
-
const oldIndex = $event.oldIndex;
|
72
|
-
const newComponent = JSON.parse(
|
73
|
-
JSON.stringify(this.widget.options.columns[newIndex])
|
74
|
-
);
|
75
|
-
const item = $event.item;
|
76
|
-
// 防止布局元素的嵌套拖拽
|
77
|
-
if (item.className.indexOf("no-put") >= 0) {
|
78
|
-
// 如果是列表中拖拽的元素需要还原到原来位置
|
79
|
-
item.tagName === "DIV" &&
|
80
|
-
this.widgetArray.splice(oldIndex, 0, newComponent);
|
81
|
-
|
82
|
-
this.widget.options.columns.splice(newIndex, 1);
|
83
|
-
return false;
|
84
|
-
}
|
85
|
-
|
86
|
-
if (!newComponent.key) {
|
87
|
-
const key =
|
88
|
-
Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
|
89
|
-
newComponent.key = key;
|
90
|
-
newComponent.model = `${newComponent.type}_${key}`;
|
91
|
-
}
|
92
|
-
this.$set(this.widget.options.columns, newIndex, newComponent);
|
93
|
-
this.selectWidget = newComponent;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
};
|
97
|
-
</script>
|
98
|
-
|
99
|
-
<style lang="scss" scoped>
|
100
|
-
.component-tableH5 {
|
101
|
-
.draggable-list-item:nth-child(1) {
|
102
|
-
display: flex;
|
103
|
-
> div:first-child {
|
104
|
-
flex: 1;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
.footer {
|
109
|
-
text-align: center;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
</style>
|