From 8b32bf5edef3729de5c96c56f7c07442f1d78183 Mon Sep 17 00:00:00 2001 From: XiuHe <1109326957@qq.com> Date: Mon, 9 Mar 2026 16:28:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BD=8D=E7=BD=AE=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/location.ts | 31 +++ admin/src/hooks/useDictOptions.ts | 25 +- admin/src/views/assets/location/edit.vue | 232 +++++-------------- admin/src/views/assets/location/index.vue | 114 ++++++--- admin/src/views/assets/unfixedinfo/index.vue | 2 +- 5 files changed, 191 insertions(+), 213 deletions(-) create mode 100644 admin/src/api/location.ts diff --git a/admin/src/api/location.ts b/admin/src/api/location.ts new file mode 100644 index 00000000..562032c7 --- /dev/null +++ b/admin/src/api/location.ts @@ -0,0 +1,31 @@ +import request from '@/utils/request' + +// 获取所有位置 +export function getLocationList() { + return request.get({ url: '/location/list' }) +} + +// 添加位置 +export function addLocation(params?: any) { + return request.post({ url: '/location/add', params }) +} + +// 修改位置 +export function updateLocation(params?: any) { + return request.post({ url: '/location/update', params }) +} + +// 获取指定位置 +export function getLocation(params?: any) { + return request.get({ url: '/location/detail', params }) +} + +// 删除位置 +export function deleteLocation(params?: any) { + return request.post({ url: '/location/del', params }) +} + +// 返回指定位置的所有子位置 +export function getSubLocations(params?: any) { + return request.get({ url: '/location/children', params }) +} \ No newline at end of file diff --git a/admin/src/hooks/useDictOptions.ts b/admin/src/hooks/useDictOptions.ts index 19cbd8d0..597f606e 100644 --- a/admin/src/hooks/useDictOptions.ts +++ b/admin/src/hooks/useDictOptions.ts @@ -47,14 +47,27 @@ export function useDictOptions(options: Options) { } } -export function useDictData(id: number) { +export function useDictData>(ids: number | number[]) { + const dictIds = Array.isArray(ids) ? ids : [ids] const dictData: any = reactive({}) - const refresh = async () => { - const data = await getDictList({ - type_id: id - }) - Object.assign(dictData, data.lists) + + // 初始化单个字典 + const initDict = async (id: number) => { + const data = await getDictList({ type_id: id }) + dictData[id] = {} + Object.assign(dictData[id], data.lists) // 保持原有数据结构 } + + // 刷新字典(支持指定ID,不传则刷新所有) + const refresh = async (targetIds?: number | number[]) => { + const targetDictIds = targetIds + ? Array.isArray(targetIds) ? targetIds : [targetIds] + : dictIds + // 并行加载指定字典 + await Promise.all(targetDictIds.map(initDict)) + } + + // 初始化所有字典 const initPromise = refresh() return { diff --git a/admin/src/views/assets/location/edit.vue b/admin/src/views/assets/location/edit.vue index dca71a33..18c6fc81 100644 --- a/admin/src/views/assets/location/edit.vue +++ b/admin/src/views/assets/location/edit.vue @@ -9,17 +9,10 @@ @close="handleClose" > - - - 目录 - 菜单 - 按钮 - - - + - - + + - - - - - -
- -
- 访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头 -
-
-
- -
- + + -
- 访问的组件路径,如:`user/setting`,默认在`views`目录下 -
-
+
-
- + -
- 访问详情页面,编辑页面时,菜单高亮显示,如`/consumer/lists` -
-
+
- -
- -
- 将作为server端API验权使用,如`auth.admin/user`,请谨慎修改 -
-
+ + - -
-
- -
-
- 访问路由的默认传递参数,如:`{"id": 1, "name": - "admin"}`或`id=1&name=admin` -
-
+ + - -
- - 缓存 - 不缓存 - -
选择缓存则会被`keep-alive`缓存
-
-
- -
- - 显示 - 隐藏 - -
- 选择隐藏则路由将不会出现在侧边栏,但仍然可以访问 -
-
-
- -
- - 正常 - 停用 - -
选择停用则路由将不会出现在侧边栏,也不能被访问
-
-
- -
- -
数值越大越排前
-
+ +
@@ -164,9 +75,9 @@