tianheng-ui 0.1.24 → 0.1.27

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.24",
4
+ "version": "0.1.27",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -5,30 +5,48 @@
5
5
  label-position="left"
6
6
  label-width="80px"
7
7
  size="small"
8
+ :rules="formRules"
9
+ ref="formRef"
8
10
  >
9
11
  <el-collapse v-model="collapseValue">
10
12
  <el-collapse-item title="表单配置" name="group-form">
11
- <el-form-item label="字段类型" required>
13
+ <el-form-item prop="fieldsType" required>
14
+ <el-tooltip
15
+ slot="label"
16
+ effect="dark"
17
+ content="字段的配置方式"
18
+ placement="top"
19
+ >
20
+ <span style="color: #409EFF;">字段类型</span>
21
+ </el-tooltip>
12
22
  <el-radio-group v-model="config.fieldsType">
13
23
  <el-radio-button label="custom">自定义</el-radio-button>
14
- <el-radio-button label="fieldsTable">字段表</el-radio-button>
24
+ <el-radio-button label="fieldsApi">接口导入</el-radio-button>
15
25
  </el-radio-group>
16
26
  </el-form-item>
17
27
  <el-form-item
18
- v-if="config.fieldsType === 'fieldsTable'"
19
- label="字段表"
28
+ v-if="config.fieldsType === 'fieldsApi'"
29
+ prop="fieldsApi"
20
30
  required
21
31
  >
32
+ <el-tooltip
33
+ slot="label"
34
+ effect="dark"
35
+ content="使用接口的出参配置可选字段"
36
+ placement="top"
37
+ >
38
+ <span style="color: #409EFF;">字段接口</span>
39
+ </el-tooltip>
22
40
  <el-select
23
- v-model="config.fieldsTable"
41
+ v-model="config.fieldsApi"
24
42
  style="width:100%"
25
43
  clearable
26
44
  placeholder="请选择"
27
45
  no-data-text="暂无接口,请前往【数据源模块】创建"
28
- @change="handleFieldsTableChange"
46
+ @change="handleFieldsApiChange"
29
47
  >
30
48
  <el-option
31
- v-for="item in fieldsOptions"
49
+ v-for="item in config.network"
32
50
  :key="item.id"
33
51
  :label="item.label"
34
52
  :value="item.id"
@@ -36,7 +54,7 @@
36
54
  </el-option>
37
55
  </el-select>
38
56
  </el-form-item>
39
- <el-form-item label="表单标题" required>
57
+ <el-form-item label="表单标题" prop="title" required>
40
58
  <el-input
41
59
  v-model="config.title"
42
60
  placeholder="请输入"
@@ -109,7 +127,7 @@
109
127
 
110
128
  <script>
