From d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期五, 11 十月 2024 08:39:15 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 UI-Project/src/layout/MainErpView.vue |  450 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 275 insertions(+), 175 deletions(-)

diff --git a/UI-Project/src/layout/MainErpView.vue b/UI-Project/src/layout/MainErpView.vue
index 20334e7..e2f4b57 100644
--- a/UI-Project/src/layout/MainErpView.vue
+++ b/UI-Project/src/layout/MainErpView.vue
@@ -1,198 +1,300 @@
 <script setup>
-import { RouterLink,useRouter} from 'vue-router'
-import  useUserInfoStore from '@/stores/userInfo'
-import request from "@/utils/request";
-import {ElMessage} from "element-plus";
-import {onMounted, reactive, ref, watch} from "vue"
-import deepClone from "@/utils/deepClone"
+import useUserInfoStore from '@/stores/userInfo'
 import userInfo from '@/stores/userInfo'
-import {Close, Grid, Histogram, MessageBox, SwitchButton} from "@element-plus/icons-vue";
-const store=userInfo()
-
+import request from '@/utils/request'
+import {ElMessage} from 'element-plus'
+import {ref, watch, onMounted } from 'vue'
+import deepClone from '@/utils/deepClone'
+import { useRouter } from 'vue-router';  
+import { useI18n } from 'vue-i18n'
+  const { t } = useI18n()
+  let language = ref(localStorage.getItem('lang') || 'zh')
+const store = userInfo()
+const isCollapse = ref(false);  
+// const { $i18n } = useI18n(); // 鑾峰彇 i18n 瀹炰緥  
 const router = useRouter()
 const userStore = useUserInfoStore()
