From a9bbbe822377536e6f3374b05e2b64b12b2f188c Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期一, 27 五月 2024 10:25:43 +0800
Subject: [PATCH] action文档

---
 Source/ProjectWeb/src/store/modules/user.js |  249 +++++--------------------------------------------
 1 files changed, 27 insertions(+), 222 deletions(-)

diff --git a/Source/ProjectWeb/src/store/modules/user.js b/Source/ProjectWeb/src/store/modules/user.js
index f522601..3b04ff9 100644
--- a/Source/ProjectWeb/src/store/modules/user.js
+++ b/Source/ProjectWeb/src/store/modules/user.js
@@ -2,7 +2,7 @@
 import {Message} from 'element-ui'
 import {setStore, getStore} from '@/util/store'
 import {isURL, validatenull} from '@/util/validate'
-import {deepClone} from '@/util/util'
+import {deepClone,queryStringToObject} from '@/util/util'
 import website from '@/config/website'
 import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons} from '@/api/user'
 import {getTopMenu, getRoutes} from '@/api/system/menu'
@@ -14,7 +14,7 @@
   const propsConfig = menu.props;
   const propsDefault = {
     label: propsConfig.label || 'name',
-    path: 'code',
+    path: propsConfig.path || 'path',
     icon: propsConfig.icon || 'icon',
     children: propsConfig.children || 'children'
   }
@@ -27,12 +27,24 @@
   } else {
     ele[propsDefault.children].forEach(child => {
       addPath(child);
-    })
-  }
+    });
 
+  }
 }
 
