diff --git a/src/api/sysDictionary.js b/src/api/system/dictionary/sysDictionary.js similarity index 100% rename from src/api/sysDictionary.js rename to src/api/system/dictionary/sysDictionary.js diff --git a/src/api/sysDictionaryDetail.js b/src/api/system/dictionary/sysDictionaryDetail.js similarity index 100% rename from src/api/sysDictionaryDetail.js rename to src/api/system/dictionary/sysDictionaryDetail.js diff --git a/src/pathInfo.json b/src/pathInfo.json index a0ce0c6..da7147e 100644 --- a/src/pathInfo.json +++ b/src/pathInfo.json @@ -69,6 +69,8 @@ "/src/view/superAdmin/authority/components/apis.vue": "Apis", "/src/view/superAdmin/authority/components/datas.vue": "Datas", "/src/view/superAdmin/authority/components/menus.vue": "Menus", + "/src/view/superAdmin/dictionary/sysDictionary.vue": "SysDictionary", + "/src/view/superAdmin/dictionary/sysDictionaryDetail.vue": "SysDictionaryDetail", "/src/view/superAdmin/index.vue": "SuperAdmin", "/src/view/superAdmin/menu/components/components-cascader.vue": "ComponentsCascader", "/src/view/superAdmin/menu/icon.vue": "Icon", diff --git a/src/pinia/modules/dictionary.js b/src/pinia/modules/dictionary.js index b0c089f..e76d19f 100644 --- a/src/pinia/modules/dictionary.js +++ b/src/pinia/modules/dictionary.js @@ -1,5 +1,5 @@ -import { findSysDictionary } from '@/api/sysDictionary' -import { getDictionaryTreeListByType } from '@/api/sysDictionaryDetail' +import { findSysDictionary } from '@/api/system/dictionary/sysDictionary' +import { getDictionaryTreeListByType } from '@/api/system/dictionary/sysDictionaryDetail' import { defineStore } from 'pinia' import { ref } from 'vue' @@ -32,9 +32,7 @@ export const useDictionaryStore = defineStore('dictionary', () => { label: item.label, value: item.value, extend: item.extend, - children: item.children - ? filterTreeByDepth(item.children, currentDepth + 1, targetDepth) - : undefined + children: item.children ? filterTreeByDepth(item.children, currentDepth + 1, targetDepth) : undefined })) } @@ -66,20 +64,12 @@ export const useDictionaryStore = defineStore('dictionary', () => { label: item.label, value: item.value, extend: item.extend, - children: - item.children && item.children.length > 0 - ? normalizeTreeData(item.children) - : undefined + children: item.children && item.children.length > 0 ? normalizeTreeData(item.children) : undefined })) } // 根据value和depth查找指定节点并返回其children - const findNodeByValue = ( - items, - targetValue, - currentDepth = 1, - maxDepth = 0 - ) => { + const findNodeByValue = (items, targetValue, currentDepth = 1, maxDepth = 0) => { for (const item of items) { // 如果找到目标value的节点 if (item.value === targetValue) { @@ -95,17 +85,8 @@ export const useDictionaryStore = defineStore('dictionary', () => { } // 如果当前深度小于最大深度,继续在children中查找 - if ( - item.children && - item.children.length > 0 && - (maxDepth === 0 || currentDepth < maxDepth) - ) { - const result = findNodeByValue( - item.children, - targetValue, - currentDepth + 1, - maxDepth - ) + if (item.children && item.children.length > 0 && (maxDepth === 0 || currentDepth < maxDepth)) { + const result = findNodeByValue(item.children, targetValue, currentDepth + 1, maxDepth) if (result !== null) { return result } @@ -120,29 +101,16 @@ export const useDictionaryStore = defineStore('dictionary', () => { // 构建缓存key,包含value和depth信息 const cacheKey = `${type}_value_${value}_depth_${depth}` - if ( - dictionaryMap.value[cacheKey] && - dictionaryMap.value[cacheKey].length - ) { + if (dictionaryMap.value[cacheKey] && dictionaryMap.value[cacheKey].length) { return dictionaryMap.value[cacheKey] } try { // 获取完整的树形结构数据 const treeRes = await getDictionaryTreeListByType({ type }) - if ( - treeRes.code === 0 && - treeRes.data && - treeRes.data.list && - treeRes.data.list.length > 0 - ) { + if (treeRes.code === 0 && treeRes.data && treeRes.data.list && treeRes.data.list.length > 0) { // 查找指定value的节点并返回其children - const targetNodeChildren = findNodeByValue( - treeRes.data.list, - value, - 1, - depth - ) + const targetNodeChildren = findNodeByValue(treeRes.data.list, value, 1, depth) if (targetNodeChildren !== null) { let resultData @@ -179,12 +147,7 @@ export const useDictionaryStore = defineStore('dictionary', () => { try { // 首先尝试获取树形结构数据 const treeRes = await getDictionaryTreeListByType({ type }) - if ( - treeRes.code === 0 && - treeRes.data && - treeRes.data.list && - treeRes.data.list.length > 0 - ) { + if (treeRes.code === 0 && treeRes.data && treeRes.data.list && treeRes.data.list.length > 0) { // 使用树形结构数据 const treeData = treeRes.data.list diff --git a/src/view/superAdmin/dictionary/sysDictionary.vue b/src/view/superAdmin/dictionary/sysDictionary.vue new file mode 100644 index 0000000..a8690c5 --- /dev/null +++ b/src/view/superAdmin/dictionary/sysDictionary.vue @@ -0,0 +1,309 @@ + + + + + diff --git a/src/view/superAdmin/dictionary/sysDictionaryDetail.vue b/src/view/superAdmin/dictionary/sysDictionaryDetail.vue new file mode 100644 index 0000000..d6964b8 --- /dev/null +++ b/src/view/superAdmin/dictionary/sysDictionaryDetail.vue @@ -0,0 +1,333 @@ + + + + +