-const user = userStore.user.userName
-store.createWebSocket();
-function quit(){
-  userStore.$patch({
-    user:null
-  })
-  router.push("/login")
+// const user = userStore.user.userName
+
+let userInfoStr = window.localStorage.getItem('userInfo')
+console.log(userInfoStr);
+// const userInfoStr = localStorage.getItem('userInfo');  
+// let userInfo = userInfoStr.user.token;  
+let token = userInfo; // 鎻愬彇 token  
+// 閫�鍑虹櫥褰曟柟娉�  
+function quit() {  
+  // localStorage.removeItem('token'); 
+  store.$patch({
+              user: null,
+              })
+  router.push('/login')  
 }
+// const quit = async () => {
+//   try  {
+//       store.$patch({user: null})
+//     const response = await request.post('/loadGlass/sys/user/logout')
+//     if (response.code === 200) {  
+//         console.log('鐧诲嚭鎴愬姛');  
+//       } else {  
+//         // 澶勭悊閿欒鎯呭喌  
+//         console.error('鐧诲嚭澶辫触', response);  
+//       } 
+// }
+// catch (error) {
+//     // 澶勭悊閿欒
+//     console.error(error);
+//   }
+// }
+// store.createWebSocket();
+// function quit() {
+//   userStore.$patch({
+//     user: null,
+//   })
+//   // router.push('/login')
+//   request.get("/loadGlass/sys/user/login").then((res) => {
+//     if (res.code === 200) {
+//     ElMessage.success(res.msg);
+//      console.log(res.data);
+//     } else {
+//     ElMessage.warning(res.msg);
+//     // router.push("/login");
+//     }
+//    });
+// }
 
 
-//鎻愬彇妯″潡鍒楄〃
-let menuList=$ref([])
-request.get("/menu").then((res) => {
-  if(res.code==200){
-    menuList= deepClone(res.data)
-  }else{
+  function replaceChineseWithEnglish(menuData) {  
+      // 瀹氫箟涓嫳鏂囧鐓у叧绯诲璞�
+       const translation  = {  
+          '涓婄墖鏈�': '小褌芯谢 蟹邪谐褉褍蟹泻懈',  
+          '鎺扮墖/璇嗗埆': '袪邪蟹谢芯屑/懈写械薪褌懈褎懈泻邪褑懈褟',  
+          '鍗у紡缂撳瓨': ' 袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉',  
+          '纾ㄨ竟鍓嶅崸寮忕紦瀛�': '袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉 锌械褉械写 褕谢懈褎芯胁泻芯泄',  
+          '涓嬬墖鍗у紡缂撳瓨': '袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉 褋褌械泻谢邪 褉邪蟹谐褉褍蟹泻懈',  
+          '纾ㄨ竟锛堝喎鍔犲伐锛�': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',  
+          '1绾跨(杈�(鍐峰姞宸�)': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 1 谢懈薪懈懈 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',  
+          '2绾跨(杈�(鍐峰姞宸�)': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 2 谢懈薪懈懈 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',  
+          '澶х悊鐗囩': '袘褍褎械褉薪邪褟 褋懈褋褌械屑邪',  
+          '閽㈠寲': '袟邪泻邪谢泻邪',  
+          '閽㈠寲鍓�': '袩械褉械写 蟹邪泻邪谢泻懈',  
+          '閽㈠寲鍚�': '袩芯褋谢械 蟹邪泻邪谢泻懈',  
+          '涓嬬墖鍙�': '小褌芯谢 褉邪蟹谐褉褍蟹泻懈',  
+          '绯荤粺绠$悊': '校锌褉邪胁谢械薪懈械 褋懈褋褌械屑芯泄',  
+          '鐢ㄦ埛绠$悊': '校锌褉邪胁谢械薪懈械 锌芯谢褜蟹芯胁邪褌械谢械屑',  
+          '鏉冮檺绠$悊': '校锌褉邪胁谢械薪懈械 锌芯谢薪芯屑芯褔懈褟屑懈',  
+          '瑙掕壊绠$悊': '校锌褉邪胁谢械薪懈械 褉芯谢褜褞',  
+     };  
+  menuData.forEach(menu => {  
+    menu.menuName = translation[menu.menuName] || menu.menuName;  
+    // if (menu.children) {  
+      menu.children && menu.children.forEach(submenu => {  
+        submenu.menuName = translation[submenu.menuName] || submenu.menuName;  
+      });  
+    // }  
+  });  
+} 
+//鎻愬彇鑿滃崟妯″潡鍒楄〃
+let menuList = $ref([])
+
+// onMounted(async () => {  
+//   try {  
+//     const res = await request.get('/loadGlass/sys/menu/getMenuTree'); // 鍋囪 request.get 杩斿洖 Promise  
+//     if (res.code == 200) { 
+//       // 浣跨敤 value 灞炴�ф潵淇敼 ref 寮曠敤鐨勫��  
+//       menuList.value = deepClone(res.data);  
+//       const language = $i18n.locale;  
+//       if (language === 'en') {  
+//         replaceChineseWithEnglish(menuList.value); // 浼犲叆 ref 鐨� value  
+//       }  
+//       console.log(res.data.token); // 濡傛灉 res.data 涓湁 token 鐨勮瘽  
+//     } else {  
+//       ElMessage.warning(res.msg);  
+//       router.push('/login');  
+//     }  
+//   } catch (error) {  
+//     // 澶勭悊璇锋眰閿欒  
+//     console.error('鑾峰彇鑿滃崟鍒楄〃鏃跺嚭閿�:', error);  
+//   }  
+// });  
+request.get('/loadGlass/sys/menu/getMenuTree').then((res) => {
+  if (res.code == 200) {
+    menuList = res.data
+    console.log(language.value)
+      if (language.value === 'en') {
+        
+        replaceChineseWithEnglish(menuList);
+      }
+  } else {
     ElMessage.warning(res.msg)
-    router.push("/login")
+    router.push('/login')
   }
 })
-
-//鑾峰彇鑿滃崟鍒楄〃
-let menuItemList=$ref([])
-request.get("/menuItem").then((res) => {
-  if(res.code==200){
-    menuItemList= deepClone(res.data)
-  }else{
-    ElMessage.warning(res.msg)
-    router.push("/login")
-  }
-})
-
 const menu = ref(null)
 let indexKey = ref(null)
+
 function handleOpen(key) {
-  indexKey.value=key
+  indexKey.value = key
 }
-watch(indexKey,(newVal,oldVal) => {
-  if(oldVal !== newVal && oldVal !== null){
-    menu.value.close(oldVal)
-  }
-},
-    {deep:true}
+watch(
+    indexKey,
+    (newVal, oldVal) => {
+      if (oldVal !== newVal && oldVal !== null) {
+        menu.value.close(oldVal)
+      }
+    },
+    {deep: true}
 )
 
 router.beforeEach((to, from) => {
   //return false
 })
 
-
 let openFlag = $ref(null)
 //鍘熷鑿滃崟鎵撳紑
 const openMenu = (menuID) => {
-    if(menuID===openFlag){
-      openFlag = null
-    }else {
-      openFlag = menuID
-    }
+  if (menuID === openFlag) {
+    openFlag = null
+  } else {
+    openFlag = menuID
+  }
 }
-
-
+function toggleCollapse() {  
+  isCollapse.value = !isCollapse.value;  
+} 
 </script>
-
+ 
 <template>
-  <div>
+  <div id="all">
     <el-container>
-      <el-header >
-        <div style="height: 100%;width: 100%;display: flex">
-          <img src="../assets/northGlass.ico" alt="" style="max-width: 100%;max-height: 100%">
-          <h3 style="margin: 1rem  ;font-weight: bold;width: 20vw;"> 娆㈣繋{{ user }}浣跨敤鍖楃幓ERP绯荤粺锛�</h3>
-          <span style="height: 70%;width: 78vw;margin-top: 1rem;" >
-
-            <el-button  class="sys-quit" @click="quit"  type="info" round>
-              <el-icon size="large"><SwitchButton  size=""/></el-icon>
+      <el-header>
+        <div style="height: 100%;width: 100%;display: flex;background-color: #fff;">
+          <img src="../assets/northGlass.ico"
+               alt=""
+               style="max-width: 100%;max-height: 100%">
+          <h3 style="margin: 1rem  ;font-weight: bold;width: 33vw;"> {{ $t('main.titleFirst') }}{{ userName }}{{ $t('main.titleLast') }}</h3>
+          <span style="height: 70%;width: 78vw;margin-top: 1rem;">
+            <!-- <el-button class="sys-quit"
+                       @click="quit"
+                       round>
+              <el-icon size="large">
+                <SwitchButton size=""/>{{ $t('main.quit') }}
+              </el-icon>
+            </el-button> -->
+            <el-button class="sys-quit"
+                       @click="quit"
+                       round>
+              <el-icon size="large">
+                <SwitchButton size=""/>{{ $t('main.quit') }}
+              </el-icon>
             </el-button>
+            <div class="header-left">
+              <el-button @click="toggleCollapse" style="height: 30px;">  
+               <el-icon><Expand /></el-icon>
+              </el-button>  
+          </div>
           </span>
-
         </div>
       </el-header>
-      <el-container >
-        <el-aside width="160px" style="height: 97%; " >
-<!--          <el-menu
-              style=" border-radius:0.5rem;border: 0.01rem solid #409EFF;margin-bottom: 0.5rem"
-              @open="handleOpen"
-              ref="menu"
-              active-color="#ffd04b"
-              background-color="#409EFF"
-              default-active="2"
-              text-color="#fff">
-            <el-sub-menu
-
-                v-for="items in menuList"
-                :index="items.id"
-                :key="items.id">
-              <template #title>
-                <el-icon v-if="items.id==1"><Grid/></el-icon>
-                <el-icon v-if="items.id==2"><Histogram/></el-icon>
-                <el-icon v-if="items.id==3"><MessageBox/></el-icon>
-                <span style="font-weight: bold;">{{items.menuName}}</span>
-              </template>
-              <router-link
-                  v-show="items.id==menuItem.menuID"
-                  v-for="menuItem in menuItemList"
-                  :to="{path:menuItem.url}">
-                <el-menu-item  >
-                  {{ menuItem.itemName}}
-                </el-menu-item>
-              </router-link>
-
-            </el-sub-menu>
-          </el-menu>-->
-          <div class="menu"  >
-              <div v-for="items in menuList">
-                <div class='menu_title' @click="openMenu(items.id)"  >{{items.menuName}}<span class='indicator' >鈻�</span></div>
-                <ul class='enter-x-left' v-show="openFlag==items.id">
-
-                  <li v-for="menuItem in menuItemList"
-                      v-show="items.id==menuItem.menuID"
-                      style="margin-bottom: 2px"
-                  >
-                    <router-link
-                        :to="{path:menuItem.url}">
-                      {{ menuItem.itemName}}
-                    </router-link>
-
-                  </li>
-                </ul>
+      <div id="line"></div>
+      <el-container>
+      <el-aside :width="isCollapse ? '0px' : '200px'" style="background-color: #fff;">
+        <el-row :span="20">
+            <el-menu :default-active="activePath" class="el-menu-vertical-demo" >
+              <div class="menu">
+            <div v-for="items in menuList">
+              <div class='menu_title' v-show="!isCollapse"
+                   @click="openMenu(items.id)">
+                <span>鈽�</span>
+                {{ items.menuName }}
               </div>
-          </div>
-        </el-aside>
-
-        <el-main>
+              <ul class='enter-x-left'
+                  v-show="openFlag==items.id">
+                <li v-for="menuItem in items.children"
+                    style="margin-bottom:2px">
+                  <router-link :to="{path:menuItem.url}">
+                    {{ menuItem.menuName }}
+                  </router-link>
+                  </li>
+                  </ul>
+                  </div>
+                  </div>
+            </el-menu>
+          </el-row>
+</el-aside>
+<el-main>
           <div id="main">
             <router-view></router-view>
           </div>
         </el-main>
-
       </el-container>
     </el-container>
   </div>
 </template>
-
+ 
 <style scoped>
-.el-container{
-  height: 100vh;
-  width: 100vw
+
+.el-menu-vertical-demo:not(.el-menu--collapse) {
+  width: 200px;
+  min-height: 400px;
+  text-align: left;
+
 }
 
-*{
+
+
+
+#all {
+  background-color: #eee;
+  height: 100%;
+}
+
+.el-container {
+  height: 100vh;
+  width: 99vw;
+}
+
+* {
   padding: 0;
   margin: 0;
 }
-:deep(.sys-quit){
+
+:deep(.sys-quit) {
   float: right;
   margin-right: 1rem;
   width: 5rem;
-
 }
-:deep(span){
+
+/* 妯嚎 */
+#line {
+  float: right;
+  width: 100%;
+  height: 1px;
+  /* margin-top: 0.5em; */
+  margin-bottom: 0.5em;
+  background: #d4c4c4;
+  position: relative;
+  text-align: center;
+}
+
+:deep(span) {
   margin-right: 0;
-
 }
-.el-collapse{
+
+.el-collapse {
   font-size: 16px;
   font-weight: bold;
 }
-#main{
+
+#main {
   width: 99%;
   float: right;
   height: 99%;
+  background-color: #fff;
 }
-
-
-
-
 /*------------*/
 
-
-
-
-.menu div div{
-
+/* .menu div div{
+ 
   width: 138px;
   height: 35px;
   line-height: 35px;
@@ -208,16 +310,12 @@
   border-bottom: 12px ;
   margin-bottom:4px;
   text-align: left;
-  cursor: pointer;
-  border-radius:8px;
-  /*   outline: none; */
-
-  background-color:#5CADFE;
-  box-shadow: 0 8px 16px 0 rgba(0,0,0,0), 0 6px 5px 0 rgba(0,0,0,0.19);
-
-
-
-}
+  cursor: pointer; */
+/* border-radius:8px; */
+/*   outline: none; */
+/* background-color:#5CADFE; */
+/* box-shadow: 0 8px 16px 0 rgba(0,0,0,0), 0 6px 5px 0 rgba(0,0,0,0.19); */
+/* } */
 
 .menu {
   width: 138px;
@@ -228,9 +326,6 @@
   font-size: 16px;
   padding-left: 15px;
   padding-right: 2px;
-
-
-
 }
 
 ul {
@@ -240,24 +335,24 @@
 }
 
 ul li {
-
   height: 28px;
+  width: 180px;
   line-height: 30px;
-  background: rgb(128, 128, 128);
+  /* background: rgb(128, 128, 128); */
   color: #000000;
   padding-left: 36px;
   cursor: pointer;
   overflow: hidden;
   text-align: left;
-  border-radius:8px;
+  /* border-radius:8px; */
   /*   outline: none; */
 
-  background: #5CADFE;
-  box-shadow: 0 8px 16px 0 rgba(0,0,0,0), 0 6px 5px 0 rgba(0,0,0,0.19);
+  /* background: #5CADFE; */
+  /* box-shadow: 0 8px 16px 0 rgba(0,0,0,0), 0 6px 5px 0 rgba(0,0,0,0.19); */
 }
 
 ul li:hover {
-  background:#5CADFE ;
+  /* background:#5CADFE ; */
   color: #ffffff;
 }
 
@@ -267,8 +362,7 @@
   font-size: 14px;
 }
 ul li a:hover {
-
-  color: #ffffff;
+  color: #1087ff;
 }
 
 .item_divider {
@@ -276,12 +370,14 @@
   height: 0px;
   /* background-color: white;
   opacity: 0.8; */
-  margin-bottom:2px;
+  margin-bottom: 2px;
 }
-.item a{
+
+.item a {
   width: 138px;
   height: 35px;
   display: block;
+  /* text-align: justify; */
   text-decoration: none;
   color: white;
   font-size: 14px;
@@ -289,29 +385,32 @@
 }
 
 .menu_title {
-  width: 138px;
-  height: 35px;
-  line-height: 35px;
-  background: #fafafa;
-  color: rgb(128, 128, 128);
-  font-size: 16px;
+  width: 180px;
+  /* white-space: nowrap;  
+  overflow: hidden;  
+  text-overflow: ellipsis;   */
+
+  height: 45px;
+  line-height: 55px;
+  /* background: #fafafa; */
+  color: rgb(43, 42, 42);
+  font-size: 17px;
   padding-left: 15px;
   transition: all 0.3s ease;
   cursor: pointer;
   position: relative;
   font-weight: bold;
   overflow: hidden;
-
 }
 
 .menu_title:hover {
   /* background: #dedede; */
-  color: #ffffff;
+  color: #3b9af9;
 }
 
 .indicator {
   display: block;
-  width: 50px;
+  width: 40px;
   height: 35px;
   font-weight: bold;
   position: absolute;
@@ -320,8 +419,6 @@
   transition: all 0.3s ease;
   text-align: center;
 }
-
-
 
 /* 鍔ㄧ敾鏁堟灉 */
 .enter-x-left {
@@ -332,26 +429,29 @@
   transform: translateX(-50px);
   transition: all 0.3s ease;
 }
-.enter-x-left:nth-child(1){
+
+.enter-x-left:nth-child(1) {
   animation-delay: 0.1s;
 }
-.enter-x-left:nth-child(2){
+
+.enter-x-left:nth-child(2) {
   animation-delay: 0.2s;
 }
+
 .enter-x-left:nth-child(3) {
   animation-delay: 0.3s;
 }
-.enter-x-left:nth-child(4){
+
+.enter-x-left:nth-child(4) {
   animation-delay: 0.4s;
 }
-
-
 @keyframes enter-x-left {
   to {
     opacity: 1;
     transform: translateX(0);
   }
 }
-
-
+.header-left{
+  margin-left: -350px;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0