Skip to content

Commit

Permalink
fix: 修复Table插槽传参错误
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Aug 11, 2023
1 parent dce76f0 commit 97344e6
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/components/Table/src/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default defineComponent({
return children && children.length
? renderTreeTableColumn(children)
: props?.slots?.default
? props.slots.default(args)
? props.slots.default(...args)
: v?.formatter
? v?.formatter?.(data.row, data.column, get(data.row, v.field), data.$index)
: isImageUrl
Expand Down Expand Up @@ -459,7 +459,7 @@ export default defineComponent({
return children && children.length
? renderTreeTableColumn(children)
: props?.slots?.default
? props.slots.default(args)
? props.slots.default(...args)
: v?.formatter
? v?.formatter?.(data.row, data.column, get(data.row, v.field), data.$index)
: isImageUrl
Expand Down
10 changes: 5 additions & 5 deletions src/views/Authorization/Department/Department.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const crudSchemas = reactive<CrudSchema[]>([
table: {
slots: {
default: (data: any) => {
return <>{data[0].row.departmentName}</>
return <>{data.row.departmentName}</>
}
}
},
Expand Down Expand Up @@ -119,7 +119,7 @@ const crudSchemas = reactive<CrudSchema[]>([
table: {
slots: {
default: (data: any) => {
const status = data[0].row.status
const status = data.row.status
return (
<>
<ElTag type={status === 0 ? 'danger' : 'success'}>
Expand Down Expand Up @@ -215,13 +215,13 @@ const crudSchemas = reactive<CrudSchema[]>([
default: (data: any) => {
return (
<>
<ElButton type="primary" onClick={() => action(data[0].row, 'edit')}>
<ElButton type="primary" onClick={() => action(data.row, 'edit')}>
{t('exampleDemo.edit')}
</ElButton>
<ElButton type="success" onClick={() => action(data[0].row, 'detail')}>
<ElButton type="success" onClick={() => action(data.row, 'detail')}>
{t('exampleDemo.detail')}
</ElButton>
<ElButton type="danger" onClick={() => delData(data[0].row)}>
<ElButton type="danger" onClick={() => delData(data.row)}>
{t('exampleDemo.del')}
</ElButton>
</>
Expand Down
12 changes: 6 additions & 6 deletions src/views/Authorization/Menu/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const tableColumns = reactive<TableColumn[]>([
label: t('menu.icon'),
slots: {
default: (data: any) => {
const icon = data[0].row.meta.icon
const icon = data.row.meta.icon
if (icon) {
return (
<>
Expand All @@ -59,7 +59,7 @@ const tableColumns = reactive<TableColumn[]>([
label: t('menu.permission'),
slots: {
default: (data: any) => {
const permission = data[0].row.meta.permission
const permission = data.row.meta.permission
return permission ? <>{permission.join(', ')}</> : null
}
}
Expand All @@ -69,7 +69,7 @@ const tableColumns = reactive<TableColumn[]>([
label: t('menu.component'),
slots: {
default: (data: any) => {
const component = data[0].row.component
const component = data.row.component
return <>{component === '#' ? '顶级目录' : component === '##' ? '子目录' : component}</>
}
}
Expand All @@ -85,8 +85,8 @@ const tableColumns = reactive<TableColumn[]>([
default: (data: any) => {
return (
<>
<ElTag type={data[0].row.status === 0 ? 'danger' : 'success'}>
{data[0].row.status === 1 ? t('userDemo.enable') : t('userDemo.disable')}
<ElTag type={data.row.status === 0 ? 'danger' : 'success'}>
{data.row.status === 1 ? t('userDemo.enable') : t('userDemo.disable')}
</ElTag>
</>
)
Expand All @@ -99,7 +99,7 @@ const tableColumns = reactive<TableColumn[]>([
width: 240,
slots: {
default: (data: any) => {
const row = data[0].row
const row = data.row
return (
<>
<ElButton type="primary" onClick={() => action(row, 'edit')}>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Authorization/Role/Role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const tableColumns = reactive<TableColumn[]>([
default: (data: any) => {
return (
<>
<ElTag type={data[0].row.status === 0 ? 'danger' : 'success'}>
{data[0].row.status === 1 ? t('userDemo.enable') : t('userDemo.disable')}
<ElTag type={data.row.status === 0 ? 'danger' : 'success'}>
{data.row.status === 1 ? t('userDemo.enable') : t('userDemo.disable')}
</ElTag>
</>
)
Expand All @@ -69,7 +69,7 @@ const tableColumns = reactive<TableColumn[]>([
width: 240,
slots: {
default: (data: any) => {
const row = data[0].row
const row = data.row
return (
<>
<ElButton type="primary" onClick={() => action(row, 'edit')}>
Expand Down
2 changes: 1 addition & 1 deletion src/views/Authorization/User/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const crudSchemas = reactive<CrudSchema[]>([
width: 240,
slots: {
default: (data: any) => {
const row = data[0].row as DepartmentUserItem
const row = data.row as DepartmentUserItem
return (
<>
<ElButton type="primary" onClick={() => action(row, 'edit')}>
Expand Down
4 changes: 2 additions & 2 deletions src/views/Components/Table/DefaultTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="tsx">
import { ContentWrap } from '@/components/ContentWrap'
import { useI18n } from '@/hooks/web/useI18n'
import { Table, TableColumn, TableSlotDefault } from '@/components/Table'
import { Table, TableColumn } from '@/components/Table'
import { getTableListApi } from '@/api/table'
import { TableData } from '@/api/table/types'
import { ref, h } from 'vue'
Expand Down Expand Up @@ -87,7 +87,7 @@ const getTableList = async (params?: Params) => {
getTableList()
const actionFn = (data: TableSlotDefault) => {
const actionFn = (data: any) => {
console.log(data)
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/views/Components/Table/TreeTable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="tsx">
import { ContentWrap } from '@/components/ContentWrap'
import { useI18n } from '@/hooks/web/useI18n'
import { Table, TableColumn, TableSlotDefault } from '@/components/Table'
import { Table, TableColumn } from '@/components/Table'
import { getTreeTableListApi } from '@/api/table'
import { reactive, unref } from 'vue'
import { ElTag, ElButton } from 'element-plus'
Expand Down Expand Up @@ -86,7 +86,7 @@ const columns = reactive<TableColumn[]>([
}
])
const actionFn = (data: TableSlotDefault) => {
const actionFn = (data) => {
console.log(data)
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/views/Components/Table/UseTableDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const columns = reactive<TableColumn[]>([
field: 'expand',
type: 'expand',
slots: {
default: (data: TableSlotDefault[]) => {
const { row } = data[0]
default: (data: TableSlotDefault) => {
const { row } = data
return (
<div class="ml-30px">
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Example/Dialog/ExampleDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ const crudSchemas = reactive<CrudSchema[]>([
default: (data: any) => {
return (
<>
<ElButton type="primary" onClick={() => action(data[0].row, 'edit')}>
<ElButton type="primary" onClick={() => action(data.row, 'edit')}>
{t('exampleDemo.edit')}
</ElButton>
<ElButton type="success" onClick={() => action(data[0].row, 'detail')}>
<ElButton type="success" onClick={() => action(data.row, 'detail')}>
{t('exampleDemo.detail')}
</ElButton>
<ElButton type="danger" onClick={() => delData(data[0].row)}>
<ElButton type="danger" onClick={() => delData(data.row)}>
{t('exampleDemo.del')}
</ElButton>
</>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Example/Page/ExamplePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ const crudSchemas = reactive<CrudSchema[]>([
default: (data: any) => {
return (
<>
<ElButton type="primary" onClick={() => action(data[0].row, 'edit')}>
<ElButton type="primary" onClick={() => action(data.row, 'edit')}>
{t('exampleDemo.edit')}
</ElButton>
<ElButton type="success" onClick={() => action(data[0].row, 'detail')}>
<ElButton type="success" onClick={() => action(data.row, 'detail')}>
{t('exampleDemo.detail')}
</ElButton>
<ElButton type="danger" onClick={() => delData(data[0].row)}>
<ElButton type="danger" onClick={() => delData(data.row)}>
{t('exampleDemo.del')}
</ElButton>
</>
Expand Down

0 comments on commit 97344e6

Please sign in to comment.