ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.3k stars 1.36k forks source link

🐛[BUG] ProTable树结构展示,二级以下取消按钮会触发onDelete删除 #8599

Open clstech opened 3 months ago

clstech commented 3 months ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

ProTable树结构展示,操作按钮,二级以下取消按钮会触发onDelete删除, 顶级菜单正常不会触发onDelete

📷 复现步骤

传入树结构给ProTable展示,二级以下取消按钮会触发onDelete删除

🏞 期望结果

二级以下操作按钮正常取消

💻 复现代码

<ProTable<API.SysMenuItem>
        columns={columns}
        actionRef={actionRef}
        rowKey="id"
        scroll={{ x: 1300 }}
        pagination={{
          showSizeChanger: false,
        }}
        editable={{
          type: 'multiple',
          editableKeys,
          onDelete: async (key, row) => {
            message.success("为什么啊")
            // const { code, msg } = await deleteSysMenu(row.id!);
            // if (code === 200) {
            //   message.success(msg);
            // } else {
            //   actionRef.current?.reload();
            // }
          },
          onSave: async (rowKey, data) => {
            const { code } = await updateSysMenu(data);
            if (code === 200) {
              message.success('更新成功');
            }
          },
          onChange: setEditableRowKeys,
        }}
        request={async (params) => {
          const { data } = await getSysMenuTree({
            name: params.name,
            type: params.type,
            permission: params.permission,
          });
          if (data !== null) {
            setMenuTree(data);
            return {
              data: data,
              success: true,
            };
          }
          message.info('没有找到数据');
          return {
            data: [],
            success: true,
          };
        }}
        toolBarRender={() => [
          <AddMenuForm key="add" actionRef={actionRef} menuTree={menuTree} />,
        ]}
      />

© 版本信息

🚑 其他信息

image