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