refactor: 移除已经弃用的方法

This commit is contained in:
dap
2025-01-15 23:34:50 +08:00
parent 11dba43d83
commit 8816086b37
3 changed files with 11 additions and 53 deletions

View File

@@ -1,6 +1,4 @@
import type { Ref } from 'vue';
import type { VxeGridDefines, VxeGridPropTypes } from '@vben/plugins/vxe-table';
import type { VxeGridPropTypes } from '@vben/plugins/vxe-table';
import { h } from 'vue';
@@ -105,21 +103,6 @@ export { useVbenVxeGrid };
export type * from '@vben/plugins/vxe-table';
/**
* 通用的表格复选框是否选中事件
* @deprecated 使用vxeCheckboxChecked代替
* @param checked 是否选中
* @returns function
*/
export function tableCheckboxEvent(checked: Ref<boolean>) {
const event: (params: VxeGridDefines.CheckboxChangeEventParams) => void = (
params,
) => {
checked.value = params.$table.getCheckboxRecords().length > 0;
};
return event;
}
/**
* 判断vxe-table的复选框是否选中
* @param tableApi api
@@ -131,28 +114,6 @@ export function vxeCheckboxChecked(
return tableApi?.grid?.getCheckboxRecords?.()?.length > 0;
}
/**
* 通用的vxe-table排序事件 支持单/多字段排序
* @deprecated 翻页后排序会丢失使用addSortParams代替
* @param tableApi api
* @param sortParams 排序参数
*/
export function vxeSortEvent(
tableApi: ReturnType<typeof useVbenVxeGrid>[1],
sortParams: VxeGridDefines.SortChangeEventParams,
) {
const { sortList } = sortParams;
// 这里是排序取消 length为0 就不传参数了
if (sortList.length === 0) {
tableApi.query();
return;
}
// 支持单/多字段排序
const orderByColumn = sortList.map((item) => item.field).join(',');
const isAsc = sortList.map((item) => item.order).join(',');
tableApi.query({ orderByColumn, isAsc });
}
/**
* 通用的 排序参数添加到请求参数中
* @param params 请求参数

View File

@@ -1,19 +1,18 @@
<script setup lang="ts">
import type { VbenFormProps } from '@vben/common-ui';
import type { Recordable } from '@vben/types';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { Page, useVbenModal } from '@vben/common-ui';
import { getPopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
tableCheckboxEvent,
useVbenVxeGrid,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { downloadExcel } from '#/utils/file/download';
import { useVbenVxeGrid, vxeCheckboxChecked } from '#/adapter/vxe-table';
import { commonDownloadExcel } from '#/utils/file/download';
import { demoExport, demoList, demoRemove } from './api';
import { columns, querySchema } from './data';
@@ -61,10 +60,6 @@ const checked = ref(false);
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
checkboxChange: tableCheckboxEvent(checked),
checkboxAll: tableCheckboxEvent(checked),
},
});
const [DemoModal, modalApi] = useVbenModal({
@@ -113,7 +108,7 @@ function handleMultiDelete() {
<a-button
v-access:code="['system:demo:export']"
@click="
downloadExcel(
commonDownloadExcel(
demoExport,
'测试单数据',
tableApi.formApi.form.values,
@@ -123,7 +118,7 @@ function handleMultiDelete() {
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!checked"
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['system:demo:remove']"