perf: 其他页面使用 Store 缓存基础数据
- EducationDialog.vue: 区域树、学科列表使用 Store - school/index.vue: 区域树使用 Store 所有基础数据调用统一使用 Store,命中缓存后秒加载
This commit is contained in:
parent
4243f6581d
commit
81b1d5327b
|
|
@ -64,6 +64,9 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
|
import useBaseDataStore from '@/store/modules/baseData'
|
||||||
|
|
||||||
|
const baseDataStore = useBaseDataStore()
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'add', 'update'])
|
const emit = defineEmits(['success', 'add', 'update'])
|
||||||
|
|
||||||
|
|
@ -165,24 +168,22 @@ const resetForm = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载区域树
|
* 加载区域树(使用 Store 缓存)
|
||||||
*/
|
*/
|
||||||
const loadRegionTree = async () => {
|
const loadRegionTree = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await request.get('/business/region/tree')
|
regionTree.value = await baseDataStore.fetchRegionTree()
|
||||||
regionTree.value = res.data || []
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
regionTree.value = []
|
regionTree.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载学科列表
|
* 加载学科列表(使用 Store 缓存)
|
||||||
*/
|
*/
|
||||||
const loadSubjectList = async () => {
|
const loadSubjectList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await request.get('/business/subject/listAll')
|
subjectList.value = await baseDataStore.fetchSubjects()
|
||||||
subjectList.value = res.data || []
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
subjectList.value = []
|
subjectList.value = []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,9 @@ import request from '@/utils/request'
|
||||||
import ClassDialog from './components/ClassDialog.vue'
|
import ClassDialog from './components/ClassDialog.vue'
|
||||||
import GradeDialog from './components/GradeDialog.vue'
|
import GradeDialog from './components/GradeDialog.vue'
|
||||||
import SchoolDialog from './components/SchoolDialog.vue'
|
import SchoolDialog from './components/SchoolDialog.vue'
|
||||||
|
import useBaseDataStore from '@/store/modules/baseData'
|
||||||
|
|
||||||
|
const baseDataStore = useBaseDataStore()
|
||||||
|
|
||||||
// 区域树相关
|
// 区域树相关
|
||||||
const treeRef = ref()
|
const treeRef = ref()
|
||||||
|
|
@ -166,12 +169,9 @@ const filterNode = (value, data) => {
|
||||||
return data.regionName.includes(value)
|
return data.regionName.includes(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取区域树
|
// 获取区域树(使用 Store 缓存)
|
||||||
const getRegionTree = async () => {
|
const getRegionTree = async () => {
|
||||||
const res = await request.get('/business/region/tree')
|
regionTree.value = await baseDataStore.fetchRegionTree()
|
||||||
if (res.code === 200) {
|
|
||||||
regionTree.value = res.data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取学校树形数据(包含年级和班级)
|
// 获取学校树形数据(包含年级和班级)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue