tianheng-ui 0.1.22 → 0.1.24

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 (37) hide show
  1. package/lib/tianheng-ui.js +13 -13
  2. package/package.json +1 -1
  3. package/packages/FormMaking/FormConfig.vue +140 -50
  4. package/packages/FormMaking/WidgetConfig.vue +146 -32
  5. package/packages/FormMaking/WidgetTools.vue +1 -1
  6. package/packages/FormMaking/custom/config.js +13 -9
  7. package/packages/FormMaking/custom/configs/blank.vue +2 -6
  8. package/packages/FormMaking/custom/configs/button.vue +4 -46
  9. package/packages/FormMaking/custom/configs/cascader.vue +4 -45
  10. package/packages/FormMaking/custom/configs/cell.vue +2 -6
  11. package/packages/FormMaking/custom/configs/checkbox.vue +15 -62
  12. package/packages/FormMaking/custom/configs/color.vue +2 -43
  13. package/packages/FormMaking/custom/configs/date.vue +2 -42
  14. package/packages/FormMaking/custom/configs/divider.vue +2 -6
  15. package/packages/FormMaking/custom/configs/editor.vue +2 -6
  16. package/packages/FormMaking/custom/configs/filler.vue +2 -6
  17. package/packages/FormMaking/custom/configs/grid.vue +2 -6
  18. package/packages/FormMaking/custom/configs/image.vue +2 -6
  19. package/packages/FormMaking/custom/configs/input.vue +2 -42
  20. package/packages/FormMaking/custom/configs/number.vue +3 -47
  21. package/packages/FormMaking/custom/configs/radio.vue +13 -60
  22. package/packages/FormMaking/custom/configs/rate.vue +2 -44
  23. package/packages/FormMaking/custom/configs/select.vue +12 -58
  24. package/packages/FormMaking/custom/configs/slider.vue +2 -43
  25. package/packages/FormMaking/custom/configs/switch.vue +2 -43
  26. package/packages/FormMaking/custom/configs/table.vue +2 -6
  27. package/packages/FormMaking/custom/configs/tableH5.vue +2 -6
  28. package/packages/FormMaking/custom/configs/tabs.vue +14 -23
  29. package/packages/FormMaking/custom/configs/text.vue +6 -7
  30. package/packages/FormMaking/custom/configs/textarea.vue +4 -45
  31. package/packages/FormMaking/custom/configs/time.vue +2 -43
  32. package/packages/FormMaking/custom/configs/upload.vue +6 -11
  33. package/packages/FormMaking/index.vue +31 -56
  34. package/packages/FormMaking/styles/index.scss +9 -9
  35. package/packages/TableMaking/custom/config.js +1 -1
  36. package/packages/TableMaking/index.vue +25 -2
  37. package/packages/TableMaking/widgetConfig.vue +39 -13
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="formMaking">
3
3
  <el-container
4
- v-if="Object.keys(widgetFormData.config).length"
4
+ v-if="Object.keys(formConfig.config).length"
5
5
  class="container-box"
6
6
  >
7
7
  <el-main>
@@ -106,7 +106,7 @@
106
106
  :client.sync="client"
107
107
  :basicComponents="basicComponents"
108
108
  :layoutComponents="layoutComponents"
109
- :formData="widgetFormData"
109
+ :formData="formConfig"
110
110
  :formValue="widgetValue"
111
111
  :oauthConfig="oauthConfig"
112
112
  :slotKeys="Object.keys($slots)"
@@ -119,7 +119,7 @@
119
119
  <el-main>
120
120
  <widget-form
121
121
  ref="widgetForm"
122
- :data="widgetFormData"
122
+ :data="formConfig"
123
123
  :select.sync="widgetFormSelect"
124
124
  :client="client"
125
125
  >
@@ -148,15 +148,18 @@
148
148
  </el-header>
149
149
  <el-main class="config-container-content">
150
150
  <widget-config
151
- v-show="configTab == 'widget'"
151
+ v-if="configTab == 'widget'"
152
152
  :data="widgetFormSelect"
153
- :config="widgetFormData.config"
153
+ :config="formConfig.config"
154
+ :fields="fields"
154
155
  @update="handleWidgetConfigUpdate"
155
156
  >
156
157
  </widget-config>
157
158
  <form-config
158
- v-show="configTab == 'form'"
159
- :data="widgetFormData.config"
159
+ v-if="configTab == 'form'"
160
+ :config="formConfig.config"
161
+ :fieldsOptions="fieldsOptions"
162
+ @fieldsTableChange="handleFieldsTableChange"
160
163
  ></form-config>
161
164
  </el-main>
162
165
  </el-container>
@@ -250,10 +253,8 @@ export default {
250
253
  type: Array,
251
254
  default: () => ["grid", "filler", "divider"]
252
255
  },
253
- remoteFuncs: {
254
- type: Object,
255
- default: () => {}
256
- }
256
+ fieldsOptions: Array,
257
+ apiOptions: Array
257
258
  },
258
259
  data() {
259
260
  this.basicComponents = basicComponents;
@@ -261,11 +262,12 @@ export default {
261
262
  this.layoutComponents = layoutComponents;
262
263
  this.baseConfig = deepClone(baseConfig);
263
264
  return {
264
- widgetFormData: this.config,
265
+ formConfig: this.config,
265
266
  widgetFormSelect: {},
266
267
  widgetValue: {},
267
- configTab: "widget",
268
- client: "monitor"
268
+ configTab: "form",
269
+ client: "monitor",
270
+ fields: []
269
271
  };
270
272
  },
271
273
  computed: {
@@ -289,7 +291,7 @@ export default {
289
291
  }
290
292
  },
291
293
  watch: {
292
- widgetFormData: {
294
+ formConfig: {
293
295
  deep: true,
294
296
  handler: function(val) {
295
297
  this.$emit("update:config", val);
@@ -302,53 +304,23 @@ export default {
302
304
  }
303
305
  this.setJSON(val);
304
306
  },
305
- remoteFuncs(val) {
307
+ apiOptions(val) {
306
308
  if (val) {
307
- const props = val.props;
308
- const options = val.options;
309
-
310
- /**
311
- * 支持外部接口转自定义事件(待完成)
312
- */
313
- // const _eventScript = options.map(item => {
314
- // return {
315
- // id: item[props.key],
316
- // label: item[props.name],
317
- // value: `
318
- // const params = ${JSON.stringify(item.params)}
319
- // const headers = ${JSON.stringify(item.headers || {})}
320
- // const request = {
321
- // url:"${item.url}",
322
- // method:"${item.method}",
323
- // data:params,
324
- // headers:headers
325
- // }
326
- // this.hendleRemoteData(request)
327
- // `
328
- // };
329
- // });
330
- // this.widgetFormData.config.eventScript = this.widgetFormData.config.eventScript.concat(
331
- // _eventScript
332
- // );
333
-
334
- const _remoteFuncs = options.map(item => {
335
- return { ...item, id: item[props.key], label: item[props.name] };
336
- });
337
- this.widgetFormData.config.remoteFuncs = _remoteFuncs;
309
+ this.formConfig.config.network = val;
338
310
  }
339
311
  }
340
312
  },
341
313
  created() {
342
314
  this.initConfig();
343
- this.widgetFormData.config = Object.assign(
315
+ this.formConfig.config = Object.assign(
344
316
  this.baseConfig,
345
- this.widgetFormData.config
317
+ this.formConfig.config
346
318
  );
347
319
 
348
- if (this.widgetFormData.list && this.widgetFormData.list.length) {
349
- this.widgetFormSelect = this.widgetFormData.list[0];
320
+ if (this.formConfig.list && this.formConfig.list.length) {
321
+ this.widgetFormSelect = this.formConfig.list[0];
350
322
  } else {
351
- this.widgetFormData.list = [];
323
+ this.formConfig.list = [];
352
324
  }
353
325
  },
354
326
  mounted() {},
@@ -383,7 +355,7 @@ export default {
383
355
  },
384
356
 
385
357
  handleClear() {
386
- this.widgetFormData = {
358
+ this.formConfig = {
387
359
  list: [],
388
360
  config: this.baseConfig
389
361
  };
@@ -414,17 +386,20 @@ export default {
414
386
  handleWidgetConfigUpdate(val) {
415
387
  this.widgetFormSelect = Object.assign(this.widgetFormSelect, val);
416
388
  },
389
+ handleFieldsTableChange(val) {
390
+ this.fields = val;
391
+ },
417
392
  clear() {
418
393
  this.handleClear();
419
394
  },
420
395
  getJSON() {
421
- return this.widgetFormData;
396
+ return this.formConfig;
422
397
  },
423
398
  getHtml() {
424
- return generateCode(JSON.stringify(this.widgetFormData));
399
+ return generateCode(JSON.stringify(this.formConfig));
425
400
  },
426
401
  setJSON(json) {
427
- this.widgetFormData = json;
402
+ this.formConfig = json;
428
403
 
429
404
  if (json.list.length > 0) {
430
405
  this.widgetFormSelect = json.list[0];
@@ -614,17 +614,17 @@ $primary-background-color: #ecf5ff;
614
614
  }
615
615
 
616
616
  .config-container-content {
617
- padding: 10px;
617
+ // padding: 10px;
618
618
 
619
- .el-form-item__label {
620
- padding: 0;
621
- font-weight: 500;
622
- }
619
+ // .el-form-item__label {
620
+ // padding: 0;
621
+ // font-weight: 500;
622
+ // }
623
623
 
624
- .el-form-item {
625
- border-bottom: solid 1px #e1e1e1;
626
- padding-bottom: 10px;
627
- }
624
+ // .el-form-item {
625
+ // border-bottom: solid 1px #e1e1e1;
626
+ // padding-bottom: 10px;
627
+ // }
628
628
 
629
629
  .config-pattern-input {
630
630
  .el-input-group__prepend,
@@ -148,7 +148,7 @@ export const tools = {
148
148
  // 接口配置
149
149
  export const network = {};
150
150
 
151
- export const tableConfig = {
151
+ export const baseConfig = {
152
152
  search,
153
153
  table,
154
154
  tools,
@@ -17,7 +17,7 @@
17
17
  <div class="th-flex_aside th-is_border_left" style="width:300px">
18
18
  <widget-config
19
19
  :config="tableConfig"
20
- :fields.sync="fields"
20
+ :fieldsOptions="fieldsOptions"
21
21
  :formOptions="formOptions"
22
22
  :apiOptions="apiOptions"
23
23
  ref="configRef"
@@ -42,7 +42,26 @@ export default {
42
42
  return deepClone(baseConfig);
43
43
  }
44
44
  },
45
- fields: Array,
45
+
46
+ /**
47
+ * 字段表配置列表。
48
+ * [
49
+ * {
50
+ * id:'', 表单id
51
+ * label:'', 表单名称
52
+ * children:[
53
+ * {
54
+ label: "主键",
55
+ alias: "id",
56
+ prop: "id",
57
+ type: "input",
58
+ align: "left"
59
+ }
60
+ * ]
61
+ * }
62
+ * ]
63
+ */
64
+ fieldsOptions: Array,
46
65
 
47
66
  /**
48
67
  * 表单配置列表。
@@ -139,6 +158,10 @@ export default {
139
158
  }
140
159
  })
141
160
  .catch(err => {
161
+ if (!this.tableConfig.table.fieldsTable) {
162
+ this.$message.warning("请选择字段表");
163
+ return reject();
164
+ }
142
165
  if (!this.tableConfig.table.title) {
143
166
  this.$message.warning("请选择列表名称");
144
167
  return reject();
@@ -48,12 +48,30 @@
48
48
  :model="config"
49
49
  label-position="left"
50
50
  label-width="80px"
51
- size="mini"
51
+ size="small"
52
52
  :rules="formRules"
53
53
  ref="formRef"
54
54
  >
55
- <el-collapse v-model="tableCollapse">
56
- <el-collapse-item title="表格配置" name="group-table">
55
+ <el-collapse v-model="collapseValue">
56
+ <el-collapse-item title="列表配置" name="group-table">
57
+ <el-form-item label="字段表" required prop="table.fieldsTable">
58
+ <el-select
59
+ v-model="config.table.fieldsTable"
60
+ style="width:100%"
61
+ clearable
62
+ placeholder="请选择"
63
+ no-data-text="暂无接口,请前往【数据源模块】创建"
64
+ @change="handleFieldsTableChange"
65
+ >
66
+ <el-option
67
+ v-for="item in fieldsOptions"
68
+ :key="item.id"
69
+ :label="item.label"
70
+ :value="item.id"
71
+ >
72
+ </el-option>
73
+ </el-select>
74
+ </el-form-item>
57
75
  <el-form-item label="列表名称" required prop="table.title">
58
76
  <el-input
59
77
  v-model="config.table.title"
@@ -64,7 +82,6 @@
64
82
  <el-select
65
83
  v-model="config.table.mounted.api"
66
84
  style="width:100%"
67
- value-key="id"
68
85
  clearable
69
86
  placeholder="请选择"
70
87
  no-data-text="暂无接口,请前往【接口模块】创建"
@@ -417,12 +434,7 @@ export default {
417
434
  return {};
418
435
  }
419
436
  },
420
- fields: {
421
- type: Array,
422
- default: () => {
423
- return [];
424
- }
425
- },
437
+ fieldsOptions: Array,
426
438
  formOptions: Array,
427
439
  apiOptions: Array
428
440
  },
@@ -434,6 +446,7 @@ export default {
434
446
  { title: "列表属性", value: 2 }
435
447
  ],
436
448
  activeTab: { title: "列表属性", value: 2 },
449
+ fields: [],
437
450
  searchField: {
438
451
  isCheckAll: false,
439
452
  isIndeterminate: false
@@ -442,7 +455,7 @@ export default {
442
455
  isCheckAll: false,
443
456
  isIndeterminate: false
444
457
  },
445
- tableCollapse: [
458
+ collapseValue: [
446
459
  "group-table",
447
460
  "group-pageInfo",
448
461
  "group-sort",
@@ -454,12 +467,15 @@ export default {
454
467
  "group-button"
455
468
  ],
456
469
  formRules: {
470
+ "table.fieldsTable": [
471
+ { required: true, message: "请选择字段表", trigger: "change" }
472
+ ],
457
473
  "table.title": [
458
474
  { required: true, message: "请选择列表名称", trigger: "change" }
459
475
  ],
460
476
  "table.mounted.api": [
461
477
  { required: true, message: "请选择列表接口", trigger: "change" }
462
- ],
478
+ ]
463
479
  },
464
480
  dialog: { show: false, data: null }
465
481
  };
@@ -568,6 +584,13 @@ export default {
568
584
  handleActionConfig(data) {
569
585
  this.dialog = { show: true, data };
570
586
  },
587
+ handleFieldsTableChange(val) {
588
+ const data = this.fieldsOptions.filter(item => {
589
+ return item.id === val;
590
+ });
591
+ if (data.length) this.fields = data[0].children;
592
+ else this.fields = [];
593
+ },
571
594
  handleFormValidate() {
572
595
  return new Promise((resolve, reject) => {
573
596
  if (this.$refs.formRef) {
@@ -585,14 +608,17 @@ export default {
585
608
 
586
609
  <style lang="scss" scoped>
587
610
  .widgetConfig {
588
- height: 100%;
589
611
  background-color: white;
590
612
  .tabs {
613
+ position: sticky;
614
+ top: 0;
591
615
  display: flex;
592
616
  align-items: center;
593
617
  height: 45px;
618
+ background-color: white;
594
619
  border-bottom: 1px solid #dcdfe6;
595
620
  box-sizing: border-box;
621
+ z-index: 100;
596
622
 
597
623
  .tabs-item {
598
624
  flex: 1;