fix sort column widen and ts non-null bug

This commit is contained in:
zou 2026-08-24 14:45:20 +08:00
parent 349f18082c
commit ca08523e0f

View File

@ -213,6 +213,7 @@ const columns = [
{ label: '层级', width: 80, align: 'center' as const },
{ prop: 'status', label: '状态', width: 100, slot: 'status', align: 'center' as const },
{ prop: 'createDate', label: '创建时间', width: 170, slot: 'createTime' },
{ label: '排序', width: 170, slot: 'sort', align: 'center' as const },
{ label: '操作', width: 280, slot: 'actions', fixed: 'right' as const, align: 'center' as const }
]
@ -252,14 +253,16 @@ onMounted(load)
<template #createTime="{ row }">
{{ fmtDate(row.createDate) }}
</template>
<template #sort="{ row }">
<el-button type="text" size="small" :disabled="siblingInfo(row)?.idx === 0" @click="moveRow(row, 'up')">↑ 上移</el-button>
<el-button type="text" size="small" :disabled="(siblingInfo(row)?.idx ?? -1) === (siblingInfo(row)?.total ?? 0) - 1" @click="moveRow(row, 'down')">↓ 下移</el-button>
</template>
<template #actions="{ row }">
<TableActions
:row="row"
:actions="[
{ label: '添加子级', type: 'primary', when: (r: any) => (r.level || 1) < 5, onClick: onAdd },
{ label: '修改', type: 'primary', onClick: onEdit },
{ label: '上移', type: 'info', when: () => { const i = siblingInfo(row); return i ? i.idx > 0 : false }, onClick: () => moveRow(row, 'up') },
{ label: '下移', type: 'info', when: () => { const i = siblingInfo(row); return i ? i.idx < i.total - 1 : false }, onClick: () => moveRow(row, 'down') },
{ label: row.status === 0 ? '禁用' : '启用', type: row.status === 0 ? 'warning' : 'success', onClick: () => toggleStatus(row) },
{ label: '删除', type: 'danger', divided: true, onClick: () => onDelete(row) }
]"