tianheng-ui 0.1.77 → 0.1.78

Sign up to get free protection for your applications and to get access to all the features.
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.77",
4
+ "version": "0.1.78",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -181,7 +181,7 @@
181
181
  <el-tooltip
182
182
  slot="label"
183
183
  effect="light"
184
- content="使用接口的出参配置可选字段"
184
+ content="使用该接口的出参配置可选字段"
185
185
  placement="top"
186
186
  >
187
187
  <span style="color: #409EFF;">字段接口</span>
@@ -217,7 +217,7 @@
217
217
  <el-tooltip
218
218
  slot="label"
219
219
  effect="light"
220
- content="开启后,选择数据接口会触发 remote-params 回调,用于从服务器查询字段"
220
+ content="开启后,选择数据接口会触发 remote-params 回调,用于从服务器获取字段"
221
221
  placement="top"
222
222
  >
223
223
  <span style="color: #409EFF;">远程字段</span>
@@ -3,14 +3,94 @@
3
3
  <el-steps :active="step" finish-status="success" simple>
4
4
  <el-step title="表单配置" icon="el-icon-s-operation" description="">
5
5
  </el-step>
6
- <el-step title="按钮配置" icon="el-icon-set-up" description=""></el-step>
6
+ <el-step
7
+ title="选择初始模板"
8
+ icon="el-icon-set-up"
9
+ description=""
10
+ ></el-step>
11
+ <!-- <el-step
12
+ title="选择初始模板"
13
+ icon="el-icon-set-up"
14
+ description=""
15
+ ></el-step> -->
7
16
  </el-steps>
8
17
  <div class="content">
9
- <div v-show="step === 0">
10
- <div>你好</div>
11
- <div>让我们来了解一些基本信息</div>
12
- </div>
13
- <div v-show="step === 1"></div>
18
+ <el-form :model="config" label-width="80px" size="small">
19
+ <div v-show="step === 0">
20
+ <el-form-item>
21
+ <el-tooltip
22
+ slot="label"
23
+ effect="light"
24
+ content="字段的配置方式"
25
+ placement="top"
26
+ >
27
+ <span style="color: #409EFF;">字段类型</span>
28
+ </el-tooltip>
29
+ <el-radio-group v-model="config.config.fields.type">
30
+ <el-radio-button label="custom">自定义</el-radio-button>
31
+ <el-radio-button label="api">接口导入</el-radio-button>
32
+ </el-radio-group>
33
+ </el-form-item>
34
+ <el-form-item v-if="config.config.fields.type === 'api'">
35
+ <el-tooltip
36
+ slot="label"
37
+ effect="light"
38
+ content="使用该接口的出参配置可选字段"
39
+ placement="top"
40
+ >
41
+ <span style="color: #409EFF;">字段接口</span>
42
+ </el-tooltip>
43
+ <el-select
44
+ v-model="config.config.fields.api"
45
+ style="width:100%"
46
+ clearable
47
+ placeholder="请选择"
48
+ no-data-text="暂无接口,请前往【接口模块】创建"
49
+ filterable
50
+ >
51
+ <el-option
52
+ v-for="item in apiOptions"
53
+ :key="item.id"
54
+ :label="item.name"
55
+ :value="item.id"
56
+ >
57
+ </el-option>
58
+ </el-select>
59
+ </el-form-item>
60
+ <el-form-item label="表单名称">
61
+ <el-input
62
+ v-model="config.config.title"
63
+ placeholder="请输入"
64
+ ></el-input>
65
+ </el-form-item>
66
+ <el-form-item>
67
+ <el-tooltip
68
+ slot="label"
69
+ effect="light"
70
+ content="开启后,选择数据接口会触发 remote-params 回调,用于从服务器获取字段"
71
+ placement="top"
72
+ >
73
+ <span style="color: #409EFF;">远程字段</span>
74
+ </el-tooltip>
75
+ <el-switch v-model="config.config.fields.remote"> </el-switch>
76
+ </el-form-item>
77
+ </div>
78
+ <div v-show="step === 1" class="formTemplates">
79
+ <div
80
+ :class="
81
+ `formTemplates-item th-border th-hover_boxShadow_light ${
82
+ formTemplateActive === index ? 'th-active' : ''
83
+ }`
84
+ "
85
+ v-for="(item, index) in formTemplates"
86
+ :key="index"
87
+ @click="handleFormTemplateClick(index)"
88
+ >
89
+ <img :src="item.img" alt="" />
90
+ <div>{{ item.name }}</div>
91
+ </div>
92
+ </div>
93
+ </el-form>
14
94
  </div>
15
95
  <div class="footer">
16
96
  <div></div>
@@ -23,31 +103,59 @@
23
103
  @click="handleBack"
24
104
  >上一步</el-button
25
105
  >
