tianheng-ui 0.1.28 → 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.28",
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 apiOptions"
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", "apiOptions"],
130
+ props: ["config", "apiConfig"],
131
131
  data() {
132
132
  return {
133
133
  collapseValue: [
@@ -158,7 +158,7 @@
158
158
  <form-config
159
159
  v-if="configTab == 'form'"
160
160
  :config="formConfig.config"
161
- :apiOptions="apiOptions"
161
+ :apiConfig="apiConfig"
162
162
  @fieldsChange="handleFieldsChange"
163
163
  ref="formConfigRef"
164
164
  ></form-config>
@@ -205,6 +205,7 @@ export default {
205
205
  return {};
206
206
  }
207
207
  },
208
+ apiOptions: Array,
208
209
  permissions: {
209
210
  type: Array,
210
211
  default: () => [
@@ -248,8 +249,7 @@ export default {
248
249
  layoutFields: {
249
250
  type: Array,
250
251
  default: () => ["grid", "filler", "divider"]
251
- },
252
- apiOptions: Array
252
+ }
253
253
  },
254
254
  data() {
255
255
  this.basicComponents = basicComponents;
@@ -262,7 +262,8 @@ export default {
262
262
  widgetValue: {},
263
263
  configTab: "form",
264
264
  client: "monitor",
265
- fields: []
265
+ fields: [],
266
+ apiConfig: {}
266
267
  };
267
268
  },
268
269
  computed: {
@@ -295,12 +296,13 @@ export default {
295
296
  config(val) {
296
297
  this.setConfig(val);
297
298
  },
298
- apiOptions() {
299
+ apiOptions(val) {
300
+ this.initApiConfig();
299
301
  this.handleFieldsChange();
300
302
  }
301
303
  },
302
304
  created() {
303
- this.initConfig();
305
+ this.initOauthConfig();
304
306
  this.formConfig = Object.assign(this.baseConfig, this.config);
305
307
 
306
308
  if (this.formConfig.list && this.formConfig.list.length) {
@@ -309,10 +311,12 @@ export default {
309
311
  this.formConfig.list = [];
310
312
  }
311
313
  },
312
- mounted() {},
314
+ mounted() {
315
+ this.initApiConfig();
316
+ },
313
317
  methods: {
314
318
  // 初始化组件配置
315
- initConfig() {
319
+ initOauthConfig() {
316
320
  if (this.oauthConfig.token) {
317
321
  const oauthInfo = {
318
322
  token: this.oauthConfig.token,
@@ -335,6 +339,14 @@ export default {
335
339
  });
336
340
  }
337
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
+ },
338
350
 
339
351
  handleConfigSelect(value) {
340
352
  this.configTab = value;
@@ -373,11 +385,9 @@ export default {
373
385
  this.widgetFormSelect = Object.assign(this.widgetFormSelect, val);
374
386
  },
375
387
  handleFieldsChange() {
376
- const dataArr = this.apiOptions.filter(item => {
377
- return item.id === this.formConfig.config.fieldsApi;
378
- });
379
- if (dataArr.length && dataArr[0].paramsOut) {
380
- this.fields = dataArr[0].paramsOut.map(item => {
388
+ const data = this.apiConfig[this.formConfig.config.fieldsApi];
389
+ if (data) {
390
+ this.fields = data.paramsOut.map(item => {
381
391
  return {
382
392
  label: item.note || item.name,
383
393
  alias: item.name,
@@ -397,7 +407,7 @@ export default {
397
407
  this.$refs.formConfigRef.formValidate().then(res => {
398
408
  if (res) {
399
409
  const data = deepClone(this.formConfig);
400
- data.config.network = this.apiOptions;
410
+ data.config.network = this.apiConfig;
401
411
  resolve(data);
402
412
  } else {
403
413
  reject();
@@ -419,7 +429,7 @@ export default {
419
429
  return reject();
420
430
  }
421
431
  const data = deepClone(this.formConfig);
422
- data.config.network = this.apiOptions;
432
+ data.config.network = this.apiConfig;
423
433
  resolve(data);
424
434
  });
425
435
  }
@@ -129,7 +129,7 @@
129
129
  @on-affirm="handleDialogAffirm"
130
130
  >
131
131
  <template v-if="dialog.action === 'preview'">
132
- <th-table-generate :config="config"> </th-table-generate>
132
+ <th-table-generate :config="deepClone(config)"> </th-table-generate>
133
133
  </template>
134
134
  <template v-else-if="dialog.action === 'importJson'">
135
135
  <el-alert
@@ -154,6 +154,8 @@
154
154
  </template>
155
155
 
156
156
  <script>
157
+ import { deepClone } from "./util";
158
+
157
159
  export default {
158
160
  props: {
159
161
  config: Object,
@@ -179,6 +181,7 @@ export default {
179
181
  created() {},
180
182
  mounted() {},
181
183
  methods: {
184
+ deepClone: deepClone,
182
185
  handleClick(val, data) {
183
186
  this.$emit("click", val, data);
184
187
  },
@@ -195,7 +198,12 @@ export default {
195
198
  this.dialog = { show: true, action, data };
196
199
  },
197
200
  handleDialogFullscreen() {
198
- this.$refs.codeEditor.resize();
201
+ if (
202
+ this.dialog.action === "importJson" ||
203
+ this.dialog.action === "generateJson"
204
+ ) {
205
+ this.$refs.codeEditor.resize();
206
+ }
199
207
  },
200
208
  handleDialogAffirm() {
201
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>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <div class="generateTable-table">
3
+ <el-table
4
+ :style="config.style.table.customStyle"
5
+ :data="data"
6
+ :border="config.style.table.border"
7
+ :height="config.style.table.height"
8
+ :max-height="config.style.table.maxHeight"
9
+ >
10
+ <el-table-column
11
+ v-for="item in config.options"
12
+ :key="item.prop"
13
+ :prop="item.prop"
14
+ :label="item.label"
15
+ :width="item.width || 180"
16
+ >
17
+ </el-table-column>
18
+ </el-table>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ export default {
24
+ props: {
25
+ data: Array,
26
+ config: Object
27
+ },
28
+ data() {
29
+ return {};
30
+ },
31
+ created() {},
32
+ mounted() {},
33
+ methods: {}
34
+ };
35
+ </script>
36
+
37
+ <style lang="scss" scoped>
38
+ .generateTable-table {
39
+ width: 100%;
40
+ }
41
+ </style>
@@ -1,16 +1,22 @@
1
1
  <template>
2
- <div class="th-table-tools">
3
- <el-button
4
- v-for="(item, index) in options"
5
- :key="index"
6
- :style="item.style"
7
- :type="item.type"
8
- :icon="item.icon"
9
- :disabled="item.disabled || disabled[item.act]"
10
- :loading="item.loading"
11
- @click="handleClick(item)"
12
- >{{ item.name }}</el-button
13
- >
2
+ <div class="generateTable-tools">
3
+ <el-form :inline="true">
4
+ <el-form-item v-for="item in options" :key="item.type">
5
+ <el-button
6
+ :style="item.style.customStyle"
7
+ :type="item.style.type"
8
+ :icon="item.style.icon"
9
+ :plain="item.style.plain"
10
+ :round="item.style.round"
11
+ :circle="item.style.circle"
12
+ :size="item.style.size"
13
+ :disabled="item.style.disabled || disabled[item.act]"
14
+ :loading="item.style.loading"
15
+ @click="handleClick(item)"
16
+ >{{ item.name }}</el-button
17
+ >
18
+ </el-form-item>
19
+ </el-form>
14
20
  </div>
15
21
  </template>
16
22
 
@@ -36,14 +42,14 @@ export default {
36
42
  },
37
43
  methods: {
38
44
  handleClick(item) {
39
- this.$emit("on-click", item);
45
+ this.$emit("click", item);
40
46
  }
41
47
  }
42
48
  };
43
49
  </script>
44
50
 
45
51
  <style lang="less" scoped>
46
- .th-table-tools {
47
- margin-bottom: 10px;
52
+ .generateTable-tools {
53
+ width: 100%;
48
54
  }
49
55
  </style>