diff --git a/src/router/index.js b/src/router/index.js index 71e8312..16d146e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -85,6 +85,19 @@ export const constantRoutes = [ meta: { title: '个人中心', icon: 'user' } } ] + }, + { + path: '/system/dict/data', + component: Layout, + hidden: true, + children: [ + { + path: 'index/:dictId?', + component: () => import('@/views/system/dict/data.vue'), + name: 'DictData', + meta: { title: '字典数据', activeMenu: '/system/dict' } + } + ] } // 业务路由(订单管理、系统管理等)将从后端动态获取 ]; diff --git a/src/views/system/dict/data.vue b/src/views/system/dict/data.vue index eff8acc..078adc8 100644 --- a/src/views/system/dict/data.vue +++ b/src/views/system/dict/data.vue @@ -193,6 +193,7 @@ const multiple = ref(true); const total = ref(0); const title = ref(""); const defaultDictType = ref(""); +const currentDictId = ref(""); const typeOptions = ref([]); const route = useRoute(); // 数据标签回显样式 @@ -225,6 +226,12 @@ const { queryParams, form, rules } = toRefs(data); /** 查询字典类型详细 */ function getTypes(dictId) { + if (!dictId) { + queryParams.value.dictType = undefined; + defaultDictType.value = ""; + getList(); + return; + } getType(dictId).then(response => { queryParams.value.dictType = response.data.dictType; defaultDictType.value = response.data.dictType; @@ -357,6 +364,16 @@ function handleExport() { }, `dict_data_${new Date().getTime()}.xlsx`); } -getTypes(route.params && route.params.dictId); +watch( + () => [route.params?.dictId, route.query?.dictId], + ([newParam, newQuery]) => { + const nextDictId = newParam ?? newQuery ?? ""; + if (nextDictId === currentDictId.value) return; + currentDictId.value = nextDictId; + getTypes(nextDictId); + }, + { immediate: true } +); + getTypeList(); diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index ead773b..d32aec1 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -107,7 +107,10 @@