mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-26 12:48:48 +08:00
fix: 修复demo中formTable几个空指针报错和selectedRowKeys丢失响应式的问题 (#2386)
Co-authored-by: 王一骅 <wangyihua@yazuishou.com>
This commit is contained in:
parent
057b82632b
commit
6844f69c20
@ -40,7 +40,7 @@ export function useCustomRow(
|
|||||||
function handleClick() {
|
function handleClick() {
|
||||||
const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef);
|
const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef);
|
||||||
if (!rowSelection || !clickToRowSelect) return;
|
if (!rowSelection || !clickToRowSelect) return;
|
||||||
const keys = getSelectRowKeys();
|
const keys = getSelectRowKeys() || [];
|
||||||
const key = getKey(record, rowKey, unref(getAutoCreateKey));
|
const key = getKey(record, rowKey, unref(getAutoCreateKey));
|
||||||
if (!key) return;
|
if (!key) return;
|
||||||
|
|
||||||
|
@ -66,13 +66,13 @@ export function useRowSelection(
|
|||||||
selectedRowKeysRef.value = rowKeys;
|
selectedRowKeysRef.value = rowKeys;
|
||||||
const allSelectedRows = findNodeAll(
|
const allSelectedRows = findNodeAll(
|
||||||
toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))),
|
toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))),
|
||||||
(item) => rowKeys.includes(item[unref(getRowKey) as string]),
|
(item) => rowKeys?.includes(item[unref(getRowKey) as string]),
|
||||||
{
|
{
|
||||||
children: propsRef.value.childrenColumnName ?? 'children',
|
children: propsRef.value.childrenColumnName ?? 'children',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const trueSelectedRows: any[] = [];
|
const trueSelectedRows: any[] = [];
|
||||||
rowKeys.forEach((key: string) => {
|
rowKeys?.forEach((key: string) => {
|
||||||
const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key);
|
const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key);
|
||||||
found && trueSelectedRows.push(found);
|
found && trueSelectedRows.push(found);
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicTable
|
<BasicTable @register="registerTable">
|
||||||
@register="registerTable"
|
|
||||||
:rowSelection="{ type: 'checkbox', selectedRowKeys: checkedKeys, onChange: onSelectChange }"
|
|
||||||
>
|
|
||||||
<template #form-custom> custom-slot </template>
|
<template #form-custom> custom-slot </template>
|
||||||
<template #headerTop>
|
<template #headerTop>
|
||||||
<a-alert type="info" show-icon>
|
<a-alert type="info" show-icon>
|
||||||
@ -44,6 +41,11 @@
|
|||||||
tableSetting: { fullScreen: true },
|
tableSetting: { fullScreen: true },
|
||||||
showIndexColumn: false,
|
showIndexColumn: false,
|
||||||
rowKey: 'id',
|
rowKey: 'id',
|
||||||
|
rowSelection: {
|
||||||
|
type: 'checkbox',
|
||||||
|
selectedRowKeys: checkedKeys,
|
||||||
|
onChange: onSelectChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function getFormValues() {
|
function getFormValues() {
|
||||||
|
Loading…
Reference in New Issue
Block a user