26
- <el-button type="primary" size="small" @click="handleNext"
27
- >下一步<i class="el-icon-right el-icon--right"></i
28
- ></el-button>
106
+ <el-button
107
+ v-if="step !== 1"
108
+ type="primary"
109
+ size="small"
110
+ @click="handleNext"
111
+ >
112
+ 下一步<i class="el-icon-right el-icon--right"></i>
113
+ </el-button>
114
+ <el-button v-else type="success" size="small" @click="handleSave">
115
+ 完&nbsp;&nbsp;&nbsp;成<i class="el-icon-finished el-icon--right"></i>
116
+ </el-button>
29
117
  </div>
30
118
  </div>
31
119
  </div>
32
120
  </template>
33
121
 
34
122
  <script>
123
+ import EmptyTemplateJson from "./assets/templates/empty.json";
124
+ import GeneralTemplateJson from "./assets/templates/general.json";
125
+ import PersonalDetailsTemplateJson from "./assets/templates/personalDetails.json";
126
+ import TableTemplateJson from "./assets/templates/table.json";
127
+ import { deepClone } from "./util";
35
128
  export default {
36
- props: { visible: { type: Boolean, default: true } },
129
+ props: { config: Object, apiOptions: Array },
37
130
  data() {
38
131
  return {
39
- show: this.visible,
40
- step: 0
132
+ step: 0,
133
+ formTemplates: [
134
+ {
135
+ img: require("./assets/images/json0.png"),
136
+ name: "空白表单",
137
+ data: EmptyTemplateJson
138
+ },
139
+ {
140
+ img: require("./assets/images/json1.png"),
141
+ name: "典型表单",
142
+ data: GeneralTemplateJson
143
+ },
144
+ {
145
+ img: require("./assets/images/json3.png"),
146
+ name: "复杂表单-人员履历",
147
+ data: PersonalDetailsTemplateJson
148
+ },
149
+ {
150
+ img: require("./assets/images/json6.png"),
151
+ name: "数据列表",
152
+ data: TableTemplateJson
153
+ }
154
+ ],
155
+ formTemplateActive: null
41
156
  };
42
157
  },
43
- watch: {
44
- visible(val) {
45
- this.show = val;
46
- },
47
- show(val) {
48
- this.$emit("update:visible", val);
49
- }
50
- },
158
+ computed: {},
51
159
  created() {},
52
160
  mounted() {},
53
161
  methods: {
@@ -57,8 +165,15 @@ export default {
57
165
  handleNext() {
58
166
  this.step++;
59
167
  },
60
- handleClose() {
61
- this.show = !this.show;
168
+ handleSave() {
169
+ if (this.formTemplateActive !== null) {
170
+ const list = this.formTemplates[this.formTemplateActive].data.list;
171
+ this.config.list = deepClone(list);
172
+ }
173
+ this.$emit("save");
174
+ },
175
+ handleFormTemplateClick(index) {
176
+ this.formTemplateActive = index;
62
177
  }
63
178
  }
64
179
  };
@@ -70,7 +185,13 @@ export default {
70
185
  height: 100%;
71
186
 
72
187
  .content {
73
- height: calc(100% - 50px);
188
+ height: calc(100% - 96px);
189
+ padding-top: 10px;
190
+ overflow-y: scroll;
191
+
192
+ .tools-item {
193
+ margin-bottom: 10px;
194
+ }
74
195
  }
75
196
  .footer {
76
197
  height: 50px;
@@ -78,9 +199,56 @@ export default {
78
199
  align-items: center;
79
200
  justify-content: space-between;
80
201
  box-sizing: border-box;
202
+ background-color: white;
81
203
 
82
204
  .stepView {
83
205
  }
84
206
  }
207
+ .fields-item {
208
+ span {
209
+ padding: 0px 8px 2px 8px;
210
+ border-radius: 4px;
211
+ }
212
+ span:nth-child(1) {
213
+ color: #1890ff;
214
+ background-color: #e8f4ff;
215
+ }
216
+ span:nth-child(2) {
217
+ color: #13ce66;
218
+ background-color: #e7faf0;
219
+ }
220
+ span:nth-child(3) {
221
+ color: #909399;
222
+ background-color: #f4f4f5;
223
+ }
224
+ }
225
+ .formTemplates {
226
+ .formTemplates-item {
227
+ display: inline-block;
228
+ margin: 10px;
229
+ padding: 10px;
230
+ width: 200px;
231
+ border-radius: 4px;
232
+ transition: 0.25s;
233
+
234
+ img {
235
+ width: 100%;
236
+ height: 180px;
237
+ object-fit: contain;
238
+ }
239
+ }
240
+ }
241
+ }
242
+ </style>
243
+
244
+ <style lang="scss">
245
+ .widgetGuide {
246
+ .el-transfer {
247
+ display: flex;
248
+ align-items: center;
249
+ }
250
+ .el-transfer-panel {
251
+ flex: 1;
252
+ }
85
253
  }
86
254
  </style>
@@ -74,7 +74,6 @@
74
74
  <el-button
75
75
  type="text"
76
76
  size="medium"
77
- disabled
78
77
  @click="handleDialogOpen('importTemplate')"
79
78
  >导入模板
80
79
  </el-button>
@@ -120,7 +119,8 @@
120
119
  :showFooter="
121
120
  dialog.action === 'previewPc' ||
122
121
  dialog.action === 'previewH5' ||
123
- dialog.action === 'importJson'
122
+ dialog.action === 'importJson' ||
123
+ dialog.action === 'importTemplate'
124
124
  "
125
125
  @on-close="handleDialogClose"
126
126
  @on-affirm="handleDialogAffirm"
@@ -133,7 +133,21 @@
133
133
  ></el-alert>
134
134
  <th-code-editor v-model="dialog.data" ref="codeEditor"></th-code-editor>
135
135
  </template>
136
- <template v-if="dialog.action === 'importTemplate'"> </template>
136
+ <div v-if="dialog.action === 'importTemplate'" class="formTemplates">
137
+ <div
138
+ :class="
139
+ `formTemplates-item th-border th-hover_boxShadow_light ${
140
+ formTemplateActive === index ? 'th-active' : ''
141
+ }`
142
+ "
143
+ v-for="(item, index) in formTemplates"
144
+ :key="index"
145
+ @click="handleFormTemplateClick(index)"
146
+ >
147
+ <img :src="item.img" alt="" />
148
+ <div>{{ item.name }}</div>
149
+ </div>
150
+ </div>
137
151
  <template v-if="dialog.action === 'generateJson'">
138
152
  <th-code-editor v-model="dialog.data" ref="codeEditor"></th-code-editor>
139
153
  </template>
@@ -164,7 +178,7 @@
164
178
  <template v-if="dialog.action === 'previewPc'">
165
179
  <generate-form
166
180
  v-if="dialog.show"
167
- :config="formData"
181
+ :config="formConfig"
168
182
  :oauthConfig="oauthConfig"
169
183
  :slotKeys="slotKeys"
170
184
  @change="handleDataChange"
@@ -188,7 +202,7 @@
188
202
  <generate-form
189
203
  v-if="dialog.show"
190
204
  class="box"
191
- :config="formData"
205
+ :config="formConfig"
192
206
  :oauthConfig="oauthConfig"
193
207
  @change="handleDataChange"
194
208
  @button-submit="handleButtonSubmit"
@@ -230,13 +244,17 @@ import { deepClone } from "./util/index";
230
244
  import * as XLSX from "xlsx/xlsx.mjs";
231
245
  import generateCode from "./util/generateCode.js";
232
246
  import GenerateForm from "./GenerateForm";
247
+ import EmptyTemplateJson from "./assets/templates/empty.json";
248
+ import GeneralTemplateJson from "./assets/templates/general.json";
249
+ import PersonalDetailsTemplateJson from "./assets/templates/personalDetails.json";
250
+ import TableTemplateJson from "./assets/templates/table.json";
233
251
  export default {
234
252
  props: {
235
253
  baseConfig: Object,
236
254
  permissions: Array,
237
255
  basicComponents: Array,
238
256
  layoutComponents: Array,
239
- formData: Object,
257
+ formConfig: Object,
240
258
  oauthConfig: Object,
241
259
  apiOptions: Array
242
260
  },
@@ -249,7 +267,6 @@ export default {
249
267
  data: null
250
268
  },
251
269
  dialogResultData: { show: false, data: null },
252
-
253
270
  dialogTitles: {
254
271
  previewPc: "预览-电脑端",
255
272
  previewH5: "预览-移动端",
@@ -258,7 +275,30 @@ export default {
258
275
  generateJson: "生成JSON",
259
276
  generateCode: "生成代码"
260
277
  },
261
- slotKeys: ["blank_1681093126000_96387"]
278
+ formTemplates: [
279
+ {
280
+ img: require("./assets/images/json0.png"),
281
+ name: "空白表单",
282
+ data: EmptyTemplateJson
283
+ },
284
+ {
285
+ img: require("./assets/images/json1.png"),
286
+ name: "典型表单",
287
+ data: GeneralTemplateJson
288
+ },
289
+ {
290
+ img: require("./assets/images/json3.png"),
291
+ name: "复杂表单-人员履历",
292
+ data: PersonalDetailsTemplateJson
293
+ },
294
+ {
295
+ img: require("./assets/images/json6.png"),
296
+ name: "数据列表",
297
+ data: TableTemplateJson
298
+ }
299
+ ],
300
+ formTemplateActive: null,
301
+ slotKeys: []
262
302
  };
263
303
  },
264
304
  created() {},
@@ -418,13 +458,13 @@ export default {
418
458
  let data = "";
419
459
  switch (action) {
420
460
  case "generateJson":
421
- data = JSON.stringify(this.formData, null, 2);
461
+ data = JSON.stringify(this.formConfig, null, 2);
422
462
  break;
423
463
  case "generateCode":
424
464
  data = {
425
465
  generate: generateCode(
426
466
  {
427
- formConfig: JSON.stringify(this.formData, null, 2),
467
+ formConfig: JSON.stringify(this.formConfig, null, 2),
428
468
  apiOptions: JSON.stringify(this.apiOptions, null, 2),
429
469
  oauthConfig: JSON.stringify(this.oauthConfig, null, 2)
430
470
  },
@@ -432,7 +472,7 @@ export default {
432
472
  ),
433
473
  making: generateCode(
434
474
  {
435
- formConfig: JSON.stringify(this.formData, null, 2),
475
+ formConfig: JSON.stringify(this.formConfig, null, 2),
436
476
  apiOptions: JSON.stringify(this.apiOptions, null, 2),
437
477
  oauthConfig: JSON.stringify(this.oauthConfig, null, 2)
438
478
  },
@@ -440,6 +480,9 @@ export default {
440
480
  )
441
481
  };
442
482
  break;
483
+ case "importTemplate":
484
+ this.formTemplateActive = null;
485
+ break;
443
486
 
444
487
  default:
445
488
  break;
@@ -453,6 +496,14 @@ export default {
453
496
  if (this.dialog.action === "importJson") {
454
497
  this.handleClick("import-json", JSON.parse(this.dialog.data));
455
498
  }
499
+ if (
500
+ this.dialog.action === "importTemplate" &&
501
+ this.formTemplateActive !== null
502
+ ) {
503
+ const list = this.formTemplates[this.formTemplateActive].data.list;
504
+ this.formConfig.list = deepClone(list);
505
+ this.$emit("importTemplate");
506
+ }
456
507
  this.handleDialogClose();
457
508
  },
458
509
  handleDialogFullscreen() {
@@ -472,8 +523,8 @@ export default {
472
523
  },
473
524
  handleNetworkConfig() {
474
525
  const fieldsApi = {
475
- fields: this.formData.config.fields.api,
476
- mounted: this.formData.config.mounted.api
526
+ fields: this.formConfig.config.fields.api,
527
+ mounted: this.formConfig.config.mounted.api
477
528
  };
478
529
  const initList = list => {
479
530
  for (const item of list) {
@@ -490,13 +541,16 @@ export default {
490
541
  }
491
542
  }
492
543
  };
493
- initList(this.formData.list);
544
+ initList(this.formConfig.list);
494
545
  const apis = Object.values(fieldsApi);
495
546
  const network = {};
496
547
  this.apiOptions.map(item => {
497
548
  if (apis.includes(item.id)) network[item.id] = item;
498
549
  });
499
- this.formData.config.network = network;
550
+ this.formConfig.config.network = network;
551
+ },
552
+ handleFormTemplateClick(index) {
553
+ this.formTemplateActive = index;
500
554
  }
501
555
  }
502
556
  };
@@ -520,6 +574,23 @@ export default {
520
574
  justify-content: right;
521
575
  }
522
576
 
577
+ .formTemplates {
578
+ .formTemplates-item {
579
+ display: inline-block;
580
+ margin: 10px;
581
+ padding: 10px;
582
+ width: 200px;
583
+ border-radius: 4px;
584
+ transition: 0.25s;
585
+
586
+ img {
587
+ width: 100%;
588
+ height: 180px;
589
+ object-fit: contain;
590
+ }
591
+ }
592
+ }
593
+
523
594
  .previewH5 {
524
595
  width: 300px;
525
596
  height: 649px;
@@ -0,0 +1,35 @@
1
+ {
2
+ "list": [],
3
+ "config": {
4
+ "fields": {
5
+ "type": "api",
6
+ "api": "",
7
+ "remote": true
8
+ },
9
+ "ui": "element",
10
+ "title": "",
11
+ "width": "",
12
+ "labelWidth": 100,
13
+ "labelPosition": "right",
14
+ "labelSuffix": ":",
15
+ "size": "small",
16
+ "disabled": false,
17
+ "hideLabel": false,
18
+ "mounted": {
19
+ "api": ""
20
+ },
21
+ "eventScript": [
22
+ {
23
+ "id": "mounted",
24
+ "label": "mounted",
25
+ "value": ""
26
+ },
27
+ {
28
+ "id": "refresh",
29
+ "label": "refresh",
30
+ "value": ""
31
+ }
32
+ ],
33
+ "network": {}
34
+ }
35
+ }