Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

列表数据勾选禁用后仍能勾选问题,显示选的数据条数也是错误的 #791

Closed
jhaso1988 opened this issue Oct 9, 2023 · 5 comments

Comments

@jhaso1988
Copy link

版本号:V3.5.5
问题描述:

列表数据勾选禁用后,单点勾选是不能勾选的,如果点击全部勾选,禁用的也将被勾选,勾选后显示选的数据条数没有排除禁用的

截图&代码:
image image image ![image](https://github.com/jeecgboot/jeecgboot-vue3/assets/34854608/de2b5c67-e649-49fe-80aa-b2ccc1d5d8d2) const [registerTable, { reload }, { selectedRowKeys, selectedRows }] = tableContext;

const rowSelection = {
type: 'checkbox',
columnWidth: 50,
selectedRowKeys: selectedRowKeys,
selectedRows: selectedRows,
getCheckboxProps(record: Recordable) {
//判断条件可随意
if (2 == record.izShow) {
return { disabled: true };
} else {
return { disabled: false };
}
},
onChange: onSelectChange,
};

/**

  • 复选框选中事件
  • @param rowKeys
  • @param rows
    */
    function onSelectChange(rowKeys, rows) {
    if (rows) {
    //判断条件可随意
    const newRows = rows.filter((item) => 2 !== item.izShow);
    selectedRows.value = newRows;
    const newRowKeys = newRows.map((item) => toRaw(item).id);
    selectedRowKeys.value = newRowKeys;
    checkedKeys.value = newRowKeys.length;
    }
    }

友情提示(为了提高issue处理效率):

  • 未按格式要求发帖,会被直接删掉;
  • 请自己初判问题描述是否清楚,是否方便我们调查处理;
  • 描述过于简单或模糊,导致无法处理的,会被直接删掉;
@jhaso1988
Copy link
Author

image

@jhaso1988
Copy link
Author

这个是批量删除后的页面展示
image

@zhangdaiscott
Copy link
Member

zy

@liaozhiyang
Copy link

1.禁用勾选功能已修复,下一版本发布。
你本地可按如下更改
src/components/Table/src/hooks/useCustomSelection.tsx
const flattedData = computed(() => {
const data = flattenData(tableData.value, childrenColumnName.value);
const rowSelection = propsRef.value.rowSelection;
if (rowSelection?.type === 'checkbox' && rowSelection.getCheckboxProps) {
for (let i = 0, len = data.length; i < len; i++) {
const record = data[i];
const result = rowSelection.getCheckboxProps(record);
if (result.disabled) {
data.splice(i, 1);
i--;
len--;
}
}
}
return data;
});
image
image

src/components/Table/src/components/CustomSelectHeader.vue
image

2.显示选的数据条数错误问题,你是删除了dataSource里面的数据吧?这个需要从selectedRowKeys中剔除勾选的数据。等禁用勾选修复之后点击删除直接设置selectedRowKeys=[]即可

@jhaso1988
Copy link
Author

更改后验证没问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants