forked from liweijie/education
教学业务:教学场地里的教学场地类型下拉框 反向覆盖问题修复
This commit is contained in:
@@ -199,7 +199,8 @@ import {
|
|||||||
addClassroom,
|
addClassroom,
|
||||||
deleteClassroom,
|
deleteClassroom,
|
||||||
updateClassroom,
|
updateClassroom,
|
||||||
listClassroom
|
listClassroom,
|
||||||
|
listAllClassroom
|
||||||
} from '@/api/teachBusiness/classroom'
|
} from '@/api/teachBusiness/classroom'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -215,6 +216,7 @@ export default {
|
|||||||
ty: ''
|
ty: ''
|
||||||
},
|
},
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
jxcdlxOptions: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
@@ -230,20 +232,42 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
/** 教学场地类型下拉:由已加载数据中的去重值动态生成,避免硬编码 */
|
|
||||||
jxcdlxOptions() {
|
|
||||||
const set = new Set()
|
|
||||||
this.tableData.forEach(row => {
|
|
||||||
if (row.jxcdlx) set.add(row.jxcdlx)
|
|
||||||
})
|
|
||||||
return Array.from(set)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
|
this.loadVenueTypeOptions()
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* 独立加载全部场地类型,避免查询结果收窄后下拉候选项同步丢失。
|
||||||
|
*/
|
||||||
|
loadVenueTypeOptions() {
|
||||||
|
return listAllClassroom().then(response => {
|
||||||
|
this.jxcdlxOptions = this.collectVenueTypes(response.data || [])
|
||||||
|
}).catch(() => {
|
||||||
|
// 全量接口异常时保留已收集选项,避免影响列表的基本查询功能。
|
||||||
|
this.mergeVenueTypeOptions(this.tableData)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
collectVenueTypes(classrooms) {
|
||||||
|
const venueTypes = new Set()
|
||||||
|
classrooms.forEach(classroom => {
|
||||||
|
const venueType = classroom.jxcdlx && String(classroom.jxcdlx).trim()
|
||||||
|
if (venueType) {
|
||||||
|
venueTypes.add(venueType)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return Array.from(venueTypes).sort((first, second) => first.localeCompare(second, 'zh-CN'))
|
||||||
|
},
|
||||||
|
|
||||||
|
mergeVenueTypeOptions(classrooms) {
|
||||||
|
const venueTypes = new Set(this.jxcdlxOptions)
|
||||||
|
this.collectVenueTypes(classrooms).forEach(venueType => venueTypes.add(venueType))
|
||||||
|
this.jxcdlxOptions = Array.from(venueTypes)
|
||||||
|
.sort((first, second) => first.localeCompare(second, 'zh-CN'))
|
||||||
|
},
|
||||||
|
|
||||||
/* ---------- 列表加载 ---------- */
|
/* ---------- 列表加载 ---------- */
|
||||||
fetchList() {
|
fetchList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
@@ -260,6 +284,7 @@ export default {
|
|||||||
listClassroom(params).then(response => {
|
listClassroom(params).then(response => {
|
||||||
const data = response.data || {}
|
const data = response.data || {}
|
||||||
this.tableData = data.records || []
|
this.tableData = data.records || []
|
||||||
|
this.mergeVenueTypeOptions(this.tableData)
|
||||||
this.total = data.total || 0
|
this.total = data.total || 0
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
@@ -324,6 +349,7 @@ export default {
|
|||||||
req.then(() => {
|
req.then(() => {
|
||||||
this.$message.success(isEdit ? '修改成功' : '新增成功')
|
this.$message.success(isEdit ? '修改成功' : '新增成功')
|
||||||
this.dialog.visible = false
|
this.dialog.visible = false
|
||||||
|
this.loadVenueTypeOptions()
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
}).catch(() => {}).finally(() => {
|
}).catch(() => {}).finally(() => {
|
||||||
this.dialog.submitting = false
|
this.dialog.submitting = false
|
||||||
@@ -341,6 +367,7 @@ export default {
|
|||||||
return deleteClassroom(row.id)
|
return deleteClassroom(row.id)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$message.success('删除成功')
|
this.$message.success('删除成功')
|
||||||
|
this.loadVenueTypeOptions()
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user