htui-yllkbz 1.5.17 → 1.5.19
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 +55 -55
- package/src/packages/HtShowBaseData/index.vue +2 -1
- package/src/packages/HtTable/htTableColumn.vue +98 -111
- package/src/packages/HtTable/index.vue +304 -264
- package/src/views/About.vue +91 -98
- package/lib/demo.html +0 -10
- package/lib/fonts/fontello.068ca2b3.ttf +0 -0
- package/lib/fonts/fontello.8d4a4e6f.woff2 +0 -0
- package/lib/fonts/fontello.a782baa8.woff +0 -0
- package/lib/fonts/fontello.e73a0647.eot +0 -0
- package/lib/htui.common.js +0 -113247
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.css +0 -1
- package/lib/htui.umd.js +0 -113257
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +0 -306
- package/lib/htui.umd.min.js.gz +0 -0
- package/lib/img/excel.bbca162d.png +0 -0
- package/lib/img/fontello.9354499c.svg +0 -72
- package/lib/img/other.2589bfcc.png +0 -0
- package/lib/img/pdf.a7d6d970.png +0 -0
- package/lib/img/txt.45f9960a.png +0 -0
- package/lib/img/vedio.8638f032.png +0 -0
|
@@ -4,132 +4,127 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-11-11 11:23:24
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2024-08-03 16:22:31
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
|
-
<div v-loading="state.loading"
|
|
10
|
+
<div v-loading="state.loading"
|
|
11
|
+
style="background:#fff">
|
|
11
12
|
<article>
|
|
12
|
-
<el-table
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:header-row-style="
|
|
13
|
+
<el-table 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
27
|
headerRowStyle || { background: 'var(--primary-92)' }
|
|
28
28
|
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
:cell-style="cellStyle"
|
|
36
|
+
:row-class-name="rowClassName"
|
|
37
|
+
:cell-class-name="cellClassName"
|
|
38
|
+
:current-row-key="currentRowKey"
|
|
39
|
+
:highlight-current-row="highlightCurrentRow"
|
|
40
|
+
:row-key="rowKey || 'id'"
|
|
41
|
+
:data="data"
|
|
42
|
+
tooltip-effect="dark"
|
|
43
|
+
:tree-props="treeProps"
|
|
44
|
+
@row-click="
|
|
45
45
|
(row, column, event) => $emit('row-click', row, column, event)
|
|
46
46
|
"
|
|
47
|
-
|
|
47
|
+
@row-contextmenu="
|
|
48
48
|
(row, column, event) => $emit('row-contextmenu', row, column, event)
|
|
49
49
|
"
|
|
50
|
-
|
|
50
|
+
@row-dblclick="
|
|
51
51
|
(row, column, event) => $emit('row-dblclick', row, column, event)
|
|
52
52
|
"
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
@header-click="(column, event) => $emit('header-click', column, event)"
|
|
54
|
+
@header-contextmenu="
|
|
55
55
|
(column, event) => $emit('header-contextmenu', column, event)
|
|
56
56
|
"
|
|
57
|
-
|
|
57
|
+
@header-dragend="headerDragend"
|
|
58
|
+
@sort-change="
|
|
58
59
|
({ column, prop, order }) =>
|
|
59
60
|
$emit('sort-change', { column, prop, order })
|
|
60
61
|
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
@expand-change="(row, da) => $emit('expand-change', row, da)"
|
|
63
|
+
@filter-change="(filter) => $emit('filter-change', filter)"
|
|
64
|
+
@current-change="
|
|
64
65
|
(currentRow, oldCurrentRow) =>
|
|
65
66
|
$emit('current-change', currentRow, oldCurrentRow)
|
|
66
67
|
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
@select="(selection, row) => $emit('select', selection, row)"
|
|
69
|
+
@select-all="(selection) => $emit('select-all', selection)"
|
|
70
|
+
@selection-change="(selection) => $emit('selection-change', selection)"
|
|
71
|
+
@cell-mouse-enter="
|
|
71
72
|
(row, column, cell, event) =>
|
|
72
73
|
$emit('cell-mouse-enter', row, column, cell, event)
|
|
73
74
|
"
|
|
74
|
-
|
|
75
|
+
@cell-mouse-leave="
|
|
75
76
|
(row, column, cell, event) =>
|
|
76
77
|
$emit('cell-mouse-leave', row, column, cell, event)
|
|
77
78
|
"
|
|
78
|
-
|
|
79
|
+
@cell-click="
|
|
79
80
|
(row, column, cell, event) =>
|
|
80
81
|
$emit('cell-click', row, column, cell, event)
|
|
81
82
|
"
|
|
82
|
-
|
|
83
|
+
@cell-dblclick="
|
|
83
84
|
(row, column, cell, event) =>
|
|
84
85
|
$emit('cell-dblclick', row, column, cell, event)
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
>
|
|
86
|
+
">
|
|
87
|
+
<template slot="empty">
|
|
88
|
+
<slot name="empty"> </slot>
|
|
89
|
+
</template>
|
|
90
|
+
<el-table-column width="55"
|
|
91
|
+
:resizable="false"
|
|
92
|
+
v-if="checked"
|
|
93
|
+
:reserve-selection="reserveSelection"
|
|
94
|
+
:selectable="(row) => row[selectKey] !== false"
|
|
95
|
+
type="selection">
|
|
96
96
|
</el-table-column>
|
|
97
|
-
<el-table-column v-if="isExpand"
|
|
97
|
+
<el-table-column v-if="isExpand"
|
|
98
|
+
type="expand">
|
|
98
99
|
<!-- 展开行专用 -->
|
|
99
100
|
<template slot-scope="props">
|
|
100
|
-
<slot
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
:rowIndex="props.$index"
|
|
105
|
-
>
|
|
101
|
+
<slot name="expand"
|
|
102
|
+
:row="props.row"
|
|
103
|
+
:column="props.column"
|
|
104
|
+
:rowIndex="props.$index">
|
|
106
105
|
</slot>
|
|
107
106
|
</template>
|
|
108
107
|
</el-table-column>
|
|
109
|
-
<el-table-column
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
width="55"
|
|
115
|
-
>
|
|
108
|
+
<el-table-column v-if="!hideOrder"
|
|
109
|
+
:resizable="false"
|
|
110
|
+
:label="keyName === undefined ? '序号' : keyName"
|
|
111
|
+
:align="'center'"
|
|
112
|
+
width="55">
|
|
116
113
|
<template slot="header">
|
|
117
114
|
<slot :name="'header_order'">
|
|
118
|
-
<div @click="showFilterModel"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
></el-button>
|
|
115
|
+
<div @click="showFilterModel"
|
|
116
|
+
v-if="showFilter"
|
|
117
|
+
title="筛选排序">
|
|
118
|
+
<el-button type="text"><i class="el-icon-s-grid"></i></el-button>
|
|
122
119
|
</div>
|
|
123
120
|
<span v-else>{{ keyName || '序号' }}</span>
|
|
124
121
|
</slot>
|
|
125
122
|
</template>
|
|
126
123
|
<template slot-scope="{ row, column, $index }">
|
|
127
|
-
<slot
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
:$index="$index"
|
|
132
|
-
>
|
|
124
|
+
<slot name="body_order"
|
|
125
|
+
:row="row"
|
|
126
|
+
:column="column"
|
|
127
|
+
:$index="$index">
|
|
133
128
|
{{
|
|
134
129
|
(state.pageInfo.currentPage - 1) * state.pageInfo.pageSize +
|
|
135
130
|
($index + 1)
|
|
@@ -138,169 +133,147 @@
|
|
|
138
133
|
</template>
|
|
139
134
|
</el-table-column>
|
|
140
135
|
|
|
141
|
-
<template v-for="(item, index) in
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
:name="child.key"
|
|
154
|
-
:row="scope.row"
|
|
155
|
-
:column="scope.column"
|
|
156
|
-
:rowIndex="scope.rowIndex"
|
|
157
|
-
>
|
|
136
|
+
<template v-for="(item, index) in showColumns">
|
|
137
|
+
|
|
138
|
+
<HtTableColumn :key="`${item.key}_${index}`"
|
|
139
|
+
:item="item"
|
|
140
|
+
@showFiles="showFiles">
|
|
141
|
+
<template v-for="child in allChildren"
|
|
142
|
+
:slot="child.key"
|
|
143
|
+
slot-scope="scope">
|
|
144
|
+
<slot :name="child.key"
|
|
145
|
+
:row="scope.row"
|
|
146
|
+
:column="scope.column"
|
|
147
|
+
:rowIndex="scope.rowIndex">
|
|
158
148
|
</slot>
|
|
159
149
|
</template>
|
|
160
|
-
<template
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
:name="'header_' + child.key"
|
|
167
|
-
:column="column"
|
|
168
|
-
:$index="$index"
|
|
169
|
-
></slot>
|
|
150
|
+
<template v-for="child in allChildren"
|
|
151
|
+
slot-scope="{ column, $index }"
|
|
152
|
+
:slot="'header_' + child.key">
|
|
153
|
+
<slot :name="'header_' + child.key"
|
|
154
|
+
:column="column"
|
|
155
|
+
:$index="$index"></slot>
|
|
170
156
|
</template>
|
|
171
157
|
|
|
172
|
-
<template :slot="item.key"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
158
|
+
<template :slot="item.key"
|
|
159
|
+
slot-scope="scope">
|
|
160
|
+
|
|
161
|
+
<slot :name="item.key"
|
|
162
|
+
:row="scope.row"
|
|
163
|
+
:column="scope.column"
|
|
164
|
+
:rowIndex="scope.rowIndex">
|
|
179
165
|
</slot>
|
|
180
166
|
</template>
|
|
181
|
-
<template
|
|
182
|
-
|
|
183
|
-
:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
:name="'header_' + item.key"
|
|
187
|
-
:column="column"
|
|
188
|
-
:$index="$index"
|
|
189
|
-
></slot>
|
|
167
|
+
<template slot-scope="{ column, $index }"
|
|
168
|
+
:slot="'header_' + item.key">
|
|
169
|
+
<slot :name="'header_' + item.key"
|
|
170
|
+
:column="column"
|
|
171
|
+
:$index="$index"></slot>
|
|
190
172
|
</template>
|
|
191
173
|
</HtTableColumn>
|
|
192
174
|
</template>
|
|
193
175
|
</el-table>
|
|
194
176
|
</article>
|
|
195
|
-
<footer v-if="!hidePage"
|
|
177
|
+
<footer v-if="!hidePage"
|
|
178
|
+
class="ht-table-footer">
|
|
196
179
|
<el-row name="footer">
|
|
197
180
|
<!-- 此处建议使用el-col -->
|
|
198
181
|
<slot name="footerLeft"></slot>
|
|
199
182
|
|
|
200
183
|
<el-col :span="$slots['footerLeft'] ? 12 : 24">
|
|
201
184
|
<!-- <p style="width:90px;float:left">共{{data.length}}条</p> -->
|
|
202
|
-
<PageInfo
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
:page-info="state.pageInfo"
|
|
209
|
-
></PageInfo>
|
|
185
|
+
<PageInfo :hide-on-single-page="pagination && pagination.hideOnSinglePage"
|
|
186
|
+
:small="pagination && pagination.small"
|
|
187
|
+
:style="pageStyle"
|
|
188
|
+
@onchange="(e) => $emit('onchange', e)"
|
|
189
|
+
:page-sizes="pagination && pagination.pageSizes"
|
|
190
|
+
:page-info="state.pageInfo"></PageInfo>
|
|
210
191
|
</el-col>
|
|
211
192
|
</el-row>
|
|
212
193
|
</footer>
|
|
213
194
|
<!-- 详情弹框 -->
|
|
214
|
-
<el-dialog
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<p
|
|
224
|
-
slot="title"
|
|
225
|
-
style="font-weight:700;font-size:18px;float:left;margin:0"
|
|
226
|
-
>
|
|
195
|
+
<el-dialog :visible.sync="state.visibleFilter"
|
|
196
|
+
title="属性设置"
|
|
197
|
+
v-if="state.visibleFilter"
|
|
198
|
+
:append-to-body="true"
|
|
199
|
+
:modal-append-to-body="true"
|
|
200
|
+
:close-on-click-modal="true"
|
|
201
|
+
width="400px">
|
|
202
|
+
<p slot="title"
|
|
203
|
+
style="font-weight:700;font-size:18px;float:left;margin:0">
|
|
227
204
|
自定义列展示
|
|
228
205
|
</p>
|
|
229
206
|
<div style="overflow:hidden;height:35vh;margin-top:12px">
|
|
230
207
|
<el-scrollbar style="height: calc(35vh + 17px)">
|
|
231
|
-
<el-tree
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
>{{ data.title
|
|
208
|
+
<el-tree :data="getAllColumns"
|
|
209
|
+
ref="tree"
|
|
210
|
+
show-checkbox
|
|
211
|
+
:expand-on-click-node="false"
|
|
212
|
+
node-key="key"
|
|
213
|
+
:check-on-click-node="false"
|
|
214
|
+
@node-drag-start="handleDragStart"
|
|
215
|
+
@node-drag-enter="handleDragEnter"
|
|
216
|
+
@node-drag-leave="handleDragLeave"
|
|
217
|
+
@node-drag-over="handleDragOver"
|
|
218
|
+
@node-drag-end="handleDragEnd"
|
|
219
|
+
@node-drop="handleDrop"
|
|
220
|
+
:default-checked-keys="state.checkedColumnKeys"
|
|
221
|
+
@check-change="changeColumns"
|
|
222
|
+
:allow-drag="allowDrag"
|
|
223
|
+
:draggable="draggable"
|
|
224
|
+
:allow-drop="allowDrop">
|
|
225
|
+
<span class="custom-tree-node"
|
|
226
|
+
slot-scope="{ node, data }">
|
|
227
|
+
<slot :name="'header_' + data.key"
|
|
228
|
+
:column="data">{{ data.title
|
|
253
229
|
}}<span style="color:#C0C4CC">{{
|
|
254
230
|
data.property ? `(${data.property})` : ''
|
|
255
|
-
}}</span></slot
|
|
256
|
-
>
|
|
231
|
+
}}</span></slot>
|
|
257
232
|
</span>
|
|
258
233
|
</el-tree>
|
|
259
234
|
</el-scrollbar>
|
|
260
235
|
</div>
|
|
261
236
|
<span slot="footer">
|
|
262
|
-
<el-button type="primary"
|
|
237
|
+
<el-button type="primary"
|
|
238
|
+
@click="confirmSortAndshow">确定</el-button>
|
|
263
239
|
<el-button @click="state.visibleFilter = false">取消</el-button>
|
|
264
240
|
<el-button @click="resetColumn">重置</el-button>
|
|
265
241
|
</span>
|
|
266
242
|
</el-dialog>
|
|
267
243
|
<!-- 附件详情弹框 -->
|
|
268
|
-
<el-dialog
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<p
|
|
279
|
-
slot="title"
|
|
280
|
-
style="font-weight:700;font-size:18px;float:left;margin:0"
|
|
281
|
-
>
|
|
244
|
+
<el-dialog :visible.sync="state.visibleFile"
|
|
245
|
+
v-if="state.visibleFile"
|
|
246
|
+
title="附件查看"
|
|
247
|
+
:append-to-body="true"
|
|
248
|
+
:modal-append-to-body="true"
|
|
249
|
+
:close-on-click-modal="true"
|
|
250
|
+
width="400px"
|
|
251
|
+
:center="true">
|
|
252
|
+
<p slot="title"
|
|
253
|
+
style="font-weight:700;font-size:18px;float:left;margin:0">
|
|
282
254
|
附件查看
|
|
283
255
|
</p>
|
|
284
256
|
|
|
285
257
|
<div style="overflow:hidden;height:calc(30vh)">
|
|
286
258
|
<el-scrollbar style="height: calc(100% + 17px)">
|
|
287
|
-
<HtUploadFiles :disabled="true"
|
|
259
|
+
<HtUploadFiles :disabled="true"
|
|
260
|
+
v-model="state.files"></HtUploadFiles>
|
|
288
261
|
</el-scrollbar>
|
|
289
262
|
</div>
|
|
290
263
|
</el-dialog>
|
|
291
264
|
</div>
|
|
292
265
|
</template>
|
|
293
266
|
<script lang="ts">
|
|
294
|
-
import { Component, Prop, Vue, Watch } from
|
|
295
|
-
import { Column, PageInfoType } from
|
|
296
|
-
import PageInfo from
|
|
297
|
-
import HtUploadFiles from
|
|
298
|
-
import HtShowBaseData from
|
|
299
|
-
import HtOrgInfo from
|
|
300
|
-
import HtSelectUnit from
|
|
301
|
-
import HtTableColumn from
|
|
302
|
-
import ElmentUI from
|
|
303
|
-
import { getSpanMethod } from
|
|
267
|
+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
268
|
+
import { Column, PageInfoType } from "@/packages/type";
|
|
269
|
+
import PageInfo from "@/packages/PageInfo/index.vue";
|
|
270
|
+
import HtUploadFiles from "@/packages/HtUploadFiles/index.vue";
|
|
271
|
+
import HtShowBaseData from "@/packages/HtShowBaseData";
|
|
272
|
+
import HtOrgInfo from "@/packages/HtOrgInfo";
|
|
273
|
+
import HtSelectUnit from "@/packages/HtSelectUnit";
|
|
274
|
+
import HtTableColumn from "./htTableColumn.vue";
|
|
275
|
+
import ElmentUI from "element-ui";
|
|
276
|
+
import { getSpanMethod } from "./table-span-method";
|
|
304
277
|
Vue.use(ElmentUI);
|
|
305
278
|
interface State {
|
|
306
279
|
pageInfo: PageInfoType;
|
|
@@ -323,7 +296,7 @@ interface State {
|
|
|
323
296
|
files?: string;
|
|
324
297
|
}
|
|
325
298
|
@Component({
|
|
326
|
-
name:
|
|
299
|
+
name: "HtTable",
|
|
327
300
|
components: {
|
|
328
301
|
PageInfo,
|
|
329
302
|
HtUploadFiles,
|
|
@@ -342,7 +315,7 @@ export default class HtTable extends Vue {
|
|
|
342
315
|
/** 分页样式自定义 */
|
|
343
316
|
@Prop() pageStyle!: string;
|
|
344
317
|
/** 合计行第一列的文本 */
|
|
345
|
-
@Prop({ default:
|
|
318
|
+
@Prop({ default: "合计" }) sumText!: string;
|
|
346
319
|
@Prop({ default: false }) defaultExpandAll!: boolean;
|
|
347
320
|
@Prop() expandRowKeys!: string[];
|
|
348
321
|
/** 自定义合并方法 */
|
|
@@ -373,8 +346,8 @@ export default class HtTable extends Vue {
|
|
|
373
346
|
@Prop() maxHeight?: string | number;
|
|
374
347
|
@Prop() rowKey?: string;
|
|
375
348
|
@Prop() stripe?: boolean;
|
|
376
|
-
@Prop() border?: boolean;
|
|
377
|
-
@Prop() size?:
|
|
349
|
+
@Prop({ default: true }) border?: boolean;
|
|
350
|
+
@Prop() size?: "medium" | "small" | "mini";
|
|
378
351
|
@Prop() fit?: boolean;
|
|
379
352
|
@Prop() showHeader?: boolean;
|
|
380
353
|
@Prop() rowClassName?: any;
|
|
@@ -382,7 +355,7 @@ export default class HtTable extends Vue {
|
|
|
382
355
|
/** 是否启用复选框 */
|
|
383
356
|
@Prop() checked!: boolean;
|
|
384
357
|
/** 设置的禁用字段值--与check同步 */
|
|
385
|
-
@Prop({ default:
|
|
358
|
+
@Prop({ default: "selectable" }) selectKey?: string;
|
|
386
359
|
/** 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 */
|
|
387
360
|
@Prop() selectable?: any;
|
|
388
361
|
@Prop() currentRowKey?: string | number;
|
|
@@ -445,7 +418,7 @@ export default class HtTable extends Vue {
|
|
|
445
418
|
this.state.visibleFilter = false;
|
|
446
419
|
if (this.uuId) {
|
|
447
420
|
window.localStorage.setItem(
|
|
448
|
-
|
|
421
|
+
"table_" + this.uuId,
|
|
449
422
|
JSON.stringify(this.columns || [])
|
|
450
423
|
);
|
|
451
424
|
}
|
|
@@ -453,25 +426,35 @@ export default class HtTable extends Vue {
|
|
|
453
426
|
/** 获取展示的keys值 */
|
|
454
427
|
getShowKeys(data: Column[]) {
|
|
455
428
|
const arr: string[] = [];
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
429
|
+
function findKeys(array: Column[]) {
|
|
430
|
+
array.forEach((item) => {
|
|
431
|
+
if (item.checked) {
|
|
432
|
+
arr.push(item.key);
|
|
433
|
+
}
|
|
434
|
+
if (item.children?.length) {
|
|
435
|
+
findKeys(item.children);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
findKeys(data);
|
|
440
|
+
|
|
461
441
|
this.state.showColumnKeys = arr;
|
|
462
442
|
}
|
|
463
443
|
/** 初始化columns */
|
|
464
444
|
creatInitColumnKey(columns: Column[]) {
|
|
465
445
|
this.state.allColumns = columns;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
446
|
+
/** 如果没有配置默认展示的字段则展示全部字段 */
|
|
447
|
+
const checkTrueArr = columns.filter((item) => item.checked !== false);
|
|
448
|
+
if (!checkTrueArr.length) {
|
|
449
|
+
this.state.allColumns.forEach((item) => {
|
|
450
|
+
item.checked = true;
|
|
451
|
+
});
|
|
452
|
+
} else {
|
|
453
|
+
this.state.allColumns.forEach((item) => {
|
|
454
|
+
item.checked = item.checked === false ? false : true;
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
this.setTableHeader(this.state.allColumns);
|
|
475
458
|
this.getShowKeys(this.state.allColumns);
|
|
476
459
|
}
|
|
477
460
|
doLayout() {
|
|
@@ -481,7 +464,7 @@ export default class HtTable extends Vue {
|
|
|
481
464
|
});
|
|
482
465
|
}
|
|
483
466
|
/** 展示附件信息 */
|
|
484
|
-
showFiles(val =
|
|
467
|
+
showFiles(val = "") {
|
|
485
468
|
this.state.files = val;
|
|
486
469
|
this.state.visibleFile = true;
|
|
487
470
|
}
|
|
@@ -519,14 +502,76 @@ export default class HtTable extends Vue {
|
|
|
519
502
|
// console.log("tree drop: ", dropNode, dropType);
|
|
520
503
|
}
|
|
521
504
|
/** 节点是否被插入 */
|
|
522
|
-
allowDrop(
|
|
523
|
-
|
|
505
|
+
allowDrop(_draggingNode: any, _dropNode: any, type: string) {
|
|
506
|
+
if (_draggingNode.level === _dropNode.level) {
|
|
507
|
+
return type === "prev" || type === "next";
|
|
508
|
+
} else {
|
|
509
|
+
// 不同级进行处理
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
524
512
|
}
|
|
525
513
|
/** 节点是否允许拖动 */
|
|
526
514
|
allowDrag(draggingNode: any) {
|
|
527
515
|
return !draggingNode.data.disabled;
|
|
528
516
|
}
|
|
517
|
+
headerDragend(
|
|
518
|
+
newWidth: number,
|
|
519
|
+
_oldWidth: number,
|
|
520
|
+
column: any,
|
|
521
|
+
_event: MouseEvent
|
|
522
|
+
) {
|
|
523
|
+
const allColumnsStr: string | null = window.localStorage.getItem(
|
|
524
|
+
"table_" + this.uuId
|
|
525
|
+
);
|
|
526
|
+
if (allColumnsStr) {
|
|
527
|
+
const Columns = JSON.parse(allColumnsStr);
|
|
529
528
|
|
|
529
|
+
let currentIndex: {
|
|
530
|
+
parentIndex: number;
|
|
531
|
+
currentIndex: number;
|
|
532
|
+
} = { parentIndex: -1, currentIndex: -1 };
|
|
533
|
+
function getCIndex(arr: Column[], _parent?: Column, pIndex = -1) {
|
|
534
|
+
for (let i = 0; i < arr.length; i++) {
|
|
535
|
+
if (arr[i].key === column.property) {
|
|
536
|
+
currentIndex = {
|
|
537
|
+
parentIndex: pIndex,
|
|
538
|
+
currentIndex: i,
|
|
539
|
+
};
|
|
540
|
+
break;
|
|
541
|
+
} else {
|
|
542
|
+
getCIndex(arr[i].children || [], arr[i], i);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
getCIndex(Columns, undefined, undefined);
|
|
547
|
+
if (currentIndex.parentIndex > -1) {
|
|
548
|
+
Columns[currentIndex.parentIndex].children[
|
|
549
|
+
currentIndex.currentIndex
|
|
550
|
+
].width = newWidth;
|
|
551
|
+
this.setTableHeader(Columns);
|
|
552
|
+
} else if (
|
|
553
|
+
currentIndex.parentIndex == -1 &&
|
|
554
|
+
currentIndex.currentIndex > -1
|
|
555
|
+
) {
|
|
556
|
+
Columns[currentIndex.currentIndex].width = newWidth;
|
|
557
|
+
this.setTableHeader(Columns);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/** 缓存table头部信息 */
|
|
562
|
+
setTableHeader(allColumns: Column[]) {
|
|
563
|
+
if (this.uuId) {
|
|
564
|
+
window.localStorage.setItem(
|
|
565
|
+
"table_" + this.uuId,
|
|
566
|
+
JSON.stringify(allColumns)
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
this.state.showColumns = allColumns;
|
|
570
|
+
|
|
571
|
+
this.state.visibleFilter = false;
|
|
572
|
+
this.state.loading = false;
|
|
573
|
+
this.doLayout();
|
|
574
|
+
}
|
|
530
575
|
/** 现在自定义列弹窗 */
|
|
531
576
|
showFilterModel() {
|
|
532
577
|
this.state.visibleFilter = true;
|
|
@@ -534,14 +579,8 @@ export default class HtTable extends Vue {
|
|
|
534
579
|
this.state.allColumns = JSON.parse(JSON.stringify(this.state.showColumns));
|
|
535
580
|
}
|
|
536
581
|
/** 自定义列表时候选中列 */
|
|
537
|
-
changeColumns(
|
|
538
|
-
|
|
539
|
-
if (checked) {
|
|
540
|
-
checkedColumnKeys.push(node.key);
|
|
541
|
-
} else {
|
|
542
|
-
checkedColumnKeys = checkedColumnKeys.filter((item) => item !== node.key);
|
|
543
|
-
}
|
|
544
|
-
this.state.checkedColumnKeys = checkedColumnKeys;
|
|
582
|
+
changeColumns() {
|
|
583
|
+
this.state.checkedColumnKeys = (this.$refs.tree as any).getCheckedKeys();
|
|
545
584
|
}
|
|
546
585
|
/** 自定义列排序的确定功能 */
|
|
547
586
|
confirmSortAndshow() {
|
|
@@ -549,50 +588,46 @@ export default class HtTable extends Vue {
|
|
|
549
588
|
this.state.showColumns = [];
|
|
550
589
|
this.state.allColumns = this.getAllColumns;
|
|
551
590
|
const { allColumns, checkedColumnKeys } = this.state;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
(item) =>
|
|
555
|
-
|
|
591
|
+
|
|
592
|
+
function findChecked(colums: Column[]) {
|
|
593
|
+
colums.forEach((item) => {
|
|
594
|
+
item.checked = checkedColumnKeys.includes(item.key);
|
|
595
|
+
//如果子级不存在直接处理
|
|
596
|
+
if (!item.children?.length) {
|
|
597
|
+
} else {
|
|
598
|
+
findChecked(item.children);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
findChecked(allColumns);
|
|
603
|
+
|
|
556
604
|
//将复选框选中行展示到列中 */
|
|
557
605
|
this.state.showColumnKeys = checkedColumnKeys;
|
|
558
606
|
//将列的顺序进行处理已经存储
|
|
559
607
|
|
|
560
|
-
|
|
561
|
-
window.localStorage.setItem(
|
|
562
|
-
'table_' + this.uuId,
|
|
563
|
-
JSON.stringify(allColumns)
|
|
564
|
-
);
|
|
565
|
-
}
|
|
566
|
-
this.state.showColumns = allColumns;
|
|
567
|
-
this.state.visibleFilter = false;
|
|
568
|
-
this.state.loading = false;
|
|
569
|
-
this.$nextTick(() => {
|
|
570
|
-
(this.$refs.comTable as any).doLayout();
|
|
571
|
-
// el-table加ref="multipleTable"
|
|
572
|
-
});
|
|
608
|
+
this.setTableHeader(allColumns);
|
|
573
609
|
|
|
574
610
|
/** 自定义列回调 */
|
|
575
|
-
this.$emit(
|
|
611
|
+
this.$emit("customColumn", allColumns);
|
|
576
612
|
}
|
|
577
613
|
|
|
578
614
|
/** 获取显示出来的table头信息 */
|
|
579
615
|
get showColumns() {
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
obj = { ...obj, [showColumnKeys[key]]: true };
|
|
584
|
-
}
|
|
585
|
-
/** 缓存起来下次使用 --todo只做了显示没有做排序缓存 */
|
|
586
|
-
if (this.uuId) {
|
|
587
|
-
window.localStorage.setItem(
|
|
588
|
-
'table_' + this.uuId,
|
|
589
|
-
JSON.stringify(showColumnKeys)
|
|
590
|
-
);
|
|
591
|
-
}
|
|
616
|
+
const stateColumns: Column[] = JSON.parse(
|
|
617
|
+
JSON.stringify(this.state.showColumns)
|
|
618
|
+
);
|
|
592
619
|
|
|
593
|
-
|
|
594
|
-
|
|
620
|
+
stateColumns.forEach((item) => {
|
|
621
|
+
if (item.children?.length && item.checked == false) {
|
|
622
|
+
const isChecked = !!item.children.find((item) => item.checked);
|
|
623
|
+
item.checked = isChecked;
|
|
624
|
+
item.children = item.children.filter((item) => item.checked !== false);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
console.log("showColumns", stateColumns);
|
|
628
|
+
return stateColumns;
|
|
595
629
|
}
|
|
630
|
+
|
|
596
631
|
get allChildren() {
|
|
597
632
|
const { showColumns } = this.state;
|
|
598
633
|
let allchildren: Column[] = [];
|
|
@@ -605,7 +640,7 @@ export default class HtTable extends Vue {
|
|
|
605
640
|
}
|
|
606
641
|
|
|
607
642
|
/** 监听 */
|
|
608
|
-
@Watch(
|
|
643
|
+
@Watch("pageInfo")
|
|
609
644
|
setPageInfo(val?: PageInfoType) {
|
|
610
645
|
if (val) {
|
|
611
646
|
const pageInfo: PageInfoType = val;
|
|
@@ -622,7 +657,12 @@ export default class HtTable extends Vue {
|
|
|
622
657
|
|
|
623
658
|
return allColumns.filter((item) => !item.hide);
|
|
624
659
|
}
|
|
625
|
-
@Watch(
|
|
660
|
+
@Watch("showColumns")
|
|
661
|
+
resetShowCOlums() {
|
|
662
|
+
console.log("重置");
|
|
663
|
+
this.doLayout();
|
|
664
|
+
}
|
|
665
|
+
@Watch("columns", { immediate: true })
|
|
626
666
|
setColumns(columns?: Column[]) {
|
|
627
667
|
if (!columns) {
|
|
628
668
|
return;
|
|
@@ -634,7 +674,7 @@ export default class HtTable extends Vue {
|
|
|
634
674
|
//---showColumnKeys 要改变
|
|
635
675
|
//---排列顺序要改变 todo
|
|
636
676
|
const allColumns: string | null = window.localStorage.getItem(
|
|
637
|
-
|
|
677
|
+
"table_" + this.uuId
|
|
638
678
|
);
|
|
639
679
|
if (allColumns) {
|
|
640
680
|
this.state.allColumns = JSON.parse(allColumns);
|