From 664cde29f7d87204ad2be6bc1ef8a0cc08739172 Mon Sep 17 00:00:00 2001 From: Leo_Ding <2405260743@qq.com> Date: Sat, 11 Oct 2025 09:34:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=89=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AreaCascader/index.vue | 29 +++++-------------- src/layouts/BasicLayout.vue | 1 + src/store/modules/dicts.js | 20 ++++++++++++- .../serverList/components/BasicInfo.vue | 9 ------ 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/components/AreaCascader/index.vue b/src/components/AreaCascader/index.vue index 6b71303..b13f364 100644 --- a/src/components/AreaCascader/index.vue +++ b/src/components/AreaCascader/index.vue @@ -8,6 +8,8 @@ diff --git a/src/layouts/BasicLayout.vue b/src/layouts/BasicLayout.vue index a903323..a17dd05 100644 --- a/src/layouts/BasicLayout.vue +++ b/src/layouts/BasicLayout.vue @@ -163,6 +163,7 @@ defineOptions({ useMultiTab() const appStore = useAppStore() const dicsStore = useDicsStore() +dicsStore.loadProvinces() // 加载省份数据 dicsStore.loadAllDictData() // 加载字典数据 const { sideMenuList, topMenuList } = useMenu() diff --git a/src/store/modules/dicts.js b/src/store/modules/dicts.js index 73f6bdb..51c5370 100644 --- a/src/store/modules/dicts.js +++ b/src/store/modules/dicts.js @@ -9,6 +9,7 @@ import useAppStore from './app' const useDicsStore = defineStore('dics', { state: () => ({ dictOptions: {}, + provinceOptions: [], }), getters: { /** @@ -58,6 +59,23 @@ const useDicsStore = defineStore('dics', { }, actions: { + // 初始加载省份 + async loadProvinces() { + try { + const response = await apis.common.getAreaList({ current: 1, pageSize: 100 }) + console.log('获取省份响应:', response) + if (Array.isArray(response.data)) { + this.provinceOptions = response.data.map((province) => ({ + ...province, + isLeaf: !province.hasChild, // 一定有子节点(市) + })) + } else { + console.warn('获取省份失败:', response.data.message) + } + } catch (error) { + console.error('请求省份数据失败:', error) + } + }, /** * 从后端加载所有字典数据 * @param commit @@ -76,7 +94,7 @@ const useDicsStore = defineStore('dics', { if (res?.data) { this.dictOptions = res.data if (res.data.length > 0) { - const dictTypes = res.data.map(item => item.code) + const dictTypes = res.data.map((item) => item.code) const requests = dictTypes.map((type) => getDictByType(type)) const results = await Promise.all(requests) // 将结果按 type 存入 dictOptions diff --git a/src/views/serverObj/serverList/components/BasicInfo.vue b/src/views/serverObj/serverList/components/BasicInfo.vue index 4ca3e7a..da9f582 100644 --- a/src/views/serverObj/serverList/components/BasicInfo.vue +++ b/src/views/serverObj/serverList/components/BasicInfo.vue @@ -56,12 +56,6 @@
生存状态: {{ formData.survivalStatus || '-' }}
- - - - - -
服务状态: {{ formData.serviceStatus || '-' }}
@@ -69,9 +63,6 @@
服务形式: {{ formData.serviceForm || '-' }}
- - -
户籍地址: