tianheng-ui 0.1.12 → 0.1.14

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.
@@ -13,39 +13,39 @@
13
13
  </div>
14
14
  <div v-if="activeTab.value === 0" class="fields">
15
15
  <el-checkbox
16
- :indeterminate="search.isIndeterminate"
17
16
  v-model="search.isCheckAll"
18
- @change="handleSearchCheckAllChange"
17
+ :indeterminate="search.isIndeterminate"
18
+ @change="val => handleCheckAllChange(val, 'search')"
19
19
  >全选</el-checkbox
20
20
  >
21
- <el-checkbox-group v-model="search.fields" @change="handleChange">
22
- <el-checkbox
23
- v-for="(item, index) in fields"
24
- :label="index"
25
- :key="index"
26
- >{{ item.label }}</el-checkbox
27
- >
28
- </el-checkbox-group>
21
+ <el-checkbox
22
+ v-for="item in fields"
23
+ :label="item.prop"
24
+ :key="`search-${item.prop}-${item.isSearch}`"
25
+ :checked="item.isSearch"
26
+ @change="val => handleCheckboxChange(val, 'search', item)"
27
+ >{{ item.label }}</el-checkbox
28
+ >
29
29
  </div>
30
30
  <div v-if="activeTab.value === 1" class="fields">
31
31
  <el-checkbox
32
- :indeterminate="table.isIndeterminate"
33
32
  v-model="table.isCheckAll"
34
- @change="handleTableCheckAllChange"
33
+ :indeterminate="table.isIndeterminate"
34
+ @change="val => handleCheckAllChange(val, 'table')"
35
35
  >全选</el-checkbox
36
36
  >
37
- <el-checkbox-group v-model="table.fields" @change="handleChange">
38
- <el-checkbox
39
- v-for="(item, index) in fields"
40
- :label="index"
41
- :key="index"
42
- >{{ item.label }}</el-checkbox
43
- >
44
- </el-checkbox-group>
37
+ <el-checkbox
38
+ v-for="item in fields"
39
+ :label="item.prop"
40
+ :key="`table-${item.prop}-${item.isTable}`"
41
+ :checked="item.isTable"
42
+ @change="val => handleCheckboxChange(val, 'table', item)"
43
+ >{{ item.label }}</el-checkbox
44
+ >
45
45
  </div>
46
- <div v-if="activeTab.value === 2" class="tableConfig">
46
+ <div v-if="activeTab.value === 2 && config.table" class="tableConfig">
47
47
  <el-form
48
- :model="tableConfig"
48
+ :model="config"
49
49
  label-position="left"
50
50
  label-width="80px"
51
51
  size="mini"
@@ -53,17 +53,17 @@
53
53
  <el-collapse v-model="tableCollapse">
54
54
  <el-collapse-item title="表格配置" name="1">
55
55
  <el-form-item label="高级查询">
56
- <el-switch v-model="tableConfig.search.show"> </el-switch>
56
+ <el-switch v-model="config.search.show"> </el-switch>
57
57
  </el-form-item>
58
58
  <el-form-item label="排序类型">
59
- <el-radio-group v-model="tableConfig.table.sort.type">
59
+ <el-radio-group v-model="config.table.sort.type">
60
60
  <el-radio-button label="1">降序</el-radio-button>
61
61
  <el-radio-button label="2">升序</el-radio-button>
62
62
  </el-radio-group>
63
63
  </el-form-item>
64
64
  <el-form-item label="排序字段">
65
65
  <el-select
66
- v-model="tableConfig.table.sort.key"
66
+ v-model="config.table.sort.key"
67
67
  placeholder="请选择"
68
68
  clearable
69
69
  >
@@ -77,18 +77,13 @@
77
77
  </el-select>
78
78
  </el-form-item>
79
79
  <el-form-item label="序号">
80
- <el-switch v-model="tableConfig.table.sequence"> </el-switch>
80
+ <el-switch v-model="config.table.sequence"> </el-switch>
81
81
  </el-form-item>
82
82
  <el-form-item label="分页设置">
83
- <el-switch v-model="tableConfig.table.pageInfo.show"> </el-switch>
83
+ <el-switch v-model="config.table.pageInfo.show"> </el-switch>
84
84
  </el-form-item>
85
- <el-form-item
86
- v-if="tableConfig.table.pageInfo.show"
87
- label="分页条数"
88
- >
89
- <el-radio-group
90
- v-model="tableConfig.table.pageInfo.options.pageSize"
91
- >
85
+ <el-form-item v-if="config.table.pageInfo.show" label="分页条数">
86
+ <el-radio-group v-model="config.table.pageInfo.options.pageSize">
92
87
  <el-radio-button :label="20">20条</el-radio-button>
93
88
  <el-radio-button :label="50">50条</el-radio-button>
94
89
  <el-radio-button :label="100">100条</el-radio-button>
@@ -96,112 +91,164 @@
96
91
  </el-radio-group>
97
92
  </el-form-item>
98
93
  </el-collapse-item>
99
- <!-- <el-collapse-item title="子表配置" name="2">
100
- <el-form-item label="子表样式">
101
- <el-select v-model="tableConfig.sortField" placeholder="请选择">
102
- <el-option
103
- v-for="item in []"
104
- :key="item.value"
105
- :label="item.label"
106
- :value="item.value"
107
- >
108
- </el-option>
109
- </el-select>
94
+ <el-collapse-item title="提示语" name="2">
95
+ <el-form-item label="空数据">
96
+ <el-input
97
+ v-model="config.table.empty.text"
98
+ placeholder="请输入"
99
+ ></el-input>
110
100
  </el-form-item>
111
- </el-collapse-item> -->
101
+ <el-form-item label="加载提示">
102
+ <el-input
103
+ v-model="config.table.loading.text"
104
+ placeholder="请输入"
105
+ ></el-input>
106
+ </el-form-item>
107
+ </el-collapse-item>
112
108
  <el-collapse-item name="3">
113
109
  <template slot="title">
114
110
  <div class="collapse-title">
115
111
  <div>按钮配置</div>
116
112
  <div
117
113
  class="collapse-title-action"
118
- @click.stop="handleActionConfig"
114
+ @click.stop="handleActionConfig()"
119
115
  >
120
116
  配置
121
117
  </div>
122
118
  </div>
123
119
  </template>
124
- <el-form-item label-width="90px">
125
- <el-checkbox v-model="tableConfig.tools.add.show" slot="label"
126
- >新增</el-checkbox
127
- >
120
+ <div
121
+ v-for="(item, index) in Object.values(config.tools)"
122
+ :key="index"
123
+ class="tools-item"
124
+ >
125
+ <el-checkbox v-model="item.show">{{ item.name }}</el-checkbox>
128
126
  <el-input
129
- v-model="tableConfig.tools.add.name"
127
+ v-model="item.text"
130
128
  placeholder="请输入内容"
129
+ size="mini"
131
130
  ></el-input>
132
- </el-form-item>
133
- <el-form-item label-width="90px">
134
- <el-checkbox v-model="tableConfig.tools.edit.show" slot="label"
135
- >编辑</el-checkbox
131
+ <i class="el-icon-set-up" @click="handleActionConfig(item)"></i>
132
+ </div>
133
+ </el-collapse-item>
134
+ </el-collapse>
135
+ </el-form>
136
+ </div>
137
+
138
+ <th-dialog
139
+ v-model="dialog.show"
140
+ title="按钮配置"
141
+ :modal-append-to-body="false"
142
+ :showFooter="false"
143
+ >
144
+ <div class="toolsSeting th-flex_box">
145
+ <el-card class="th-flex_left" style="width:200px;margin-right:10px;">
146
+ <el-tree
147
+ :data="Object.values(config.tools || [])"
148
+ :props="{ label: 'name' }"
149
+ node-key="name"
150
+ @node-click="handleActionConfig"
151
+ ></el-tree>
152
+ </el-card>
153
+ <el-card v-if="dialog.data" class="th-fiex_right">
154
+ <el-form
155
+ ref="form"
156
+ :model="dialog.data"
157
+ label-width="80px"
158
+ size="mini"
159
+ >
160
+ <el-form-item label="按钮模型">
161
+ <el-button
162
+ :type="dialog.data.type"
163
+ :icon="dialog.data.icon"
164
+ :plain="dialog.data.plain"
165
+ :round="dialog.data.round"
166
+ >{{ dialog.data.text }}</el-button
136
167
  >
