列设置添加缓存
调整监测点台账导出id重复问题
This commit is contained in:
@@ -1,8 +1,22 @@
|
|||||||
<script lang='ts'>
|
<script lang="ts">
|
||||||
import { defineComponent, createVNode, reactive } from 'vue'
|
import { defineComponent, createVNode, reactive } from 'vue'
|
||||||
import { Column } from 'vxe-table'
|
import { Column } from 'vxe-table'
|
||||||
import { uuid } from '@/utils/random'
|
import { uuid } from '@/utils/random'
|
||||||
|
|
||||||
|
/** storage 开启时列必须有稳定 field;序号/操作等无 field 列按 title 生成 */
|
||||||
|
function resolveColumnField(attr: Record<string, any>): string | undefined {
|
||||||
|
if (attr.field) return attr.field
|
||||||
|
if (attr.prop) return attr.prop
|
||||||
|
// checkbox / radio / expand / seq 等类型列由 vxe 内部处理,可不强制 field
|
||||||
|
if (attr.type && ['checkbox', 'radio', 'expand', 'html'].includes(attr.type)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
if (attr.title != null && attr.title !== '') {
|
||||||
|
return `__col_${attr.title}`
|
||||||
|
}
|
||||||
|
return `col_${uuid()}`
|
||||||
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Column',
|
name: 'Column',
|
||||||
props: {
|
props: {
|
||||||
@@ -12,9 +26,13 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const attr = reactive(props.attr)
|
const attr = reactive({ ...props.attr })
|
||||||
attr['align'] = attr['align'] ? attr['align'] : 'center'
|
attr['align'] = attr['align'] ? attr['align'] : 'center'
|
||||||
attr['column-key'] = attr['column-key'] ? attr['column-key'] : attr.prop || uuid()
|
const field = resolveColumnField(attr)
|
||||||
|
if (field) {
|
||||||
|
attr.field = field
|
||||||
|
}
|
||||||
|
attr['column-key'] = attr['column-key'] ? attr['column-key'] : attr.field || attr.prop || uuid()
|
||||||
return () => {
|
return () => {
|
||||||
return createVNode(Column, attr, slots.default)
|
return createVNode(Column, attr, slots.default)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ export const defaultAttribute: VxeTableProps = {
|
|||||||
stripe: true,
|
stripe: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
columnConfig: { resizable: true, useKey: true },
|
columnConfig: { resizable: true, useKey: true },
|
||||||
rowConfig: { isCurrent: true, isHover: true, keyField: 'id' },
|
rowConfig: { isCurrent: true, isHover: true, },
|
||||||
scrollX: { scrollToLeftOnChange: true },
|
scrollX: { scrollToLeftOnChange: true },
|
||||||
scrollY: { enabled: false },
|
scrollY: { enabled: false },
|
||||||
// 注意:全局不要默认开启 treeConfig,会与 stripe 冲突;树表在页面自行配置
|
// 注意:全局不要默认开启 treeConfig,会与 stripe 冲突;树表在页面自行配置
|
||||||
customConfig: { enabled: true, allowFixed: false, showFooter: false, immediate: true, mode: 'default' },
|
customConfig: { enabled: true, allowFixed: true, storage: true, showFooter: false, immediate: true ,mode:'default'},
|
||||||
showOverflow: 'tooltip',
|
showOverflow: 'tooltip',
|
||||||
showHeaderOverflow: false
|
showHeaderOverflow: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :style="{ height: typeof props.height === 'string' ? props.height : tableStore.table.height }">
|
<div :style="{ height: typeof props.height === 'string' ? props.height : tableStore.table.height }">
|
||||||
<div v-if="showCustomColumn && !tableStore?.table?.customColumnInHeader" class="table-custom-toolbar">
|
<div v-if="showCustomColumn && !tableStore?.table?.customColumnInHeader" class="table-custom-toolbar">
|
||||||
<el-button icon="el-icon-Setting" @mousedown="onCustomColumnMousedown" @click="openCustomColumn">列设置</el-button>
|
<el-button icon="el-icon-Setting" @mousedown="onCustomColumnMousedown" @click="openCustomColumn">
|
||||||
|
列设置
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<vxe-table
|
<vxe-table
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
height="auto"
|
height="auto"
|
||||||
:key="key"
|
:key="key"
|
||||||
|
:id="getTableId()"
|
||||||
:data="tableStore.table.data"
|
:data="tableStore.table.data"
|
||||||
v-loading="tableStore.table.loading"
|
v-loading="tableStore.table.loading"
|
||||||
v-bind="tableBindProps"
|
v-bind="tableBindProps"
|
||||||
@checkbox-all="selectChangeEvent"
|
@checkbox-all="selectChangeEvent"
|
||||||
@checkbox-change="selectChangeEvent"
|
@checkbox-change="selectChangeEvent"
|
||||||
@cell-click="onCellClick"
|
@cell-click="onCellClick"
|
||||||
>
|
>
|
||||||
<!-- @sort-change="handleSortChange" -->
|
<!-- @sort-change="handleSortChange" -->
|
||||||
<!-- Column 组件内部是 el-table-column -->
|
<!-- Column 组件内部是 el-table-column -->
|
||||||
<template v-if="isGroup">
|
<template v-if="isGroup">
|
||||||
<GroupColumn :column="tableStore.table.column" />
|
<GroupColumn :column="tableStore.table.column" />
|
||||||
@@ -163,6 +166,9 @@ const openCustomColumn = () => {
|
|||||||
const getRef = () => {
|
const getRef = () => {
|
||||||
return tableRef.value
|
return tableRef.value
|
||||||
}
|
}
|
||||||
|
const getTableId = () => {
|
||||||
|
return tableStore.table.filename || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || ''
|
||||||
|
}
|
||||||
// 排序
|
// 排序
|
||||||
const handleSortChange = ({ column, order }: { column: TableColumn; order: 'asc' | 'desc' | null }) => {
|
const handleSortChange = ({ column, order }: { column: TableColumn; order: 'asc' | 'desc' | null }) => {
|
||||||
// console.log('排序列:', column?.property);
|
// console.log('排序列:', column?.property);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import { useConfig } from '@/stores/config'
|
|||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import { useNavTabs } from '@/stores/navTabs'
|
import { useNavTabs } from '@/stores/navTabs'
|
||||||
import { logout } from '@/api/user-boot/user'
|
import { logout } from '@/api/user-boot/user'
|
||||||
|
import { Local } from '@/utils/storage'
|
||||||
import Config from './config.vue'
|
import Config from './config.vue'
|
||||||
import PopupPwd from './popup/password.vue'
|
import PopupPwd from './popup/password.vue'
|
||||||
import AdminInfo from './popup/adminInfo.vue'
|
import AdminInfo from './popup/adminInfo.vue'
|
||||||
@@ -114,8 +115,8 @@ const handleLogout = async () => {
|
|||||||
|
|
||||||
// 清理本地数据
|
// 清理本地数据
|
||||||
const clearLocalData = () => {
|
const clearLocalData = () => {
|
||||||
// 清空 localStorage
|
// 清空 localStorage(保留 VXE 自定义列、DevTools 配置)
|
||||||
window.localStorage.clear()
|
Local.clear()
|
||||||
|
|
||||||
// 清空用户状态
|
// 清空用户状态
|
||||||
adminInfo.reset()
|
adminInfo.reset()
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { validatePwd } from '@/utils/common'
|
|||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useNavTabs } from '@/stores/navTabs'
|
import { useNavTabs } from '@/stores/navTabs'
|
||||||
|
import { Local } from '@/utils/storage'
|
||||||
const navTabs = useNavTabs()
|
const navTabs = useNavTabs()
|
||||||
const adminInfo = useAdminInfo()
|
const adminInfo = useAdminInfo()
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
@@ -103,7 +104,7 @@ const submit = () => {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
navTabs.closeTabs()
|
navTabs.closeTabs()
|
||||||
window.localStorage.clear()
|
Local.clear()
|
||||||
adminInfo.reset()
|
adminInfo.reset()
|
||||||
router.push({ name: 'login' })
|
router.push({ name: 'login' })
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|||||||
@@ -17,7 +17,21 @@ export const Local = {
|
|||||||
window.localStorage.removeItem(key)
|
window.localStorage.removeItem(key)
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
|
// 退出登录时保留表格自定义列、Vue DevTools 等配置
|
||||||
|
const preserveKeys = [
|
||||||
|
'VXE_CUSTOM_STORE',
|
||||||
|
'__VUE_DEVTOOLS_NEXT_PLUGIN_SETTINGS__dev.esm.pinia__',
|
||||||
|
]
|
||||||
|
const preserved: Record<string, string | null> = {}
|
||||||
|
preserveKeys.forEach(key => {
|
||||||
|
preserved[key] = window.localStorage.getItem(key)
|
||||||
|
})
|
||||||
window.localStorage.clear()
|
window.localStorage.clear()
|
||||||
|
preserveKeys.forEach(key => {
|
||||||
|
if (preserved[key] !== null) {
|
||||||
|
window.localStorage.setItem(key, preserved[key] as string)
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const tableStore = new TableStore({
|
|||||||
publicHeight: 65,
|
publicHeight: 65,
|
||||||
isWebPaging: true,
|
isWebPaging: true,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
filename: '监测点台账',
|
filename: '监测点台账 ',
|
||||||
column: [
|
column: [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -155,7 +155,7 @@ const tableStore = new TableStore({
|
|||||||
{ field: 'powerFlag', title: '用户性质', width: '120px' },
|
{ field: 'powerFlag', title: '用户性质', width: '120px' },
|
||||||
|
|
||||||
/* { field: 'comFlag', title: '通讯状态 ', minWidth: 120 },*/
|
/* { field: 'comFlag', title: '通讯状态 ', minWidth: 120 },*/
|
||||||
{ field: 'id', title: '监测点序号', minWidth: 90 },
|
{ field: 'runNo', title: '监测点序号', minWidth: 90 },
|
||||||
{
|
{
|
||||||
field: 'comFlag',
|
field: 'comFlag',
|
||||||
title: '通讯状态',
|
title: '通讯状态',
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
maxlength="32"
|
maxlength="32"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
clearable
|
clearable
|
||||||
style="minWidth: 280px;"
|
style="min-Width: 280px;"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user