From 5ad8759685592a6c55d2137acdea7ffa964815f2 Mon Sep 17 00:00:00 2001 From: kubbo <390378816@qq.com> Date: Fri, 10 Feb 2023 23:26:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E5=85=B8=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=8F=9C=E5=8D=95=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/core/AppDictionary/AppDictionary.vue | 120 +++++++++++++ .../apps/core/AppDictionary/dictDetail.vue | 170 ++++++++++++++++++ web/src/apps/{ => core}/AppMenu.vue | 41 +++-- web/src/components/KuSelect.vue | 10 +- web/src/components/sliderNav.vue | 9 +- web/src/utils/dict.js | 13 +- web/src/utils/router.js | 2 +- 7 files changed, 341 insertions(+), 24 deletions(-) create mode 100644 web/src/apps/core/AppDictionary/AppDictionary.vue create mode 100644 web/src/apps/core/AppDictionary/dictDetail.vue rename web/src/apps/{ => core}/AppMenu.vue (80%) diff --git a/web/src/apps/core/AppDictionary/AppDictionary.vue b/web/src/apps/core/AppDictionary/AppDictionary.vue new file mode 100644 index 0000000..8ee3aa6 --- /dev/null +++ b/web/src/apps/core/AppDictionary/AppDictionary.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/web/src/apps/core/AppDictionary/dictDetail.vue b/web/src/apps/core/AppDictionary/dictDetail.vue new file mode 100644 index 0000000..ac86422 --- /dev/null +++ b/web/src/apps/core/AppDictionary/dictDetail.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/web/src/apps/AppMenu.vue b/web/src/apps/core/AppMenu.vue similarity index 80% rename from web/src/apps/AppMenu.vue rename to web/src/apps/core/AppMenu.vue index 6e594bc..9217c64 100644 --- a/web/src/apps/AppMenu.vue +++ b/web/src/apps/core/AppMenu.vue @@ -23,7 +23,7 @@ - + - + @@ -61,19 +61,29 @@ diff --git a/web/src/components/KuSelect.vue b/web/src/components/KuSelect.vue index 2eb92b6..93f02c8 100644 --- a/web/src/components/KuSelect.vue +++ b/web/src/components/KuSelect.vue @@ -6,7 +6,7 @@ @@ -54,7 +54,13 @@ export default { ...this.prop } }, - ops: v => v.dict ? v.$dict.getDict(v.dict) : v.selectList + ops: v => { + if (v.dict) { + const options = {} + v.$dict.getDict(v.dict).map(e => options[e.dictValue] = e.dictName) + return options + } else return v.selectList + } }, methods: { getOptions() { diff --git a/web/src/components/sliderNav.vue b/web/src/components/sliderNav.vue index 46bc6cb..4de02b5 100644 --- a/web/src/components/sliderNav.vue +++ b/web/src/components/sliderNav.vue @@ -14,7 +14,8 @@
@@ -59,8 +60,12 @@ export default { this.menus = this.$arr2tree(menus, {parent: "parent"}) } }).finally(() => { + //超管才有的初始化菜单 if (this.menus.length == 0 && this.user.level == 1) { - this.menus = [{id: '202302071139', label: "菜单管理", route: "AppMenu"}] + this.menus = [ + {id: '202302071139', label: "菜单管理", route: "AppMenu"}, + {id: '202302102232', label: "字典管理", route: "AppDictionary"}, + ] } }) }, diff --git a/web/src/utils/dict.js b/web/src/utils/dict.js index 99eef24..c06883b 100644 --- a/web/src/utils/dict.js +++ b/web/src/utils/dict.js @@ -4,7 +4,6 @@ import http from "./axios"; * 封装字典工具类 */ const $dict = { - url: "/api/dict/listByCodes", loading: [], resolves: [], getStorage() { @@ -13,9 +12,15 @@ const $dict = { }, getData(codeList) { codeList = [codeList].flat().filter(Boolean).toString() - return http.post(this.url, null, { + return http.post("/api/dict/listByCodes", null, { withoutToken: true, params: {codeList} }).then(res => res?.data && this.setStorage(res.data)) + .finally(() => this.setStorage({ + key: "yesOrNo", values: [ + {dictValue: '0', dictName: "否"}, + {dictValue: '1', dictName: "是"} + ] + })) }, load(...code) { return new Promise(resolve => { @@ -32,8 +37,8 @@ const $dict = { }) }, setStorage(data) { - let ds = this.getStorage() - data.map(p => { + let ds = this.getStorage(); + [data].flat().map(p => { if (ds.some(d => d.key == p.key)) { const index = ds.findIndex(d => d.key == p.key) ds.splice(index, 1, p) diff --git a/web/src/utils/router.js b/web/src/utils/router.js index 4ab20f3..426e991 100644 --- a/web/src/utils/router.js +++ b/web/src/utils/router.js @@ -6,7 +6,7 @@ import {mainStore} from "./store"; let home = {name: "工作台", path: "/", component: () => import('../views/home')}, routes = [{name: "登录", path: "/login", component: () => import('../views/login')}] const loadApps = () => { - const files = import.meta.glob('../apps/App*.vue'), apps = [] + const files = import.meta.glob('../apps/**/App*.vue'), apps = [] return Promise.all(Object.keys(files).map(path => { return files?.[path]()?.then(file => { if (file.default) {