🐛(table): 修复 treetable 的 slots 的参数 data 不正确问题

This commit is contained in:
就眠儀式 2022-07-05 16:24:36 +08:00
parent 6fc3dc44f8
commit dc56a071b7
3 changed files with 9 additions and 8 deletions

View File

@ -258,7 +258,7 @@ const childrenIndentSize = props.currentIndentSize + props.indentSize;
<!-- 嵌套表单 --> <!-- 嵌套表单 -->
<tr class="layui-table-cell-expand" v-if="slot.expand && isExpand"> <tr class="layui-table-cell-expand" v-if="slot.expand && isExpand">
<slot name="expand"></slot> <slot name="expand" :data="data"></slot>
</tr> </tr>
<!-- 树形结构 --> <!-- 树形结构 -->
@ -286,10 +286,10 @@ const childrenIndentSize = props.currentIndentSize + props.indentSize;
@contextmenu="contextmenu" @contextmenu="contextmenu"
v-model:selectedKeys="tableSelectedKeys" v-model:selectedKeys="tableSelectedKeys"
> >
<template v-for="name in slotsData" #[name]> <template v-for="name in slotsData" #[name]="{ data }">
<slot :name="name" :data="data"></slot> <slot :name="name" :data="data"></slot>
</template> </template>
<template v-if="slot.expand" #expand> <template v-if="slot.expand" #expand="{ data }">
<slot name="expand" :data="data"></slot> <slot name="expand" :data="data"></slot>
</template> </template>
</table-row> </table-row>

View File

@ -400,7 +400,7 @@ props.dataSource.map((value: any) => {
</colgroup> </colgroup>
<tbody> <tbody>
<!-- 渲染 --> <!-- 渲染 -->
<template v-for="(data, index) in tableDataSource" :key="data"> <template v-for="(data, index) in tableDataSource" :key="index">
<table-row <table-row
:id="id" :id="id"
:index="index" :index="index"
@ -420,10 +420,10 @@ props.dataSource.map((value: any) => {
@contextmenu="contextmenu" @contextmenu="contextmenu"
v-model:selectedKeys="tableSelectedKeys" v-model:selectedKeys="tableSelectedKeys"
> >
<template v-for="name in slotsData" #[name]> <template v-for="name in slotsData" #[name]="{ data }">
<slot :name="name" :data="data"></slot> <slot :name="name" :data="data"></slot>
</template> </template>
<template v-if="slot.expand" #expand> <template v-if="slot.expand" #expand="{ data }">
<slot name="expand" :data="data"></slot> <slot name="expand" :data="data"></slot>
</template> </template>
</table-row> </table-row>

View File

@ -381,6 +381,7 @@ export default {
<template> <template>
<lay-table :columns="columns7" :dataSource="dataSource7"> <lay-table :columns="columns7" :dataSource="dataSource7">
<template #score="{ data }">{{ data }}</template>
</lay-table> </lay-table>
</template> </template>
@ -403,8 +404,8 @@ export default {
] ]
const dataSource7 = [ const dataSource7 = [
{name:"系统管理", score:100, children: [{name:"用户管理", score:100, children: [{name:"用户修改", score:100},{name:"用户删除", score:100}]},{name:"角色管理", score:100}]}, {name:"系统管理", score:100, children: [{name:"用户管理", score:99, children: [{name:"用户修改", score:98},{name:"用户删除", score:97}]},{name:"角色管理", score:96}]},
{name:"电商管理", score:100, children: [{name:"商品管理", score:100},{name:"分类管理", score:100}]}, {name:"电商管理", score:100, children: [{name:"商品管理", score:11},{name:"分类管理", score:22}]},
] ]
return { return {