| | |
| | | class="basic-table" |
| | | :class="{ |
| | | 'table-form-container': getBindValues.useSearchForm, |
| | | inset: getBindValues.inset, |
| | | }" |
| | | > |
| | | <BasicForm |
| | | v-bind="getFormProps" |
| | | v-if="getBindValues.useSearchForm" |
| | | :submitOnReset="true" |
| | | :submitButtonOptions="{ loading }" |
| | | :tableAction="tableAction" |
| | | @register="registerForm" |
| | | @submit="handleSearchInfoChange" |
| | | @advanced-change="redoHeight" |
| | |
| | | ref="tableElRef" |
| | | v-bind="getBindValues" |
| | | :rowClassName="getRowClassName" |
| | | :class="{ |
| | | hidden: !getEmptyDataIsShowTable, |
| | | }" |
| | | v-show="getEmptyDataIsShowTable" |
| | | @change="handleTableChange" |
| | | > |
| | | <template #[item]="data" v-for="item in Object.keys($slots)"> |
| | |
| | | </div> |
| | | </template> |
| | | <script lang="ts"> |
| | | import { defineComponent, ref, computed, unref, watch, nextTick, toRaw } from 'vue'; |
| | | import { Table } from 'ant-design-vue'; |
| | | import { basicProps } from './props'; |
| | | import type { |
| | | BasicTableProps, |
| | | FetchParams, |
| | | GetColumnsParams, |
| | | TableActionType, |
| | | SizeType, |
| | | SorterResult, |
| | | TableCustomRecord, |
| | | } from './types/table'; |
| | | import { PaginationProps } from './types/pagination'; |
| | | |
| | | import { isFunction, isString } from '/@/utils/is'; |
| | | |
| | | import { defineComponent, ref, computed, unref, watch, nextTick, toRaw } from 'vue'; |
| | | import { Table } from 'ant-design-vue'; |
| | | import renderTitle from './components/renderTitle'; |
| | | import renderFooter from './components/renderFooter'; |
| | | import renderExpandIcon from './components/renderExpandIcon'; |
| | | import { BasicForm, FormProps, useForm } from '/@/components/Form/index'; |
| | | |
| | | import { isFunction, isString } from '/@/utils/is'; |
| | | import { deepMerge } from '/@/utils'; |
| | | import { omit } from 'lodash-es'; |
| | | |
| | | import { usePagination } from './hooks/usePagination'; |
| | | import { useColumns } from './hooks/useColumns'; |
| | |
| | | import { useRowSelection } from './hooks/useRowSelection'; |
| | | import { useTableScroll } from './hooks/useTableScroll'; |
| | | import { provideTable } from './hooks/useProvinceTable'; |
| | | import { BasicForm, FormProps, useForm } from '/@/components/Form/index'; |
| | | import { omit } from 'lodash-es'; |
| | | import { ROW_KEY } from './const'; |
| | | import { PaginationProps } from './types/pagination'; |
| | | import { deepMerge } from '/@/utils'; |
| | | import { TableCustomRecord } from 'ant-design-vue/types/table/table'; |
| | | import { useEvent } from '/@/hooks/event/useEvent'; |
| | | |
| | | import { useEventListener } from '/@/hooks/event/useEventListener'; |
| | | import { basicProps } from './props'; |
| | | import { ROW_KEY } from './const'; |
| | | import './style/index.less'; |
| | | export default defineComponent({ |
| | | props: basicProps, |
| | |
| | | return !!unref(getDataSourceRef).length; |
| | | }); |
| | | |
| | | function getRowClassName(record: TableCustomRecord<any>, index: number) { |
| | | watch( |
| | | () => unref(getDataSourceRef), |
| | | () => { |
| | | handleSummary(); |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | function getRowClassName(record: TableCustomRecord, index: number) { |
| | | const { striped, rowClassName } = unref(getMergeProps); |
| | | if (!striped) return; |
| | | if (rowClassName && isFunction(rowClassName)) { |
| | |
| | | fetch({ searchInfo: info, page: 1 }); |
| | | } |
| | | |
| | | function handleTableChange(pagination: PaginationProps) { |
| | | const { clearSelectOnPageChange } = unref(getMergeProps); |
| | | function handleTableChange( |
| | | pagination: PaginationProps, |
| | | // @ts-ignore |
| | | filters: Partial<Record<string, string[]>>, |
| | | sorter: SorterResult |
| | | ) { |
| | | const { clearSelectOnPageChange, sortFn } = unref(getMergeProps); |
| | | if (clearSelectOnPageChange) { |
| | | clearSelectedRowKeys(); |
| | | } |
| | | setPagination(pagination); |
| | | |
| | | if (sorter && isFunction(sortFn)) { |
| | | const sortInfo = sortFn(sorter); |
| | | fetch({ sortInfo }); |
| | | return; |
| | | } |
| | | fetch(); |
| | | } |
| | | |
| | |
| | | } |
| | | const bodyDomList = tableEl.$el.querySelectorAll('.ant-table-body') as HTMLDivElement[]; |
| | | const bodyDom = bodyDomList[0]; |
| | | useEvent({ |
| | | useEventListener({ |
| | | el: bodyDom, |
| | | name: 'scroll', |
| | | listener: () => { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | watch( |
| | | () => unref(getDataSourceRef), |
| | | () => { |
| | | handleSummary(); |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | function setProps(props: Partial<BasicTableProps>) { |
| | | innerPropsRef.value = deepMerge(unref(innerPropsRef) || {}, props); |
| | |
| | | handleTableChange, |
| | | getRowClassName, |
| | | wrapRef, |
| | | tableAction, |
| | | ...tableAction, |
| | | }; |
| | | }, |