tianheng-ui 0.1.51 → 0.1.53

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.1.51",
4
+ "version": "0.1.53",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -218,6 +218,7 @@ export default {
218
218
  }
219
219
  this.hendleElementRemoteData(item);
220
220
  },
221
+ // 获取组件的远端数据
221
222
  hendleElementRemoteData(item) {
222
223
  if (!item.options.remote) return;
223
224
  if (item.type === "upload" || item.type === "button") return;
@@ -229,17 +230,17 @@ export default {
229
230
  method: api.method,
230
231
  headers: api.headers
231
232
  };
233
+
234
+ // 因为是组件的远端接口,优先级:默认值 > 路由参数
232
235
  const params = {};
233
236
  for (let e of api.inParams) {
234
237
  const value =
235
- getProperty(this.models, e.pAlias) ||
236
- getProperty(this.query, e.pAlias) ||
237
- null;
238
- setProperty(params, e.pAlias, value);
238
+ e.defaultValue || getProperty(this.query, e.alias) || null;
239
+ setProperty(params, e.alias, value);
239
240
  }
240
241
  if (api.needPage) {
241
- params.pageNum = 1;
242
- params.pageSize = 20;
242
+ params.pageNum = params.pageNum || 1;
243
+ params.pageSize = params.pageSize || 20;
243
244
  }
244
245
  if (["get", "delete"].includes(api.method.toLowerCase()))
245
246
  requestConfig.params = params;
@@ -271,12 +272,6 @@ export default {
271
272
  const api = this.formConfig.config.network[val];
272
273
  if (!api) return this.$message.warning("未知的接口,请检查配置信息");
273
274
 
274
- const requestConfig = {
275
- url: api.url,
276
- method: api.method,
277
- headers: api.headers
278
- };
279
-
280
275
  let params = {};
281
276
  const inParams = api.inParams;
282
277
  const initParams = list => {
@@ -290,11 +285,16 @@ export default {
290
285
  });
291
286
  };
292
287
  initParams(inParams);
293
-
294
288
  if (api.needPage) {
295
- params.pageNum = 1;
296
- params.pageSize = 20;
289
+ params.pageNum = params.pageNum || 1;
290
+ params.pageSize = params.pageNum || 20;
297
291
  }
292
+
293
+ const requestConfig = {
294
+ url: api.url,
295
+ method: api.method,
296
+ headers: api.headers
297
+ };
298
298
  if (["get", "delete"].includes(api.method.toLowerCase()))
299
299
  requestConfig.params = params;
300
300
  else requestConfig.data = params;
@@ -515,9 +515,9 @@ export default {
515
515
  "data.options.remoteFunc"(val) {
516
516
  this.handleFieldsApiChange(val);
517
517
  },
518
- apiOptions() {
519
- this.handleFieldsApiChange(this.config.fields.api, true);
520
- }
518
+ // apiOptions() {
519
+ // this.handleFieldsApiChange(this.config.fields.api, true);
520
+ // }
521
521
  },
522
522
  created() {
523
523
  this.activeTab = this.tabsMenus[1];
@@ -322,6 +322,19 @@ export default {
322
322
  }
323
323
  };
324
324
  initList(this.formConfig.list);
325
+
326
+ const initParams = (paramsList, pAlias, bool) => {
327
+ paramsList.forEach(item => {
328
+ if (bool) {
329
+ item.elType = "input";
330
+ item.align = "left";
331
+ }
332
+ item.pAlias = pAlias ? `${pAlias}.${item.alias}` : item.alias;
333
+ if (item.children && item.children.length) {
334
+ initParams(item.children, item.pAlias);
335
+ }
336
+ });
337
+ };
325
338
  const apis = Object.values(fieldsApi);
326
339
  const network = {};
327
340
  this.apiOptions.map(api => {
@@ -329,8 +342,10 @@ export default {
329
342
  // 初始化接口参数
330
343
  if (this.formConfig.config.fields.remote && isGetParams) {
331
344
  const callback = res => {
332
- api.inParams = res.inParams;
333
- api.outParams = res.outParams;
345
+ api.inParams = deepClone(res.inParams);
346
+ api.outParams = deepClone(res.outParams);
347
+ initParams(api.inParams, null, false);
348
+ initParams(api.outParams, null, false);
334
349
  };
335
350
  this.$emit("remote-params", api.id, callback);
336
351
  }
@@ -15,11 +15,13 @@ export const table = {
15
15
  pageInfo: {
16
16
  show: true,
17
17
  options: {
18
- pageCount: 0,
19
- pageSize: 20,
20
- currentPage: 1,
21
- total: 0,
22
- sizes: [10, 20, 50, 100],
18
+ pageCount: 0, //总页数
19
+ pageSize: 20, //每页条数
20
+ pageSizeName: "pageSize",
21
+ currentPage: 1, //当前页数
22
+ currentPageName: "pageNum",
23
+ total: 0, //总条数
24
+ sizes: [10, 20, 50, 100], //每页显示个数
23
25
  layout: "total,sizes,prev,pager,next,jumper"
24
26
  },
25
27
  style: {
@@ -404,8 +404,10 @@ export default {
404
404
  params[key] = paramsData[key] || this.query[key];
405
405
  }
406
406
  if (this.tableConfig.pageInfo.show) {
407
- params.current = this.tableConfig.pageInfo.options.currentPage;
408
- params.size = this.tableConfig.pageInfo.options.pageSize;
407
+ const pageInfo = this.tableConfig.pageInfo.options;
408
+ params[pageInfo.currentPageName || "pageNum"] =
409
+ pageInfo.currentPage;
410
+ params[pageInfo.pageSizeName || "pageSize"] = pageInfo.pageSize;
409
411
  }
410
412
  break;
411
413
  case "add":
@@ -111,13 +111,13 @@ export default {
111
111
  this.apiOptions.map(api => {
112
112
  if (apis.includes(api.id)) {
113
113
  // 初始化接口参数
114
- if (this.tableConfig.table.fields.remote) {
115
- const callback = res => {
116
- api.inParams = res.inParams;
117
- api.outParams = res.outParams;
118
- };
119
- this.$emit("remote-params", api.id, callback);
120
- }
114
+ // if (this.tableConfig.table.fields.remote) {
115
+ // const callback = res => {
116
+ // api.inParams = res.inParams;
117
+ // api.outParams = res.outParams;
118
+ // };
119
+ // this.$emit("remote-params", api.id, callback);
120
+ // }
121
121
  network[api.id] = api;
122
122
  }
123
123
  });
@@ -174,6 +174,14 @@
174
174
  >
175
175
  </el-radio-group>
176
176
  </el-form-item>
177
+ <el-form-item label="分页参数">
178
+ <el-input placeholder="请输入" v-model="config.table.pageInfo.options.currentPageName">
179
+ <template slot="prepend">页码</template>
180
+ </el-input>
181
+ <el-input placeholder="请输入" v-model="config.table.pageInfo.options.pageSizeName">
182
+ <template slot="prepend">条数</template>
183
+ </el-input>
184
+ </el-form-item>
177
185
  <el-form-item>
178
186
  <el-tooltip slot="label" effect="light" placement="top">
179
187
  <div slot="content">
@@ -763,6 +771,15 @@ export default {
763
771
  },
764
772
  "config.tools.import.api"(val) {
765
773
  if (this.config.tools.import.show) this.handleFieldsApiChange(val);
774
+ },
775
+ apiOptions() {
776
+ if (this.config.table.mounted.api)
777
+ this.handleFieldsApiChange(this.config.table.mounted.api, true);
778
+
779
+ const toolsArr = Object.values(this.config.tools);
780
+ for (const item of toolsArr) {
781
+ if (item.api && item.show) this.handleFieldsApiChange(item.api);
782
+ }
766
783
  }
767
784
  },
768
785
  computed: {