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

[Table] 与Drawer联用时drag-sort="row-handler"控制台报错 #4985

Open
Zccf opened this issue Feb 5, 2025 · 1 comment
Open

[Table] 与Drawer联用时drag-sort="row-handler"控制台报错 #4985

Zccf opened this issue Feb 5, 2025 · 1 comment
Labels

Comments

@Zccf
Copy link

Zccf commented Feb 5, 2025

tdesign-vue-next 版本

1.10.7

重现链接

No response

重现步骤

以下为会出现报错的代码(可直接复制运行):

  <t-drawer v-model:visible="drawerVisible" size="55%">
    <t-table
      row-key="index"
      :columns="columns"
      :data="data"
      :loading="loading"
      drag-sort="row-handler"
      lazy-load
      @drag-sort="onDragSort"
    >
    </t-table>
  </t-drawer>
  <t-button @click="drawerVisible = !drawerVisible">打开Drawer</t-button>
</template>

<script lang="jsx" setup>
import { CheckCircleFilledIcon, CloseCircleFilledIcon, ErrorCircleFilledIcon, MoveIcon } from 'tdesign-icons-vue-next';
import { ref } from 'vue';

const drawerVisible = ref(false);

const statusNameListMap = {
  0: { label: '审批通过', theme: 'success', icon: <CheckCircleFilledIcon /> },
  1: { label: '审批失败', theme: 'danger', icon: <CloseCircleFilledIcon /> },
  2: { label: '审批过期', theme: 'warning', icon: <ErrorCircleFilledIcon /> },
};

const initialData = [];
for (let i = 0; i < 5; i++) {
  initialData.push({
    index: i + 1,
    applicant: ['贾明', '张三', '王芳'][i % 3],
    status: i % 3,
    channel: ['电子签署', '纸质签署', '纸质签署'][i % 3],
    detail: {
      email: ['[email protected]', '[email protected]', '[email protected]'][i % 3],
    },
    matters: ['宣传物料制作费用', 'algolia 服务报销', '相关周边制作费', '激励奖品快递费'][i % 4],
    time: [2, 3, 1, 4][i % 4],
    createTime: ['2022-01-01', '2022-02-01', '2022-03-01', '2022-04-01', '2022-05-01'][i % 4],
  });
}

const columns = [
  {
    colKey: 'drag', // 列拖拽排序必要参数
    title: '排序',
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    cell: () => (
      <span>
        <MoveIcon />
      </span>
    ),
    width: 46,
  },
  { colKey: 'applicant', title: '申请人', width: '100' },
  {
    colKey: 'status',
    title: '申请状态',
    width: '150',
    cell: (h, { row }) => {
      return (
        <t-tag shape="round" theme={statusNameListMap[row.status].theme} variant="light-outline">
          {statusNameListMap[row.status].icon}
          {statusNameListMap[row.status].label}
        </t-tag>
      );
    },
  },
  { colKey: 'channel', title: '签署方式', width: '120' },
  { colKey: 'detail.email', title: '邮箱地址', ellipsis: true },
  { colKey: 'createTime', title: '申请时间' },
];

const loading = ref(false);
const data = ref([...initialData]);

// { currentIndex, targetIndex, current, target, data, newData, e }
const onDragSort = (params) => {
  console.log('交换行', params);
  data.value = params.newData;
};
</script>

期望结果

期望控制台无报错

实际结果

控制台输出错误内容: tbody does not exist.

框架版本

3.3.13

浏览器版本

131.0.2903.70 (正式版本) (arm64)

系统版本

MacOS 15.0.1

Node版本

v20.16.0

补充说明

如 重现步骤中的代码所示,在t-drawer 组件中的 t-table 组件中使用了 drag-sort="row-handler" 属性后,控制台就会报错

Copy link
Contributor

github-actions bot commented Feb 5, 2025

👋 @Zccf,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@Zccf Zccf changed the title [组件名称] 描述问题的标题 [t-drawer] 在t-drawer组件中使用t-table的drag-sort="row-handler"报错 Feb 5, 2025
@uyarn uyarn added this to TDesign Feb 18, 2025
@Wesley-0808 Wesley-0808 changed the title [t-drawer] 在t-drawer组件中使用t-table的drag-sort="row-handler"报错 [Table] 与Drawer联用时drag-sort="row-handler"控制台报错 Mar 2, 2025
@Wesley-0808 Wesley-0808 added 🐞 bug Something isn't working warning and removed 🐞 bug Something isn't working labels Mar 2, 2025
@uyarn uyarn added the to be published to be published label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants