xiaochan 1 рік тому
батько
коміт
b45209b29c

+ 1 - 1
src/layout/MenuV2/MenuV2.vue

@@ -36,7 +36,7 @@
 
 <script setup lang="ts">
 import MenuItemV2 from "./MenuItemV2.vue";
-import {computed, nextTick, onMounted, reactive, Ref, ref, watch} from "vue";
+import {computed, nextTick, onMounted, Ref, ref, watch} from "vue";
 import {useRoute} from "vue-router";
 import Logo from '../HeaderV2/Logo.vue'
 import XEUtils from "xe-utils";

+ 2 - 30
src/router/index.ts

@@ -19,14 +19,7 @@ import {useUserStore} from "@/pinia/user-store";
 
 const router = createRouter({
     history: createWebHistory(),
-    routes: [...Dashboard, {
-        path: '/:path(.*)*',
-        name: 'notFound',
-        component: () => import( '@/views/system/404.vue'),
-        meta: {
-            hideTabs: true
-        }
-    }],
+    routes: [...Dashboard],
 })
 
 const vueFile = import.meta.glob('../views/**/*.{vue,tsx}');
@@ -39,29 +32,8 @@ export const routerMenus: Ref<IntergrationMenu[]> = ref([])
 async function beforeAddRoutes() {
     await useUserStore().getUserInfo
     routerMenus.value = await getUserMenu()
-    routerMenus.value.push({
-        type: 2,
-        path: '/',
-        name: 'Home',
-        pathParams: '',
-        metaHideTabs: true,
-        metaShowMenu: false,
-        completePath: "/",
-        redirect: '/dashboard',
-        component: 'Layout',
-        children: [
-            {
-                type: 1,
-                path: 'dashboard',
-                name: 'dashboard',
-                pathParams: '',
-                metaHideTabs: true,
-                metaShowMenu: false,
-                component: '../views/dashboard/index.vue',
-            }
-        ]
-    })
     const routers = addRoutes(routerMenus.value)
+    console.log(routerMenus.value)
     routers.forEach(item => {
         router.addRoute(item)
     })

+ 20 - 12
src/router/modules/dashboard.ts

@@ -7,7 +7,7 @@ declare module 'vue-router' {
         title?: string;
         hideTabs?: boolean,
         passRule?: boolean,
-        needToken?: boolean,
+        showMenu?: boolean,
         mainCard?: boolean,
         mainRolling?: boolean
     }
@@ -19,73 +19,81 @@ const route: Array<RouteRecordRaw> = [
         name: 'login',
         component: createNameComponent(() => import('@/views/system/login.vue')),
         hideMenu: true,
-        meta: {title: '登录', hideTabs: true, needToken: false},
+        meta: {title: '登录', hideTabs: true},
     }, {
         path: '/jumpRedirect',
         name: 'jumpRedirect',
         component: createNameComponent(() => import('@/views/system/JumpRedirect.vue')),
         hideMenu: true,
-        meta: {title: '跳转重定向', hideTabs: true, needToken: false},
+        meta: {title: '跳转重定向', hideTabs: true},
     },
     {
         path: '/mzEmr/:patientInfo?',
         name: 'mzEmr',
         component: createNameComponent(() => import('@/views/mz-emr/MzEmr.vue')),
         hideMenu: true,
-        meta: {title: '门诊电子病历', hideTabs: true, needToken: false},
+        meta: {title: '门诊电子病历', hideTabs: true},
     },
     {
         path: '/shareholderCard/:patientInfo?',
         name: 'shareholderCard',
         component: createNameComponent(() => import('@/views/mz-emr/ShareholderCard.vue')),
         hideMenu: true,
-        meta: {title: '股东卡优惠', hideTabs: true, needToken: false},
+        meta: {title: '股东卡优惠', hideTabs: true},
     },
     {
         path: '/scrollSource',
         name: 'scrollSource',
         component: createNameComponent(() => import('@/views/single-page/TodayClinicResource.vue')),
         hideMenu: true,
-        meta: {title: '今日号源', hideTabs: true, needToken: false},
+        meta: {title: '今日号源', hideTabs: true},
     },
     {
         path: '/lottery',
         name: 'lottery',
         component: createNameComponent(() => import('@/views/single-page/Lottery.vue')),
-        meta: {title: '抽奖', needToken: false}
+        meta: {title: '抽奖', hideTabs: true}
     },
     {
         path: '/myEmrEditor/:pat?/:refresh?',
         name: 'myEmrEditor',
         component: createNameComponent(() => import('@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/Home.vue')),
         hideMenu: true,
-        meta: {title: '电子病历', hideTabs: true, needToken: false},
+        meta: {title: '电子病历', hideTabs: true},
     },
     {
         path: '/fluorescenceTest',
         name: 'fluorescenceTest',
         component: createNameComponent(() => import('@/components/zhu-yuan-yi-sheng/emr/auxiliary-tools/fluorescence-test/FluorescenceTest.vue')),
         hideMenu: true,
-        meta: {title: '荧光检验', hideTabs: true, needToken: false},
+        meta: {title: '荧光检验', hideTabs: true},
     },
     {
         path: '/siSettleDetailList/:patientId?/:times?',
         name: 'siSettleDetailList',
         component: createNameComponent(() => import('@/views/medical-insurance/allpatient/SiSettleDetailList.vue')),
-        meta: {title: '医保结算单', needToken: false},
+        meta: {title: '医保结算单', hideTabs: true},
     },
     {
         path: '/view/patient360',
         name: 'patient360',
         component: createNameComponent(() => import('@/views/view/patient360/src/Patient360.vue')),
-        meta: {title: '患者360', hideTabs: true, needToken: false},
+        meta: {title: '患者360', hideTabs: true},
     },
     {
         path: '/blank',
         name: 'blank',
         component: () => import('@/views/system/Blank.vue'),
-        meta: {hideTabs: true, needToken: false},
+        meta: {hideTabs: true},
     },
+    {
+        path: '/:path(.*)*',
+        name: 'notFound',
+        component: () => import( '@/views/system/404.vue'),
+        meta: {
+            hideTabs: true
+        }
+    }
 ];
 
 export default route