-
+function updateCode(items) {
+  items.forEach(item => {
+    item.pathValue = item.path;
+    item.path = '/' + item.code;
+    item.query = {}; // 鍒濆鍖� item.query
+    if(item.pathValue.indexOf('?')!=-1) {
+      item.query = queryStringToObject(item.pathValue)
+    }
+    if (item.children && item.children.length > 0) {
+      updateCode(item.children);
+    }
+  });
+}
 
 const user = {
   state: {
@@ -50,17 +62,16 @@
     //鏍规嵁鐢ㄦ埛鍚嶇櫥褰�
     LoginByUsername({commit}, userInfo) {
       return new Promise((resolve, reject) => {
-        loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key, ).then(res => {
+        loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key,).then(res => {
           const data = res.data;
-          if(data.success){
-            debugger;
+          if (data.success) {
             commit('SET_TOKEN', data.obj.sessionInfo.token);
             commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token);
             commit('SET_TENANT_ID', data.tenant_id);
             commit('SET_USER_INFO', data.obj.sessionInfo);
             commit('DEL_ALL_TAG');
             commit('CLEAR_LOCK');
-          }else {
+          } else {
             Message({
               message: data.msg,
               type: 'error'
@@ -88,7 +99,7 @@
     //鏍规嵁绗笁鏂逛俊鎭櫥褰�
     LoginBySocial({commit}, userInfo) {
       return new Promise((resolve) => {
-        loginBySocial(userInfo.tenantId, userInfo.source,  userInfo.state).then(res => {
+        loginBySocial(userInfo.tenantId, userInfo.source, userInfo.state).then(res => {
           const data = res.data;
           if (data.error_description) {
             Message({
@@ -206,218 +217,13 @@
     GetMenu({commit, dispatch}, topMenuId) {
       return new Promise(resolve => {
         getRoutes('modelManagmentNode').then((res) => {
-          const list =[
-            {
-              "action": null,
-              "actionName": null,
-              "alias": "璧勬簮搴�",
-              "category": null,
-              "categoryName": null,
-              "children": [
-                {
-                  "action": null,
-                  "actionName": null,
-                  "alias": "鐭ヨ瘑搴�",
-                  "category": null,
-                  "categoryName": null,
-                  "children": [
-                    {
-                      "action": null,
-                      "actionName": null,
-                      "alias": "resourcelib",
-                      "category": null,
-                      "categoryName": null,
-                      "children": [],
-                      "code": "resourcelib",
-                      "hasChildren": false,
-                      "id": "2C5FABD2-535F-8568-8E61-C643BA7D77A1",
-                      "isOpen": null,
-                      "isOpenName": null,
-                      "meta": {
-                        "keepAlive": false
-                      },
-                      "name": "璁惧璧勬簮搴�",
-                      "parentId": "9B00AD2C-A407-7F71-B35C-58E466E53A33",
-                      "parentName": null,
-                      "path": "bs=test?image=resource&type=folder&context=resourcemanager&querytype=0&querytemplate=resourcelibroot",
-                      "remark": null,
-                      "sort": 1,
-                      "source": ""
-                    },
-                    {
-                      "action": null,
-                      "actionName": null,
-                      "alias": "宸ヨ壓鐭ヨ瘑搴�",
-                      "category": null,
-                      "categoryName": null,
-                      "children": [],
-                      "code": "gongyi",
-                      "hasChildren": false,
-                      "id": "AC04E222-F14B-F4FF-11BB-DFE8917A2756",
-                      "isOpen": null,
-                      "isOpenName": null,
-                      "meta": {
-                        "keepAlive": false
-                      },
-                      "name": "宸ヨ壓鐭ヨ瘑搴�",
-                      "parentId": "9B00AD2C-A407-7F71-B35C-58E466E53A33",
-                      "parentName": null,
-                      "path": "bs=UI?image=report&type=folder&context=knowledgemanager&querytype=0&querytemplate=knowledgelibroot",
-                      "remark": null,
-                      "sort": 2,
-                      "source": ""
-                    }
-                  ],
-                  "code": "zhishiku",
-                  "hasChildren": true,
-                  "id": "9B00AD2C-A407-7F71-B35C-58E466E53A33",
-                  "isOpen": null,
-                  "isOpenName": null,
-                  "meta": {
-                    "keepAlive": false
-                  },
-                  "name": "鐭ヨ瘑搴�",
-                  "parentId": "4EDC91B8-E3B2-D126-E75C-D2CEC59F53CE",
-                  "parentName": null,
-                  "path": "bs=/base",
-                  "remark": null,
-                  "sort": 1,
-                  "source": ""
-                },
-                {
-                  "action": null,
-                  "actionName": null,
-                  "alias": "TemplateLib",
-                  "category": null,
-                  "categoryName": null,
-                  "children": [
-                    {
-                      "action": null,
-                      "actionName": null,
-                      "alias": "CardTemplateLib",
-                      "category": null,
-                      "categoryName": null,
-                      "children": [],
-                      "code": "CardTemplateLib",
-                      "hasChildren": false,
-                      "id": "E6E963E7-2DF6-80EE-2A61-FA86E0F3D5F2",
-                      "isOpen": null,
-                      "isOpenName": null,
-                      "meta": {
-                        "keepAlive": false
-                      },
-                      "name": "鍗$墖妯℃澘",
-                      "parentId": "8493A92A-13DA-8800-140D-9C0C4A722665",
-                      "parentName": null,
-                      "path": "bs=?image=card&type=folder&context=cardtemplatemanager&querytype=0&querytemplate=cardtemplateroot",
-                      "remark": null,
-                      "sort": 1,
-                      "source": ""
-                    }
-                  ],
-                  "code": "TemplateLib",
-                  "hasChildren": true,
-                  "id": "8493A92A-13DA-8800-140D-9C0C4A722665",
-                  "isOpen": null,
-                  "isOpenName": null,
-                  "meta": {
-                    "keepAlive": false
-                  },
-                  "name": "妯℃澘搴�",
-                  "parentId": "4EDC91B8-E3B2-D126-E75C-D2CEC59F53CE",
-                  "parentName": null,
-                  "path": "bs=mb",
-                  "remark": null,
-                  "sort": 2,
-                  "source": ""
-                },
-                {
-                  "action": null,
-                  "actionName": null,
-                  "alias": "鍏稿瀷鏁版嵁搴�",
-                  "category": null,
-                  "categoryName": null,
-                  "children": [
-                    {
-                      "action": null,
-                      "actionName": null,
-                      "alias": "鍏稿瀷瑙勭▼",
-                      "category": null,
-                      "categoryName": null,
-                      "children": [],
-                      "code": "guicheng",
-                      "hasChildren": false,
-                      "id": "B3EC1413-1A33-61E3-DDD1-CB4D0CFD0C6E",
-                      "isOpen": null,
-                      "isOpenName": null,
-                      "meta": {
-                        "keepAlive": false
-                      },
-                      "name": "鍏稿瀷瑙勭▼",
-                      "parentId": "BDBD6CFA-2F4C-EEF7-C380-5E9BBF6A37B3",
-                      "parentName": null,
-                      "path": "bs=?image=typical&type=workorder&context=TypicalProcessLib",
-                      "remark": null,
-                      "sort": 1,
-                      "source": ""
-                    }
-                  ],
-                  "code": "dianxing",
-                  "hasChildren": true,
-                  "id": "BDBD6CFA-2F4C-EEF7-C380-5E9BBF6A37B3",
-                  "isOpen": null,
-                  "isOpenName": null,
-                  "meta": {
-                    "keepAlive": false
-                  },
-                  "name": "鍏稿瀷鏁版嵁搴�",
-                  "parentId": "4EDC91B8-E3B2-D126-E75C-D2CEC59F53CE",
-                  "parentName": null,
-                  "path": "bs=dx",
-                  "remark": null,
-                  "sort": 3,
-                  "source": ""
-                }
-              ],
-              "code": "ziyuanku",
-              "hasChildren": true,
-              "id": "4EDC91B8-E3B2-D126-E75C-D2CEC59F53CE",
-              "isOpen": null,
-              "isOpenName": null,
-              "meta": {
-                "keepAlive": false
-              },
-              "name": "璧勬簮搴�",
-              "parentId": "modelManagmentNode",
-              "parentName": null,
-              "path": "bs=zy",
-              "remark": null,
-              "sort": 913,
-              "source": ""
-            }
-          ];
           const data = res.data.obj;
-          let menu = deepClone(list);
+          let menu = deepClone(data);
           menu.forEach(ele => {
             addPath(ele, true);
+            updateCode([ele]);
           });
-          updateCode(menu)
-          function updateCode(items) {
-            items.forEach(item => {
-              // 灏嗗瓧绗︿覆鍒嗗壊鎴愭暟缁勶紝浠�'?'浣滀负鍒嗛殧绗�
-              let parts = item.path.split("?");
-              // 濡傛灉鏁扮粍鐨勯暱搴﹀ぇ浜�1锛岃〃绀烘湁'?'锛屽垯鍙栫涓�涓厓绱犵殑绗竴涓儴鍒嗭紝鍚﹀垯鐩存帴鍙栨暣涓瓧绗︿覆
-              let bsValue = parts.length > 1 ? parts[0].split("=")[1] : item.path.split("=")[1];
-              if (bsValue ===''  || bsValue === undefined || bsValue === null) {
-                bsValue = "UI";
-              }
-              item.path = bsValue === 'UI' ? '/base/UIContentViewer' :  `/custom-ui/${bsValue}`;
-              // 濡傛灉children涓嶄负绌猴紝閫掑綊璋冪敤杩欎釜鍑芥暟
-              if (item.children && item.children.length > 0) {
-                updateCode(item.children);
-              }
-            });
-          }
+
           commit('SET_MENU_ALL', menu)
           commit('SET_MENU', menu)
           //dispatch('GetButtons');s
@@ -438,7 +244,6 @@
   },
   mutations: {
     SET_TOKEN: (state, token) => {
-      debugger;
       setToken(token);
       state.token = token;
       setStore({name: 'token', content: state.token})
@@ -454,15 +259,15 @@
         }
       })
       state.menuAll = menu
-      setStore({ name: 'menuAll', content: state.menuAll })
+      setStore({name: 'menuAll', content: state.menuAll})
     },
     SET_MENU_ALL_NULL: (state) => {
       state.menuAll = []
-      setStore({ name: 'menuAll', content: state.menuAll })
+      setStore({name: 'menuAll', content: state.menuAll})
     },
     SET_MENU: (state, menu) => {
       state.menu = menu
-      setStore({ name: 'menu', content: state.menu })
+      setStore({name: 'menu', content: state.menu})
     },
     SET_REFRESH_TOKEN: (state, refreshToken) => {
       setRefreshToken(refreshToken)

--
Gitblit v1.9.3