137
- <el-input
138
- v-model="tableConfig.tools.edit.name"
139
- placeholder="请输入内容"
140
- ></el-input>
141
168
  </el-form-item>
142
- <el-form-item label-width="90px">
143
- <el-checkbox v-model="tableConfig.tools.detail.show" slot="label"
144
- >详情</el-checkbox
145
- >
146
- <el-input
147
- v-model="tableConfig.tools.detail.name"
148
- placeholder="请输入内容"
149
- ></el-input>
169
+ <el-form-item label="按钮名称">
170
+ <el-input v-model="dialog.data.text"></el-input>
150
171
  </el-form-item>
151
- <el-form-item label-width="90px">
152
- <el-checkbox v-model="tableConfig.tools.delete.show" slot="label"
153
- >删除</el-checkbox
154
- >
155
- <el-input
156
- v-model="tableConfig.tools.delete.name"
157
- placeholder="请输入内容"
158
- ></el-input>
172
+ <el-form-item label="按钮类型">
173
+ <el-radio-group v-model="dialog.data.type">
174
+ <el-radio label="">默认</el-radio>
175
+ <el-radio label="primary">主要按钮</el-radio>
176
+ <el-radio label="success">成功按钮</el-radio>
177
+ <el-radio label="info">信息按钮</el-radio>
178
+ <el-radio label="warning">警告按钮</el-radio>
179
+ <el-radio label="danger">危险按钮</el-radio>
180
+ </el-radio-group>
159
181
  </el-form-item>
160
- <el-form-item label-width="90px">
161
- <el-checkbox
162
- v-model="tableConfig.tools.batchDelete.show"
163
- slot="label"
164
- >批量删除</el-checkbox
165
- >
166
- <el-input
167
- v-model="tableConfig.tools.batchDelete.name"
168
- placeholder="请输入内容"
169
- ></el-input>
182
+ <el-form-item label="按钮空心">
183
+ <el-switch v-model="dialog.data.plain"> </el-switch>
184
+ </el-form-item>
185
+ <el-form-item label="按钮圆角">
186
+ <el-switch v-model="dialog.data.round"> </el-switch>
170
187
  </el-form-item>
171
- <el-form-item label-width="90px">
172
- <el-checkbox v-model="tableConfig.tools.export.show" slot="label"
173
- >导出</el-checkbox
188
+ <el-form-item label="按钮图标">
189
+ <th-icons v-model="dialog.data.icon"></th-icons>
190
+ </el-form-item>
191
+ <el-form-item label="关联表单">
192
+ <el-select
193
+ v-model="dialog.data.form"
194
+ style="width:100%"
195
+ value-key="id"
196
+ clearable
197
+ placeholder="请关联表单"
198
+ no-data-text="暂无表单,请前往【表单模块】创建"
174
199
  >
175
- <el-input
176
- v-model="tableConfig.tools.export.name"
177
- placeholder="请输入内容"
178
- ></el-input>
200
+ <el-option
201
+ v-for="item in formOptions"
202
+ :key="item.id"
203
+ :label="item.label"
204
+ :value="item"
205
+ >
206
+ </el-option>
207
+ </el-select>
179
208
  </el-form-item>
180
- <el-form-item label-width="90px">
181
- <el-checkbox v-model="tableConfig.tools.import.show" slot="label"
182
- >导入</el-checkbox
209
+ <el-form-item label="关联接口">
210
+ <el-select
211
+ v-model="dialog.data.api"
212
+ style="width:100%"
213
+ value-key="id"
214
+ clearable
215
+ placeholder="如关联表单中已配置接口,请勿重复关联"
216
+ no-data-text="暂无接口,请前往【接口模块】创建"
183
217
  >
