tianheng-ui 0.0.84 → 0.0.86

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.0.84",
4
+ "version": "0.0.86",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -64,6 +64,11 @@
64
64
  </el-option>
65
65
  </el-option-group>
66
66
  </el-select>
67
+ <!-- <el-input
68
+ v-model="widget.options.remoteFunc"
69
+ placeholder="请输入远端方法"
70
+ >
71
+ </el-input> -->
67
72
 
68
73
  <el-input v-model="widget.options.props.value">
69
74
  <template slot="prepend">
@@ -396,7 +396,6 @@ export default {
396
396
  GenerateForm
397
397
  },
398
398
  props: {
399
- formName: String,
400
399
  data: {
401
400
  type: Object,
402
401
  default: () => {
@@ -531,6 +530,9 @@ export default {
531
530
  }
532
531
  },
533
532
  data(val) {
533
+ if (val && val.config) {
534
+ val.config = Object.assign(this.widgetFormData.config, val.config);
535
+ }
534
536
  this.setJSON(val);
535
537
  }
536
538
  },
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div>
2
+ <div v-if="tableJson">
3
3
  <!-- 搜索栏 -->
4
4
  <search
5
5
  v-if="searchConfig.show"
@@ -73,6 +73,12 @@
73
73
  </th-form-generate>
74
74
  </th-dialog>
75
75
  </div>
76
+ <th-empty
77
+ v-else
78
+ :image="require('@/assets/images/notData.png')"
79
+ description="未获取到配置信息,请联系管理员。"
80
+ >
81
+ </th-empty>
76
82
  </template>
77
83
 
78
84
  <script>
@@ -96,6 +102,7 @@ export default {
96
102
  },
97
103
  data() {
98
104
  return {
105
+ id: "",
99
106
  tableJson: {},
100
107
  axios: null,
101
108
  networkConfig: {},
@@ -174,6 +181,8 @@ export default {
174
181
  };
175
182
  },
176
183
  created() {
184
+ const code = this.$route.path.split("/").pop();
185
+ this.id = code;
177
186
  this.initConfig();
178
187
  },
179
188
  mounted() {},
@@ -183,9 +192,15 @@ export default {
183
192
  this.axios = Axios.init(this.config);
184
193
  const info = sessionStorage.getItem("th_oauth_info");
185
194
  if (info) {
186
- const code = this.$route.params.id;
187
- this.requestConfigData(code);
188
- } else {
195
+ this.requestConfigData();
196
+ } else if (this.config.token) {
197
+ const oauthInfo = {
198
+ token: this.config.token,
199
+ baseUrl: this.config.baseUrl
200
+ };
201
+ sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
202
+ this.requestConfigData();
203
+ } else if (this.config.network) {
189
204
  // 模拟授权认证流程
190
205
  this.axios({
191
206
  url: this.config.network.url,
@@ -193,16 +208,19 @@ export default {
193
208
  data: this.config.network.params,
194
209
  headers: this.config.network.headers
195
210
  }).then(res => {
196
- const oauthInfo = { token: res.data, baseUrl: "" };
211
+ const oauthInfo = { token: res.data, baseUrl: this.config.baseUrl };
197
212
  sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
198
- const code = this.$route.params.id;
199
- this.requestConfigData(code);
213
+ // this.axios.defaults.baseURL = this.config.baseUrl;
214
+ this.requestConfigData();
200
215
  });
201
216
  }
202
217
  },
203
218
  // 获取配置信息
204
- requestConfigData(code) {
205
- this.tableJson = tableItemConfig(code);
219
+ requestConfigData() {
220
+ this.tableJson = tableItemConfig(this.id);
221
+ if (!this.tableJson) {
222
+ return;
223
+ }
206
224
  // 网络请求
207
225
  this.networkConfig = this.tableJson.network;
208
226
 
@@ -309,14 +327,14 @@ export default {
309
327
  this.dialog.action.loading = false;
310
328
  });
311
329
  },
312
- requestDeleteData(data, callback) {
330
+ requestDeleteData(callback) {
313
331
  if (!this.networkConfig.delete) return;
314
332
  this.dialog.action.loading = true;
315
333
  const apiInfo = this.networkConfig.delete;
316
334
  this.axios({
317
335
  url: apiInfo.api,
318
336
  method: apiInfo.method,
319
- data
337
+ data: { ids: this.dialog.data.id }
320
338
  })
321
339
  .then(res => {
322
340
  callback(true);
@@ -327,6 +345,36 @@ export default {
327
345
  this.dialog.action.loading = false;
328
346
  });
329
347
  },
348
+ requestBatchDeleteData() {
349
+ if (!this.networkConfig.batchDelete) return;
350
+ this.$confirm("确认删除多条数据吗?", "操作提示", {
351
+ confirmButtonText: "删除",
352
+ cancelButtonText: "取消",
353
+ type: "warning"
354
+ })
355
+ .then(() => {
356
+ this.dialog.action.loading = true;
357
+ const data = [];
358
+ for (const item of this.tableSelectionData) {
359
+ data.push(item.id);
360
+ }
361
+ const apiInfo = this.networkConfig.batchDelete;
362
+ this.axios({
363
+ url: apiInfo.api,
364
+ method: apiInfo.method,
365
+ data
366
+ })
367
+ .then(res => {
368
+ callback(true);
369
+ this.dialog.action.loading = false;
370
+ this.requestListData();
371
+ })
372
+ .catch(err => {
373
+ this.dialog.action.loading = false;
374
+ });
375
+ })
376
+ .catch(() => {});
377
+ },
330
378
  requestFormConfigData() {
331
379
  setTimeout(() => {
332
380
  const form = this.dialog.action.form;
@@ -335,11 +383,9 @@ export default {
335
383
  }, 1000);
336
384
  },
337
385
  handleSearchSubmit(val) {
338
- console.log("handleSearchSubmit =>", val);
339
386
  this.requestListData();
340
387
  },
341
388
  handleSearchReset(val) {
342
- console.log("handleSearchReset =>", val);
343
389
  this.requestListData();
344
390
  },
345
391
  handleToolsClick(action) {
@@ -350,12 +396,8 @@ export default {
350
396
  this.requestFormConfigData();
351
397
  break;
352
398
  case "batchDelete":
353
- action.loading = true;
354
- setTimeout(() => {
355
- action.loading = false;
356
- this.tableSelectionData = [];
357
- this.$refs.tableRef.getTable().clearSelection();
358
- }, 1000);
399
+ this.dialog = { show: false, data: {}, action: action };
400
+ this.requestBatchDeleteData();
359
401
  break;
360
402
  case "export":
361
403
  action.loading = true;
@@ -384,7 +426,8 @@ export default {
384
426
  this.requestFormConfigData();
385
427
  break;
386
428
  case "delete":
387
- this.requestDeleteData({ ids: item.id }, callback);
429
+ this.dialog = { show: false, data: item, action: action };
430
+ this.requestDeleteData(callback);
388
431
  break;
389
432
 
390
433
  default:
@@ -414,11 +457,9 @@ export default {
414
457
  this.formConfig = null;
415
458
  },
416
459
  handlePagingChange(val) {
417
- console.log("handlePagingChange =>", val);
418
460
  this.requestListData();
419
461
  },
420
462
  handleSelectionChange(val) {
421
- console.log("handleSelectionChange =>", val);
422
463
  this.tableSelectionData = val;
423
464
  }
424
465
  }
@@ -223,7 +223,8 @@ const formConfig = {
223
223
  }
224
224
  ]
225
225
  }
226
- }
226
+ },
227
+ '2':{}
227
228
  };
228
229
 
229
230
  export const formItemConfig = key => {
@@ -426,6 +427,6 @@ const tableConfig = {
426
427
  };
427
428
 
428
429
  export const tableItemConfig = key => {
429
- const config = tableConfig[key] || {};
430
+ const config = tableConfig[key] || null;
430
431
  return JSON.parse(JSON.stringify(config));
431
432
  };