htui-yllkbz 1.2.42 → 1.2.46

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htui-yllkbz",
3
- "version": "1.2.42",
3
+ "version": "1.2.46",
4
4
  "typings": "types/index.d.ts",
5
5
  "main": "lib/htui.common.js",
6
6
  "style": "lib/htui.css",
@@ -5,10 +5,11 @@
5
5
  * @Author: hutao
6
6
  * @Date: 2021-11-11 11:23:24
7
7
  * @LastEditors: hutao
8
- * @LastEditTime: 2022-01-04 09:30:09
8
+ * @LastEditTime: 2022-01-11 10:22:35
9
9
  -->
10
10
  <template>
11
11
  <div v-loading="state.loading">
12
+
12
13
  <article>
13
14
  <el-table ref="comTable"
14
15
  :height="height"
@@ -17,6 +18,10 @@
17
18
  :stripe="stripe"
18
19
  :size="size"
19
20
  :fit="fit"
21
+ :header-row-style="headerRowStyle"
22
+ :header-row-class-name="headerRowClassName"
23
+ :header-cell-class-name="headerCellClassName"
24
+ :header-cell-style="headerCellStyle"
20
25
  :show-header="showHeader"
21
26
  :empty-text="emptyText||'暂无数据'"
22
27
  :row-style="rowStyle"
@@ -42,28 +47,39 @@
42
47
  @cell-click="(row, column, cell, event)=>$emit('cell-click',row, column, cell, event)"
43
48
  @cell-dblclick="(row, column, cell, event)=>$emit('cell-dblclick',row, column, cell, event)">
44
49
  <el-table-column width="55"
50
+ :resizable="false"
45
51
  v-if="checked"
46
52
  :reserve-selection="reserveSelection"
47
53
  :selectable="selectable"
48
54
  type='selection'>
49
55
  </el-table-column>
50
56
  <el-table-column v-if="!hideOrder"
57
+ :resizable="false"
51
58
  :label="keyName===undefined?'序号':keyName"
52
59
  :align="'center'"
53
60
  width="55">
54
61
  <template slot="header">
55
- <slot :name="'header_order'"></slot>
62
+ <slot :name="'header_order'">
63
+ <div @click="showFilterModel"
64
+ v-if="showFilter"
65
+ title="筛选排序">
66
+ <el-button type="text"><i class="el-icon-s-grid"></i></el-button>
67
+ </div>
68
+ <span v-else>{{keyName||'序号'}}</span>
69
+
70
+ </slot>
56
71
  </template>
57
72
  <template slot-scope="scope">
58
73
  {{(state.pageInfo.currentPage-1)*state.pageInfo.pageSize+(scope.$index+1)}}
59
74
  </template>
60
75
  </el-table-column>
61
- <template v-for="item in columns">
76
+ <template v-for="item in showColumns">
62
77
  <el-table-column :label="item.title"
63
78
  :key='item.key'
64
79
  :fixed="item.fixed"
65
80
  :align="item.align"
66
81
  v-if="!item.hide"
82
+ :resizable="item.resizable"
67
83
  :header-align="item.headerAlign"
68
84
  :column-key="item.columnKey"
69
85
  :class-name="item.className"
@@ -127,6 +143,16 @@
127
143
  <el-tag type="danger"
128
144
  v-else>否</el-tag>
129
145
  </template>
146
+ <!-- 处理部门人员 -->
147
+ <template v-else-if="item.type==='img'">
148
+ <span v-if="fileToken in getPropByPath(row,item.key).split(',')">
149
+ <el-image style="width: 38px; height: 38px;margin-right:5px"
150
+ :src="'/files/api/filing/file/download/'+fileToken"
151
+ :preview-src-list="['/files/api/filing/file/download/'+fileToken]">
152
+ </el-image>
153
+ </span>
154
+
155
+ </template>
130
156
  <!-- 其他 -->
131
157
  <span v-else>{{getPropByPath(row,item.key)}}</span>
132
158
  </slot>
@@ -160,6 +186,39 @@
160
186
 
161
187
  </el-row>
162
188
  </footer>
189
+ <!-- 详情弹框 -->
190
+ <el-dialog :visible.sync="state.visibleFilter"
191
+ title="属性设置"
192
+ :close-on-click-modal="true"
193
+ width="400px"
194
+ :center="true">
195
+ <div style='overflow:hidden;height:500px'>
196
+ <el-scrollbar style='height: 517px'>
197
+ <el-tree :data="columns"
198
+ ref="tree"
199
+ show-checkbox
200
+ node-key="key"
201
+ :check-on-click-node="false"
202
+ @node-drag-start="handleDragStart"
203
+ @node-drag-enter="handleDragEnter"
204
+ @node-drag-leave="handleDragLeave"
205
+ @node-drag-over="handleDragOver"
206
+ @node-drag-end="handleDragEnd"
207
+ @node-drop="handleDrop"
208
+ :default-checked-keys="state.showColumnKeys"
209
+ @check-change="changeColumns"
210
+ :allow-drag="allowDrag"
211
+ draggable
212
+ :allow-drop="allowDrop">
213
+ <span class="custom-tree-node"
214
+ slot-scope="{ node, data }">
215
+ <slot :name="'header_'+data.key"
216
+ :column="data">{{data.title}}</slot>
217
+ </span>
218
+ </el-tree>
219
+ </el-scrollbar>
220
+ </div>
221
+ </el-dialog>
163
222
  </div>
164
223
  </template>
165
224
  <script lang='ts'>
@@ -169,6 +228,13 @@ import PageInfo from "@/packages/PageInfo/index.vue";
169
228
  interface State {
170
229
  pageInfo: PageInfoType;
171
230
  loading: boolean;
231
+ /** 展示出来的列表名 */
232
+ showColumns: Column[];
233
+ showColumnKeys: string[];
234
+ /** 是否展示筛选框 */
235
+ visibleFilter: boolean;
236
+ /** 当前拖动的数据 */
237
+ currentColumn?: Column;
172
238
  }
173
239
  @Component({
174
240
  name: "HtTable",
@@ -182,6 +248,10 @@ export default class HtTable extends Vue {
182
248
  @Prop() data!: any[];
183
249
  /** 序号对应的名称 */
184
250
  @Prop() keyName?: string;
251
+ /** 是否增加筛选功能 */
252
+ @Prop() showFilter?: boolean;
253
+ /** table的唯一值用于table数据筛选 */
254
+ @Prop() uuId?: string;
185
255
  /** 是否隐藏分页 */
186
256
  @Prop() hidePage!: boolean;
187
257
  /** 是否启用复选框 */
@@ -205,6 +275,10 @@ export default class HtTable extends Vue {
205
275
  @Prop() hideOrder?: boolean;
206
276
  @Prop() pageInfo?: PageInfoType;
207
277
  @Prop() emptyText?: string | number;
278
+ @Prop() headerRowStyle?: any;
279
+ @Prop() headerRowClassName?: any;
280
+ @Prop() headerCellStyle?: any;
281
+
208
282
  /** 分页的所有额外信息通过此参数传递 */
209
283
  @Prop() pagination?: any;
210
284
  state: State = {
@@ -215,9 +289,84 @@ export default class HtTable extends Vue {
215
289
  skipCount: 0,
216
290
  totalCount: 0,
217
291
  },
292
+ showColumns: [],
293
+ currentColumn: undefined,
294
+ visibleFilter: false,
295
+ showColumnKeys: [],
218
296
  };
219
297
  created() {
220
298
  this.setPageInfo(this.pageInfo);
299
+ this.state.showColumns = this.columns;
300
+ if (this.uuId) {
301
+ //通过uuid获取缓存起来的header显示信息
302
+ const showKeys: string | null = window.localStorage.getItem(
303
+ "table_" + this.uuId
304
+ );
305
+ if (showKeys) {
306
+ this.state.showColumnKeys = JSON.parse(showKeys);
307
+ } else {
308
+ this.creatInitColumnKey();
309
+ }
310
+ } else {
311
+ this.creatInitColumnKey();
312
+ }
313
+ }
314
+ creatInitColumnKey() {
315
+ this.state.showColumnKeys = this.columns.reduce((arr: string[], item) => {
316
+ arr.push(item.key);
317
+ return arr;
318
+ }, []);
319
+ }
320
+ changeColumns(node: any, checked: boolean) {
321
+ let { showColumnKeys } = this.state;
322
+ if (checked) {
323
+ showColumnKeys.push(node.key);
324
+ } else {
325
+ showColumnKeys = showColumnKeys.filter((item) => item !== node.key);
326
+ }
327
+ this.state.showColumnKeys = showColumnKeys;
328
+ }
329
+ handleDragStart(node: any) {
330
+ this.state.currentColumn = node.data;
331
+ }
332
+ handleDragEnter() {
333
+ // console.log("tree drag enter: ", dropNode.label);
334
+ }
335
+ handleDragLeave() {
336
+ //console.log("tree drag leave: ", dropNode.label);
337
+ }
338
+ handleDragOver() {
339
+ // console.log("tree drag over: ", dropNode.label);
340
+ }
341
+ handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
342
+ const { showColumns, currentColumn, showColumnKeys } = this.state;
343
+ // if ((dropType === "before" || dropType === "after") && currentColumn) {
344
+ // const data = showColumns.filter(
345
+ // (item) => item.key !== currentColumn?.key
346
+ // );
347
+ // const index = data.findIndex((item) => item.key === dropNode.data.key);
348
+ // dropType === "before"
349
+ // ? data.splice(index, 0, currentColumn)
350
+ // : data.splice(index + 1, 0, currentColumn);
351
+ // console.log("tree drag end: ", currentColumn, showColumnKeys);
352
+ if (currentColumn && showColumnKeys.includes(currentColumn.key)) {
353
+ setTimeout(() => {
354
+ (this.$refs.tree as any).setChecked(currentColumn, true);
355
+ }, 0);
356
+ }
357
+
358
+ // }
359
+ }
360
+ handleDrop() {
361
+ // console.log("tree drop: ", dropNode, dropType);
362
+ }
363
+ /** 节点是否被插入 */
364
+ allowDrop(draggingNode: any, dropNode: any, type: string) {
365
+ return type !== "inner";
366
+ }
367
+ /** 节点是否允许拖动 */
368
+ allowDrag(draggingNode: any) {
369
+ return !draggingNode.data.disabled;
221
370
  }
222
371
  /** 处理table里面根据字段获取对应的值 */
223
372
  getPropByPath(obj: any, path: string, strict = true) {
@@ -246,6 +395,9 @@ export default class HtTable extends Vue {
246
395
  // };
247
396
  return tempObj ? tempObj[keyArr[i]] : null;
248
397
  }
398
+ showFilterModel() {
399
+ this.state.visibleFilter = true;
400
+ }
249
401
  /** 遍历循环展示row数据 */
250
402
  showValue(row: any, key: string) {
251
403
  if (key) {
@@ -270,6 +422,25 @@ export default class HtTable extends Vue {
270
422
  return "";
271
423
  }
272
424
  }
425
+ /** 获取显示出来的table头信息 */
426
+ get showColumns() {
427
+ const { showColumnKeys, showColumns } = this.state;
428
+ let obj: any = {};
429
+ for (const key in showColumnKeys) {
430
+ obj = { ...obj, [showColumnKeys[key]]: true };
431
+ }
432
+ /** 缓存起来下次使用 --todo只做了显示没有做排序缓存 */
433
+ if (this.uuId) {
434
+ window.localStorage.setItem(
435
+ "table_" + this.uuId,
436
+ JSON.stringify(showColumnKeys)
437
+ );
438
+ }
439
+
440
+ const data = showColumns.filter((item) => obj[item.key as string]);
441
+ return data;
442
+ }
443
+
273
444
  /** 监听 */
274
445
  @Watch("pageInfo")
275
446
  setPageInfo(val?: PageInfoType) {
@@ -283,6 +454,10 @@ export default class HtTable extends Vue {
283
454
  };
284
455
  }
285
456
  }
457
+ @Watch("columns")
458
+ setColumns(columns?: Column[]) {
459
+ this.state.showColumns = columns || [];
460
+ }
286
461
  }
287
462
  </script>
288
463
  <style lang='scss' scoped></style>
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-10-25 17:05:17
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-01-04 09:55:26
7
+ * @LastEditTime: 2022-01-11 14:39:04
8
8
  */
9
9
  /** 初始的默认条数 */
10
10
  export const defalutPageSize = 10
@@ -53,9 +53,10 @@ export interface Column {
53
53
 
54
54
  key: string;
55
55
  title: string;
56
+
56
57
  width?: number | string;
57
58
  minWidth?: number | string;
58
- fixed?: 'left' | 'rigth' | boolean;
59
+ fixed?: 'left' | 'right' | boolean;
59
60
  sortable?: 'custom' | boolean;
60
61
  resizable?: boolean;
61
62
  align?: 'left' | 'right' | 'center';
@@ -69,10 +70,12 @@ export interface Column {
69
70
  /** 时间是否跨行展示 */
70
71
  spread?: boolean;
71
72
  /** 通过type展示相应的数据 用户id|部门id|时间格式化|是否布尔值*/
72
- type?: 'userId' | 'org' | 'time' | 'common' | 'boolean',
73
+ type?: 'userId' | 'org' | 'time' | 'common' | 'boolean' | 'img',
73
74
  /** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
74
75
  commonType?: 'userId' | 'departmentId' | 'baseDataId' | 'roleId' | 'baseDataName' | 'baseDataValue',
75
76
  showOverflowTooltip?: boolean,
77
+ /** 筛选时候是否禁用 */
78
+ disabled?: boolean;
76
79
  }
77
80
  export interface PageInfoType {
78
81
  currentPage: number;
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:41:40
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-01-04 09:47:44
7
+ * @LastEditTime: 2022-01-11 10:29:04
8
8
  -->
9
9
  <template>
10
10
  <div>
@@ -89,6 +89,7 @@ export default class Index extends Vue {
89
89
  age: 12,
90
90
  sex: 0,
91
91
  id: 1,
92
+
92
93
  test: { title: "测试" },
93
94
  time: "2022-01-20T00:00:00+08:00",
94
95
  },
@@ -130,6 +131,7 @@ export default class Index extends Vue {
130
131
  title: "姓名",
131
132
  key: "test.title",
132
133
  width: "300px",
134
+ disabled: true,
133
135
  },
134
136
  {
135
137
  title: "姓额外名",
@@ -171,7 +173,7 @@ export default class Index extends Vue {
171
173
  // };
172
174
  // }
173
175
  save(e: string, f: string) {
174
- console.log("e,f", e, f);
176
+ // console.log("e,f", e, f);
175
177
  }
176
178
  /** 监听 */
177
179
  /** 计算属性 */