refactor: 判断vxe-table的复选框是否选中

This commit is contained in:
dap
2024-12-11 11:09:16 +08:00
parent 3014b62086
commit 7ec3cfb3fd
19 changed files with 62 additions and 157 deletions

View File

@@ -9,8 +9,8 @@ import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
tableCheckboxEvent,
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridDefines,
type VxeGridProps,
} from '#/adapter/vxe-table';
@@ -77,18 +77,15 @@ const gridOptions: VxeGridProps = {
id: 'monitor-logininfo-index',
};
const checked = ref(false);
const canUnlock = ref(false);
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
checkboxChange: (e: VxeGridDefines.CheckboxChangeEventParams) => {
const records = e.$table.getCheckboxRecords();
checked.value = records.length > 0;
const records = e.$grid.getCheckboxRecords();
canUnlock.value = records.length === 1 && records[0]?.status === '1';
},
checkboxAll: tableCheckboxEvent(checked),
},
});
@@ -125,7 +122,6 @@ function handleMultiDelete() {
onOk: async () => {
await loginInfoRemove(ids);
await tableApi.query();
checked.value = false;
},
});
}
@@ -138,7 +134,6 @@ async function handleUnlock() {
const { userName } = records[0];
await userUnlock(userName);
await tableApi.query();
checked.value = false;
canUnlock.value = false;
tableApi.grid.clearCheckboxRow();
}
@@ -173,7 +168,7 @@ function handleDownloadExcel() {
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!checked"
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['monitor:logininfor:remove']"