Update TableProMax.vue

This commit is contained in:
TimSpan 2025-06-27 15:34:11 +08:00
parent 76b1105337
commit f40878eb22
1 changed files with 33 additions and 49 deletions

View File

@ -1,16 +1,15 @@
<template> <template>
<div class="table-pro-content"> <div class="table-pro-content">
<div class="card padding" v-if="props.searchFormOptions"> <div class="card padding" v-if="props.searchFormOptions">
<FormProMax ref="searchFormRef" :form-item-options="props.searchFormOptions" v-model:value="searchParams" <FormProMax ref="searchFormRef" :form-item-options="props.searchFormOptions" v-model:value="searchParams" v-bind="props.searchFormProps">
v-bind="props.searchFormProps">
<template v-slot:formOperation> <template v-slot:formOperation>
<a-space class="margin-right flex-end"> <a-space class="margin-right flex-end">
<a-button type="primary" @click="search"> <a-button type="primary" @click="search">
<search-outlined/> <search-outlined />
搜索 搜索
</a-button> </a-button>
<a-button danger @click="resetFormAndTable"> <a-button danger @click="resetFormAndTable">
<rollback-outlined/> <rollback-outlined />
重置 重置
</a-button> </a-button>
</a-space> </a-space>
@ -27,7 +26,7 @@
<a-tooltip> <a-tooltip>
<template #title>刷新数据</template> <template #title>刷新数据</template>
<a-button shape="circle" @click="requestGetTableData"> <a-button shape="circle" @click="requestGetTableData">
<ReloadOutlined/> <ReloadOutlined />
</a-button> </a-button>
</a-tooltip> </a-tooltip>
</template> </template>
@ -35,7 +34,7 @@
<a-tooltip> <a-tooltip>
<template #title>打印数据</template> <template #title>打印数据</template>
<a-button shape="circle"> <a-button shape="circle">
<PrinterOutlined/> <PrinterOutlined />
</a-button> </a-button>
</a-tooltip> </a-tooltip>
</template> </template>
@ -70,17 +69,12 @@
<script setup lang="ts" generic="T extends BaseTableRowRecord = {},P extends { [key: string]: any } ={}"> <script setup lang="ts" generic="T extends BaseTableRowRecord = {},P extends { [key: string]: any } ={}">
import FormProMax from '@/components/form/FormProMax.vue' import FormProMax from '@/components/form/FormProMax.vue'
import {PrinterOutlined, ReloadOutlined, RollbackOutlined, SearchOutlined} from '@ant-design/icons-vue' import { PrinterOutlined, ReloadOutlined, RollbackOutlined, SearchOutlined } from '@ant-design/icons-vue'
import {computed, onMounted, Ref, ref} from 'vue' import { computed, onMounted, Ref, ref } from 'vue'
import {FormInstance} from 'ant-design-vue' import { FormInstance } from 'ant-design-vue'
import useTableProMax from '@/hooks/useTableProMax.ts' import useTableProMax from '@/hooks/useTableProMax.ts'
import {includes, isEmpty} from 'lodash-es' import { includes, isEmpty } from 'lodash-es'
import { import { BaseTableRowRecord, TableProMaxProps, TableProMaxRowSelect, TableProMaxSlots } from '@/types/components/table/index.ts'
BaseTableRowRecord,
TableProMaxProps,
TableProMaxRowSelect,
TableProMaxSlots
} from '@/types/components/table/index.ts'
// //
const selectKeys = ref<string[]>([]) const selectKeys = ref<string[]>([])
@ -156,7 +150,7 @@ const tableColumns = computed(() => {
dataIndex: 'index', dataIndex: 'index',
width: 60, width: 60,
title: '序号', title: '序号',
customRender: ({index}) => index + 1, customRender: ({ index }) => index + 1,
}) })
} }
} }
@ -172,16 +166,7 @@ const searchFormRef = ref<FormInstance>() as Ref<FormInstance>
*/ */
const searchParams = ref<P | Record<string, any>>(props.defaultSearchParams || {}) as Ref<P> const searchParams = ref<P | Record<string, any>>(props.defaultSearchParams || {}) as Ref<P>
const { const { loading, dataSource, pageParams, search, requestGetTableData, handleSizeChange, handleCurrentChange, resetState } = useTableProMax(
loading,
dataSource,
pageParams,
search,
requestGetTableData,
handleSizeChange,
handleCurrentChange,
resetState
} = useTableProMax(
props.requestApi, props.requestApi,
searchFormRef, searchFormRef,
searchParams, searchParams,
@ -189,7 +174,6 @@ const {
props.dataCallback, props.dataCallback,
props.requestError props.requestError
) )
// console.log('pageParams', pageParams)
onMounted(() => props.requestAuto && requestGetTableData(true)) onMounted(() => props.requestAuto && requestGetTableData(true))