htui-yllkbz 1.4.9 → 1.4.11
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/lib/htui.common.js +2890 -2074
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +2890 -2074
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +52 -52
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/packages/HtTable/htTableColumn.vue +242 -0
- package/src/packages/HtTable/index.ts +3 -2
- package/src/packages/HtTable/index.vue +18 -2
- package/src/packages/HtTable/table-span-method.ts +135 -0
- package/src/packages/HtTable/table.vue +607 -0
- package/src/packages/type.ts +6 -4
- package/src/router/index.ts +3 -2
- package/src/views/About.vue +33 -28
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion: ht-table
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-11 11:23:24
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2023-04-09 15:35:02
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<div v-loading="state.loading" style="background:#fff">
|
|
11
|
+
<article>
|
|
12
|
+
<el-table
|
|
13
|
+
ref="comTable"
|
|
14
|
+
:height="height"
|
|
15
|
+
:max-height="maxHeight"
|
|
16
|
+
:sum-text="sumText"
|
|
17
|
+
:show-summary="showSummary"
|
|
18
|
+
:summary-method="summaryMethod"
|
|
19
|
+
:border="border"
|
|
20
|
+
:default-expand-all="defaultExpandAll"
|
|
21
|
+
:expand-row-keys="expandRowKeys"
|
|
22
|
+
:stripe="stripe !== undefined ? stripe : true"
|
|
23
|
+
:size="size || 'small'"
|
|
24
|
+
:fit="fit"
|
|
25
|
+
:span-method="spanMethodCom"
|
|
26
|
+
:header-row-style="
|
|
27
|
+
headerRowStyle || { background: 'var(--primary-92)' }
|
|
28
|
+
"
|
|
29
|
+
:header-row-class-name="headerRowClassName"
|
|
30
|
+
:header-cell-class-name="headerCellClassName"
|
|
31
|
+
:header-cell-style="headerCellStyle"
|
|
32
|
+
:show-header="showHeader"
|
|
33
|
+
:empty-text="emptyText || '暂无数据'"
|
|
34
|
+
:row-style="rowStyle"
|
|
35
|
+
:row-class-name="rowClassName"
|
|
36
|
+
:current-row-key="currentRowKey"
|
|
37
|
+
:highlight-current-row="highlightCurrentRow"
|
|
38
|
+
:row-key="rowKey || 'id'"
|
|
39
|
+
:data="data"
|
|
40
|
+
tooltip-effect="dark"
|
|
41
|
+
@row-click="
|
|
42
|
+
(row, column, event) => $emit('row-click', row, column, event)
|
|
43
|
+
"
|
|
44
|
+
@row-contextmenu="
|
|
45
|
+
(row, column, event) => $emit('row-contextmenu', row, column, event)
|
|
46
|
+
"
|
|
47
|
+
@row-dblclick="
|
|
48
|
+
(row, column, event) => $emit('row-dblclick', row, column, event)
|
|
49
|
+
"
|
|
50
|
+
@header-click="(column, event) => $emit('header-click', column, event)"
|
|
51
|
+
@header-contextmenu="
|
|
52
|
+
(column, event) => $emit('header-contextmenu', column, event)
|
|
53
|
+
"
|
|
54
|
+
@sort-change="
|
|
55
|
+
({ column, prop, order }) =>
|
|
56
|
+
$emit('sort-change', { column, prop, order })
|
|
57
|
+
"
|
|
58
|
+
@expand-change="(row, da) => $emit('expand-change', row, da)"
|
|
59
|
+
@filter-change="(filter) => $emit('filter-change', filter)"
|
|
60
|
+
@current-change="
|
|
61
|
+
(currentRow, oldCurrentRow) =>
|
|
62
|
+
$emit('current-change', currentRow, oldCurrentRow)
|
|
63
|
+
"
|
|
64
|
+
@select="(selection, row) => $emit('select', selection, row)"
|
|
65
|
+
@select-all="(selection) => $emit('select-all', selection)"
|
|
66
|
+
@selection-change="(selection) => $emit('selection-change', selection)"
|
|
67
|
+
@cell-mouse-enter="
|
|
68
|
+
(row, column, cell, event) =>
|
|
69
|
+
$emit('cell-mouse-enter', row, column, cell, event)
|
|
70
|
+
"
|
|
71
|
+
@cell-mouse-leave="
|
|
72
|
+
(row, column, cell, event) =>
|
|
73
|
+
$emit('cell-mouse-leave', row, column, cell, event)
|
|
74
|
+
"
|
|
75
|
+
@cell-click="
|
|
76
|
+
(row, column, cell, event) =>
|
|
77
|
+
$emit('cell-click', row, column, cell, event)
|
|
78
|
+
"
|
|
79
|
+
@cell-dblclick="
|
|
80
|
+
(row, column, cell, event) =>
|
|
81
|
+
$emit('cell-dblclick', row, column, cell, event)
|
|
82
|
+
"
|
|
83
|
+
>
|
|
84
|
+
<el-table-column
|
|
85
|
+
width="55"
|
|
86
|
+
:resizable="false"
|
|
87
|
+
v-if="checked"
|
|
88
|
+
:reserve-selection="reserveSelection"
|
|
89
|
+
:selectable="(row) => row[selectKey] !== false"
|
|
90
|
+
type="selection"
|
|
91
|
+
>
|
|
92
|
+
</el-table-column>
|
|
93
|
+
<el-table-column v-if="isExpand" type="expand">
|
|
94
|
+
<!-- 展开行专用 -->
|
|
95
|
+
<template slot-scope="props">
|
|
96
|
+
<slot
|
|
97
|
+
name="expand"
|
|
98
|
+
:row="props.row"
|
|
99
|
+
:column="props.column"
|
|
100
|
+
:rowIndex="props.$index"
|
|
101
|
+
>
|
|
102
|
+
</slot>
|
|
103
|
+
</template>
|
|
104
|
+
</el-table-column>
|
|
105
|
+
<el-table-column
|
|
106
|
+
v-if="!hideOrder"
|
|
107
|
+
:resizable="false"
|
|
108
|
+
:label="keyName === undefined ? '序号' : keyName"
|
|
109
|
+
:align="'center'"
|
|
110
|
+
width="55"
|
|
111
|
+
>
|
|
112
|
+
<template slot="header">
|
|
113
|
+
<slot :name="'header_order'">
|
|
114
|
+
<div @click="showFilterModel" v-if="showFilter" title="筛选排序">
|
|
115
|
+
<el-button type="text"
|
|
116
|
+
><i class="el-icon-s-grid"></i
|
|
117
|
+
></el-button>
|
|
118
|
+
</div>
|
|
119
|
+
<span v-else>{{ keyName || '序号' }}</span>
|
|
120
|
+
</slot>
|
|
121
|
+
</template>
|
|
122
|
+
<template slot-scope="{ row, column, $index }">
|
|
123
|
+
<slot
|
|
124
|
+
name="body_order"
|
|
125
|
+
:row="row"
|
|
126
|
+
:column="column"
|
|
127
|
+
:$index="$index"
|
|
128
|
+
>
|
|
129
|
+
{{
|
|
130
|
+
(state.pageInfo.currentPage - 1) * state.pageInfo.pageSize +
|
|
131
|
+
($index + 1)
|
|
132
|
+
}}
|
|
133
|
+
</slot>
|
|
134
|
+
</template>
|
|
135
|
+
</el-table-column>
|
|
136
|
+
<template v-for="(item, index) in state.showColumns">
|
|
137
|
+
<HtTableColumn
|
|
138
|
+
:key="`${item.key}_${index}`"
|
|
139
|
+
:item="item"
|
|
140
|
+
></HtTableColumn>
|
|
141
|
+
</template>
|
|
142
|
+
</el-table>
|
|
143
|
+
</article>
|
|
144
|
+
<footer v-if="!hidePage" class="ht-table-footer">
|
|
145
|
+
<el-row name="footer">
|
|
146
|
+
<!-- 此处建议使用el-col -->
|
|
147
|
+
<slot name="footerLeft"></slot>
|
|
148
|
+
|
|
149
|
+
<el-col :span="$slots['footerLeft'] ? 12 : 24">
|
|
150
|
+
<!-- <p style="width:90px;float:left">共{{data.length}}条</p> -->
|
|
151
|
+
<PageInfo
|
|
152
|
+
:hide-on-single-page="pagination && pagination.hideOnSinglePage"
|
|
153
|
+
:small="pagination && pagination.small"
|
|
154
|
+
:style="pageStyle"
|
|
155
|
+
@onchange="(e) => $emit('onchange', e)"
|
|
156
|
+
:page-sizes="pagination && pagination.pageSizes"
|
|
157
|
+
:page-info="state.pageInfo"
|
|
158
|
+
></PageInfo>
|
|
159
|
+
</el-col>
|
|
160
|
+
</el-row>
|
|
161
|
+
</footer>
|
|
162
|
+
<!-- 详情弹框 -->
|
|
163
|
+
<el-dialog
|
|
164
|
+
:visible.sync="state.visibleFilter"
|
|
165
|
+
title="属性设置"
|
|
166
|
+
v-if="state.visibleFilter"
|
|
167
|
+
:append-to-body="true"
|
|
168
|
+
:modal-append-to-body="true"
|
|
169
|
+
:close-on-click-modal="true"
|
|
170
|
+
width="400px"
|
|
171
|
+
>
|
|
172
|
+
<p
|
|
173
|
+
slot="title"
|
|
174
|
+
style="font-weight:700;font-size:18px;float:left;margin:0"
|
|
175
|
+
>
|
|
176
|
+
自定义列展示
|
|
177
|
+
</p>
|
|
178
|
+
<div style="overflow:hidden;height:35vh;margin-top:12px">
|
|
179
|
+
<el-scrollbar style="height: calc(35vh + 17px)">
|
|
180
|
+
<el-tree
|
|
181
|
+
:data="getAllColumns"
|
|
182
|
+
ref="tree"
|
|
183
|
+
show-checkbox
|
|
184
|
+
:expand-on-click-node="false"
|
|
185
|
+
node-key="key"
|
|
186
|
+
:check-on-click-node="false"
|
|
187
|
+
@node-drag-start="handleDragStart"
|
|
188
|
+
@node-drag-enter="handleDragEnter"
|
|
189
|
+
@node-drag-leave="handleDragLeave"
|
|
190
|
+
@node-drag-over="handleDragOver"
|
|
191
|
+
@node-drag-end="handleDragEnd"
|
|
192
|
+
@node-drop="handleDrop"
|
|
193
|
+
:default-checked-keys="state.checkedColumnKeys"
|
|
194
|
+
@check-change="changeColumns"
|
|
195
|
+
:allow-drag="allowDrag"
|
|
196
|
+
:draggable="draggable"
|
|
197
|
+
:allow-drop="allowDrop"
|
|
198
|
+
>
|
|
199
|
+
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
200
|
+
<slot :name="'header_' + data.key" :column="data"
|
|
201
|
+
>{{ data.title
|
|
202
|
+
}}<span style="color:#C0C4CC">{{
|
|
203
|
+
data.property ? `(${data.property})` : ''
|
|
204
|
+
}}</span></slot
|
|
205
|
+
>
|
|
206
|
+
</span>
|
|
207
|
+
</el-tree>
|
|
208
|
+
</el-scrollbar>
|
|
209
|
+
</div>
|
|
210
|
+
<span slot="footer">
|
|
211
|
+
<el-button type="primary" @click="confirmSortAndshow">确定</el-button>
|
|
212
|
+
<el-button @click="state.visibleFilter = false">取消</el-button>
|
|
213
|
+
<el-button @click="resetColumn">重置</el-button>
|
|
214
|
+
</span>
|
|
215
|
+
</el-dialog>
|
|
216
|
+
<!-- 附件详情弹框 -->
|
|
217
|
+
<el-dialog
|
|
218
|
+
:visible.sync="state.visibleFile"
|
|
219
|
+
v-if="state.visibleFile"
|
|
220
|
+
title="附件查看"
|
|
221
|
+
:append-to-body="true"
|
|
222
|
+
:modal-append-to-body="true"
|
|
223
|
+
:close-on-click-modal="true"
|
|
224
|
+
width="400px"
|
|
225
|
+
:center="true"
|
|
226
|
+
>
|
|
227
|
+
<p
|
|
228
|
+
slot="title"
|
|
229
|
+
style="font-weight:700;font-size:18px;float:left;margin:0"
|
|
230
|
+
>
|
|
231
|
+
附件查看
|
|
232
|
+
</p>
|
|
233
|
+
|
|
234
|
+
<div style="overflow:hidden;height:calc(30vh)">
|
|
235
|
+
<el-scrollbar style="height: calc(100% + 17px)">
|
|
236
|
+
<HtUploadFiles :disabled="true" v-model="state.files"></HtUploadFiles>
|
|
237
|
+
</el-scrollbar>
|
|
238
|
+
</div>
|
|
239
|
+
</el-dialog>
|
|
240
|
+
</div>
|
|
241
|
+
</template>
|
|
242
|
+
<script lang="ts">
|
|
243
|
+
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
|
244
|
+
import { Column, PageInfoType } from '@/packages/type';
|
|
245
|
+
import PageInfo from '@/packages/PageInfo/index.vue';
|
|
246
|
+
import HtUploadFiles from '@/packages/HtUploadFiles/index.vue';
|
|
247
|
+
import HtShowBaseData from '@/packages/HtShowBaseData';
|
|
248
|
+
import HtOrgInfo from '@/packages/HtOrgInfo';
|
|
249
|
+
import HtSelectUnit from '@/packages/HtSelectUnit';
|
|
250
|
+
import HtTableColumn from './htTableColumn.vue';
|
|
251
|
+
import ElmentUI from 'element-ui';
|
|
252
|
+
import { getSpanMethod } from './table-span-method';
|
|
253
|
+
Vue.use(ElmentUI);
|
|
254
|
+
interface State {
|
|
255
|
+
pageInfo: PageInfoType;
|
|
256
|
+
loading: boolean;
|
|
257
|
+
/** 展示出来的列表名 */
|
|
258
|
+
showColumns: Column[];
|
|
259
|
+
/** 全部的列 */
|
|
260
|
+
allColumns: Column[];
|
|
261
|
+
/** 列表展示的列 */
|
|
262
|
+
showColumnKeys: string[];
|
|
263
|
+
/** 自定义列表选中的列 */
|
|
264
|
+
checkedColumnKeys: string[];
|
|
265
|
+
/** 是否展示筛选框 */
|
|
266
|
+
visibleFilter: boolean;
|
|
267
|
+
/** 是否展示附件 */
|
|
268
|
+
visibleFile: boolean;
|
|
269
|
+
/** 当前拖动的数据 */
|
|
270
|
+
currentColumn?: Column;
|
|
271
|
+
/** 附件ids */
|
|
272
|
+
files?: string;
|
|
273
|
+
}
|
|
274
|
+
@Component({
|
|
275
|
+
name: 'HtTable',
|
|
276
|
+
components: {
|
|
277
|
+
PageInfo,
|
|
278
|
+
HtUploadFiles,
|
|
279
|
+
HtShowBaseData,
|
|
280
|
+
HtOrgInfo,
|
|
281
|
+
HtSelectUnit,
|
|
282
|
+
HtTableColumn,
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
export default class HtTable extends Vue {
|
|
286
|
+
/** 默认的table头 */
|
|
287
|
+
@Prop({ default: [] }) columns!: Column[];
|
|
288
|
+
@Prop() data!: any[];
|
|
289
|
+
/** 是否在表尾显示合计行 */
|
|
290
|
+
@Prop({ default: false }) showSummary!: boolean;
|
|
291
|
+
/** 分页样式自定义 */
|
|
292
|
+
@Prop() pageStyle!: string;
|
|
293
|
+
/** 合计行第一列的文本 */
|
|
294
|
+
@Prop({ default: '合计' }) sumText!: string;
|
|
295
|
+
@Prop({ default: false }) defaultExpandAll!: boolean;
|
|
296
|
+
@Prop() expandRowKeys!: string[];
|
|
297
|
+
/** 自定义合并方法 */
|
|
298
|
+
@Prop() summaryMethod!: any;
|
|
299
|
+
/** 序号对应的名称 */
|
|
300
|
+
@Prop() keyName?: string;
|
|
301
|
+
/** 合并单元格 */
|
|
302
|
+
@Prop() spanMethod?: {
|
|
303
|
+
rowspan: number;
|
|
304
|
+
colspan: number;
|
|
305
|
+
};
|
|
306
|
+
/** 是否启用展开行功能 */
|
|
307
|
+
@Prop() isExpand?: boolean;
|
|
308
|
+
/** 打开配置列 */
|
|
309
|
+
@Prop() configShow?: boolean;
|
|
310
|
+
/** 是否增加筛选功能 */
|
|
311
|
+
@Prop() showFilter?: boolean;
|
|
312
|
+
/** table的唯一值用于table数据筛选 */
|
|
313
|
+
@Prop() uuId?: string;
|
|
314
|
+
/** 是否隐藏分页 */
|
|
315
|
+
@Prop() hidePage!: boolean;
|
|
316
|
+
|
|
317
|
+
/** 仅对 type=selection 的列有效,类型为 Boolean,为 true 则会在数据更新之后保留之前选中的数据(需指定 row-key) */
|
|
318
|
+
@Prop() reserveSelection!: boolean;
|
|
319
|
+
@Prop() height?: string | number;
|
|
320
|
+
@Prop() maxHeight?: string | number;
|
|
321
|
+
@Prop() rowKey?: string;
|
|
322
|
+
@Prop() stripe?: boolean;
|
|
323
|
+
@Prop() border?: boolean;
|
|
324
|
+
@Prop() size?: 'medium' | 'small' | 'mini';
|
|
325
|
+
@Prop() fit?: boolean;
|
|
326
|
+
@Prop() showHeader?: boolean;
|
|
327
|
+
@Prop() rowClassName?: any;
|
|
328
|
+
/** 是否启用复选框 */
|
|
329
|
+
@Prop() checked!: boolean;
|
|
330
|
+
/** 设置的禁用字段值--与check同步 */
|
|
331
|
+
@Prop({ default: 'selectable' }) selectKey?: string;
|
|
332
|
+
/** 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 */
|
|
333
|
+
@Prop() selectable?: any;
|
|
334
|
+
@Prop() currentRowKey?: string | number;
|
|
335
|
+
@Prop() highlightCurrentRow?: boolean;
|
|
336
|
+
@Prop() rowStyle?: any;
|
|
337
|
+
@Prop() hideOrder?: boolean;
|
|
338
|
+
@Prop() pageInfo?: PageInfoType;
|
|
339
|
+
@Prop() emptyText?: string | number;
|
|
340
|
+
@Prop() headerRowStyle?: any;
|
|
341
|
+
@Prop() headerRowClassName?: any;
|
|
342
|
+
@Prop() headerCellClassName?: any;
|
|
343
|
+
@Prop() headerCellStyle?: any;
|
|
344
|
+
/** 是否可以拖动排序 */
|
|
345
|
+
@Prop({ default: true }) draggable?: boolean;
|
|
346
|
+
@Prop() spanMethodProps?: {
|
|
347
|
+
/** 需要合并的key值--将指定的列的行进行合并 */
|
|
348
|
+
colRows?: string[];
|
|
349
|
+
/** 将指定的列进行合并时候 合并规则必须相同 */
|
|
350
|
+
sameColRows?: string[];
|
|
351
|
+
relateProps?: { [key: string]: string };
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/** 分页的所有额外信息通过此参数传递 */
|
|
355
|
+
@Prop() pagination?: any;
|
|
356
|
+
state: State = {
|
|
357
|
+
loading: false,
|
|
358
|
+
files: undefined,
|
|
359
|
+
pageInfo: {
|
|
360
|
+
currentPage: 1,
|
|
361
|
+
pageSize: 10,
|
|
362
|
+
skipCount: 0,
|
|
363
|
+
totalCount: 0,
|
|
364
|
+
},
|
|
365
|
+
showColumns: [],
|
|
366
|
+
allColumns: [],
|
|
367
|
+
currentColumn: undefined,
|
|
368
|
+
visibleFilter: false,
|
|
369
|
+
visibleFile: false,
|
|
370
|
+
showColumnKeys: [],
|
|
371
|
+
checkedColumnKeys: [],
|
|
372
|
+
};
|
|
373
|
+
created() {
|
|
374
|
+
this.setPageInfo(this.pageInfo);
|
|
375
|
+
//this.setColumns(this.columns);
|
|
376
|
+
|
|
377
|
+
// console.log("this.columns", this.columns);
|
|
378
|
+
}
|
|
379
|
+
resetColumn() {
|
|
380
|
+
if (this.configShow) {
|
|
381
|
+
this.columns.forEach((item) => {
|
|
382
|
+
item.checked = !!item.deafaultShow;
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
this.creatInitColumnKey(this.columns);
|
|
386
|
+
} else {
|
|
387
|
+
this.creatInitColumnKey(this.columns || []);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
this.state.visibleFilter = false;
|
|
391
|
+
if (this.uuId) {
|
|
392
|
+
window.localStorage.setItem(
|
|
393
|
+
'table_' + this.uuId,
|
|
394
|
+
JSON.stringify(this.columns || [])
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** 获取展示的keys值 */
|
|
399
|
+
getShowKeys(data: Column[]) {
|
|
400
|
+
const arr: string[] = [];
|
|
401
|
+
data.forEach((item) => {
|
|
402
|
+
if (item.checked) {
|
|
403
|
+
arr.push(item.key);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
this.state.showColumnKeys = arr;
|
|
407
|
+
}
|
|
408
|
+
/** 初始化columns */
|
|
409
|
+
creatInitColumnKey(columns: Column[]) {
|
|
410
|
+
this.state.allColumns = columns;
|
|
411
|
+
this.state.showColumns = columns;
|
|
412
|
+
|
|
413
|
+
this.state.allColumns.forEach((item) => {
|
|
414
|
+
item.checked = item.checked === false ? false : true;
|
|
415
|
+
});
|
|
416
|
+
this.$nextTick(() => {
|
|
417
|
+
(this.$refs.comTable as any).doLayout();
|
|
418
|
+
// el-table加ref="comTable"
|
|
419
|
+
});
|
|
420
|
+
this.getShowKeys(this.state.allColumns);
|
|
421
|
+
}
|
|
422
|
+
doLayout() {
|
|
423
|
+
this.$nextTick(() => {
|
|
424
|
+
(this.$refs.comTable as any).doLayout();
|
|
425
|
+
// el-table加ref="comTable"
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/** 展示附件信息 */
|
|
429
|
+
showFiles(val = '') {
|
|
430
|
+
this.state.files = val;
|
|
431
|
+
this.state.visibleFile = true;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
handleDragStart(node: any) {
|
|
435
|
+
this.state.currentColumn = node.data;
|
|
436
|
+
}
|
|
437
|
+
handleDragEnter() {
|
|
438
|
+
// console.log("tree drag enter: ", dropNode.label);
|
|
439
|
+
}
|
|
440
|
+
handleDragLeave() {
|
|
441
|
+
//console.log("tree drag leave: ", dropNode.label);
|
|
442
|
+
}
|
|
443
|
+
handleDragOver() {
|
|
444
|
+
// console.log("tree drag over: ", dropNode.label);
|
|
445
|
+
}
|
|
446
|
+
handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
|
|
447
|
+
const { showColumns, currentColumn, checkedColumnKeys } = this.state;
|
|
448
|
+
// if ((dropType === "before" || dropType === "after") && currentColumn) {
|
|
449
|
+
// const data = showColumns.filter(
|
|
450
|
+
// (item) => item.key !== currentColumn?.key
|
|
451
|
+
// );
|
|
452
|
+
// const index = data.findIndex((item) => item.key === dropNode.data.key);
|
|
453
|
+
// dropType === "before"
|
|
454
|
+
// ? data.splice(index, 0, currentColumn)
|
|
455
|
+
// : data.splice(index + 1, 0, currentColumn);
|
|
456
|
+
|
|
457
|
+
if (currentColumn && checkedColumnKeys.includes(currentColumn.key)) {
|
|
458
|
+
setTimeout(() => {
|
|
459
|
+
(this.$refs.tree as any).setChecked(currentColumn, true);
|
|
460
|
+
}, 0);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
handleDrop() {
|
|
464
|
+
// console.log("tree drop: ", dropNode, dropType);
|
|
465
|
+
}
|
|
466
|
+
/** 节点是否被插入 */
|
|
467
|
+
allowDrop(draggingNode: any, dropNode: any, type: string) {
|
|
468
|
+
return type !== 'inner';
|
|
469
|
+
}
|
|
470
|
+
/** 节点是否允许拖动 */
|
|
471
|
+
allowDrag(draggingNode: any) {
|
|
472
|
+
return !draggingNode.data.disabled;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/** 现在自定义列弹窗 */
|
|
476
|
+
showFilterModel() {
|
|
477
|
+
this.state.visibleFilter = true;
|
|
478
|
+
this.state.checkedColumnKeys = this.state.showColumnKeys;
|
|
479
|
+
this.state.allColumns = JSON.parse(JSON.stringify(this.state.showColumns));
|
|
480
|
+
}
|
|
481
|
+
/** 自定义列表时候选中列 */
|
|
482
|
+
changeColumns(node: any, checked: boolean) {
|
|
483
|
+
let { checkedColumnKeys } = this.state;
|
|
484
|
+
if (checked) {
|
|
485
|
+
checkedColumnKeys.push(node.key);
|
|
486
|
+
} else {
|
|
487
|
+
checkedColumnKeys = checkedColumnKeys.filter((item) => item !== node.key);
|
|
488
|
+
}
|
|
489
|
+
this.state.checkedColumnKeys = checkedColumnKeys;
|
|
490
|
+
}
|
|
491
|
+
/** 自定义列排序的确定功能 */
|
|
492
|
+
confirmSortAndshow() {
|
|
493
|
+
this.state.loading = true;
|
|
494
|
+
this.state.showColumns = [];
|
|
495
|
+
this.state.allColumns = this.getAllColumns;
|
|
496
|
+
const { allColumns, checkedColumnKeys } = this.state;
|
|
497
|
+
//对列表check复制
|
|
498
|
+
allColumns.forEach(
|
|
499
|
+
(item) => (item.checked = checkedColumnKeys.includes(item.key))
|
|
500
|
+
);
|
|
501
|
+
//将复选框选中行展示到列中 */
|
|
502
|
+
this.state.showColumnKeys = checkedColumnKeys;
|
|
503
|
+
//将列的顺序进行处理已经存储
|
|
504
|
+
|
|
505
|
+
if (this.uuId) {
|
|
506
|
+
window.localStorage.setItem(
|
|
507
|
+
'table_' + this.uuId,
|
|
508
|
+
JSON.stringify(allColumns)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
this.state.showColumns = allColumns;
|
|
512
|
+
this.state.visibleFilter = false;
|
|
513
|
+
this.state.loading = false;
|
|
514
|
+
this.$nextTick(() => {
|
|
515
|
+
(this.$refs.comTable as any).doLayout();
|
|
516
|
+
// el-table加ref="multipleTable"
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
/** 自定义列回调 */
|
|
520
|
+
this.$emit('customColumn', allColumns);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** 获取显示出来的table头信息 */
|
|
524
|
+
get showColumns() {
|
|
525
|
+
const { showColumnKeys, showColumns } = this.state;
|
|
526
|
+
let obj: any = {};
|
|
527
|
+
for (const key in showColumnKeys) {
|
|
528
|
+
obj = { ...obj, [showColumnKeys[key]]: true };
|
|
529
|
+
}
|
|
530
|
+
/** 缓存起来下次使用 --todo只做了显示没有做排序缓存 */
|
|
531
|
+
if (this.uuId) {
|
|
532
|
+
window.localStorage.setItem(
|
|
533
|
+
'table_' + this.uuId,
|
|
534
|
+
JSON.stringify(showColumnKeys)
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const data = showColumns.filter((item) => obj[item.key as string]);
|
|
539
|
+
return data;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** 监听 */
|
|
543
|
+
@Watch('pageInfo')
|
|
544
|
+
setPageInfo(val?: PageInfoType) {
|
|
545
|
+
if (val) {
|
|
546
|
+
const pageInfo: PageInfoType = val;
|
|
547
|
+
this.state.pageInfo = {
|
|
548
|
+
currentPage: Number(pageInfo.currentPage),
|
|
549
|
+
pageSize: Number(pageInfo.pageSize),
|
|
550
|
+
skipCount: Number(pageInfo.skipCount),
|
|
551
|
+
totalCount: Number(pageInfo.totalCount),
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
get getAllColumns() {
|
|
556
|
+
const { allColumns } = this.state;
|
|
557
|
+
|
|
558
|
+
return allColumns.filter((item) => !item.hide);
|
|
559
|
+
}
|
|
560
|
+
@Watch('columns', { immediate: true })
|
|
561
|
+
setColumns(columns?: Column[]) {
|
|
562
|
+
if (!columns) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
if (this.uuId) {
|
|
566
|
+
//通过uuid获取缓存起来的header显示信息
|
|
567
|
+
//-todo
|
|
568
|
+
//---columns 要改变
|
|
569
|
+
//---showColumnKeys 要改变
|
|
570
|
+
//---排列顺序要改变 todo
|
|
571
|
+
const allColumns: string | null = window.localStorage.getItem(
|
|
572
|
+
'table_' + this.uuId
|
|
573
|
+
);
|
|
574
|
+
if (allColumns) {
|
|
575
|
+
this.state.allColumns = JSON.parse(allColumns);
|
|
576
|
+
this.state.showColumns = JSON.parse(allColumns);
|
|
577
|
+
this.getShowKeys(this.state.allColumns);
|
|
578
|
+
} else {
|
|
579
|
+
if (this.configShow) {
|
|
580
|
+
columns.forEach((item) => (item.checked = !!item.deafaultShow));
|
|
581
|
+
this.creatInitColumnKey(columns);
|
|
582
|
+
} else {
|
|
583
|
+
this.creatInitColumnKey(columns || []);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
if (this.configShow) {
|
|
588
|
+
columns.forEach((item) => (item.checked = !!item.deafaultShow));
|
|
589
|
+
this.creatInitColumnKey(columns);
|
|
590
|
+
} else {
|
|
591
|
+
this.creatInitColumnKey(columns || []);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
get spanMethodCom() {
|
|
596
|
+
return this.spanMethod
|
|
597
|
+
? this.spanMethod
|
|
598
|
+
: getSpanMethod(
|
|
599
|
+
this.data,
|
|
600
|
+
this.spanMethodProps?.colRows || [],
|
|
601
|
+
this.spanMethodProps?.sameColRows || [],
|
|
602
|
+
this.spanMethodProps?.relateProps
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
</script>
|
|
607
|
+
<style lang="scss" scoped></style>
|
package/src/packages/type.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-10-25 17:05:17
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2023-
|
|
7
|
+
* @LastEditTime: 2023-04-09 10:34:44
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -68,9 +68,9 @@ export interface Column {
|
|
|
68
68
|
hide?: boolean;
|
|
69
69
|
/** 时间是否跨行展示 */
|
|
70
70
|
spread?: boolean;
|
|
71
|
-
/** 通过type展示相应的数据 用户id|部门id|时间格式化|是否布尔值|图片
|
|
72
|
-
type?: 'userId' | 'org' | 'time' | 'common' | 'boolean' | 'img' | 'file' | 'unit' | 'position';
|
|
73
|
-
/** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time
|
|
71
|
+
/** 通过type展示相应的数据 用户id|部门id|时间格式化|是否布尔值|图片 |附件 |* |unit是新资产的单位 position资产位置 |日期 */
|
|
72
|
+
type?: 'userId' | 'org' | 'time' | 'common' | 'boolean' | 'img' | 'file' | 'unit' | 'position' | 'date';
|
|
73
|
+
/** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
|
|
74
74
|
commonType?: 'userId' | 'departmentId' | 'baseDataId' | 'roleId' | 'baseDataName' | 'baseDataValue';
|
|
75
75
|
/** 当type===common时候 设置是否隐藏基础数据的value */
|
|
76
76
|
hideCode?: boolean;
|
|
@@ -83,6 +83,8 @@ export interface Column {
|
|
|
83
83
|
property?: string;
|
|
84
84
|
/** 自定义列时候处理是否被选中 */
|
|
85
85
|
checked?: boolean;
|
|
86
|
+
/** 是否存在合并单元格,如果有子项则用children处理 */
|
|
87
|
+
children?: Column[];
|
|
86
88
|
}
|
|
87
89
|
export interface PageInfoType {
|
|
88
90
|
currentPage: number;
|
package/src/router/index.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-12-29 15:18:26
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2023-
|
|
7
|
+
* @LastEditTime: 2023-04-09 11:05:05
|
|
8
8
|
*/
|
|
9
9
|
import { RouteConfig } from "vue-router";
|
|
10
10
|
import Index from "../views/Index.vue";
|
|
11
11
|
import Login from "vue-kst-auth";
|
|
12
|
+
import About from "../views/About.vue";
|
|
12
13
|
|
|
13
14
|
const routes: Array<RouteConfig> = [
|
|
14
15
|
{
|
|
@@ -28,7 +29,7 @@ const routes: Array<RouteConfig> = [
|
|
|
28
29
|
meta: {
|
|
29
30
|
title: "资产管理"
|
|
30
31
|
},
|
|
31
|
-
component:
|
|
32
|
+
component: About
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
path: "assetManagement",
|