tianheng-ui 0.1.25 → 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.25",
4
+ "version": "0.1.27",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -5,10 +5,12 @@
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 required>
13
+ <el-form-item prop="fieldsType" required>
12
14
  <el-tooltip
13
15
  slot="label"
14
16
  effect="dark"
@@ -22,7 +24,11 @@
22
24
  <el-radio-button label="fieldsApi">接口导入</el-radio-button>
23
25
  </el-radio-group>
24
26
  </el-form-item>
25
- <el-form-item v-if="config.fieldsType === 'fieldsApi'" required>
27
+ <el-form-item
28
+ v-if="config.fieldsType === 'fieldsApi'"
29
+ prop="fieldsApi"
30
+ required
31
+ >
26
32
  <el-tooltip
27
33
  slot="label"
28
34
  effect="dark"
@@ -48,7 +54,7 @@
48
54
  </el-option>
49
55
  </el-select>
50
56
  </el-form-item>
51
- <el-form-item label="表单标题" required>
57
+ <el-form-item label="表单标题" prop="title" required>
52
58
  <el-input
53
59
  v-model="config.title"
54
60
  placeholder="请输入"
@@ -129,7 +135,18 @@ export default {
129
135
  "group-resultData",
130
136
  "group-label",
131
137
  "group-attributes"
132
- ]
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
+ }
133
150
  };
134
151
  },
135
152
  methods: {
@@ -149,6 +166,13 @@ export default {
149
166
  });
150
167
  this.$emit("fieldsChange", fields);
151
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
+ });
152
176
  }
153
177
  }
154
178
  };
@@ -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
@@ -159,6 +159,7 @@
159
159
  v-if="configTab == 'form'"
160
160
  :config="formConfig.config"
161
161
  @fieldsChange="handleFieldsChange"
162
+ ref="formConfigRef"
162
163
  ></form-config>
163
164
  </el-main>
164
165
  </el-container>
@@ -390,8 +391,36 @@ export default {
390
391
  clear() {
391
392
  this.handleClear();
392
393
  },
393
- getJSON() {
394
- 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
+ }
395
424
  },
396
425
  getHtml() {
397
426
  return generateCode(JSON.stringify(this.formConfig));
@@ -39,7 +39,7 @@ export default {
39
39
  config: {
40
40
  type: Object,
41
41
  default: () => {
42
- return deepClone(baseConfig);
42
+ return {};
43
43
  }
44
44
  },
45
45
 
@@ -86,6 +86,7 @@ export default {
86
86
  }
87
87
  },
88
88
  data() {
89
+ this.baseConfig = deepClone(baseConfig);
89
90
  return {
90
91
  tableConfig: this.config,
91
92
  client: "monitor"
@@ -99,14 +100,16 @@ export default {
99
100
  }
100
101
  },
101
102
  config(val) {
102
- this.tableConfig = val;
103
+ this.tableConfig = Object.assign(this.baseConfig, val);
103
104
  this.handleNetwork();
104
105
  },
105
106
  apiOptions(val) {
106
107
  this.handleNetwork();
107
108
  }
108
109
  },
109
- mounted() {},
110
+ mounted() {
111
+ this.tableConfig = Object.assign(this.baseConfig, this.tableConfig);
112
+ },
110
113
  methods: {
111
114
  handleNetwork() {
112
115
  const network = {};
@@ -129,10 +132,10 @@ export default {
129
132
  break;
130
133
  }
131
134
  },
132
- getJson() {
135
+ getConfig() {
133
136
  return new Promise((resolve, reject) =>
134
137
  this.$refs.configRef
135
- .handleFormValidate()
138
+ .formValidate()
136
139
  .then(res => {
137
140
  if (res) {
138
141
  const data = deepClone(this.tableConfig);
@@ -609,7 +609,7 @@ export default {
609
609
  this.fields = fields;
610
610
  } else this.fields = [];
611
611
  },
612
- handleFormValidate() {
612
+ formValidate() {
613
613
  return new Promise((resolve, reject) => {
614
614
  if (this.$refs.formRef) {
615
615
  this.$refs.formRef.validate(valid => {