tianheng-ui 0.1.28 → 0.1.30

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.
@@ -0,0 +1,43 @@
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
+ console.log(this.config)
34
+ },
35
+ methods: {}
36
+ };
37
+ </script>
38
+
39
+ <style lang="scss" scoped>
40
+ .generateTable-table {
41
+ width: 100%;
42
+ }
43
+ </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>
@@ -5,8 +5,8 @@
5
5
  v-if="searchConfig.show"
6
6
  :data="searchData"
7
7
  :options="searchConfig.options"
8
- @on-search="requestListData"
9
- @on-reset="requestListData"
8
+ @search="requestListData"
9
+ @reset="requestListData"
10
10
  />
11
11
 
12
12
  <!-- 菜单栏 -->
@@ -17,11 +17,13 @@
17
17
  batchDelete: tableSelectionData.length === 0,
18
18
  export: tableSelectionData.length === 0
19
19
  }"
20
- @on-click="handleToolsClick"
20
+ @click="handleToolsClick"
21
21
  />
22
22
 
23
+ <STable v-if="tableConfig" :data="tableData" :config="tableConfig"></STable>
24
+
23
25
  <!-- 表格 -->
24
- <th-table
26
+ <!-- <th-table
25
27
  v-if="tableConfig.options.length"
26
28
  ref="tableRef"
27
29
  :data="tableData"
@@ -53,7 +55,7 @@
53
55
  >
54
56
  </th-table-action>
55
57
  </template>
56
- </th-table>
58
+ </th-table> -->
57
59
 
58
60
  <!-- 表单 -->
59
61
  <th-dialog
@@ -88,11 +90,11 @@
88
90
  <script>
89
91
  import Search from "./custom/items/search";
90
92
  import Tools from "./custom/items/tools";
91
- import { toolsItemConfig } from "./util/index";
93
+ import STable from "./custom/items/table";
92
94
  import * as Axios from "lib/theme-chalk/js/axios";
93
95
  export default {
94
96
  name: "thTableGenerate",
95
- components: { Search, Tools },
97
+ components: { Search, Tools, STable },
96
98
  props: {
97
99
  config: Object,
98
100
  oauthConfig: {
@@ -136,8 +138,17 @@ export default {
136
138
  searchConfig: { show: false, options: [] },
137
139
  searchData: {},
138
140
  toolsConfig: { show: false, options: [] },
139
- tableConfig: { options: [], pageInfo: {} },
140
- tableData: [],
141
+ tableConfig: null,
142
+ tableData: [
143
+ { id: 1 },
144
+ { id: 2 },
145
+ { id: 3 },
146
+ { id: 4 },
147
+ { id: 5 },
148
+ { id: 6 },
149
+ { id: 7 },
150
+ { id: 8 }
151
+ ],
141
152
  tableSelectionData: [],
142
153
  dialog: { show: false, data: {}, action: {} },
143
154
  formConfig: null,
@@ -195,19 +206,14 @@ export default {
195
206
 
196
207
  // 搜索栏
197
208
  this.searchConfig = this.tableJson.search;
198
- if (this.searchConfig.show) {
199
- this.searchConfig.options.map(item => {
200
- this.$set(this.searchData, item.prop, item.defaultValue || "");
201
- });
202
- }
209
+ this.searchConfig.options.map(item => {
210
+ this.$set(this.searchData, item.prop, item.defaultValue || "");
211
+ });
203
212
 
204
213
  // table
205
- for (let i = 0; i < this.tableJson.table.options.length; i++) {
206
- const element = this.tableJson.table.options[i];
207
- delete element.type;
208
- }
209
- if (this.tableJson.table.sequence) {
210
- this.tableJson.table.options.unshift({
214
+ this.tableConfig = this.tableJson.table;
215
+ if (this.tableConfig.sequence) {
216
+ this.tableConfig.options.unshift({
211
217
  type: "index",
212
218
  label: "序号"
213
219
  });
@@ -220,32 +226,28 @@ export default {
220
226
  actions: []
221
227
  };
222
228
 
229
+ // tools
230
+ this.toolsConfig = { show: false, options: [] };
223
231
  // 按position处理按钮,1:公共区,2:行内区
224
- for (const key in this.tableJson.tools) {
225
- if (Object.hasOwnProperty.call(this.tableJson.tools, key)) {
226
- const element = this.tableJson.tools[key];
227
- if (!element.show) continue;
228
- if (key === "batchDelete") {
229
- this.tableJson.table.options.unshift({
230
- type: "selection"
231
- });
232
- }
233
- const dic = toolsItemConfig(key, element);
234
- dic.form = element.form;
235
- if (element.position === 1 || element.position === "header") {
236
- this.toolsConfig.show = true;
237
- this.toolsConfig.options.push(dic);
238
- } else if (element.position === 2 || element.position === "row") {
239
- action.hide = false;
240
- action.actions.push(dic);
241
- }
232
+ Object.values(this.tableJson.tools).map(item => {
233
+ if (!item.show) return;
234
+ if (item.type === "batchDelete") {
235
+ this.tableConfig.options.unshift({
236
+ type: "selection"
237
+ });
242
238
  }
243
- }
239
+ if (item.position === 1 || item.position === "header") {
240
+ this.toolsConfig.show = true;
241
+ this.toolsConfig.options.push(item);
242
+ } else if (item.position === 2 || item.position === "row") {
243
+ action.hide = false;
244
+ action.actions.push(item);
245
+ }
246
+ });
244
247
  action.width = action.actions.length * 60 + 20;
245
- this.tableJson.table.options.push(action);
248
+ if (!action.hide) this.tableConfig.options.push(action);
246
249
 
247
- this.tableConfig = this.tableJson.table;
248
- this.requestListData();
250
+ // this.requestListData();
249
251
  },
250
252
  requestListData() {
251
253
  if (!this.networkConfig.mounted) return;
@@ -396,7 +398,7 @@ export default {
396
398
  },
397
399
  handleToolsClick(action) {
398
400
  console.log("handleToolsClick =>", action);
399
- switch (action.act) {
401
+ switch (action.type) {
400
402
  case "add":
401
403
  this.dialog = { show: true, data: {}, action: action };
402
404
  this.requestFormConfigData(action);
@@ -186,6 +186,14 @@
186
186
  <i class="el-icon-set-up" @click="handleActionConfig(item)"></i>
187
187
  </div>
188
188
  </el-collapse-item>
189
+ <el-collapse-item
190
+ title="table 样式配置(电脑端)"
191
+ name="group-style_table"
192
+ >
193
+ <el-form-item label="是否边框">
194
+ <el-switch v-model="config.table.style.table.border"> </el-switch>
195
+ </el-form-item>
196
+ </el-collapse-item>
189
197
  <el-collapse-item
190
198
  title="cell 样式配置(移动端)"
191
199
  name="group-style_cell"
@@ -351,6 +359,7 @@
351
359
  :icon="dialog.data.style.icon"
352
360
  :plain="dialog.data.style.plain"
353
361
  :round="dialog.data.style.round"
362
+ :circle="dialog.data.style.circle"
354
363
  :size="dialog.data.style.size"
355
364
  >{{ dialog.data.text }}</el-button
356
365
  >
@@ -366,6 +375,7 @@
366
375
  <el-radio label="info">信息按钮</el-radio>
367
376
  <el-radio label="warning">警告按钮</el-radio>
368
377
  <el-radio label="danger">危险按钮</el-radio>
378
+ <el-radio label="text">文字按钮</el-radio>
369
379
  </el-radio-group>
370
380
  </el-form-item>
371
381
  <el-form-item label="按钮大小">
@@ -383,7 +393,7 @@
383
393
  <el-switch v-model="dialog.data.style.round"> </el-switch>
384
394
  </el-form-item>
385
395
  <el-form-item label="是否圆型">
386
- <el-switch v-model="dialog.data.style.round"> </el-switch>
396
+ <el-switch v-model="dialog.data.style.circle"> </el-switch>
387
397
  </el-form-item>
388
398
  <el-form-item label="按钮图标">
389
399
  <th-icons v-model="dialog.data.style.icon"></th-icons>
@@ -465,11 +475,12 @@ export default {
465
475
  "group-pageInfo",
466
476
  "group-sort",
467
477
  "group-hint",
478
+ "group-network",
479
+ "group-button",
480
+ "group-style_table",
468
481
  "group-style_cell",
469
482
  "group-style_title",
470
- "group-style_value",
471
- "group-network",
472
- "group-button"
483
+ "group-style_value"
473
484
  ],
474
485
  formRules: {
475
486
  "table.fieldsType": [
@@ -490,14 +501,14 @@ export default {
490
501
  },
491
502
  watch: {
492
503
  config(val) {
493
- this.handleFieldsApiChange(val.table.mounted.api)
504
+ this.handleFieldsApiChange(val.table.mounted.api);
494
505
  this.handleFields();
495
506
  },
496
507
  fields(val) {
497
508
  this.handleFields();
498
509
  },
499
- apiOptions(){
500
- this.handleFieldsApiChange(this.config.table.mounted.api)
510
+ apiOptions() {
511
+ this.handleFieldsApiChange(this.config.table.mounted.api);
501
512
  }
502
513
  },
503
514
  computed: {
@@ -606,7 +617,7 @@ export default {
606
617
  label: item.note || item.name,
607
618
  alias: item.name,
608
619
  prop: item.name,
609
- type: "input",
620
+ elType: "input",
610
621
  align: "left"
611
622
  };
612
623
  });
@@ -31,11 +31,10 @@
31
31
  <div class="table-item-custom drag">
32
32
  <i class="iconfont icon-drag drag-widget"></i>
33
33
  </div>
34
- <div>{{ item.label }}</div>
35
- <!-- <div>{{ item.prop }}</div> -->
34
+ <el-input v-model="item.label" size="mini"></el-input>
36
35
  <div>
37
36
  <el-select
38
- v-model="item.type"
37
+ v-model="item.elType"
39
38
  placeholder="请选择"
40
39
  size="mini"
41
40
  disabled
@@ -103,8 +102,7 @@
103
102
  <div class="table-item-custom drag">
104
103
  <i class="iconfont icon-drag drag-widget"></i>
105
104
  </div>
106
- <div>{{ item.label }}</div>
107
- <!-- <div>{{ item.prop }}</div> -->
105
+ <el-input v-model="item.label" size="mini"></el-input>
108
106
  <div>
109
107
  <el-select v-model="item.align" placeholder="请选择" size="mini">
110
108
  <el-option