mirror of
https://gitee.com/elegant_wings/dbd-meeting-html.git
synced 2025-06-21 10:19:36 +08:00
20250521修复 筛选过后,点击详情页面查看并返回后,筛选条件都没了,还需要重新筛选,用户使用起来比较麻烦每次都需要重新进行筛选.
解决方案: 采用本地存储、在列表页增加两个按钮供用户自行选择是否保存筛选条件、详情页新增返回列表按钮,便于用户操作
This commit is contained in:
parent
acf66a4c37
commit
2ab5283eeb
@ -84,6 +84,8 @@
|
|||||||
<span class='table-page-search-submitButtons'>
|
<span class='table-page-search-submitButtons'>
|
||||||
<a-button type='primary' @click='$refs.table.refresh(true)'>查询</a-button>
|
<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' @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='exportRepair()'>导出工单模版</a-button>
|
||||||
<a-button style='margin-left: 8px' type='primary' @click='importDataVisible()'>导入</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>
|
<a-button style='margin-left: 8px' type='primary' @click='exportRepairList()'>导出工单数据</a-button>
|
||||||
@ -382,6 +384,12 @@ export default {
|
|||||||
this.isShowModel = true
|
this.isShowModel = true
|
||||||
}
|
}
|
||||||
this.selectType()
|
this.selectType()
|
||||||
|
// 恢复之前保存的筛选条件
|
||||||
|
this.restoreFilterConditions()
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
// 从详情页返回时恢复筛选条件
|
||||||
|
this.restoreFilterConditions()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fatherMethod(val) {
|
fatherMethod(val) {
|
||||||
@ -395,25 +403,8 @@ export default {
|
|||||||
this.selectedRows = selectedRows
|
this.selectedRows = selectedRows
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.queryParam = {
|
// 直接调用清除筛选条件的方法
|
||||||
'type': 'all',
|
this.clearUserFilterConditions()
|
||||||
'explain': '',
|
|
||||||
'sn': '',
|
|
||||||
'typeId': '',
|
|
||||||
'deviceId': '',
|
|
||||||
'status': '',
|
|
||||||
'repairLevel': '',
|
|
||||||
'beginTime': '',
|
|
||||||
'endTime': '',
|
|
||||||
'evalService': '',
|
|
||||||
'timeout': '',
|
|
||||||
'remark': '',
|
|
||||||
'name': ''
|
|
||||||
}
|
|
||||||
this.handleOk(true)
|
|
||||||
// this.queryParam = {}
|
|
||||||
// this.queryParam.typeId = ''
|
|
||||||
// this.selectRepairList()
|
|
||||||
},
|
},
|
||||||
customRequest(file) {
|
customRequest(file) {
|
||||||
// file 是上传的文件 其内容会在放在下面截图中
|
// file 是上传的文件 其内容会在放在下面截图中
|
||||||
@ -580,6 +571,13 @@ export default {
|
|||||||
this.$refs.modal.add()
|
this.$refs.modal.add()
|
||||||
},
|
},
|
||||||
handleView(repairId) {
|
handleView(repairId) {
|
||||||
|
// 不再自动保存筛选条件,而是依赖用户主动点击保存按钮
|
||||||
|
// try {
|
||||||
|
// this.saveFilterConditions()
|
||||||
|
// } catch (e) {
|
||||||
|
// console.error('保存筛选条件失败', e)
|
||||||
|
// }
|
||||||
|
// 跳转到详情页
|
||||||
this.$router.push({ name: 'repairView', query: { repairId: repairId } })
|
this.$router.push({ name: 'repairView', query: { repairId: repairId } })
|
||||||
},
|
},
|
||||||
handleEdit(record) {
|
handleEdit(record) {
|
||||||
@ -613,6 +611,144 @@ export default {
|
|||||||
onCancel() {
|
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: {}
|
watch: {}
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- 维修进度 -->
|
<!-- 维修进度 -->
|
||||||
<a-card :bordered='false' title='维修进度'>
|
<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-steps :current="nowStep" progressDot style='width: 80%;margin: 0px auto'>
|
||||||
<a-step>
|
<a-step>
|
||||||
<template v-slot:title>
|
<template v-slot:title>
|
||||||
@ -345,6 +348,20 @@ export default {
|
|||||||
rollback() {
|
rollback() {
|
||||||
this.$router.push('/repair/repairList')
|
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) {
|
openFile(e) {
|
||||||
window.open(e.target.currentSrc)
|
window.open(e.target.currentSrc)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user