+ 21 - 0
src/utils/cy-use/usePromise.ts

@@ -0,0 +1,21 @@
+// @ts-nocheck
+export default function usePromise<D>() {
+    const tmp: {
+        resolve: (value: any) => void;
+        reject: (value: any) => void;
+        promise: Promise<D>;
+    } = {
+        resolve(value: any) {
+
+        },
+        reject(value: any) {
+
+        },
+        promise: null
+    }
+    tmp.promise = new Promise((resolve, reject) => {
+        tmp.resolve = resolve
+        tmp.reject = reject
+    })
+    return tmp
+}

+ 1 - 0
src/views/settings/menu-settings/MenuSettings.vue

@@ -9,6 +9,7 @@ const menuTreeData = ref<IntergrationMenu[]>([])
 const dialogRef = ref()
 
 function modify(row) {
+  console.log(row)
   dialogRef.value.openDialog(row)
 }
 

+ 45 - 24
src/views/settings/menu-settings/dialog.vue

@@ -21,6 +21,8 @@ import XEUtils from "xe-utils";
 import {eachAndReturnList} from "@/utils/cyRefList";
 import {useCompRef} from "@/utils/useCompRef";
 import {QuestionFilled} from "@element-plus/icons-vue";
+import axios from "axios";
+import usePromise from "@/utils/cy-use/usePromise";
 
 const props = defineProps<{
   cascaderData: any[],
@@ -30,14 +32,38 @@ const emits = defineEmits<{
   (e: "saveCallback"): void,
 }>()
 
-const icon = ref('')
+const icons = ref([])
 
-async function importCss() {
-  const cssContent = await fetch('../src/icons/iconfont.css');
-  icon.value = await cssContent.text();
+function importCss() {
+  const promise = usePromise<string[]>();
+  nextTick(() => {
+    const styles: any = document.styleSheets;
+    let sheetsList = [];
+    let sheetsIconList = [];
+    for (let i = 0; i < styles.length; i++) {
+      if (styles[i].href && styles[i].href.indexOf('/icons/iconfont') > -1) {
+        sheetsList.push(styles[i]);
+      }
+    }
+    for (let i = 0; i < sheetsList.length; i++) {
+      for (let j = 0; j < sheetsList[i].cssRules.length; j++) {
+        if (sheetsList[i].cssRules[j].selectorText && sheetsList[i].cssRules[j].selectorText.indexOf('.icon-') > -1) {
+          sheetsIconList.push(
+              `${sheetsList[i].cssRules[j].selectorText.substring(1, sheetsList[i].cssRules[j].selectorText.length).replace(/\:\:before/gi, '')}`
+          );
+        }
+      }
+    }
+    if (sheetsIconList.length > 0) promise.resolve(sheetsIconList);
+    else promise.reject('未获取到值,请刷新重试');
+  })
+
+  return promise.promise
 }
 
-importCss()
+importCss().then((res) => {
+  icons.value = res
+})
 
 const showDialog = ref(false)
 const currentData = ref<IntergrationMenu>({
@@ -75,13 +101,14 @@ async function save() {
   await fromRef.value?.validate()
   if (currentData.value.cascaders?.length > 0) {
     currentData.value.parentId = currentData.value!.cascaders?.[currentData.value.cascaders!.length - 1]
+  } else {
+    currentData.value.parentId = null
   }
   await updateMenuSettings(currentData.value)
   showDialog.value = false
   emits('saveCallback')
 }
 
-const icons = ref([])
 const routerKey = ref([])
 
 const layout = [
@@ -96,12 +123,6 @@ const layout = [
 ]
 
 function dialogOpen() {
-  const regex = /.(?<icon>.*):before/g;
-  const matches = icon.value.matchAll(regex);
-  console.log(matches)
-  icons.value = eachAndReturnList((matches as string[]), (item) => {
-    return item[1]
-  })
 
   const view = import.meta.glob('/src/views/**/*.{vue,tsx}');
 
@@ -278,8 +299,8 @@ defineExpose({
         <el-col :span="12">
           <el-form-item label="隐藏标签">
             <el-switch v-model="currentData.metaHideTabs"
-                       :active-value="1"
-                       :inactive-value="0"
+                       :active-value="true"
+                       :inactive-value="false"
                        active-text="是"
                        inactive-text="否"
             />
@@ -289,8 +310,8 @@ defineExpose({
         <el-col :span="12">
           <el-form-item label="无需权限">
             <el-switch v-model="currentData.metaPassRule"
-                       :active-value="1"
-                       :inactive-value="0"
+                       :active-value="true"
+                       :inactive-value="false"
                        active-text="是"
                        inactive-text="否"
             />
@@ -300,8 +321,8 @@ defineExpose({
         <el-col :span="12">
           <el-form-item label="卡片类型">
             <el-switch v-model="currentData.mainCard"
-                       :active-value="1"
-                       :inactive-value="0"
+                       :active-value="true"
+                       :inactive-value="false"
                        active-text="是"
                        inactive-text="否"
             />
@@ -311,8 +332,8 @@ defineExpose({
         <el-col :span="12">
           <el-form-item label="超出滚动">
             <el-switch v-model="currentData.mainOverflowAuto"
-                       :active-value="1"
-                       :inactive-value="0"
+                       :active-value="true"
+                       :inactive-value="false"
                        active-text="是"
                        inactive-text="否"
             />
@@ -320,10 +341,10 @@ defineExpose({
         </el-col>
 
         <el-col :span="12">
-          <el-form-item label="无需登录">
-            <el-switch v-model="currentData.metaNeedToken"
-                       :active-value="1"
-                       :inactive-value="0"
+          <el-form-item label="显示菜单">
+            <el-switch v-model="currentData.metaShowMenu"
+                       :active-value="true"
+                       :inactive-value="false"
                        active-text="是"
                        inactive-text="否"
             />