184
- <el-input
185
- v-model="tableConfig.tools.import.name"
186
- placeholder="请输入内容"
187
- ></el-input>
218
+ <el-option
219
+ v-for="item in apiOptions"
220
+ :key="item.id"
221
+ :label="item.label"
222
+ :value="item"
223
+ >
224
+ </el-option>
225
+ </el-select>
188
226
  </el-form-item>
189
- </el-collapse-item>
190
- </el-collapse>
191
- </el-form>
192
- </div>
227
+ </el-form>
228
+ </el-card>
229
+ </div>
230
+ </th-dialog>
193
231
  </div>
194
232
  </template>
195
233
 
196
234
  <script>
235
+ import { deepClone } from "../FormMaking/util";
197
236
  export default {
198
237
  props: {
238
+ config: {
239
+ type: Object,
240
+ default: () => {
241
+ return { search: { options: [] } };
242
+ }
243
+ },
199
244
  fields: {
200
245
  type: Array,
201
246
  default: () => {
202
247
  return [];
203
248
  }
204
- }
249
+ },
250
+ formOptions: Array,
251
+ apiOptions: Array
205
252
  },
206
253
  data() {
207
254
  return {
@@ -212,100 +259,121 @@ export default {
212
259
  ],
213
260
  activeTab: { title: "查询字段", value: 0 },
214
261
  search: {
215
- fields: [],
216
262
  isCheckAll: false,
217
263
  isIndeterminate: false
218
264
  },
219
265
  table: {
220
- fields: [],
221
266
  isCheckAll: false,
222
267
  isIndeterminate: false
223
268
  },
224
- tableCollapse: ["1", "3"],
225
- tableConfig: {
226
- search: {
227
- show: true,
228
- options: []
229
- },
230
- table: {
231
- options: [],
232
- pageInfo: {
233
- show: true,
234
- options: {
235
- pageCount: 0, // 总页数
236
- pageSize: 20, // 每页展示的条数
237
- currentPage: 1, // 当前页码
238
- total: 0, // 总条数
239
- sizes: [10, 20, 30, 50, 100]
240
- }
241
- },
242
- sort: { type: "1", key: "" },
243
- loading: { show: false, text: "加载中", image: "" },
244
- empty: { show: true, text: "暂无数据", image: "" },
245
- sequence: true //是否显示序号
246
- },
247
- tools: {
248
- add: { show: true, name: "新增", position: 1 },
249
- edit: { show: true, name: "编辑", position: 2 },
250
- detail: { show: false, name: "查看", position: 2 },
251
- delete: { show: true, name: "删除", position: 2 },
252
- batchDelete: { show: false, name: "批量删除", position: 1 },
253
- export: { show: false, name: "导出", position: 1 },
254
- import: { show: false, name: "导入", position: 1 }
255
- },
256
- network: {}
257
- }
269
+ tableCollapse: ["1", "2", "3"],
270
+ dialog: { show: false, data: null }
258
271
  };
259
272
  },
273
+ watch: {
274
+ config(val) {
275
+ this.handleFields();
276
+ },
277
+ fields(val) {
278
+ this.handleFields();
279
+ }
280
+ },
281
+ computed: {
282
+ searchActiveFields() {
283
+ const data = this.config.search.options.map(item => {
284
+ return item.prop;
285
+ });
286
+ return data;
287
+ },
288
+ tableActiveFields() {
289
+ const data = this.config.table.options.map(item => {
290
+ return item.prop;
291
+ });
292
+ return data;
293
+ }
294
+ },
260
295
  mounted() {},
