tianheng-ui 0.1.43 → 0.1.45

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.
Files changed (58) hide show
  1. package/lib/tianheng-ui.js +13 -13
  2. package/package.json +1 -1
  3. package/packages/FormMaking/GenerateForm.vue +93 -84
  4. package/packages/FormMaking/GenerateFormItem.vue +40 -130
  5. package/packages/FormMaking/WidgetConfig.vue +123 -59
  6. package/packages/FormMaking/WidgetFormItem.vue +1 -1
  7. package/packages/FormMaking/WidgetTools.vue +34 -9
  8. package/packages/FormMaking/custom/config.js +6 -2
  9. package/packages/FormMaking/custom/configs/button.vue +2 -2
  10. package/packages/FormMaking/custom/configs/cascader.vue +2 -2
  11. package/packages/FormMaking/custom/configs/checkbox.vue +2 -2
  12. package/packages/FormMaking/custom/configs/grid.vue +12 -0
  13. package/packages/FormMaking/custom/configs/list.vue +18 -0
  14. package/packages/FormMaking/custom/configs/radio.vue +2 -2
  15. package/packages/FormMaking/custom/configs/select.vue +2 -2
  16. package/packages/FormMaking/custom/configs/tabs.vue +2 -2
  17. package/packages/FormMaking/custom/configs/upload.vue +2 -2
  18. package/packages/FormMaking/custom/items/alliance.vue +2 -2
  19. package/packages/FormMaking/custom/items/blank_dev.vue +2 -2
  20. package/packages/FormMaking/custom/items/blank_pro.vue +2 -2
  21. package/packages/FormMaking/custom/items/button.vue +2 -2
  22. package/packages/FormMaking/custom/items/cascader.vue +2 -2
  23. package/packages/FormMaking/custom/items/cell.vue +2 -2
  24. package/packages/FormMaking/custom/items/checkbox.vue +2 -2
  25. package/packages/FormMaking/custom/items/color.vue +2 -2
  26. package/packages/FormMaking/custom/items/date.vue +2 -2
  27. package/packages/FormMaking/custom/items/divider.vue +2 -2
  28. package/packages/FormMaking/custom/items/editor.vue +2 -2
  29. package/packages/FormMaking/custom/items/filler.vue +2 -2
  30. package/packages/FormMaking/custom/items/grid_dev.vue +2 -2
  31. package/packages/FormMaking/custom/items/grid_pro.vue +18 -4
  32. package/packages/FormMaking/custom/items/image.vue +2 -2
  33. package/packages/FormMaking/custom/items/input.vue +2 -2
  34. package/packages/FormMaking/custom/items/list_dev.vue +2 -2
  35. package/packages/FormMaking/custom/items/number.vue +2 -2
  36. package/packages/FormMaking/custom/items/radio.vue +2 -2
  37. package/packages/FormMaking/custom/items/rate.vue +2 -2
  38. package/packages/FormMaking/custom/items/select.vue +2 -2
  39. package/packages/FormMaking/custom/items/slider.vue +2 -2
  40. package/packages/FormMaking/custom/items/switch.vue +2 -2
  41. package/packages/FormMaking/custom/items/tableH5_dev.vue +2 -2
  42. package/packages/FormMaking/custom/items/tableH5_pro.vue +26 -18
  43. package/packages/FormMaking/custom/items/table_dev.vue +2 -2
  44. package/packages/FormMaking/custom/items/table_pro.vue +10 -5
  45. package/packages/FormMaking/custom/items/tabs_dev.vue +2 -2
  46. package/packages/FormMaking/custom/items/tabs_pro.vue +14 -9
  47. package/packages/FormMaking/custom/items/text.vue +2 -2
  48. package/packages/FormMaking/custom/items/textarea.vue +2 -2
  49. package/packages/FormMaking/custom/items/time.vue +2 -2
  50. package/packages/FormMaking/custom/items/upload.vue +2 -2
  51. package/packages/FormMaking/custom/mixins/index.js +69 -13
  52. package/packages/FormMaking/index.vue +62 -57
  53. package/packages/TableMaking/custom/config.js +4 -1
  54. package/packages/TableMaking/custom/items/table/index-h5.vue +21 -30
  55. package/packages/TableMaking/custom/items/table/index-pc.vue +3 -3
  56. package/packages/TableMaking/index.vue +44 -6
  57. package/packages/TableMaking/widgetConfig.vue +99 -49
  58. package/packages/TableMaking/widgetTable.vue +4 -4
