1、封装table组件
// tableBox.vue
<template>
<div class="table-c">
<a-table
:expandIcon="customIcon"
:columns="tableColumns"
:data-source="dataSource"
:pagination="pagination"
:loading="loading"
:rowSelection="rowSelection"
@change="change"
@expand="expand"
>
<template
v-for="i in tableColumns"
:key="i.key"
v-slot:[i.slots?.customRender]="{ record }"
>
<slot :name="i.slots?.customRender" :record="record"></slot>
</template>
<template v-slot:[expandedRowRender]="{ record }">
<slot name="expandedRowRender" :record="record"></slot>
</template>
</a-table>
<a-modal
title="列表设置"
v-model:visible="visible"
:width="800"
:confirmLoading="tableHeadLoading"
:bodyStyle="{
paddingBottom: '10px',
}"
>
<a-checkbox-group v-model:value="tableHead" class="checked-item">
<a-row>
<a-col
:span="5"
v-for="check in columns"
:key="check.key"
:offset="1"
>
<a-checkbox :value="check.key" :disabled="check.key == 'action'">
<span
v-text="check.key == 'action' ? '操作' : check.title"
></span>
</a-checkbox>
</a-col>
</a-row>
</a-checkbox-group>
<template #footer>
<div class="pop-btn-box">
<div class="btn-left">
<a-button @click="checkAll">全选</a-button>
<a-button @click="checkNoAll">全不选</a-button>
</div>
<div class="btn-right">
<a-button @click="handleHeadCancel">返回</a-button>
<a-button type="primary" @click="setConfirm" class="ok-btn"
>确定</a-button
>
</div>
</div>
</template>
</a-modal>
</div>
</template>