张卓
2022-09-20 5aead44ba1be31db948dfd8362c2bfcbedbbce29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<template>
<div>
    <div class="systemTable">
<!--      :rowSelection="rowSelection"-->
        <a-table
                :loading="loading"
                :dataSource="dataSource"
                @change="handleTableChange"
                :columns="columns"
                :pagination="paginationProps">  //分页属性
            <!--
            <slot name="columns"></slot>
            -->
        </a-table>
    </div>
</div>
</template>
 
<style lang="less">
.systemTable {
    :global {
        .ant-table-pagination {
            margin-top: 24px;
        }
    }
 
    .tableAlert {
        margin-bottom: 16px;
    }
}
</style>
 
<script lang="tsx">
import {
    Component,
    Prop,
    Vue,
    Emit,
    Watch
} from 'vue-property-decorator';
import * as _ from 'lodash';
 
@Component({})
export default class SystemTable extends Vue {
 
    // private needTotalList: any[] = [];
 
    private selectedRowKeys: any[] = [];
 
    // get rowSelection() {
    //     return {
    //         selectedRowKeys: this.selectedRowKeys,
    //         onChange: this.handleRowSelectChange,
    //         getCheckboxProps: (record: any) => ({
    //             props: {
    //                 disabled: record.disabled,
    //             },
    //         }),
    //     };
    // }
 
    @Prop({
        type: Boolean,
        default: false,
    })
    private loading!: boolean;
 
    // @Prop({
    //     type: Object,
    //     default: () => {},
    // })
    // private pagination!: any;
 
    @Prop({
        type:Object,
        default:()=>{
        }
    })
    private paginationProps!:any;
 
    @Prop({
        type: Array,
        default: () => [],
    })
    private columns!: any[];
 
 
    @Prop({
        type: Array,
        default: () => [],
    })
    private dataSource!: any[];
 
    @Prop({
        type: Array,
        default: () => [],
    })
    private selectedRows!: any[];
 
    @Prop({
        type: Number,
        default: false,
    })
    private total!: number;
 
    // get pagination(): any {
    //     return {
    //         total: this.total ? this.total : 0,
    //         pageSize: 5,//每页中显示10条数据
    //         showSizeChanger: true,
    //         pageSizeOptions: null,//每页中显示的数据
    //         showTotal: (total:number) => `共有 ${this.total} 条数据`,  //分页中显示总的数据
    //     };
    // }
 
 
    private handleTableChange(pagination: any, filters: any, sorter: any): void {
        this.pageSend(pagination.current)
        this.onTableChange(pagination, filters, sorter);
    }
 
    private handleRowSelectChange(selectedRowKeys: any, selectedRows: any): void {
        this.selectedRowKeys = selectedRowKeys;
 
        // this.needTotalList = this.needTotalList.map((item: any) => ({
        //     ...item,
        //     total: _.sumBy(selectedRows, item.dataIndex),
        // }));
        this.onSelectChange(selectedRowKeys, selectedRows);
 
    }
 
    private mounted() {
        // this.needTotalList = this.initTotalList(this.columns);
    }
    // private initTotalList(columns: any[]) {
    //     const totalList: any[] = [];
    //     columns.forEach((column: any) => {
    //         if (column.needTotal) {
    //             totalList.push({ ...column,
    //                 total: 0,
    //             });
    //         }
    //     });
    //     return totalList;
    // }
    @Emit('cPage')
    private pageSend(page: number) {
        return page;
    }
    @Emit('selectChange')
    private onSelectChange(selectedRowKeys: any, selectedRows: any) {
 
    }
 
    @Emit('tableChange')
    private onTableChange(pagination: any, filters: any, sorter: any) {
    }
 
}
</script>