tianheng-ui 0.0.80 → 0.0.81
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 +5 -5
- package/package.json +1 -1
- package/packages/FormMaking/GenerateForm.vue +3 -3
- package/packages/FormMaking/GenerateFormItem.vue +10 -15
- package/packages/FormMaking/index.vue +1 -0
- package/packages/Table/search.vue +3 -0
- package/packages/TableMaking/generateTable.vue +113 -44
- package/packages/TableMaking/util/Log.js +99 -0
- package/packages/TableMaking/util/axios.js +10 -11
- package/packages/TableMaking/util/index.js +340 -90
package/package.json
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
:models.sync="models"
|
18
18
|
:widget="item"
|
19
19
|
:slotKeys="slotKeys"
|
20
|
-
:remote="
|
20
|
+
:remote="remoteData"
|
21
21
|
:config="formJson.config"
|
22
22
|
:prop="item.type === 'grid' ? '' : item.model"
|
23
23
|
:componentsData="componentsData"
|
@@ -44,7 +44,7 @@
|
|
44
44
|
:models.sync="models"
|
45
45
|
:widget="item"
|
46
46
|
:slotKeys="slotKeys"
|
47
|
-
:remote="
|
47
|
+
:remote="remoteData"
|
48
48
|
:config="formJson.config"
|
49
49
|
:prop="item.type === 'grid' ? '' : item.model"
|
50
50
|
:componentsData="componentsData"
|
@@ -71,7 +71,7 @@ export default {
|
|
71
71
|
return {};
|
72
72
|
}
|
73
73
|
},
|
74
|
-
|
74
|
+
remoteData: {
|
75
75
|
type: Object,
|
76
76
|
default: () => {
|
77
77
|
return {};
|
@@ -728,18 +728,14 @@ export default {
|
|
728
728
|
}
|
729
729
|
},
|
730
730
|
created() {
|
731
|
-
if (
|
732
|
-
this.widget.
|
733
|
-
this.
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
label: item[this.widget.options.props.label],
|
740
|
-
children: item[this.widget.options.props.children]
|
741
|
-
};
|
742
|
-
});
|
731
|
+
if (this.widget.options.remote) {
|
732
|
+
const remoteData = this.remote[this.widget.model] || [];
|
733
|
+
this.widget.options.remoteOptions = remoteData.map(item => {
|
734
|
+
return {
|
735
|
+
value: item[this.widget.options.props.value],
|
736
|
+
label: item[this.widget.options.props.label],
|
737
|
+
children: item[this.widget.options.props.children]
|
738
|
+
};
|
743
739
|
});
|
744
740
|
}
|
745
741
|
|
@@ -747,9 +743,8 @@ export default {
|
|
747
743
|
this.widget.type === "upload" &&
|
748
744
|
this.remote[this.widget.options.remoteFunc]
|
749
745
|
) {
|
750
|
-
this.remote[this.widget.options.remoteFunc]
|
751
|
-
|
752
|
-
});
|
746
|
+
const remoteData = this.remote[this.widget.options.remoteFunc] || {};
|
747
|
+
this.widget.options.remoteApi = remoteData;
|
753
748
|
}
|
754
749
|
},
|
755
750
|
mounted() {
|
@@ -5,8 +5,8 @@
|
|
5
5
|
v-if="searchConfig.show"
|
6
6
|
:data="searchData"
|
7
7
|
:options="searchConfig.options"
|
8
|
-
@on-search="
|
9
|
-
@on-reset="
|
8
|
+
@on-search="requestListData"
|
9
|
+
@on-reset="requestListData"
|
10
10
|
/>
|
11
11
|
|
12
12
|
<!-- 菜单栏 -->
|
@@ -67,12 +67,10 @@
|
|
67
67
|
v-if="formConfig"
|
68
68
|
:data="formConfig"
|
69
69
|
:value="dialog.data"
|
70
|
+
:remoteData="remoteData"
|
70
71
|
ref="formGenerate"
|
71
72
|
>
|
72
73
|
</th-form-generate>
|
73
|
-
<!-- <span slot="footer">
|
74
|
-
<th-table-tools :options="dialogOptions" @on-click="handleToolsClick" />
|
75
|
-
</span> -->
|
76
74
|
</th-dialog>
|
77
75
|
</div>
|
78
76
|
</template>
|
@@ -80,30 +78,27 @@
|
|
80
78
|
<script>
|
81
79
|
import Search from "./custom/items/search";
|
82
80
|
import Tools from "./custom/items/tools";
|
83
|
-
import { toolsItemConfig, formItemConfig } from "./util/index";
|
81
|
+
import { toolsItemConfig, formItemConfig, tableItemConfig } from "./util/index";
|
84
82
|
import * as Axios from "./util/axios";
|
85
83
|
export default {
|
86
84
|
name: "thTableGenerate",
|
87
85
|
components: { Search, Tools },
|
88
86
|
props: {
|
89
|
-
|
87
|
+
config: {
|
90
88
|
type: Object,
|
91
89
|
default: () => {
|
92
|
-
return {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
type: Object,
|
97
|
-
default: () => {
|
98
|
-
return {};
|
90
|
+
return {
|
91
|
+
debug: false,
|
92
|
+
appId: ""
|
93
|
+
};
|
99
94
|
}
|
100
95
|
}
|
101
96
|
},
|
102
97
|
data() {
|
103
98
|
return {
|
104
|
-
tableJson:
|
105
|
-
network: {},
|
99
|
+
tableJson: {},
|
106
100
|
axios: null,
|
101
|
+
networkConfig: {},
|
107
102
|
searchConfig: { show: false, options: [] },
|
108
103
|
searchData: {},
|
109
104
|
toolsConfig: { show: false, options: [] },
|
@@ -111,31 +106,105 @@ export default {
|
|
111
106
|
tableData: [],
|
112
107
|
tableSelectionData: [],
|
113
108
|
dialog: { show: false, data: {}, action: {} },
|
114
|
-
formConfig: null
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
109
|
+
formConfig: null,
|
110
|
+
remoteData: {
|
111
|
+
projectTypeId: [
|
112
|
+
{
|
113
|
+
id: "1597785308467281921",
|
114
|
+
name: "自然资源",
|
115
|
+
sort: "1",
|
116
|
+
tenantId: "1514528042264793089",
|
117
|
+
createBy: "舒浪",
|
118
|
+
createTime: 1669776678000,
|
119
|
+
updateBy: "舒浪",
|
120
|
+
updateTime: 1669787428000
|
121
|
+
},
|
122
|
+
{
|
123
|
+
id: "1597785379552346114",
|
124
|
+
name: "智慧政务",
|
125
|
+
sort: "2",
|
126
|
+
tenantId: "1514528042264793089",
|
127
|
+
createBy: "舒浪",
|
128
|
+
createTime: 1669776695000,
|
129
|
+
updateBy: "舒浪",
|
130
|
+
updateTime: 1669776893000
|
131
|
+
},
|
132
|
+
{
|
133
|
+
id: "1597785424695640065",
|
134
|
+
name: "数字乡村",
|
135
|
+
sort: "3",
|
136
|
+
tenantId: "1514528042264793089",
|
137
|
+
createBy: "舒浪",
|
138
|
+
createTime: 1669776705000,
|
139
|
+
updateBy: null,
|
140
|
+
updateTime: null
|
141
|
+
},
|
142
|
+
{
|
143
|
+
id: "1597885800635691009",
|
144
|
+
name: "测试分类啊啊啊",
|
145
|
+
sort: "0",
|
146
|
+
tenantId: "1514528042264793089",
|
147
|
+
createBy: "舒浪",
|
148
|
+
createTime: 1669800637000,
|
149
|
+
updateBy: null,
|
150
|
+
updateTime: null
|
151
|
+
},
|
152
|
+
{
|
153
|
+
id: "1597886150885240833",
|
154
|
+
name: "123123123",
|
155
|
+
sort: "0",
|
156
|
+
tenantId: "1514528042264793089",
|
157
|
+
createBy: "舒浪",
|
158
|
+
createTime: 1669800720000,
|
159
|
+
updateBy: null,
|
160
|
+
updateTime: null
|
161
|
+
},
|
162
|
+
{
|
163
|
+
id: "1597886566523990017",
|
164
|
+
name: "2222",
|
165
|
+
sort: "0",
|
166
|
+
tenantId: "1514528042264793089",
|
167
|
+
createBy: "舒浪",
|
168
|
+
createTime: 1669800819000,
|
169
|
+
updateBy: null,
|
170
|
+
updateTime: null
|
171
|
+
}
|
172
|
+
]
|
126
173
|
}
|
127
|
-
}
|
174
|
+
};
|
128
175
|
},
|
129
176
|
created() {
|
130
|
-
this.axios = Axios.init(this.apiConfig);
|
131
|
-
},
|
132
|
-
mounted() {
|
133
177
|
this.initConfig();
|
134
178
|
},
|
179
|
+
mounted() {},
|
135
180
|
methods: {
|
181
|
+
// 初始化组件配置
|
136
182
|
initConfig() {
|
183
|
+
this.axios = Axios.init(this.config);
|
184
|
+
const info = sessionStorage.getItem("th_oauth_info");
|
185
|
+
if (info) {
|
186
|
+
const code = this.$route.params.id;
|
187
|
+
this.requestConfigData(code);
|
188
|
+
} else {
|
189
|
+
// 模拟授权认证流程
|
190
|
+
this.axios({
|
191
|
+
url: this.config.network.url,
|
192
|
+
method: this.config.network.method,
|
193
|
+
data: this.config.network.params,
|
194
|
+
headers: this.config.network.headers
|
195
|
+
}).then(res => {
|
196
|
+
const oauthInfo = { token: res.data };
|
197
|
+
sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
|
198
|
+
const code = this.$route.params.id;
|
199
|
+
this.requestConfigData(code);
|
200
|
+
});
|
201
|
+
}
|
202
|
+
},
|
203
|
+
// 获取配置信息
|
204
|
+
requestConfigData(code) {
|
205
|
+
this.tableJson = tableItemConfig(code);
|
137
206
|
// 网络请求
|
138
|
-
this.
|
207
|
+
this.networkConfig = this.tableJson.network;
|
139
208
|
|
140
209
|
// 搜索栏
|
141
210
|
this.searchConfig = this.tableJson.search;
|
@@ -162,8 +231,7 @@ export default {
|
|
162
231
|
if (!element.show) continue;
|
163
232
|
if (key === "batchDelete") {
|
164
233
|
this.tableJson.table.options.unshift({
|
165
|
-
type: "selection"
|
166
|
-
label: ""
|
234
|
+
type: "selection"
|
167
235
|
});
|
168
236
|
}
|
169
237
|
const dic = toolsItemConfig(key, element);
|
@@ -184,9 +252,9 @@ export default {
|
|
184
252
|
this.requestListData();
|
185
253
|
},
|
186
254
|
requestListData() {
|
187
|
-
if (!this.
|
255
|
+
if (!this.networkConfig.mounted) return;
|
188
256
|
this.tableConfig.loading.show = true;
|
189
|
-
const apiInfo = this.
|
257
|
+
const apiInfo = this.networkConfig.mounted;
|
190
258
|
const params = {
|
191
259
|
current: this.tableConfig.pageInfo.options.currentPage,
|
192
260
|
size: this.tableConfig.pageInfo.options.pageSize,
|
@@ -208,9 +276,9 @@ export default {
|
|
208
276
|
});
|
209
277
|
},
|
210
278
|
requestAddData(data) {
|
211
|
-
if (!this.
|
279
|
+
if (!this.networkConfig.add) return;
|
212
280
|
this.dialog.action.loading = true;
|
213
|
-
const apiInfo = this.
|
281
|
+
const apiInfo = this.networkConfig.add;
|
214
282
|
this.axios({
|
215
283
|
url: apiInfo.api,
|
216
284
|
method: apiInfo.method,
|
@@ -225,9 +293,9 @@ export default {
|
|
225
293
|
});
|
226
294
|
},
|
227
295
|
requestEditData(data) {
|
228
|
-
if (!this.
|
296
|
+
if (!this.networkConfig.edit) return;
|
229
297
|
this.dialog.action.loading = true;
|
230
|
-
const apiInfo = this.
|
298
|
+
const apiInfo = this.networkConfig.edit;
|
231
299
|
this.axios({
|
232
300
|
url: apiInfo.api,
|
233
301
|
method: apiInfo.method,
|
@@ -242,9 +310,9 @@ export default {
|
|
242
310
|
});
|
243
311
|
},
|
244
312
|
requestDeleteData(data, callback) {
|
245
|
-
if (!this.
|
313
|
+
if (!this.networkConfig.delete) return;
|
246
314
|
this.dialog.action.loading = true;
|
247
|
-
const apiInfo = this.
|
315
|
+
const apiInfo = this.networkConfig.delete;
|
248
316
|
this.axios({
|
249
317
|
url: apiInfo.api,
|
250
318
|
method: apiInfo.method,
|
@@ -272,6 +340,7 @@ export default {
|
|
272
340
|
},
|
273
341
|
handleSearchReset(val) {
|
274
342
|
console.log("handleSearchReset =>", val);
|
343
|
+
this.requestListData();
|
275
344
|
},
|
276
345
|
handleToolsClick(action) {
|
277
346
|
console.log("handleToolsClick =>", action);
|
@@ -305,7 +374,7 @@ export default {
|
|
305
374
|
},
|
306
375
|
handlePagingChange(val) {
|
307
376
|
console.log("handlePagingChange =>", val);
|
308
|
-
this.requestListData()
|
377
|
+
this.requestListData();
|
309
378
|
},
|
310
379
|
handleSelectionChange(val) {
|
311
380
|
console.log("handleSelectionChange =>", val);
|
@@ -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,21 +1,23 @@
|
|
1
1
|
import axios from "axios";
|
2
|
+
import Log from "./Log";
|
2
3
|
import { Notification } from "element-ui";
|
3
4
|
|
4
5
|
export const init = baseConfig => {
|
5
6
|
// 创建axios实例
|
6
7
|
const Axios = axios.create({
|
7
8
|
baseURL: baseConfig.baseUrl,
|
8
|
-
timeout:
|
9
|
+
timeout: 60000 // 请求超时时间
|
9
10
|
// withCredentials: true, //允许携带cookie
|
10
11
|
});
|
11
12
|
|
12
13
|
// 添加请求拦截器
|
13
14
|
Axios.interceptors.request.use(
|
14
15
|
config => {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
const info = sessionStorage.getItem("th_oauth_info");
|
17
|
+
if (info) {
|
18
|
+
const token = JSON.parse(info).token;
|
19
|
+
config.headers["Authorization"] = token;
|
20
|
+
}
|
19
21
|
return config;
|
20
22
|
},
|
21
23
|
error => {
|
@@ -44,12 +46,9 @@ export const init = baseConfig => {
|
|
44
46
|
return Promise.reject("error");
|
45
47
|
}
|
46
48
|
|
47
|
-
if (baseConfig.
|
48
|
-
|
49
|
-
|
50
|
-
console.log(response.request.responseURL);
|
51
|
-
console.log("request res =>", response);
|
52
|
-
console.log("\n");
|
49
|
+
if (baseConfig.debug) {
|
50
|
+
Log.prettyPrimary("Request Url:", response.request.responseURL);
|
51
|
+
Log.prettySuccess("Request Res:", response);
|
53
52
|
}
|
54
53
|
|
55
54
|
return response.data;
|