fix: 修复Table插槽传参错误
This commit is contained in:
parent
dce76f042d
commit
97344e68f5
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -85,7 +85,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||
table: {
|
||||
slots: {
|
||||
default: (data: any) => {
|
||||
return <>{data[0].row.departmentName}</>
|
||||
return <>{data.row.departmentName}</>
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -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'}>
|
||||
|
@ -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>
|
||||
</>
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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}</>
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
</>
|
||||
)
|
||||
|
@ -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')}>
|
||||
|
|
|
@ -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>
|
||||
</>
|
||||
)
|
||||
|
@ -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')}>
|
||||
|
|
|
@ -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')}>
|
||||
|
|
|
@ -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'
|
||||
|
@ -87,7 +87,7 @@ const getTableList = async (params?: Params) => {
|
|||
|
||||
getTableList()
|
||||
|
||||
const actionFn = (data: TableSlotDefault) => {
|
||||
const actionFn = (data: any) => {
|
||||
console.log(data)
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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'
|
||||
|
@ -86,7 +86,7 @@ const columns = reactive<TableColumn[]>([
|
|||
}
|
||||
])
|
||||
|
||||
const actionFn = (data: TableSlotDefault) => {
|
||||
const actionFn = (data) => {
|
||||
console.log(data)
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
</>
|
||||
|
|
|
@ -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>
|
||||
</>
|
||||
|
|
Loading…
Reference in New Issue