添加导出
This commit is contained in:
@@ -35,14 +35,6 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="过滤" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
v-model="row.filterable"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
@@ -51,6 +43,15 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 导出 -->
|
||||
<el-table-column label="导出" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
:model-value="row.isExport === 'Y'"
|
||||
@change="(val) => { row.isExport = val ? 'Y' : 'N'; handleConfigChange() }"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</ElDrawer>
|
||||
@@ -66,10 +67,10 @@ interface ColumnConfig {
|
||||
label: string
|
||||
hide: boolean
|
||||
fixed: string | boolean
|
||||
filterable: boolean
|
||||
sortable: string | boolean
|
||||
showColumn: boolean
|
||||
sortNum?: number
|
||||
isExport?: string // 'Y' 表示导出,'N' 表示不导出
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -101,10 +102,11 @@ const initColumnConfig = () => {
|
||||
label: column.label || key,
|
||||
hide: column.hide || false,
|
||||
fixed: column.fixed || false,
|
||||
filterable: column.filterable || false,
|
||||
sortable: column.sortable || false,
|
||||
showColumn: column.showColumn !== false,
|
||||
sortNum: column.sortNum
|
||||
sortNum: column.sortNum,
|
||||
// 默认全部勾选导出,如果已有配置则使用配置值
|
||||
isExport: column.isExport !== undefined ? column.isExport : 'Y'
|
||||
}
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@@ -129,8 +131,8 @@ const saveConfig = debounce(() => {
|
||||
config[item.prop] = {
|
||||
hide: item.hide,
|
||||
fixed: item.fixed,
|
||||
filterable: item.filterable,
|
||||
sortable: item.sortable
|
||||
sortable: item.sortable,
|
||||
isExport: item.isExport || 'Y' // 默认导出
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1499,12 +1499,12 @@ const handleColumnConfigConfirm = async (config: Record<string, ColumnConfig>) =
|
||||
if (colConfig.fixed !== undefined) {
|
||||
tableOption.value.column[prop].fixed = colConfig.fixed
|
||||
}
|
||||
if (colConfig.filterable !== undefined) {
|
||||
tableOption.value.column[prop].filterable = colConfig.filterable
|
||||
}
|
||||
if (colConfig.sortable !== undefined) {
|
||||
tableOption.value.column[prop].sortable = colConfig.sortable
|
||||
}
|
||||
if (colConfig.isExport !== undefined) {
|
||||
tableOption.value.column[prop].isExport = colConfig.isExport
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1520,18 +1520,22 @@ const handleColumnConfigConfirm = async (config: Record<string, ColumnConfig>) =
|
||||
if (colConfig.fixed !== undefined) {
|
||||
column.fixed = colConfig.fixed
|
||||
}
|
||||
if (colConfig.filterable !== undefined) {
|
||||
column.filterable = colConfig.filterable
|
||||
}
|
||||
if (colConfig.sortable !== undefined) {
|
||||
column.sortable = colConfig.sortable
|
||||
}
|
||||
if (colConfig.isExport !== undefined) {
|
||||
column.isExport = colConfig.isExport
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 强制更新表格布局和配置
|
||||
await nextTick()
|
||||
if (crudRef.value && crudRef.value.$refs && crudRef.value.$refs.table) {
|
||||
// 强制更新表格布局
|
||||
if (crudRef.value.$refs && crudRef.value.$refs.table) {
|
||||
crudRef.value.$refs.table.doLayout()
|
||||
// 强制 Vue 重新渲染列配置
|
||||
await nextTick()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1541,7 +1545,8 @@ const handleColumnConfigConfirm = async (config: Record<string, ColumnConfig>) =
|
||||
Object.keys(config).forEach(prop => {
|
||||
saveConfig[prop] = {
|
||||
...config[prop],
|
||||
isShowColumn: config[prop].hide ? 'N' : 'Y' // hide=true checkbox选中→'N',hide=false checkbox不选中→'Y'
|
||||
isShowColumn: config[prop].hide ? 'N' : 'Y', // hide=true checkbox选中→'N',hide=false checkbox不选中→'Y'
|
||||
isExport: config[prop].isExport || 'Y' // 默认导出
|
||||
}
|
||||
})
|
||||
await saveColumnConfig(pageId, saveConfig)
|
||||
@@ -1599,12 +1604,12 @@ const loadColumnConfigToCrudRef = async () => {
|
||||
if (colConfig.fixed !== undefined) {
|
||||
tableOption.value.column[prop].fixed = colConfig.fixed
|
||||
}
|
||||
if (colConfig.filterable !== undefined) {
|
||||
tableOption.value.column[prop].filterable = colConfig.filterable
|
||||
}
|
||||
if (colConfig.sortable !== undefined) {
|
||||
tableOption.value.column[prop].sortable = colConfig.sortable
|
||||
}
|
||||
if (colConfig.isExport !== undefined) {
|
||||
tableOption.value.column[prop].isExport = colConfig.isExport
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1630,12 +1635,12 @@ const loadColumnConfigToCrudRef = async () => {
|
||||
if (colConfig.fixed !== undefined) {
|
||||
column.fixed = colConfig.fixed
|
||||
}
|
||||
if (colConfig.filterable !== undefined) {
|
||||
column.filterable = colConfig.filterable
|
||||
}
|
||||
if (colConfig.sortable !== undefined) {
|
||||
column.sortable = colConfig.sortable
|
||||
}
|
||||
if (colConfig.isExport !== undefined) {
|
||||
column.isExport = colConfig.isExport
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -113,15 +113,15 @@ const initDB = (): Promise<IDBDatabase> => {
|
||||
export interface ColumnConfig {
|
||||
hide?: boolean
|
||||
fixed?: string | boolean
|
||||
filterable?: boolean
|
||||
sortable?: string | boolean
|
||||
isShowColumn?: string // 'Y' 表示显示,'N' 表示隐藏
|
||||
isExport?: string // 'Y' 表示导出,'N' 表示不导出
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存列配置
|
||||
* @param key 唯一标识(通常是 route.params.id)
|
||||
* @param config 列配置对象,格式:{ prop: { hide, fixed, filterable, sortable } }
|
||||
* @param config 列配置对象,格式:{ prop: { hide, fixed, sortable, isExport } }
|
||||
*/
|
||||
export const saveColumnConfig = async (key: string, config: Record<string, ColumnConfig>): Promise<void> => {
|
||||
try {
|
||||
@@ -142,7 +142,7 @@ export const saveColumnConfig = async (key: string, config: Record<string, Colum
|
||||
/**
|
||||
* 读取列配置
|
||||
* @param key 唯一标识(通常是 route.params.id)
|
||||
* @returns 列配置对象,格式:{ prop: { hide, fixed, filterable, sortable } }
|
||||
* @returns 列配置对象,格式:{ prop: { hide, fixed, sortable, isExport } }
|
||||
*/
|
||||
export const getColumnConfig = async (key: string): Promise<Record<string, ColumnConfig> | null> => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user