111
129
  export default {
112
- props: ["config", "fieldsOptions"],
130
+ props: ["config"],
113
131
  data() {
114
132
  return {
115
133
  collapseValue: [
@@ -117,16 +135,44 @@ export default {
117
135
  "group-resultData",
118
136
  "group-label",
119
137
  "group-attributes"
120
- ]
138
+ ],
139
+ formRules: {
140
+ fieldsType: [
141
+ { required: true, message: "请选择字段类型", trigger: "change" }
142
+ ],
143
+ fieldsApi: [
144
+ { required: true, message: "请选择字段类型", trigger: "change" }
145
+ ],
146
+ title: [
147
+ { required: true, message: "请选择字段类型", trigger: "change" }
148
+ ]
149
+ }
121
150
  };
122
151
  },
123
152
  methods: {
124
- handleFieldsTableChange(val) {
125
- const data = this.fieldsOptions.filter(item => {
153
+ handleFieldsApiChange(val) {
154
+ const dataArr = this.config.network.filter(item => {
126
155
  return item.id === val;
127
156
  });
128
- if (data.length) this.$emit("fieldsTableChange", data[0].children);
129
- else this.$emit("fieldsTableChange", []);
157
+ if (dataArr.length && dataArr[0].paramsOut) {
158
+ const fields = dataArr[0].paramsOut.map(item => {
159
+ return {
160
+ label: item.note || item.name,
161
+ alias: item.name,
162
+ prop: item.name,
163
+ type: "input",
164
+ align: "left"
165
+ };
166
+ });
167
+ this.$emit("fieldsChange", fields);
168
+ } else this.$emit("fieldsChange", []);
169
+ },
170
+ formValidate() {
171
+ return new Promise((resolve, reject) => {
172
+ this.$refs.formRef.validate(valid => {
173
+ resolve(valid);
174
+ });
175
+ });
130
176
  }
131
177
  }
132
178
  };
@@ -14,7 +14,7 @@
14
14
  <el-tooltip
15
15
  slot="label"
16
16
  effect="dark"
17
- content="【组件切换】会导致该组件配置信息重置,请谨慎使用!"
17
+ content="会导致该组件配置信息重置,请谨慎使用!"
18
18
  placement="top"
19
19
  >
20
20
  <span style="color: #409EFF;">组件切换</span>
@@ -38,10 +38,10 @@
38
38
  <el-tooltip
39
39
  slot="label"
40
40
  effect="dark"
41
- content="【组件标识】是表单组件关联数据表字段的唯一键"
41
+ content="组件关联数据表中的唯一字段"
42
42
  placement="top"
43
43
  >
44
- <span style="color: #409EFF;">组件标识</span>
44
+ <span style="color: #409EFF;">组件字段</span>
45
45
  </el-tooltip>
46
46
  <el-input
47
47
  v-if="config.fieldsType === 'custom'"
@@ -62,10 +62,15 @@
62
62
  </el-option>
63
63
  </el-select>
64
64
  </el-form-item>
65
- <el-form-item
66
- v-if="config.fieldsType === 'fieldsTable'"
67
- label="字段标识"
68
- >
65
+ <el-form-item v-if="config.fieldsType === 'fieldsApi'">
66
+ <el-tooltip
67
+ slot="label"
68
+ effect="dark"
69
+ content="表单提交时的入参名,对应数据表中的字段"
70
+ placement="top"
71
+ >
72
+ <span style="color: #409EFF;">字段标识</span>
73
+ </el-tooltip>
69
74
  <el-input v-model="data.model" readonly></el-input>
70
75
  </el-form-item>
71
76
  </el-collapse-item>
@@ -3,7 +3,7 @@
3
3
  <th-empty
4
4
  class="form-empty"
5
5
  v-if="data.list.length == 0"
6
- :image="require('@/assets/images/notData.png')"
6
+ :image="require('../../lib/theme-chalk/images/notData.png')"
7
7
  description="从左侧拖拽来添加字段"
8
8
  ></th-empty>
9
9
  <el-form
@@ -772,8 +772,8 @@ export const layoutComponents = [
772
772
  export const templateComponents = [];
773
773
 
774
774
  export const baseConfig = {
775
- fieldsType: "custom",
776
- fieldsTable: "",
775
+ fieldsType: "fieldsApi",
776
+ fieldsApi: "",
777
777
  ui: "element",
778
778
  title: "",
779
779
  width: "",
@@ -158,8 +158,8 @@
158
158
  <form-config
159
159
  v-if="configTab == 'form'"
160
160
  :config="formConfig.config"
161
- :fieldsOptions="fieldsOptions"
162
- @fieldsTableChange="handleFieldsTableChange"
161
+ @fieldsChange="handleFieldsChange"
162
+ ref="formConfigRef"
163
163
  ></form-config>
164
164
  </el-main>
165
165
  </el-container>
@@ -253,7 +253,6 @@ export default {
253
253
  type: Array,
254
254
  default: () => ["grid", "filler", "divider"]
255
255
  },
256
- fieldsOptions: Array,
257
256
  apiOptions: Array
258
257
  },
259
258
  data() {
@@ -386,14 +385,42 @@ export default {
386
385
  handleWidgetConfigUpdate(val) {
387
386
  this.widgetFormSelect = Object.assign(this.widgetFormSelect, val);
388
387
  },
389
- handleFieldsTableChange(val) {
388
+ handleFieldsChange(val) {
390
389
  this.fields = val;
391
390
  },
392
391
  clear() {
393
392
  this.handleClear();
394
393
  },
395
- getJSON() {
396
- return this.formConfig;
394
+ getConfig() {
395
+ if (this.$refs.formConfigRef) {
396
+ return new Promise((resolve, reject) =>
397
+ this.$refs.formConfigRef.formValidate().then(res => {
398
+ if (res) {
399
+ const data = deepClone(this.formConfig);
400
+ resolve(data);
401
+ } else {
402
+ reject();
403
+ }
404
+ })
405
+ );
406
+ } else {
407
+ return new Promise((resolve, reject) => {
408
+ if (!this.formConfig.config.fieldsType) {
409
+ this.$message.warning("请选择字段类型");
410
+ return reject();
411
+ }
412
+ if (!this.formConfig.config.fieldsApi) {
413
+ this.$message.warning("请选择字段接口");
414
+ return reject();
415
+ }
416
+ if (!this.formConfig.config.title) {
417
+ this.$message.warning("请填写表单标题");
418
+ return reject();
419
+ }
420
+ const data = deepClone(this.formConfig);
421
+ resolve(data);
422
+ });
423
+ }
397
424
  },
398
425
  getHtml() {
399
426
  return generateCode(JSON.stringify(this.formConfig));
@@ -9,14 +9,14 @@
9
9
  @click="handleClick('monitor')"
10
10
  >
11
11
  </el-button>
12
- <!-- <el-button
13
- :class="{ active: client === 'mobile' }"
14
- type="text"
15
- size="medium"
16
- icon="el-icon-mobile"
17
- @click="client = 'mobile'"
18
- >
19
- </el-button> -->
12
+ <el-button
13
+ :class="{ active: client === 'mobile' }"
14
+ type="text"
15
+ size="medium"
16
+ icon="el-icon-mobile"
17
+ @click="handleClick('mobile')"
18
+ >
19
+ </el-button>
20
20
  </div>
21
21
  <div class="right">
22
22
  <slot> </slot>
@@ -9,6 +9,7 @@ export const table = {
9
9
  mounted: {
10
10
  api: ""
11
11
  },
12
+ fieldsType: "fieldsApi",
12
13
  style: {
13
14
  cell: {
14
15
  customStyle: "",
@@ -10,6 +10,7 @@
10
10
  <slot name="action"></slot>
11
11
  </widget-tools>
12
12
  <widget-table
13
+ v-if="client === 'monitor'"
13
14
  style="height:calc(100% - 45px)"
14
15
  :config="tableConfig"
15
16
  ></widget-table>
@@ -17,7 +18,6 @@
17
18
  <div class="th-flex_aside th-is_border_left" style="width:300px">
18
19
  <widget-config
19
20
  :config="tableConfig"
20
- :fieldsOptions="fieldsOptions"
21
21
  :formOptions="formOptions"
22
22
  :apiOptions="apiOptions"
23
23
  ref="configRef"
@@ -39,30 +39,10 @@ export default {
39
39
  config: {
40
40
  type: Object,
41
41
  default: () => {
42
- return deepClone(baseConfig);
42
+ return {};
43
43
  }
44
44
  },
45
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,
65
-
66
46
  /**
67
47
  * 表单配置列表。
68
48
  * 只关联表单id,渲染器通过接口查询表单配置信息
@@ -106,6 +86,7 @@ export default {
106
86
  }
107
87
  },
108
88
  data() {
89
+ this.baseConfig = deepClone(baseConfig);
109
90
  return {
110
91
  tableConfig: this.config,
111
92
  client: "monitor"
@@ -119,14 +100,16 @@ export default {
119
100
  }
120
101
  },
121
102
  config(val) {
122
- this.tableConfig = val;
103
+ this.tableConfig = Object.assign(this.baseConfig, val);
123
104
  this.handleNetwork();
124
105
  },
125
106
  apiOptions(val) {
126
107
  this.handleNetwork();
127
108
  }
128
109
  },
129
- mounted() {},
110
+ mounted() {
111
+ this.tableConfig = Object.assign(this.baseConfig, this.tableConfig);
112
+ },
130
113
  methods: {
131
114
  handleNetwork() {
132
115
  const network = {};
@@ -140,15 +123,19 @@ export default {
140
123
  case "import-json":
141
124
  this.tableConfig = data;
142
125
  break;
126
+ case "monitor":
127
+ case "mobile":
128
+ this.client = action;
129
+ break;
143
130
 
144
131
  default:
145
132
  break;
146
133
  }
147
134
  },
148
- getJson() {
135
+ getConfig() {
149
136
  return new Promise((resolve, reject) =>
150
137
  this.$refs.configRef
151
- .handleFormValidate()
138
+ .formValidate()
152
139
  .then(res => {
153
140
  if (res) {
154
141
  const data = deepClone(this.tableConfig);
@@ -54,17 +54,40 @@
54
54
  >
55
55
  <el-collapse v-model="collapseValue">
56
56
  <el-collapse-item title="列表配置" name="group-table">
57
- <el-form-item label="字段表" required prop="table.fieldsTable">
57
+ <el-form-item required prop="table.fieldsType">
58
+ <el-tooltip
59
+ slot="label"
60
+ effect="dark"
61
+ content="字段的配置方式"
62
+ placement="top"
63
+ >
64
+ <span style="color: #409EFF;">字段类型</span>
65
+ </el-tooltip>
66
+ <el-radio-group v-model="config.table.fieldsType">
67
+ <el-radio-button label="custom" disabled
68
+ >自定义</el-radio-button
69
+ >
70
+ <el-radio-button label="fieldsApi">接口导入</el-radio-button>
71
+ </el-radio-group> </el-form-item
72
+ ><el-form-item required prop="table.mounted.api">
73
+ <el-tooltip
74
+ slot="label"
75
+ effect="dark"
76
+ content="列表初始化完成后,调用该接口获取列表数据"
77
+ placement="top"
78
+ >
79
+ <span style="color: #409EFF;">列表接口</span>
80
+ </el-tooltip>
58
81
  <el-select
59
- v-model="config.table.fieldsTable"
82
+ v-model="config.table.mounted.api"
60
83
  style="width:100%"
61
84
  clearable
62
85
  placeholder="请选择"
63
- no-data-text="暂无接口,请前往【数据源模块】创建"
64
- @change="handleFieldsTableChange"
86
+ no-data-text="暂无接口,请前往【接口模块】创建"
87
+ @change="handleFieldsApiChange"
65
88
  >
66
89
  <el-option
67
- v-for="item in fieldsOptions"
90
+ v-for="item in apiOptions"
68
91
  :key="item.id"
69
92
  :label="item.label"
70
93
  :value="item.id"
@@ -78,29 +101,12 @@
78
101
  placeholder="请输入"
79
102
  ></el-input>
80
103
  </el-form-item>
81
- <el-form-item label="列表接口" required prop="table.mounted.api">
82
- <el-select
83
- v-model="config.table.mounted.api"
84
- style="width:100%"
85
- clearable
86
- placeholder="请选择"
87
- no-data-text="暂无接口,请前往【接口模块】创建"
88
- >
89
- <el-option
90
- v-for="item in apiOptions"
91
- :key="item.id"
92
- :label="item.label"
93
- :value="item.id"
94
- >
95
- </el-option>
96
- </el-select>
104
+ <el-form-item label="列表序号">
105
+ <el-switch v-model="config.table.sequence"> </el-switch>
97
106
  </el-form-item>
98
107
  <el-form-item label="开启查询">
99
108
  <el-switch v-model="config.search.show"> </el-switch>
100
109
  </el-form-item>
101
- <el-form-item label="列表序号">
102
- <el-switch v-model="config.table.sequence"> </el-switch>
103
- </el-form-item>
104
110
  </el-collapse-item>
105
111
  <el-collapse-item title="排序配置" name="group-sort">
106
112
  <el-form-item label="排序类型">
@@ -434,7 +440,6 @@ export default {
434
440
  return {};
435
441
  }
436
442
  },
437
- fieldsOptions: Array,
438
443
  formOptions: Array,
439
444
  apiOptions: Array
440
445
  },
@@ -467,7 +472,10 @@ export default {
467
472
  "group-button"
468
473
  ],
469
474
  formRules: {
470
- "table.fieldsTable": [
475
+ "table.fieldsType": [
476
+ { required: true, message: "请选择字段类型", trigger: "change" }
477
+ ],
478
+ "table.fieldsApi": [
471
479
  { required: true, message: "请选择字段表", trigger: "change" }
472
480
  ],
473
481
  "table.title": [
@@ -584,14 +592,24 @@ export default {
584
592
  handleActionConfig(data) {
585
593
  this.dialog = { show: true, data };
586
594
  },
587
- handleFieldsTableChange(val) {
588
- const data = this.fieldsOptions.filter(item => {
595
+ handleFieldsApiChange(val) {
596
+ const dataArr = this.apiOptions.filter(item => {
589
597
  return item.id === val;
590
598
  });
591
- if (data.length) this.fields = data[0].children;
592
- else this.fields = [];
599
+ if (dataArr.length && dataArr[0].paramsOut) {
600
+ const fields = dataArr[0].paramsOut.map(item => {
601
+ return {
602
+ label: item.note || item.name,
603
+ alias: item.name,
604
+ prop: item.name,
605
+ type: "input",
606
+ align: "left"
607
+ };
608
+ });
609
+ this.fields = fields;
610
+ } else this.fields = [];
593
611
  },
594
- handleFormValidate() {
612
+ formValidate() {
595
613
  return new Promise((resolve, reject) => {
596
614
  if (this.$refs.formRef) {
597
615
  this.$refs.formRef.validate(valid => {