tianheng-ui 0.1.27 → 0.1.29

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.27",
4
+ "version": "0.1.29",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -46,7 +46,7 @@
46
46
  @change="handleFieldsApiChange"
47
47
  >
48
48
  <el-option
49
- v-for="item in config.network"
49
+ v-for="item in Object.values(apiConfig)"
50
50
  :key="item.id"
51
51
  :label="item.label"
52
52
  :value="item.id"
@@ -127,7 +127,7 @@
127
127
 
128
128
  <script>
129
129
  export default {
130
- props: ["config"],
130
+ props: ["config", "apiConfig"],
131
131
  data() {
132
132
  return {
133
133
  collapseValue: [
@@ -150,22 +150,8 @@ export default {
150
150
  };
151
151
  },
152
152
  methods: {
153
- handleFieldsApiChange(val) {
154
- const dataArr = this.config.network.filter(item => {
155
- return item.id === val;
156
- });
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", []);
153
+ handleFieldsApiChange() {
154
+ this.$emit("fieldsChange");
169
155
  },
170
156
  formValidate() {
171
157
  return new Promise((resolve, reject) => {
@@ -117,7 +117,7 @@ export default {
117
117
  },
118
118
  watch: {
119
119
  config(val) {
120
- this.setJSON(val);
120
+ this.setConfig(val);
121
121
  },
122
122
  formJson: {
123
123
  handler(val) {
@@ -262,7 +262,7 @@ export default {
262
262
  onInputChange(value, field) {
263
263
  this.$emit("on-change", field, value, this.models);
264
264
  },
265
- setJSON(json) {
265
+ setConfig(json) {
266
266
  this.formJson = json;
267
267
  this.generateModle(this.formJson.list);
268
268
  }
@@ -66,12 +66,12 @@
66
66
  <el-tooltip
67
67
  slot="label"
68
68
  effect="dark"
69
- content="表单提交时的入参名,对应数据表中的字段"
69
+ content="表单提交时的入参名,对应数据表中的字段,非必要不修改!"
70
70
  placement="top"
71
71
  >
72
72
  <span style="color: #409EFF;">字段标识</span>
73
73
  </el-tooltip>
74
- <el-input v-model="data.model" readonly></el-input>
74
+ <el-input v-model="data.model"></el-input>
75
75
  </el-form-item>
76
76
  </el-collapse-item>
77
77
 
@@ -772,29 +772,32 @@ export const layoutComponents = [
772
772
  export const templateComponents = [];
773
773
 
774
774
  export const baseConfig = {
775
- fieldsType: "fieldsApi",
776
- fieldsApi: "",
777
- ui: "element",
778
- title: "",
779
- width: "",
780
- labelWidth: 100,
781
- labelPosition: "right",
782
- labelSuffix: ":",
783
- size: "small",
784
- disabled: false,
785
- hideLabel: false,
786
- mounted: { api: "" },
787
- eventScript: [
788
- {
789
- id: "mounted",
790
- label: "mounted",
791
- value: ""
792
- },
793
- {
794
- id: "refresh",
795
- label: "refresh",
796
- value: ""
797
- }
798
- ],
799
- network: []
775
+ list: [],
776
+ config: {
777
+ fieldsType: "fieldsApi",
778
+ fieldsApi: "",
779
+ ui: "element",
780
+ title: "",
781
+ width: "",
782
+ labelWidth: 100,
783
+ labelPosition: "right",
784
+ labelSuffix: ":",
785
+ size: "small",
786
+ disabled: false,
787
+ hideLabel: false,
788
+ mounted: { api: "" },
789
+ eventScript: [
790
+ {
791
+ id: "mounted",
792
+ label: "mounted",
793
+ value: ""
794
+ },
795
+ {
796
+ id: "refresh",
797
+ label: "refresh",
798
+ value: ""
799
+ }
800
+ ],
801
+ network: []
802
+ }
800
803
  };
@@ -158,6 +158,7 @@
158
158
  <form-config
159
159
  v-if="configTab == 'form'"
160
160
  :config="formConfig.config"
161
+ :apiConfig="apiConfig"
161
162
  @fieldsChange="handleFieldsChange"
162
163
  ref="formConfigRef"
163
164
  ></form-config>
@@ -197,18 +198,14 @@ export default {
197
198
  GenerateForm
198
199
  },
199
200
  props: {
200
- config: {
201
- type: Object,
202
- default: () => {
203
- return { config: {}, list: [] };
204
- }
205
- },
201
+ config: Object,
206
202
  oauthConfig: {
207
203
  type: Object,
208
204
  default: () => {
209
205
  return {};
210
206
  }
211
207
  },
208
+ apiOptions: Array,
212
209
  permissions: {
213
210
  type: Array,
214
211
  default: () => [
@@ -252,8 +249,7 @@ export default {
252
249
  layoutFields: {
253
250
  type: Array,
254
251
  default: () => ["grid", "filler", "divider"]
255
- },
256
- apiOptions: Array
252
+ }
257
253
  },
258
254
  data() {
259
255
  this.basicComponents = basicComponents;
@@ -261,12 +257,13 @@ export default {
261
257
  this.layoutComponents = layoutComponents;
262
258
  this.baseConfig = deepClone(baseConfig);
263
259
  return {
264
- formConfig: this.config,
260
+ formConfig: this.baseConfig,
265
261
  widgetFormSelect: {},
266
262
  widgetValue: {},
267
263
  configTab: "form",
268
264
  client: "monitor",
269
- fields: []
265
+ fields: [],
266
+ apiConfig: {}
270
267
  };
271
268
  },
272
269
  computed: {
@@ -294,27 +291,19 @@ export default {
294
291
  deep: true,
295
292
  handler: function(val) {
296
293
  this.$emit("update:config", val);
297
- // this.$emit("on-change", val);
298
294
  }
299
295
  },
300
296
  config(val) {
301
- if (val && val.config) {
302
- val.config = Object.assign(this.baseConfig, val.config);
303
- }
304
- this.setJSON(val);
297
+ this.setConfig(val);
305
298
  },
306
299
  apiOptions(val) {
307
- if (val) {
308
- this.formConfig.config.network = val;
309
- }
300
+ this.initApiConfig();
301
+ this.handleFieldsChange();
310
302
  }
311
303
  },
312
304
  created() {
313
- this.initConfig();
314
- this.formConfig.config = Object.assign(
315
- this.baseConfig,
316
- this.formConfig.config
317
- );
305
+ this.initOauthConfig();
306
+ this.formConfig = Object.assign(this.baseConfig, this.config);
318
307
 
319
308
  if (this.formConfig.list && this.formConfig.list.length) {
320
309
  this.widgetFormSelect = this.formConfig.list[0];
@@ -322,10 +311,12 @@ export default {
322
311
  this.formConfig.list = [];
323
312
  }
324
313
  },
325
- mounted() {},
314
+ mounted() {
315
+ this.initApiConfig();
316
+ },
326
317
  methods: {
327
318
  // 初始化组件配置
328
- initConfig() {
319
+ initOauthConfig() {
329
320
  if (this.oauthConfig.token) {
330
321
  const oauthInfo = {
331
322
  token: this.oauthConfig.token,
@@ -348,6 +339,14 @@ export default {
348
339
  });
349
340
  }
350
341
  },
342
+ initApiConfig() {
343
+ this.apiConfig = {};
344
+ if (this.apiOptions.length) {
345
+ this.apiOptions.map(item => {
346
+ this.apiConfig[item.id] = item;
347
+ });
348
+ }
349
+ },
351
350
 
352
351
  handleConfigSelect(value) {
353
352
  this.configTab = value;
@@ -372,7 +371,7 @@ export default {
372
371
  case "import-excel":
373
372
  case "import-json":
374
373
  case "import-template":
375
- this.setJSON(data);
374
+ this.setConfig(data);
376
375
  break;
377
376
  case "clear":
378
377
  this.handleClear();
@@ -385,8 +384,19 @@ export default {
385
384
  handleWidgetConfigUpdate(val) {
386
385
  this.widgetFormSelect = Object.assign(this.widgetFormSelect, val);
387
386
  },
388
- handleFieldsChange(val) {
389
- this.fields = val;
387
+ handleFieldsChange() {
388
+ const data = this.apiConfig[this.formConfig.config.fieldsApi];
389
+ if (data) {
390
+ this.fields = data.paramsOut.map(item => {
391
+ return {
392
+ label: item.note || item.name,
393
+ alias: item.name,
394
+ prop: item.name,
395
+ type: "input",
396
+ align: "left"
397
+ };
398
+ });
399
+ } else this.fields = [];
390
400
  },
391
401
  clear() {
392
402
  this.handleClear();
@@ -397,6 +407,7 @@ export default {
397
407
  this.$refs.formConfigRef.formValidate().then(res => {
398
408
  if (res) {
399
409
  const data = deepClone(this.formConfig);
410
+ data.config.network = this.apiConfig;
400
411
  resolve(data);
401
412
  } else {
402
413
  reject();
@@ -418,6 +429,7 @@ export default {
418
429
  return reject();
419
430
  }
420
431
  const data = deepClone(this.formConfig);
432
+ data.config.network = this.apiConfig;
421
433
  resolve(data);
422
434
  });
423
435
  }
@@ -425,12 +437,14 @@ export default {
425
437
  getHtml() {
426
438
  return generateCode(JSON.stringify(this.formConfig));
427
439
  },
428
- setJSON(json) {
429
- this.formConfig = json;
440
+ setConfig(val) {
441
+ this.formConfig = Object.assign(this.baseConfig, val);
430
442
 
431
- if (json.list.length > 0) {
432
- this.widgetFormSelect = json.list[0];
443
+ if (this.formConfig.list.length > 0) {
444
+ this.widgetFormSelect = this.formConfig.list[0];
433
445
  }
446
+
447
+ this.handleFieldsChange();
434
448
  }
435
449
  }
436
450
  };
@@ -35,7 +35,6 @@
35
35
  type="text"
36
36
  size="medium"
37
37
  icon="el-icon-view"
38
- disabled
39
38
  @click="handleDialogOpen('preview')"
40
39
  >预览
41
40
  </el-button>
@@ -129,7 +128,9 @@
129
128
  @on-close="handleDialogClose"
130
129
  @on-affirm="handleDialogAffirm"
131
130
  >
132
- <template v-if="dialog.action === 'preview'"></template>
131
+ <template v-if="dialog.action === 'preview'">
132
+ <th-table-generate :config="deepClone(config)"> </th-table-generate>
133
+ </template>
133
134
  <template v-else-if="dialog.action === 'importJson'">
134
135
  <el-alert
135
136
  type="info"
@@ -153,6 +154,8 @@
153
154
  </template>
154
155
 
155
156
  <script>
157
+ import { deepClone } from "./util";
158
+
156
159
  export default {
157
160
  props: {
158
161
  config: Object,
@@ -178,6 +181,7 @@ export default {
178
181
  created() {},
179
182
  mounted() {},
180
183
  methods: {
184
+ deepClone: deepClone,
181
185
  handleClick(val, data) {
182
186
  this.$emit("click", val, data);
183
187
  },
@@ -194,7 +198,12 @@ export default {
194
198
  this.dialog = { show: true, action, data };
195
199
  },
196
200
  handleDialogFullscreen() {
197
- this.$refs.codeEditor.resize();
201
+ if (
202
+ this.dialog.action === "importJson" ||
203
+ this.dialog.action === "generateJson"
204
+ ) {
205
+ this.$refs.codeEditor.resize();
206
+ }
198
207
  },
199
208
  handleDialogAffirm() {
200
209
  const action = this.dialog.action;
@@ -10,30 +10,6 @@ export const table = {
10
10
  api: ""
11
11
  },
12
12
  fieldsType: "fieldsApi",
13
- style: {
14
- cell: {
15
- customStyle: "",
16
- margin: "",
17
- padding: "20rpx",
18
- "border-bottom": "1px solid #e5e5e5"
19
- },
20
- title: {
21
- customStyle: "",
22
- margin: "",
23
- padding: "",
24
- width: "",
25
- "text-align": "",
26
- color: "#999"
27
- },
28
- value: {
29
- customStyle: "",
30
- margin: "",
31
- padding: "",
32
- width: "",
33
- "text-align": "",
34
- color: "#333"
35
- }
36
- },
37
13
  options: [],
38
14
  pageInfo: {
39
15
  show: true,
@@ -59,7 +35,35 @@ export const table = {
59
35
  text: "暂无数据",
60
36
  image: ""
61
37
  },
62
- sequence: true
38
+ sequence: true,
39
+ style: {
40
+ table: {
41
+ border: true,
42
+ customStyle: ""
43
+ },
44
+ cell: {
45
+ customStyle: "",
46
+ margin: "",
47
+ padding: "20rpx",
48
+ "border-bottom": "1px solid #e5e5e5"
49
+ },
50
+ title: {
51
+ customStyle: "",
52
+ margin: "",
53
+ padding: "",
54
+ width: "",
55
+ "text-align": "",
56
+ color: "#999"
57
+ },
58
+ value: {
59
+ customStyle: "",
60
+ margin: "",
61
+ padding: "",
62
+ width: "",
63
+ "text-align": "",
64
+ color: "#333"
65
+ }
66
+ }
63
67
  };
64
68
 
65
69
  // 按钮配置
@@ -1,74 +1,78 @@
1
1
  <template>
2
- <div class="th-table-search" v-if="options.length">
3
- <div
4
- v-for="(item, index) in options"
5
- class="th-table-search-item"
6
- :key="index"
7
- >
8
- <span class="th-table-search-item-title">{{ item.label }}:</span>
9
- <el-input
10
- v-if="item.type === 'input'"
11
- v-model="params[item.prop]"
12
- :style="{ width: `${item.width || '180'}px` }"
13
- :placeholder="item.placeholder || '请输入'"
14
- :disabled="item.disabled"
15
- clearable
16
- ></el-input>
17
- <el-date-picker
18
- v-if="item.type === 'date'"
19
- v-model="params[item.prop]"
20
- :style="{ width: `${item.width || '180'}px` }"
21
- :type="item.dateType || 'date'"
22
- :format="item.format"
23
- :value-format="item.valueFormat"
24
- range-separator="至"
25
- start-placeholder="开始日期"
26
- end-placeholder="结束日期"
27
- clearable
2
+ <div class="generateTable-search">
3
+ <el-form :inline="true" :model="data" size="small">
4
+ <el-form-item
5
+ v-for="item in options"
6
+ :key="item.prop"
7
+ :label="item.label"
28
8
  >
29
- </el-date-picker>
30
- <el-select
31
- v-if="item.type === 'select'"
32
- v-model="params[item.prop]"
33
- :style="{ width: `${item.width || '180'}px` }"
34
- :placeholder="item.placeholder || '请选择'"
35
- :multiple="item.multiple"
36
- :multiple-limit="item.multipleLimit"
37
- :filterable="item.filterable"
38
- :disabled="item.disabled"
39
- clearable
40
- >
41
- <template v-if="item.remote">
42
- <el-option
43
- v-for="option in item.remoteData"
44
- :key="option[item.props.value]"
45
- :label="option[item.props.label]"
46
- :value="option[item.props.value]"
47
- >
48
- </el-option>
49
- </template>
50
- <template v-else>
51
- <el-option
52
- v-for="option in item.staticData"
53
- :key="option.value"
54
- :label="option.label"
55
- :value="option.value"
56
- >
57
- </el-option>
58
- </template>
59
- </el-select>
60
- </div>
61
-
62
- <el-button type="primary" icon="el-icon-search" plain @click="doSearch"
63
- >查询</el-button
64
- >
65
- <el-button
66
- type="primary"
67
- icon="el-icon-refresh-right"
68
- plain
69
- @click="doReset"
70
- >重置</el-button
71
- >
9
+ <el-input
10
+ v-if="item.type === 'input' || item.elType === 'input'"
11
+ v-model="data[item.prop]"
12
+ :style="{ width: `${item.width || '180'}px` }"
13
+ :placeholder="item.placeholder || '请输入'"
14
+ :disabled="item.disabled"
15
+ clearable
16
+ ></el-input>
17
+ <el-date-picker
18
+ v-if="item.type === 'date' || item.elType === 'date'"
19
+ v-model="data[item.prop]"
20
+ :style="{ width: `${item.width || '180'}px` }"
21
+ :type="item.dateType || 'date'"
22
+ :format="item.format"
23
+ :value-format="item.valueFormat"
24
+ range-separator=""
25
+ start-placeholder="开始日期"
26
+ end-placeholder="结束日期"
27
+ clearable
28
+ >
29
+ </el-date-picker>
30
+ <el-select
31
+ v-if="item.type === 'select' || item.elType === 'select'"
32
+ v-model="data[item.prop]"
33
+ :style="{ width: `${item.width || '180'}px` }"
34
+ :placeholder="item.placeholder || '请选择'"
35
+ :multiple="item.multiple"
36
+ :multiple-limit="item.multipleLimit"
37
+ :filterable="item.filterable"
38
+ :disabled="item.disabled"
39
+ clearable
40
+ >
41
+ <template v-if="item.remote">
42
+ <el-option
43
+ v-for="option in item.remoteData"
44
+ :key="option[item.props.value]"
45
+ :label="option[item.props.label]"
46
+ :value="option[item.props.value]"
47
+ >
48
+ </el-option>
49
+ </template>
50
+ <template v-else>
51
+ <el-option
52
+ v-for="option in item.staticData"
53
+ :key="option.value"
54
+ :label="option.label"
55
+ :value="option.value"
56
+ >
57
+ </el-option>
58
+ </template>
59
+ </el-select>
60
+ </el-form-item>
61
+ <el-form-item>
62
+ <el-button type="primary" icon="el-icon-search" plain @click="doSearch">
63
+ 查询
64
+ </el-button>
65
+ </el-form-item>
66
+ <el-form-item>
67
+ <el-button
68
+ type="primary"
69
+ icon="el-icon-refresh-right"
70
+ plain
71
+ @click="doReset"
72
+ >重置</el-button
73
+ >
74
+ </el-form-item>
75
+ </el-form>
72
76
  </div>
73
77
  </template>
74
78
 
@@ -89,70 +93,24 @@ export default {
89
93
  }
90
94
  },
91
95
  data() {
92
- return {
93
- params: this.data,
94
- datePickerTypes: [
95
- "year",
96
- "month",
97
- "date",
98
- "dates",
99
- "week",
100
- "datetime",
101
- "datetimerange",
102
- "daterange",
103
- "monthrange"
104
- ]
105
- };
106
- },
107
- watch: {
108
- options: {
109
- handler(newVal, oldVal) {
110
- if (newVal && newVal.length) {
111
- newVal.map(item => {
112
- this.$set(this.params, item.prop, item.defaultValue || "");
113
- });
114
- }
115
- },
116
- deep: true,
117
- immediate: true
118
- },
119
- data(val) {
120
- this.params = val;
121
- },
122
- params: {
123
- deep: true,
124
- handler(val) {
125
- this.$emit("update:data", val);
126
- }
127
- }
96
+ return {};
128
97
  },
129
98
  methods: {
130
99
  doSearch() {
131
- this.$emit("on-search", this.params);
100
+ this.$emit("search", this.data);
132
101
  },
133
102
  doReset() {
134
103
  this.options.map(item => {
135
- this.$set(this.params, item.prop, item.defaultValue || "");
104
+ this.$set(this.data, item.prop, item.defaultValue || "");
136
105
  });
137
- this.$emit("on-reset", this.params);
106
+ this.$emit("reset", this.data);
138
107
  }
139
108
  }
140
109
  };
141
110
  </script>
142
111
 
143
112
  <style lang="scss" scoped>
144
- .th-table-search {
145
- margin-bottom: 10px;
146
- &-item {
147
- display: inline-block;
148
- margin-right: 15px;
149
- margin-bottom: 10px;
150
- &-title {
151
- font-size: 14px;
152
- }
153
- }
154
- .th-table-search-item:last-child {
155
- margin-right: 20px !important;
156
- }
113
+ .generateTable-search {
114
+ width: 100%;
157
115
  }
158
116
  </style>