261
296
  methods: {
297
+ handleFields() {
298
+ this.fields.forEach(item => {
299
+ item.isSearch = this.searchActiveFields.includes(item.prop);
300
+ item.isTable = this.tableActiveFields.includes(item.prop);
301
+ });
302
+ this.search = {
303
+ isCheckAll: this.searchActiveFields.length === this.fields.length,
304
+ isIndeterminate:
305
+ this.searchActiveFields.length !== 0 &&
306
+ this.searchActiveFields.length !== this.fields.length
307
+ };
308
+ this.table = {
309
+ isCheckAll: this.tableActiveFields.length === this.fields.length,
310
+ isIndeterminate:
311
+ this.tableActiveFields.length !== 0 &&
312
+ this.tableActiveFields.length !== this.fields.length
313
+ };
314
+ },
262
315
  handleTabsSelect(val) {
263
316
  this.activeTab = val;
264
317
  },
265
- handleChange() {
266
- if (this.activeTab.value === 0) {
267
- const count = this.search.fields.length;
268
- this.search.isCheckAll = count === this.fields.length;
269
- this.search.isIndeterminate = count > 0 && count < this.fields.length;
270
- this.$emit("fields-change", {
271
- type: this.activeTab.value,
272
- data: this.search.fields
318
+ handleCheckAllChange(bool, action) {
319
+ if (action === "search") {
320
+ this.fields.forEach(item => {
321
+ item.isSearch = bool;
273
322
  });
274
- } else {
275
- const count = this.table.fields.length;
276
- this.table.isCheckAll = count === this.fields.length;
277
- this.table.isIndeterminate = count > 0 && count < this.fields.length;
278
- this.$emit("fields-change", {
279
- type: this.activeTab.value,
280
- data: this.table.fields
323
+ const data = deepClone(this.fields);
324
+ this.config.search.options = bool ? data : [];
325
+ this.search.isCheckAll = bool;
326
+ this.search.isIndeterminate = false;
327
+ return;
328
+ }
329
+ if (action === "table") {
330
+ this.fields.forEach(item => {
331
+ item.isTable = bool;
281
332
  });
333
+ const data = deepClone(this.fields);
334
+ this.config.table.options = bool ? data : [];
335
+ this.table.isCheckAll = bool;
336
+ this.table.isIndeterminate = false;
282
337
  }
283
338
  },
284
- handleSearchCheckAllChange(val) {
285
- const list = [];
286
- if (val) {
287
- for (let i = 0; i < this.fields.length; i++) {
288
- list.push(i);
289
- }
339
+ handleCheckboxChange(bool, action, data) {
340
+ if (action === "search") {
341
+ data.isSearch = bool;
342
+ bool
343
+ ? this.config.search.options.push(deepClone(data))
344
+ : (this.config.search.options = this.config.search.options.filter(
345
+ item => {
346
+ return item.prop !== data.prop;
347
+ }
348
+ ));
349
+ this.search = {
350
+ isCheckAll: this.config.search.options.length === this.fields.length,
351
+ isIndeterminate:
352
+ this.config.search.options.length !== 0 &&
353
+ this.config.search.options.length !== this.fields.length
354
+ };
355
+ return;
290
356
  }
291
- this.search.fields = list;
292
- this.search.isIndeterminate = false;
293
- this.handleChange();
294
- },
295
- handleTableCheckAllChange(val) {
296
- const list = [];
297
- if (val) {
298
- for (let i = 0; i < this.fields.length; i++) {
299
- list.push(i);
300
- }
357
+ if (action === "table") {
358
+ data.isTable = bool;
359
+ bool
360
+ ? this.config.table.options.push(deepClone(data))
361
+ : (this.config.table.options = this.config.table.options.filter(
362
+ item => {
363
+ return item.prop !== data.prop;
364
+ }
365
+ ));
366
+ this.table = {
367
+ isCheckAll: this.config.table.options.length === this.fields.length,
368
+ isIndeterminate:
369
+ this.config.table.options.length !== 0 &&
370
+ this.config.table.options.length !== this.fields.length
371
+ };
372
+ return;
301
373
  }
302
- this.table.fields = list;
303
- this.table.isIndeterminate = false;
304
- this.handleChange();
305
374
  },
306
- handleActionConfig() {},
307
- getJson() {
308
- return JSON.parse(JSON.stringify(this.tableConfig));
375
+ handleActionConfig(data) {
376
+ this.dialog = { show: true, data };
309
377
  }
310
378
  }
311
379
  };
@@ -368,6 +436,21 @@ export default {
368
436
  color: #409eff;
369
437
  }
370
438
  }
439
+ .tools-item {
440
+ display: flex;
441
+ align-items: center;
442
+ padding: 7px 0;
443
+
444
+ .el-checkbox {
445
+ width: 140px;
446
+ }
447
+ > i {
448
+ height: 20px;
449
+ line-height: 20px;
450
+ padding-left: 10px;
451
+ cursor: pointer;
452
+ }
453
+ }
371
454
  }
372
455
  }
373
456
  </style>
@@ -13,17 +13,21 @@
13
13
  <div class="table-item-custom">隐藏</div>
14
14
  </div>
15
15
  <draggable
16
+ v-if="config.search"
16
17
  class="search-content"
17
- v-model="searchData"
18
+ v-model="config.search.options"
18
19
  v-bind="{
19
20
  group: 'people',
20
21
  ghostClass: 'ghost',
21
22
  animation: 200,
22
23
  handle: '.drag-widget'
23
24
  }"
24
- @end="handleSearchMoveEnd"
25
25
  >
26
- <div v-for="item in searchData" :key="item.prop" class="table-item">
26
+ <div
27
+ v-for="item in config.search.options"
28
+ :key="item.prop"
29
+ class="table-item"
30
+ >
27
31
  <div class="table-item-custom drag">
28
32
  <i class="iconfont icon-drag drag-widget"></i>
29
33
  </div>
@@ -67,6 +71,7 @@
67
71
  </div>
68
72
  </div>
69
73
  </draggable>
74
+ <div v-else class="search-content"></div>
70
75
  </div>
71
76
  <div class="table-title">列表字段</div>
72
77
  <div class="tableList" style="height: calc(100% - 240px);">
@@ -80,17 +85,21 @@
80
85
  <div class="table-item-custom">隐藏</div>
81
86
  </div>
82
87
  <draggable
88
+ v-if="config.table"
83
89
  class="table-content"
84
- v-model="tableData"
90
+ v-model="config.table.options"
85
91
  v-bind="{
86
92
  group: 'people',
87
93
  ghostClass: 'ghost',
88
94
  animation: 200,
89
95
  handle: '.drag-widget'
90
96
  }"
91
- @end="handleTableMoveEnd"
92
97
  >
93
- <div v-for="item in tableData" :key="item.prop" class="table-item">
98
+ <div
99
+ v-for="item in config.table.options"
100
+ :key="item.prop"
101
+ class="table-item"
102
+ >
94
103
  <div class="table-item-custom drag">
95
104
  <i class="iconfont icon-drag drag-widget"></i>
96
105
  </div>
@@ -141,23 +150,10 @@ import Draggable from "vuedraggable";
141
150
  export default {
142
151
  components: { Draggable },
143
152
  props: {
144
- searchFields: {
145
- type: Array,
146
- default: () => {
147
- return [];
148
- }
149
- },
150
- tableFields: {
151
- type: Array,
152
- default: () => {
153
- return [];
154
- }
155
- }
153
+ config: Object
156
154
  },
157
155
  data() {
158
156
  return {
159
- searchData: this.searchFields,
160
- tableData: this.tableFields,
161
157
  componentOptions: [
162
158
  { label: "输入框", value: "input" },
163
159
  { label: "下拉框", value: "select" },
@@ -172,34 +168,8 @@ export default {
172
168
  codeEditorValue: ""
173
169
  };
174
170
  },
175
- watch: {
176
- searchData: {
177
- handler(val) {
178
- this.$emit("update:searchFields", val);
179
- },
180
- deep: true
181
- },
182
- searchFields(val) {
183
- this.searchData = val;
184
- },
185
- tableData: {
186
- handler(val) {
187
- this.$emit("update:tableFields", val);
188
- },
189
- deep: true
190
- },
191
- tableFields(val) {
192
- this.tableData = val;
193
- }
194
- },
195
171
  mounted() {},
196
172
  methods: {
197
- handleSearchMoveEnd(val) {
198
- this.$emit("move", { type: "search", data: val });
199
- },
200
- handleTableMoveEnd(val) {
201
- this.$emit("move", { type: "table", data: val });
202
- },
203
173
  handleStaticData(val) {
204
174
  this.dialog = {
205
175
  visible: true,