@@ -111,7 +111,6 @@
111
111
  :basicComponents="basicComponents"
112
112
  :layoutComponents="layoutComponents"
113
113
  :formData="formConfig"
114
- :formValue="widgetValue"
115
114
  :oauthConfig="oauthConfig"
116
115
  :apiOptions="apiOptions"
117
116
  @click="handleWidgetToolsChange"
@@ -133,10 +132,8 @@
133
132
  <widget-config
134
133
  :data="widgetFormSelect"
135
134
  :config="formConfig.config"
136
- :fields="fields"
137
- :apiConfig="apiConfig"
135
+ :apiOptions="apiOptions"
138
136
  ref="configRef"
139
- @fieldsChange="handleFieldsChange"
140
137
  @update="handleWidgetConfigUpdate"
141
138
  >
142
139
  </widget-config>
@@ -229,9 +226,7 @@ export default {
229
226
  return {
230
227
  formConfig: this.baseConfig,
231
228
  widgetFormSelect: {},
232
- widgetValue: {},
233
229
  configTab: "form",
234
- fields: [],
235
230
  apiConfig: {},
236
231
  collapseValue: ["group-basic", "group-advance", "group-layout"]
237
232
  };
@@ -265,11 +260,10 @@ export default {
265
260
  },
266
261
  config(val) {
267
262
  this.setConfig(val);
268
- this.initApiConfig();
263
+ this.handleNetworkConfig();
269
264
  },
270
265
  apiOptions(val) {
271
- this.initApiConfig();
272
- this.handleFieldsChange();
266
+ this.handleNetworkConfig();
273
267
  }
274
268
  },
275
269
  created() {
@@ -283,7 +277,7 @@ export default {
283
277
  }
284
278
  },
285
279
  mounted() {
286
- this.initApiConfig();
280
+ this.handleNetworkConfig();
287
281
  },
288
282
  methods: {
289
283
  // 初始化组件配置
@@ -310,14 +304,35 @@ export default {
310
304
  });
311
305
  }
312
306
  },
