20250521修复 筛选过后,点击详情页面查看并返回后,筛选条件都没了,还需要重新筛选,用户使用起来比较麻烦每次都需要重新进行筛选.

解决方案:
采用本地存储、在列表页增加两个按钮供用户自行选择是否保存筛选条件、详情页新增返回列表按钮,便于用户操作
This commit is contained in:
luoyu 2025-05-21 21:06:19 +08:00
parent acf66a4c37
commit 2ab5283eeb
2 changed files with 172 additions and 19 deletions

View File

@ -84,6 +84,8 @@
<span class='table-page-search-submitButtons'>
<a-button type='primary' @click='$refs.table.refresh(true)'>查询</a-button>
<a-button style='margin-left: 8px' @click='reset()'>重置</a-button>
<a-button style='margin-left: 8px' type='primary' @click='saveUserFilterConditions'>保存筛选条件</a-button>
<a-button style='margin-left: 8px' type='danger' @click='clearUserFilterConditions'>清除筛选条件</a-button>
<a-button style='margin-left: 8px' type='primary' @click='exportRepair()'>导出工单模版</a-button>
<a-button style='margin-left: 8px' type='primary' @click='importDataVisible()'>导入</a-button>
<a-button style='margin-left: 8px' type='primary' @click='exportRepairList()'>导出工单数据</a-button>
@ -382,6 +384,12 @@ export default {
this.isShowModel = true
}
this.selectType()
//
this.restoreFilterConditions()
},
activated() {
//
this.restoreFilterConditions()
},
methods: {
fatherMethod(val) {
@ -395,25 +403,8 @@ export default {
this.selectedRows = selectedRows
},
reset() {
this.queryParam = {
'type': 'all',
'explain': '',
'sn': '',
'typeId': '',
'deviceId': '',
'status': '',
'repairLevel': '',
'beginTime': '',
'endTime': '',
'evalService': '',
'timeout': '',
'remark': '',
'name': ''
}
this.handleOk(true)
// this.queryParam = {}
// this.queryParam.typeId = ''
// this.selectRepairList()
//
this.clearUserFilterConditions()
},
customRequest(file) {
// file
@ -580,6 +571,13 @@ export default {
this.$refs.modal.add()
},
handleView(repairId) {
//
// try {
// this.saveFilterConditions()
// } catch (e) {
// console.error('', e)
// }
//
this.$router.push({ name: 'repairView', query: { repairId: repairId } })
},
handleEdit(record) {
@ -613,6 +611,144 @@ export default {
onCancel() {
}
})
},
// localStorage
saveFilterConditions() {
//
let formattedDateRange = null;
if (this.dateRange && this.dateRange.length === 2) {
formattedDateRange = [
this.dateRange[0].format('YYYY-MM-DD'),
this.dateRange[1].format('YYYY-MM-DD')
];
}
const filterConditions = {
queryParam: JSON.parse(JSON.stringify(this.queryParam)), //
dateRange: formattedDateRange,
typeId: this.queryParam.typeId || '',
deviceId: this.queryParam.deviceId || ''
}
// localStorage
localStorage.setItem('repairListFilterConditions', JSON.stringify(filterConditions))
},
// localStorage
restoreFilterConditions() {
const savedConditions = localStorage.getItem('repairListFilterConditions')
if (savedConditions) {
try {
const conditions = JSON.parse(savedConditions)
//
if (conditions.queryParam) {
this.queryParam = conditions.queryParam
}
//
if (conditions.dateRange && conditions.dateRange.length === 2) {
this.dateRange = [
this.$moment(conditions.dateRange[0]),
this.$moment(conditions.dateRange[1])
]
this.queryParam.startTime = conditions.dateRange[0]
this.queryParam.endTime = conditions.dateRange[1]
}
//
if (conditions.typeId) {
//
this.selectDevice(conditions.typeId)
//
if (conditions.deviceId) {
this.$nextTick(() => {
this.queryParam.deviceId = conditions.deviceId
})
}
}
//
this.$nextTick(() => {
if (this.$refs.table) {
this.$refs.table.refresh(true)
// 使
this.$message.info('已应用保存的筛选条件')
}
})
} catch (e) {
console.error('恢复筛选条件失败:', e)
}
}
},
saveUserFilterConditions() {
//
try {
//
const hasFilter = Object.keys(this.queryParam).some(key => {
// type'all'
if (key === 'type' && this.queryParam[key] === 'all') {
return false
}
//
return this.queryParam[key] !== '' && this.queryParam[key] !== null && this.queryParam[key] !== undefined
})
//
const hasDateRange = this.dateRange && this.dateRange.length === 2
if (!hasFilter && !hasDateRange) {
this.$message.info('当前没有设置筛选条件,无需保存')
return
}
//
this.saveFilterConditions()
this.$message.success('筛选条件已保存,下次访问将自动应用')
} catch (e) {
console.error('保存筛选条件失败', e)
this.$message.error('保存筛选条件失败')
}
},
clearUserFilterConditions() {
//
try {
// localStorage
localStorage.removeItem('repairListFilterConditions')
//
this.queryParam = {
'type': 'all',
'explain': '',
'sn': '',
'typeId': '',
'deviceId': '',
'status': '',
'repairLevel': '',
'beginTime': '',
'endTime': '',
'evalService': '',
'timeout': '',
'remark': '',
'name': ''
}
//
this.dateRange = []
//
this.$nextTick(() => {
if (this.$refs.table) {
this.$refs.table.refresh(true)
}
})
this.$message.success('筛选条件已清除,列表已重置')
} catch (e) {
console.error('清除筛选条件失败', e)
this.$message.error('清除筛选条件失败')
}
}
},
watch: {}

View File

@ -2,6 +2,9 @@
<div>
<!-- 维修进度 -->
<a-card :bordered='false' title='维修进度'>
<template slot="extra">
<a-button type="primary" @click="goBack">返回列表</a-button>
</template>
<a-steps :current="nowStep" progressDot style='width: 80%;margin: 0px auto'>
<a-step>
<template v-slot:title>
@ -345,6 +348,20 @@ export default {
rollback() {
this.$router.push('/repair/repairList')
},
goBack() {
// URL便
console.log("当前URL:", window.location.href)
// 使
this.$router.go(-1)
// 3
setTimeout(() => {
if (window.location.href.includes('repairView')) {
window.location.href = '/#/admin/repair'
}
}, 3000)
},
openFile(e) {
window.open(e.target.currentSrc)
}