|
@@ -1,10 +1,12 @@
|
|
|
import {defineStore} from "pinia";
|
|
|
import {readonly} from "vue";
|
|
|
import {frontGetAllSysLabelsForQd} from "@/api/modules/web/list";
|
|
|
+import {useAppStore} from "@/stores/app";
|
|
|
|
|
|
export const useWebStore = defineStore('web', {
|
|
|
state: () => ({
|
|
|
- searchAreaTree: [],
|
|
|
+ searchAreaTree: <any>[],
|
|
|
+ searchAreaTreeRoleAuth: <any>[],
|
|
|
treeLevelSplit: '???'
|
|
|
}),
|
|
|
getters: {
|
|
@@ -36,7 +38,7 @@ export const useWebStore = defineStore('web', {
|
|
|
map.set(v.treeId, v)
|
|
|
// 索引额外添加键id
|
|
|
if (v.indexTableName) {
|
|
|
- map.set(v.id, v)
|
|
|
+ map.set(v.indexId, v)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -49,7 +51,7 @@ export const useWebStore = defineStore('web', {
|
|
|
getSearchAreaTree() {
|
|
|
return new Promise(resolve => {
|
|
|
frontGetAllSysLabelsForQd().then(res => {
|
|
|
- this.searchAreaTree = readonly(res.data.filter(tag => tag.sysLabels?.length > 0).map(tag => {
|
|
|
+ const getTree = (arr) => JSON.parse(JSON.stringify(arr)).filter(tag => tag.sysLabels?.length > 0).map(tag => {
|
|
|
tag.treeId = tag.id
|
|
|
tag.treeName = tag.labelName
|
|
|
tag.children = tag.sysLabels?.filter(type => type.sysIndexList?.length > 0).map(type => {
|
|
@@ -66,8 +68,17 @@ export const useWebStore = defineStore('web', {
|
|
|
})
|
|
|
tag.__id = tag.treeId
|
|
|
return tag
|
|
|
- }).filter(tag => tag.children?.length > 0))
|
|
|
- resolve(this.searchAreaTree)
|
|
|
+ }).filter(tag => tag.children?.length > 0)
|
|
|
+ this.searchAreaTree = readonly(getTree(res.data))
|
|
|
+ const AppStore = useAppStore()
|
|
|
+ this.searchAreaTreeRoleAuth = readonly(getTree(res.data.map(tag => {
|
|
|
+ tag.sysLabels.map(type => {
|
|
|
+ type.sysIndexList = type.sysIndexList?.filter(index => AppStore.userInfo.sysRoles.some(r => r.sysRoleIndices.some(a => a.labelId == tag.id && a.typeId == type.id && a.indexId == index.indexId)))
|
|
|
+ return type
|
|
|
+ })
|
|
|
+ return tag
|
|
|
+ })))
|
|
|
+ resolve({allTree: this.searchAreaTree, roleTree: this.searchAreaTreeRoleAuth})
|
|
|
})
|
|
|
})
|
|
|
}
|