Update TableProMax.vue
This commit is contained in:
parent
76b1105337
commit
f40878eb22
|
@ -1,16 +1,15 @@
|
|||
<template>
|
||||
<div class="table-pro-content">
|
||||
<div class="card padding" v-if="props.searchFormOptions">
|
||||
<FormProMax ref="searchFormRef" :form-item-options="props.searchFormOptions" v-model:value="searchParams"
|
||||
v-bind="props.searchFormProps">
|
||||
<FormProMax ref="searchFormRef" :form-item-options="props.searchFormOptions" v-model:value="searchParams" v-bind="props.searchFormProps">
|
||||
<template v-slot:formOperation>
|
||||
<a-space class="margin-right flex-end">
|
||||
<a-button type="primary" @click="search">
|
||||
<search-outlined/>
|
||||
<search-outlined />
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button danger @click="resetFormAndTable">
|
||||
<rollback-outlined/>
|
||||
<rollback-outlined />
|
||||
重置
|
||||
</a-button>
|
||||
</a-space>
|
||||
|
@ -27,7 +26,7 @@
|
|||
<a-tooltip>
|
||||
<template #title>刷新数据</template>
|
||||
<a-button shape="circle" @click="requestGetTableData">
|
||||
<ReloadOutlined/>
|
||||
<ReloadOutlined />
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
@ -35,34 +34,34 @@
|
|||
<a-tooltip>
|
||||
<template #title>打印数据</template>
|
||||
<a-button shape="circle">
|
||||
<PrinterOutlined/>
|
||||
<PrinterOutlined />
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
</a-space>
|
||||
</div>
|
||||
<a-table
|
||||
class="margin-top"
|
||||
v-bind="props"
|
||||
:columns="tableColumns"
|
||||
:row-selection="props.isSelection ? (props.selectionProps ? props.selectionProps : defaultSelectProps) : null"
|
||||
:data-source="dataSource"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
class="margin-top"
|
||||
v-bind="props"
|
||||
:columns="tableColumns"
|
||||
:row-selection="props.isSelection ? (props.selectionProps ? props.selectionProps : defaultSelectProps) : null"
|
||||
:data-source="dataSource"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
>
|
||||
<template v-for="(_, key) in slots" v-slot:[key]="scope">
|
||||
<slot v-if="!includes(['tableHeader', 'tableHeaderRight'], String(key))" :name="key" v-bind="scope"></slot>
|
||||
</template>
|
||||
</a-table>
|
||||
<a-pagination
|
||||
v-if="props.isPagination"
|
||||
class="flex-end margin-top margin-right"
|
||||
v-model:current="pageParams.current"
|
||||
v-model:page-size="pageParams.size"
|
||||
:total="pageParams.total"
|
||||
v-bind="props.paginationProps"
|
||||
@change="handleCurrentChange"
|
||||
@showSizeChange="handleSizeChange"
|
||||
v-if="props.isPagination"
|
||||
class="flex-end margin-top margin-right"
|
||||
v-model:current="pageParams.current"
|
||||
v-model:page-size="pageParams.size"
|
||||
:total="pageParams.total"
|
||||
v-bind="props.paginationProps"
|
||||
@change="handleCurrentChange"
|
||||
@showSizeChange="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -70,17 +69,12 @@
|
|||
|
||||
<script setup lang="ts" generic="T extends BaseTableRowRecord = {},P extends { [key: string]: any } ={}">
|
||||
import FormProMax from '@/components/form/FormProMax.vue'
|
||||
import {PrinterOutlined, ReloadOutlined, RollbackOutlined, SearchOutlined} from '@ant-design/icons-vue'
|
||||
import {computed, onMounted, Ref, ref} from 'vue'
|
||||
import {FormInstance} from 'ant-design-vue'
|
||||
import { PrinterOutlined, ReloadOutlined, RollbackOutlined, SearchOutlined } from '@ant-design/icons-vue'
|
||||
import { computed, onMounted, Ref, ref } from 'vue'
|
||||
import { FormInstance } from 'ant-design-vue'
|
||||
import useTableProMax from '@/hooks/useTableProMax.ts'
|
||||
import {includes, isEmpty} from 'lodash-es'
|
||||
import {
|
||||
BaseTableRowRecord,
|
||||
TableProMaxProps,
|
||||
TableProMaxRowSelect,
|
||||
TableProMaxSlots
|
||||
} from '@/types/components/table/index.ts'
|
||||
import { includes, isEmpty } from 'lodash-es'
|
||||
import { BaseTableRowRecord, TableProMaxProps, TableProMaxRowSelect, TableProMaxSlots } from '@/types/components/table/index.ts'
|
||||
|
||||
//
|
||||
const selectKeys = ref<string[]>([])
|
||||
|
@ -156,7 +150,7 @@ const tableColumns = computed(() => {
|
|||
dataIndex: 'index',
|
||||
width: 60,
|
||||
title: '序号',
|
||||
customRender: ({index}) => index + 1,
|
||||
customRender: ({ index }) => index + 1,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -172,24 +166,14 @@ const searchFormRef = ref<FormInstance>() as Ref<FormInstance>
|
|||
*/
|
||||
const searchParams = ref<P | Record<string, any>>(props.defaultSearchParams || {}) as Ref<P>
|
||||
|
||||
const {
|
||||
loading,
|
||||
dataSource,
|
||||
pageParams,
|
||||
search,
|
||||
requestGetTableData,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
resetState
|
||||
} = useTableProMax(
|
||||
props.requestApi,
|
||||
searchFormRef,
|
||||
searchParams,
|
||||
props.isPagination,
|
||||
props.dataCallback,
|
||||
props.requestError
|
||||
const { loading, dataSource, pageParams, search, requestGetTableData, handleSizeChange, handleCurrentChange, resetState } = useTableProMax(
|
||||
props.requestApi,
|
||||
searchFormRef,
|
||||
searchParams,
|
||||
props.isPagination,
|
||||
props.dataCallback,
|
||||
props.requestError
|
||||
)
|
||||
// console.log('pageParams', pageParams)
|
||||
|
||||
onMounted(() => props.requestAuto && requestGetTableData(true))
|
||||
|
||||
|
|
Loading…
Reference in New Issue