|
|
@ -49,7 +49,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
import { createVNode, ref } from 'vue'; |
|
|
|
import { createVNode, ref, computed } from 'vue'; |
|
|
|
import { message, Modal } from 'ant-design-vue'; |
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; |
|
|
|
import type { EleProTable } from 'ele-admin-pro'; |
|
|
@ -97,54 +97,26 @@ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 表格列配置 - 使用 hideInTable 控制默认显示 |
|
|
|
const columns = ref<ColumnItem[]>([ |
|
|
|
<% var coreFieldCount = 0; %> |
|
|
|
// 完整的列配置(包含所有字段) |
|
|
|
const allColumns = ref<ColumnItem[]>([ |
|
|
|
<% for(field in table.fields) { %> |
|
|
|
<% if(field.propertyName != 'tenantId'){ %> |
|
|
|
<% |
|
|
|
// 判断是否为核心字段(默认显示) |
|
|
|
var isCoreField = field.keyFlag || |
|
|
|
field.propertyName == 'name' || |
|
|
|
field.propertyName == 'title' || |
|
|
|
field.propertyName == 'code' || |
|
|
|
field.propertyName == 'status' || |
|
|
|
field.propertyName == 'sort' || |
|
|
|
field.propertyName == 'createTime'; |
|
|
|
|
|
|
|
// 限制核心字段数量,避免显示过多列 |
|
|
|
if(isCoreField && coreFieldCount >= 5) { |
|
|
|
isCoreField = false; |
|
|
|
} |
|
|
|
if(isCoreField) { |
|
|
|
coreFieldCount = coreFieldCount + 1; |
|
|
|
} |
|
|
|
%> |
|
|
|
{ |
|
|
|
title: '${field.comment!field.propertyName}', |
|
|
|
dataIndex: '${field.propertyName}', |
|
|
|
key: '${field.propertyName}', |
|
|
|
align: 'center', |
|
|
|
<% if(!isCoreField){ %> |
|
|
|
hideInTable: true, // 非核心字段默认隐藏,用户可通过列设置显示 |
|
|
|
<% } %> |
|
|
|
<% if(field.keyFlag){ %> |
|
|
|
width: 90, |
|
|
|
<% } else if(field.propertyName == 'createTime' || field.propertyName == 'updateTime'){ %> |
|
|
|
width: 120, |
|
|
|
width: 200, |
|
|
|
align: 'center', |
|
|
|
sorter: true, |
|
|
|
ellipsis: true, |
|
|
|
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd') |
|
|
|
<% } else if(field.propertyType == 'String' && (field.propertyName.contains('remark') || field.propertyName.contains('description') || field.propertyName.contains('content'))){ %> |
|
|
|
width: 200, |
|
|
|
ellipsis: true |
|
|
|
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss') |
|
|
|
<% } else if(field.propertyType == 'String'){ %> |
|
|
|
width: 150, |
|
|
|
ellipsis: true |
|
|
|
<% } else if(field.propertyName == 'status'){ %> |
|
|
|
width: 80 |
|
|
|
<% } else if(field.propertyName == 'sort'){ %> |
|
|
|
width: 80 |
|
|
|
width: 120 |
|
|
|
<% } else { %> |
|
|
|
width: 120 |
|
|
|
<% } %> |
|
|
@ -161,6 +133,26 @@ |
|
|
|
} |
|
|
|
]); |
|
|
|
|
|
|
|
// 默认显示的核心列(最多5个主要字段) |
|
|
|
const defaultVisibleColumns = [ |
|
|
|
<% var count = 0; %> |
|
|
|
<% for(field in table.fields) { %> |
|
|
|
<% if(field.keyFlag || field.propertyName == 'name' || field.propertyName == 'title' || field.propertyName == 'status' || field.propertyName == 'createTime'){ %> |
|
|
|
'${field.propertyName}', |
|
|
|
<% count = count + 1; %> |
|
|
|
<% if(count >= 5) break; %> |
|
|
|
<% } %> |
|
|
|
<% } %> |
|
|
|
'action' |
|
|
|
]; |
|
|
|
|
|
|
|
// 根据默认可见列过滤显示的列 |
|
|
|
const columns = computed(() => { |
|
|
|
return allColumns.value.filter(col => |
|
|
|
defaultVisibleColumns.includes(col.dataIndex) || col.key === 'action' |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
/* 搜索 */ |
|
|
|
const reload = (where?: ${entity}Param) => { |
|
|
|
selection.value = []; |
|
|
|