313
- initApiConfig() {
314
- this.apiConfig = {};
315
- if (this.apiOptions.length) {
316
- this.apiOptions.map(item => {
317
- this.apiConfig[item.id] = item;
318
- });
307
+ handleNetworkConfig() {
308
+ if (!this.apiOptions.length || !this.formConfig.config) {
309
+ this.formConfig.config.network = {};
310
+ return;
319
311
  }
320
- this.formConfig.config.network = this.apiConfig;
312
+ const fieldsApi = {
313
+ fields: this.formConfig.config.fields.api,
314
+ mounted: this.formConfig.config.mounted.api
315
+ };
316
+ const initList = list => {
317
+ for (const item of list) {
318
+ if (item.type === "grid" || item.type === "tabs") {
319
+ item.options.columns.forEach(e => {
320
+ initList(e.list);
321
+ });
322
+ } else if (item.type === "table" || item.type === "tableH5") {
323
+ initList(item.options.columns);
324
+ } else if (item.options.remote) {
325
+ fieldsApi[item.model] = item.options.remoteFunc;
326
+ }
327
+ }
328
+ };
329
+ initList(this.formConfig.list);
330
+ const apis = Object.values(fieldsApi);
331
+ const network = {};
332
+ this.apiOptions.map(item => {
333
+ if (apis.includes(item.id)) network[item.id] = item;
334
+ });
335
+ this.formConfig.config.network = network;
321
336
  },
322
337
 
323
338
  handleConfigSelect(value) {
@@ -329,6 +344,7 @@ export default {
329
344
  this.widgetFormSelect = {};
330
345
  },
331
346
  handleWidgetToolsChange(val, data) {
347
+ console.log(val, data);
332
348
  switch (val) {
333
349
  case "import-excel":
334
350
  case "import-json":
@@ -345,55 +361,46 @@ export default {
345
361
  handleWidgetConfigUpdate(val) {
346
362
  this.widgetFormSelect = Object.assign(this.widgetFormSelect, val);
347
363
  },
348
- handleFieldsChange() {
349
- const data = this.apiConfig[this.formConfig.config.fieldsApi];
350
- if (data) {
351
- this.fields = data.paramsOut.map(item => {
352
- return {
353
- label: item.note || item.name,
354
- alias: item.name,
355
- prop: item.name,
356
- type: "input",
357
- align: "left"
358
- };
359
- });
360
- } else this.fields = [];
361
- },
362
364
  clear() {
363
365
  this.handleClear();
364
366
  },
365
367
  getConfig() {
368
+ const formValidate = () => {
369
+ if (!this.formConfig.config.fields.type) {
370
+ this.$message.warning("请选择字段类型");
371
+ return false;
372
+ }
373
+ if (
374
+ this.formConfig.config.fields.type === "api" &&
375
+ !this.formConfig.config.fields.api
376
+ ) {
377
+ this.$message.warning("请选择字段接口");
378
+ return false;
379
+ }
380
+ if (!this.formConfig.config.title) {
381
+ this.$message.warning("请填写表单标题");
382
+ return false;
383
+ }
384
+ return true;
385
+ };
366
386
  return new Promise((resolve, reject) =>
367
387
  this.$refs.configRef
368
388
  .formValidate()
369
389
  .then(res => {
370
390
  if (res) {
371
- const data = deepClone(this.formConfig);
372
- data.config.network = this.apiConfig;
373
- resolve(data);
374
- } else {
375
- reject();
376
- }
391
+ if (formValidate()) {
392
+ this.handleNetworkConfig();
393
+ const data = deepClone(this.formConfig);
394
+ resolve(data);
395
+ } else reject();
396
+ } else reject();
377
397
  })
378
398
  .catch(err => {
379
- if (!this.formConfig.config.fieldsType) {
380
- this.$message.warning("请选择字段类型");
381
- return reject();
382
- }
383
- if (
384
- this.formConfig.config.fieldsType === "fieldsApi" &&
385
- !this.formConfig.config.fieldsApi
386
- ) {
387
- this.$message.warning("请选择字段接口");
388
- return reject();
389
- }
390
- if (!this.formConfig.config.title) {
391
- this.$message.warning("请填写表单标题");
392
- return reject();
393
- }
394
- const data = deepClone(this.formConfig);
395
- data.config.network = this.apiConfig;
396
- resolve(data);
399
+ if (formValidate()) {
400
+ this.handleNetworkConfig();
401
+ const data = deepClone(this.formConfig);
402
+ resolve(data);
403
+ } else reject();
397
404
  })
398
405
  );
399
406
  },
@@ -406,8 +413,6 @@ export default {
406
413
  if (this.formConfig.list.length > 0) {
407
414
  this.widgetFormSelect = this.formConfig.list[0];
408
415
  }
409
-
410
- this.handleFieldsChange();
411
416
  }
412
417
  }
413
418
  };
@@ -6,7 +6,10 @@ export const search = {
6
6
 
7
7
  // 列表配置
8
8
  export const table = {
9
- fieldsType: "fieldsApi",
9
+ fields: {
10
+ type: "api",
11
+ remote: false
12
+ },
10
13
  mounted: { api: "" },
11
14
  options: [],
12
15
  pageInfo: {
@@ -57,48 +57,21 @@ export default {
57
57
  return [];
58
58
  },
59
59
  cellStyle() {
60
- let styleText = "";
61
60
  if (this.config.style) {
62
61
  const style = this.config.style.cell || {};
63
- const keys = Object.keys(style).filter(key => {
64
- return key !== "customStyle";
65
- });
66
- for (let key of keys) {
67
- styleText += `${key}: ${style[key]};`;
68
- }
69
- styleText += style.customStyle;
70
- styleText = styleText.replace(/rpx/g, "px");
71
- return styleText;
62
+ return this.initStyle(style);
72
63
  }
73
64
  },
74
65
  titleStyle() {
75
- let styleText = "";
76
66
  if (this.config.style) {
77
67
  const style = this.config.style.title || {};
78
- const keys = Object.keys(style).filter(key => {
79
- return key !== "customStyle";
80
- });
81
- for (let key of keys) {
82
- styleText += `${key}: ${style[key]};`;
83
- }
84
- styleText += style.customStyle;
85
- styleText = styleText.replace(/rpx/g, "px");
86
- return styleText;
68
+ return this.initStyle(style);
87
69
  }
88
70
  },
89
71
  valueStyle() {
90
- let styleText = "";
91
72
  if (this.config.style) {
92
73
  const style = this.config.style.value || {};
93
- const keys = Object.keys(style).filter(key => {
94
- return key !== "customStyle";
95
- });
96
- for (let key of keys) {
97
- styleText += `${key}: ${style[key]};`;
98
- }
99
- styleText += style.customStyle;
100
- styleText = styleText.replace(/rpx/g, "px");
101
- return styleText;
74
+ return this.initStyle(style);
102
75
  }
103
76
  }
104
77
  },
@@ -109,6 +82,24 @@ export default {
109
82
  },
110
83
  handleActionClick(action, item) {
111
84
  this.$emit("action", action, item);
85
+ },
86
+ initStyle(style) {
87
+ let styleText = "";
88
+ let customStyle = "";
89
+ for (let key of Object.keys(style)) {
90
+ const value = style[key];
91
+ if (!value) continue;
92
+ if (key === "customStyle") {
93
+ customStyle = value.replace(/{/g, "");
94
+ customStyle = customStyle.replace(/}/g, "");
95
+ customStyle = customStyle.replace(/\/n/g, "");
96
+ } else {
97
+ styleText += `${key}: ${value};`;
98
+ }
99
+ }
100
+ if (customStyle) styleText += customStyle;
101
+ styleText = styleText.replace(/rpx/g, "px");
102
+ return styleText;
112
103
  }
113
104
  }
114
105
  };
@@ -20,8 +20,8 @@
20
20
  </el-table-column>
21
21
  <el-table-column
22
22
  v-else
23
- :key="item.pProp"
24
- :prop="item.pProp"
23
+ :key="item.pAlias"
24
+ :prop="item.pAlias"
25
25
  :label="item.label"
26
26
  :width="item.width"
27
27
  >
@@ -32,7 +32,7 @@
32
32
  :scope="scope"
33
33
  :option="item"
34
34
  />
35
- <span v-else>{{ getValue(scope.row, item.pProp) }}</span>
35
+ <span v-else>{{ getValue(scope.row, item.pAlias) }}</span>
36
36
  </template>
37
37
  </el-table-column>
38
38
  </template>
@@ -19,6 +19,7 @@
19
19
  :config="tableConfig"
20
20
  :formOptions="formOptions"
21
21
  :apiOptions="apiOptions"
22
+ @remote-params="handleRemoteParams"
22
23
  ref="configRef"
23
24
  ></widget-config>
24
25
  </div>
@@ -87,17 +88,41 @@ export default {
87
88
  };
88
89
  },
89
90
  watch: {
91
+ apiOptions(val) {
92
+ this.handleNetwork();
93
+ },
94
+ config(val) {
95
+ this.tableConfig = Object.assign(this.baseConfig, val);
96
+ this.handleNetwork();
97
+ },
90
98
  tableConfig: {
91
99
  deep: true,
92
100
  handler: function(val) {
93
101
  this.$emit("update:config", val);
94
102
  }
95
103
  },
96
- config(val) {
97
- this.tableConfig = Object.assign(this.baseConfig, val);
104
+ "tableConfig.table.mounted.api"(val) {
98
105
  this.handleNetwork();
99
106
  },
100
- apiOptions(val) {
107
+ "tableConfig.tools.add.api"(val) {
108
+ this.handleNetwork();
109
+ },
110
+ "tableConfig.tools.edit.api"(val) {
111
+ this.handleNetwork();
112
+ },
113
+ "tableConfig.tools.look.api"(val) {
114
+ this.handleNetwork();
115
+ },
116
+ "tableConfig.tools.delete.api"(val) {
117
+ this.handleNetwork();
118
+ },
119
+ "tableConfig.tools.batchDelete.api"(val) {
120
+ this.handleNetwork();
121
+ },
122
+ "tableConfig.tools.export.api"(val) {
123
+ this.handleNetwork();
124
+ },
125
+ "tableConfig.tools.import.api"(val) {
101
126
  this.handleNetwork();
102
127
  }
103
128
  },
@@ -106,9 +131,19 @@ export default {
106
131
  },
107
132
  methods: {
108
133
  handleNetwork() {
134
+ const apis = [];
135
+ if (this.tableConfig.table.mounted.api)
136
+ apis.push(this.tableConfig.table.mounted.api);
137
+ const toolsArr = Object.values(this.tableConfig.tools);
138
+ for (const item of toolsArr) {
139
+ if (item.api) apis.push(item.api);
140
+ }
141
+
109
142
  const network = {};
110
143
  this.apiOptions.map(item => {
111
- network[item.id] = item;
144
+ if (apis.includes(item.id)) {
145
+ network[item.id] = item;
146
+ }
112
147
  });
113
148
  this.tableConfig.network = network;
114
149
  },
@@ -126,6 +161,9 @@ export default {
126
161
  break;
127
162
  }
128
163
  },
164
+ handleRemoteParams(val, callback) {
165
+ this.$emit("remote-params", val, callback);
166
+ },
129
167
  getConfig() {
130
168
  return new Promise((resolve, reject) =>
131
169
  this.$refs.configRef
@@ -139,12 +177,12 @@ export default {
139
177
  }
140
178
  })
141
179
  .catch(err => {
142
- if (!this.tableConfig.table.fieldsType) {
180
+ if (!this.tableConfig.table.fields.type) {
143
181
  this.$message.warning("请选择字段表");
144
182
  return reject();
145
183
  }
146
184
  if (
147
- this.tableConfig.table.fieldsType === "fieldsApi" &&
185
+ this.tableConfig.table.fields.type === "api" &&
148
186
  !this.tableConfig.table.mounted.api
149
187
  ) {
150
188
  this.$message.warning("请选择列表接口");
@@ -23,7 +23,7 @@
23
23
  node-key="key"
24
24
  :default-expand-all="true"
25
25
  :check-strictly="true"
26
- :props="{ label: 'label', value: 'prop' }"
26
+ :props="{ label: 'label', value: 'alias' }"
27
27
  @check-change="handleTreeCheckChange('search')"
28
28
  >
29
29
  </el-tree>
@@ -37,7 +37,7 @@
37
37
  node-key="key"
38
38
  :default-expand-all="true"
39
39
  :check-strictly="true"
40
- :props="{ label: 'label', value: 'prop' }"
40
+ :props="{ label: 'label', value: 'alias' }"
41
41
  @check-change="handleTreeCheckChange('table')"
42
42
  >
43
43
  </el-tree>
@@ -57,7 +57,7 @@
57
57
  >
58
58
  <el-collapse v-model="collapseValue">
59
59
  <el-collapse-item title="列表配置" name="group-table">
60
- <el-form-item required prop="table.fieldsType">
60
+ <el-form-item required prop="table.fields.type">
61
61
  <el-tooltip
62
62
  slot="label"
63
63
  effect="light"
@@ -66,13 +66,25 @@
66
66
  >
67
67
  <span style="color: #409EFF;">字段类型</span>
68
68
  </el-tooltip>
69
- <el-radio-group v-model="config.table.fieldsType">
69
+ <el-radio-group v-model="config.table.fields.type">
70
70
  <el-radio-button label="custom" disabled
71
71
  >自定义</el-radio-button
72
72
  >
73
- <el-radio-button label="fieldsApi">接口导入</el-radio-button>
74
- </el-radio-group> </el-form-item
75
- ><el-form-item required prop="table.mounted.api">
73
+ <el-radio-button label="api">接口导入</el-radio-button>
74
+ </el-radio-group>
75
+ </el-form-item>
76
+ <el-form-item>
77
+ <el-tooltip
78
+ slot="label"
79
+ effect="light"
80
+ content="开启后,列表接口值修改,会触发 remote-params 回调,用于从服务器查询字段,"
81
+ placement="top"
82
+ >
83
+ <span style="color: #409EFF;">远程字段</span>
84
+ </el-tooltip>
85
+ <el-switch v-model="config.table.fields.remote"> </el-switch>
86
+ </el-form-item>
87
+ <el-form-item required prop="table.mounted.api">
76
88
  <el-tooltip
77
89
  slot="label"
78
90
  effect="light"
@@ -87,12 +99,13 @@
87
99
  clearable
88
100
  placeholder="请选择"
89
101
  no-data-text="暂无接口,请前往【接口模块】创建"
102
+ filterable
90
103
  @change="handleFieldsApiChange"
91
104
  >
92
105
  <el-option
93
106
  v-for="item in apiOptions"
94
107
  :key="item.id"
95
- :label="item.label"
108
+ :label="item.name"
96
109
  :value="item.id"
97
110
  >
98
111
  </el-option>
@@ -126,7 +139,7 @@
126
139
  >
127
140
  <el-option
128
141
  v-for="item in config.table.options"
129
- :key="item.prop"
142
+ :key="item.alias"
130
143
  :label="item.label"
131
144
  :value="item.alias"
132
145
  >
@@ -340,14 +353,19 @@
340
353
  clearable
341
354
  ></el-input>
342
355
  </el-form-item>
343
- <el-form-item label="自定义">
344
- <el-input
356
+ <el-form-item label-width="0">
357
+ <el-tooltip effect="light" placement="top">
358
+ <div slot="content">
359
+ <div>样式编辑器,可编写css样式</div>
360
+ <div>示例:</div>
361
+ <div v-html="cssDemo"></div>
362
+ </div>
363
+ <span style="color: #409EFF;">css样式</span>
364
+ </el-tooltip>
365
+ <th-code-editor
345
366
  v-model="config.table.style.cell.customStyle"
346
- type="textarea"
347
- :rows="2"
348
- placeholder="请输入"
349
- >
350
- </el-input>
367
+ language="css"
368
+ ></th-code-editor>
351
369
  </el-form-item>
352
370
  </el-collapse-item>
353
371
  <el-collapse-item name="group-style_title">
@@ -397,14 +415,19 @@
397
415
  clearable
398
416
  ></el-input>
399
417
  </el-form-item>
400
- <el-form-item label="自定义">
401
- <el-input
418
+ <el-form-item label-width="0">
419
+ <el-tooltip effect="light" placement="top">
420
+ <div slot="content">
421
+ <div>样式编辑器,可编写css样式</div>
422
+ <div>示例:</div>
423
+ <div v-html="cssDemo"></div>
424
+ </div>
425
+ <span style="color: #409EFF;">css样式</span>
426
+ </el-tooltip>
427
+ <th-code-editor
402
428
  v-model="config.table.style.title.customStyle"
403
- type="textarea"
404
- :rows="2"
405
- placeholder="请输入"
406
- >
407
- </el-input>
429
+ language="css"
430
+ ></th-code-editor>
408
431
  </el-form-item>
409
432
  </el-collapse-item>
410
433
  <el-collapse-item name="group-style_value">
@@ -454,14 +477,19 @@
454
477
  clearable
455
478
  ></el-input>
456
479
  </el-form-item>
457
- <el-form-item label="自定义">
458
- <el-input
480
+ <el-form-item label-width="0">
481
+ <el-tooltip effect="light" placement="top">
482
+ <div slot="content">
483
+ <div>样式编辑器,可编写css样式</div>
484
+ <div>示例:</div>
485
+ <div v-html="cssDemo"></div>
486
+ </div>
487
+ <span style="color: #409EFF;">css样式</span>
488
+ </el-tooltip>
489
+ <th-code-editor
459
490
  v-model="config.table.style.value.customStyle"
460
- type="textarea"
461
- :rows="2"
462
- placeholder="请输入"
463
- >
464
- </el-input>
491
+ language="css"
492
+ ></th-code-editor>
465
493
  </el-form-item>
466
494
  </el-collapse-item>
467
495
  </el-collapse>
@@ -601,7 +629,7 @@
601
629
  <el-option
602
630
  v-for="item in apiOptions"
603
631
  :key="item.id"
604
- :label="item.label"
632
+ :label="item.name"
605
633
  :value="item.id"
606
634
  >
607
635
  </el-option>
@@ -669,32 +697,36 @@ export default {
669
697
  { label: "右对齐", value: "right" }
670
698
  ],
671
699
  formRules: {
672
- "table.fieldsType": [
700
+ "table.fields.type": [
673
701
  { required: true, message: "请选择字段类型", trigger: "change" }
674
702
  ],
675
- "table.fieldsApi": [
676
- { required: true, message: "请选择字段表", trigger: "change" }
703
+ "table.mounted.api": [
704
+ { required: true, message: "请选择列表接口", trigger: "change" }
677
705
  ],
678
706
  "table.title": [
679
707
  { required: true, message: "请选择列表名称", trigger: "change" }
680
- ],
681
- "table.mounted.api": [
682
- { required: true, message: "请选择列表接口", trigger: "change" }
683
708
  ]
684
709
  },
685
710
  fieldsTree: {
686
711
  search: [],
687
712
  table: []
688
713
  },
689
- dialog: { show: false, data: null }
714
+ dialog: { show: false, data: null },
715
+ cssDemo: `
716
+ {<br>
717
+ padding: 10px;<br>
718
+ margin: 10px;<br>
719
+ color: red;<br>
720
+ }
721
+ `
690
722
  };
691
723
  },
692
724
  watch: {
693
725
  config(val) {
694
- this.handleFieldsApiChange(val.table.mounted.api);
726
+ this.handleInitFields(val.table.mounted.api);
695
727
  },
696
728
  apiOptions() {
697
- this.handleFieldsApiChange(this.config.table.mounted.api);
729
+ this.handleInitFields(this.config.table.mounted.api);
698
730
  }
699
731
  },
700
732
  computed: {
@@ -717,25 +749,43 @@ export default {
717
749
  this.dialog = { show: true, data };
718
750
  },
719
751
  handleFieldsApiChange(val) {
752
+ this.fieldsTree = { search: [], table: [] };
753
+ this.config.search.options = [];
754
+ this.config.table.options = [];
755
+ this.handleInitFields(val);
756
+ },
757
+ handleInitFields(apiId) {
720
758
  const api = this.apiOptions.filter(item => {
721
- return item.id === val;
759
+ return item.id === apiId;
722
760
  })[0];
723
- if (!api) return (this.fieldsTree = { search: [], table: [] });
761
+ if (!api) return;
724
762
 
725
- const initParams = (paramsList, pProp) => {
763
+ const initParams = (paramsList, pAlias) => {
726
764
  paramsList.forEach(item => {
727
765
  item.elType = "input";
728
766
  item.align = "left";
729
- item.pProp = pProp ? `${pProp}.${item.prop}` : item.prop;
767
+ item.pAlias = pAlias ? `${pAlias}.${item.alias}` : item.alias;
730
768
  if (item.children && item.children.length) {
731
- initParams(item.children, item.pProp);
769
+ initParams(item.children, item.pAlias);
732
770
  }
733
771
  });
734
772
  };
735
- this.fieldsTree.search = deepClone(api.interfaceParameterInputList) || [];
736
- initParams(this.fieldsTree.search);
737
- this.fieldsTree.table = deepClone(api.interfaceParameterOutPutList) || [];
738
- initParams(this.fieldsTree.table);
773
+ if (this.config.table.fields.remote) {
774
+ const callback = res => {
775
+ api.inParams = res.inParams;
776
+ api.outParams = res.outParams;
777
+ this.fieldsTree.search = deepClone(res.inParams) || [];
778
+ initParams(this.fieldsTree.search);
779
+ this.fieldsTree.table = deepClone(res.outParams) || [];
780
+ initParams(this.fieldsTree.table);
781
+ };
782
+ this.$emit("remote-params", apiId, callback);
783
+ } else {
784
+ this.fieldsTree.search = deepClone(api.inParams) || [];
785
+ initParams(this.fieldsTree.search);
786
+ this.fieldsTree.table = deepClone(api.outParams) || [];
787
+ initParams(this.fieldsTree.table);
788
+ }
739
789
  },
740
790
  handleTreeCheckChange(action) {
741
791
  if (action === "search") {