From e6a899cbf6d9cdf709d0f1deef91ff4d3f36abe8 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 10 二月 2026 11:01:14 +0800
Subject: [PATCH] 进销存升级app: 1.添加菜单权限
---
src/pages/index.vue | 301 +++++++++++++++++++++++++++---------------
src/pages/login.vue | 6
src/pages.json | 2
src/pages/cooperativeOffice/collaborativeApproval/index.vue | 2
src/pages/indexItem.vue | 46 +++++
src/store/modules/user.ts | 17 ++
src/api/menu.js | 9 +
src/pages_template/pages/login/index2.vue | 9 +
8 files changed, 276 insertions(+), 116 deletions(-)
diff --git a/src/api/menu.js b/src/api/menu.js
new file mode 100644
index 0000000..faef101
--- /dev/null
+++ b/src/api/menu.js
@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+// 鑾峰彇璺敱
+export const getRouters = () => {
+ return request({
+ url: '/getRouters',
+ method: 'get'
+ })
+}
\ No newline at end of file
diff --git a/src/pages.json b/src/pages.json
index 351c7dc..e88a800 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -312,7 +312,7 @@
{
"path": "pages/cooperativeOffice/collaborativeApproval/index7",
"style": {
- "navigationBarTitleText": "鍑哄簱绠$悊",
+ "navigationBarTitleText": "鍙戣揣瀹℃壒",
"navigationStyle": "custom"
}
},
diff --git a/src/pages/cooperativeOffice/collaborativeApproval/index.vue b/src/pages/cooperativeOffice/collaborativeApproval/index.vue
index a7a5b2d..6c3defa 100644
--- a/src/pages/cooperativeOffice/collaborativeApproval/index.vue
+++ b/src/pages/cooperativeOffice/collaborativeApproval/index.vue
@@ -157,7 +157,7 @@
4: "鎶ラ攢绠$悊",
5: "閲囪喘绠$悊",
6: "鎶ヤ环绠$悊",
- 7: "鍑哄簱绠$悊",
+ 7: "鍙戣揣瀹℃壒",
8: "鍗遍櫓浣滀笟绠$悊",
};
return titleMap[type] || "瀹℃壒绠$悊";
diff --git a/src/pages/index.vue b/src/pages/index.vue
index 7094cf9..81a0c94 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -38,7 +38,7 @@
<!-- </view>-->
<!-- </view>-->
<!-- 钀ラ攢绠$悊妯″潡 -->
- <view class="common-module marketing-module">
+ <view class="common-module marketing-module" v-if="hasMarketingItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">钀ラ攢绠$悊</text>
@@ -62,7 +62,7 @@
</view>
</view>
<!-- <!– 閲囪喘绠$悊妯″潡 –>-->
- <view class="common-module purchase-module">
+ <view class="common-module purchase-module" v-if="hasPurchaseItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">閲囪喘绠$悊</text>
@@ -86,7 +86,7 @@
</view>
</view>
<!-- <!– 鍗忓悓鍔炲叕妯″潡 –> -->
- <view class="common-module collaboration-module">
+ <view class="common-module collaboration-module" v-if="hasCollaborationItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">鍗忓悓鍔炲叕</text>
@@ -110,7 +110,7 @@
</view>
</view>
<!-- 瀹夊叏鐢熶骇妯″潡 -->
- <view class="common-module collaboration-module">
+ <view class="common-module collaboration-module" v-if="hasSafetyItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">瀹夊叏鐢熶骇</text>
@@ -134,7 +134,7 @@
</view>
</view>
<!-- 浜哄姏璧勬簮妯″潡 -->
- <view class="common-module collaboration-module">
+ <view class="common-module collaboration-module" v-if="hasHumanResourcesItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">浜哄姏璧勬簮</text>
@@ -158,36 +158,7 @@
</view>
</view>
<!-- 鐢熶骇绠℃帶妯″潡 -->
- <!-- <view class="common-module production-module">-->
- <!-- <view class="module-header">-->
- <!-- <view class="module-title-container">-->
- <!-- <text class="module-title">鐢熶骇绠℃帶</text>-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- <view class="module-content">-->
- <!-- <up-grid-->
- <!-- :border="false"-->
- <!-- col="4"-->
- <!-- >-->
- <!-- <up-grid-item-->
- <!-- v-for="(item, index) in productionItems"-->
- <!-- :key="index"-->
- <!-- @click="handleCommonItemClick(item)"-->
- <!-- >-->
- <!-- <view class="icon-container" :style="{ background: item.bgColor }">-->
- <!-- <up-icon-->
- <!-- :name="item.icon"-->
- <!-- :size="58"-->
- <!-- color="#ffffff"-->
- <!-- ></up-icon>-->
- <!-- </view>-->
- <!-- <text class="item-label">{{item.label}}</text>-->
- <!-- </up-grid-item>-->
- <!-- </up-grid>-->
- <!-- </view>-->
- <!-- </view>-->
- <!-- 鐢熶骇绠℃帶妯″潡 -->
- <view class="common-module equipment-module">
+ <view class="common-module equipment-module" v-if="hasProductionItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">鐢熶骇绠℃帶</text>
@@ -211,7 +182,7 @@
</view>
</view>
<!-- 璁惧绠$悊妯″潡 -->
- <view class="common-module equipment-module">
+ <view class="common-module equipment-module" v-if="hasEquipmentItems">
<view class="module-header">
<view class="module-title-container">
<text class="module-title">璁惧绠$悊</text>
@@ -238,7 +209,7 @@
</template>
<script setup>
- import { ref, onMounted, nextTick, reactive } from "vue";
+ import { ref, onMounted, nextTick, reactive, computed } from "vue";
import { userLoginFacotryList } from "@/api/login";
import { getProductWorkOrderById } from "@/api/productionManagement/productionReporting";
import modal from "@/plugins/modal";
@@ -369,12 +340,8 @@
// 鍗忓悓鍔炲叕鍔熻兘鏁版嵁
const collaborationItems = reactive([
{
- icon: "/static/images/icon/gongchuguanli@2x.png",
- label: "鑰冨嫟绠$悊",
- },
- {
icon: "/static/images/icon/baoxiaoguanli.png",
- label: "璐㈠姟绠$悊",
+ label: "鍗忓悓瀹℃壒",
},
{
icon: "/static/images/icon/huiyiliebiao@2x.png",
@@ -396,10 +363,6 @@
icon: "/static/images/icon/guizhangzhidu@2x.png",
label: "瑙勭珷鍒跺害",
},
- // {
- // icon: "/static/images/icon/xietongshenpi@2x.png",
- // label: "鍗忓悓瀹℃壒",
- // },
{
icon: "/static/images/icon/kehubaifang@2x.png",
label: "瀹㈡埛鎷滆",
@@ -452,26 +415,6 @@
{
icon: "/static/images/icon/shbeibaoyang@2x.png",
label: "璁惧淇濆吇",
- },
- {
- icon: "/static/images/icon/guzhangfenxi@2x.png",
- label: "鍒嗘瀽杩芥函",
- bgColor: "#ff9800",
- },
- {
- icon: "/static/images/icon/zhinengpaidan@2x.png",
- label: "鏅鸿兘娲惧崟",
- bgColor: "#ff6b35",
- },
- {
- icon: "/static/images/icon/zuoyezhidao@2x.png",
- label: "浣滀笟鎸囧",
- bgColor: "#4caf50",
- },
- {
- icon: "/static/images/icon/jieguoyanzheng@2x.png",
- label: "缁撴灉楠岃瘉",
- bgColor: "#9c27b0",
},
{
icon: "/static/images/icon/xunjianshangchuan@2x.png",
@@ -563,19 +506,39 @@
url: "/pages/cooperativeOffice/collaborativeApproval/index4",
});
break;
- case "鑰冨嫟绠$悊":
+ case "鍗忓悓瀹℃壒":
uni.navigateTo({
- url: "/pages/indexItem?label=鑰冨嫟绠$悊",
- });
- break;
- case "璐㈠姟绠$悊":
- uni.navigateTo({
- url: "/pages/indexItem?label=璐㈠姟绠$悊",
+ url: "/pages/indexItem?label=鍗忓悓瀹℃壒",
});
break;
case "浼氳绠$悊":
uni.navigateTo({
url: "/pages/indexItem?label=浼氳绠$悊",
+ });
+ break;
+ case "閫氱煡鍏憡":
+ uni.navigateTo({
+ url: "/pages/cooperativeOffice/noticeManagement/index",
+ });
+ break;
+ case "鐭ヨ瘑搴�":
+ uni.navigateTo({
+ url: "/pages/managementMeetings/knowledgeBase/index",
+ });
+ break;
+ case "鐢ㄥ嵃绠$悊":
+ uni.navigateTo({
+ url: "/pages/managementMeetings/sealManagement/index",
+ });
+ break;
+ case "瑙勭珷鍒跺害":
+ uni.navigateTo({
+ url: "/pages/managementMeetings/rulesRegulationsManagement/index",
+ });
+ break;
+ case "瀹㈡埛鎷滆":
+ uni.navigateTo({
+ url: "/pages/cooperativeOffice/clientVisit/index",
});
break;
case "閲囪喘绠$悊":
@@ -588,7 +551,7 @@
url: "/pages/cooperativeOffice/collaborativeApproval/index6",
});
break;
- case "鍑哄簱绠$悊":
+ case "鍙戣揣瀹℃壒":
uni.navigateTo({
url: "/pages/cooperativeOffice/collaborativeApproval/index7",
});
@@ -626,37 +589,6 @@
case "浼氳鐪嬫澘":
uni.navigateTo({
url: "/pages/managementMeetings/meetingBoard/index",
- });
- break;
- case "閫氱煡鍏憡":
- uni.navigateTo({
- url: "/pages/cooperativeOffice/noticeManagement/index",
- });
- break;
- case "鐭ヨ瘑搴�":
- uni.navigateTo({
- url: "/pages/managementMeetings/knowledgeBase/index",
- });
- break;
- case "鐢ㄥ嵃绠$悊":
- uni.navigateTo({
- url: "/pages/managementMeetings/sealManagement/index",
- });
- break;
- case "瑙勭珷鍒跺害":
- uni.navigateTo({
- url: "/pages/managementMeetings/rulesRegulationsManagement/index",
- });
- break;
-
- case "鍗忓悓瀹℃壒":
- uni.navigateTo({
- url: "/pages/cooperativeOffice/collaborativeApproval/index",
- });
- break;
- case "瀹㈡埛鎷滆":
- uni.navigateTo({
- url: "/pages/cooperativeOffice/clientVisit/index",
});
break;
case "鐢熶骇璁㈠崟":
@@ -910,6 +842,14 @@
});
};
function loginSuccess(result) {
+ // 鑾峰彇璺敱鏉冮檺
+ userStore.getRouters().then(() => {
+ console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
+ // 杩囨护鑿滃崟椤�
+ filterMenuItemsByRoutes();
+ }).catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
uni.reLaunch({
url: "/pages/index",
});
@@ -922,9 +862,156 @@
}
};
+ // 鏍规嵁璺敱鏉冮檺杩囨护鑿滃崟椤�
+ const filterMenuItemsByRoutes = () => {
+ const routers = userStore.routers || [];
+
+ // 濡傛灉娌℃湁璺敱鏉冮檺鏁版嵁锛屼笉杩涜杩囨护锛堟樉绀烘墍鏈夎彍鍗曪級
+ if (!routers || routers.length === 0) {
+ console.log("鏆傛棤璺敱鏉冮檺鏁版嵁锛屾樉绀烘墍鏈夎彍鍗�");
+ return;
+ }
+
+ // 鏀堕泦鎵�鏈夋湁鏉冮檺鐨勮彍鍗曟爣棰橈紙鏍规嵁 meta.title锛�
+ const allowedMenuTitles = new Set();
+ const collectMenuTitles = (routes) => {
+ if (!Array.isArray(routes)) return;
+ routes.forEach(route => {
+ // 鏀堕泦褰撳墠璺敱鐨勬爣棰�
+ if (route.meta && route.meta.title) {
+ allowedMenuTitles.add(route.meta.title);
+ }
+ // 閫掑綊澶勭悊瀛愯矾鐢�
+ if (route.children && route.children.length > 0) {
+ collectMenuTitles(route.children);
+ }
+ });
+ };
+ collectMenuTitles(routers);
+
+ console.log("鍏佽鐨勮彍鍗曟爣棰�:", Array.from(allowedMenuTitles));
+ console.log("杩囨护鍓� - 钀ラ攢绠$悊:", marketingItems.length, "閲囪喘绠$悊:", purchaseItems.length, "鍗忓悓鍔炲叕:", collaborationItems.length);
+ console.log("杩囨护鍓� - 瀹夊叏鐢熶骇:", safetyItems.length, "浜哄姏璧勬簮:", humanResourcesItems.length, "鐢熶骇绠℃帶:", productionItems.length, "璁惧绠$悊:", equipmentItems.length);
+
+ // 杩囨护钀ラ攢绠$悊鑿滃崟
+ const originalMarketing = [
+ { icon: "/static/images/icon/xiaoshoutaizhang@2x.png", label: "閿�鍞彴璐�" },
+ { icon: "/static/images/icon/kaipiaodengji@2x.png", label: "寮�绁ㄧ櫥璁�" },
+ { icon: "/static/images/icon/kaipiaotaizhang@2x.png", label: "寮�绁ㄥ彴璐�" },
+ { icon: "/static/images/icon/huikuandengji@2x.png", label: "鍥炴鐧昏" },
+ { icon: "/static/images/icon/huikuanliushui@2x.png", label: "鍥炴娴佹按" },
+ { icon: "/static/images/icon/kehuwanglai@2x.png", label: "瀹㈡埛寰�鏉�" },
+ ];
+ const filteredMarketing = originalMarketing.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ marketingItems.splice(0, marketingItems.length, ...filteredMarketing);
+
+ // 杩囨护鍗忓悓鍔炲叕鑿滃崟
+ const originalCollaboration = [
+ { icon: "/static/images/icon/baoxiaoguanli.png", label: "鍗忓悓瀹℃壒" },
+ { icon: "/static/images/icon/huiyiliebiao@2x.png", label: "浼氳绠$悊" },
+ { icon: "/static/images/icon/tongzhigonggao@2x.png", label: "閫氱煡鍏憡" },
+ { icon: "/static/images/icon/zhishiku@2x.png", label: "鐭ヨ瘑搴�" },
+ { icon: "/static/images/icon/yongyinguanli@2x.png", label: "鐢ㄥ嵃绠$悊" },
+ { icon: "/static/images/icon/guizhangzhidu@2x.png", label: "瑙勭珷鍒跺害" },
+ { icon: "/static/images/icon/kehubaifang@2x.png", label: "瀹㈡埛鎷滆" },
+ ];
+ const filteredCollaboration = originalCollaboration.filter(item => {
+ // 澶勭悊鏍囬涓嶅畬鍏ㄥ尮閰嶇殑鎯呭喌
+ let matched = allowedMenuTitles.has(item.label);
+ // 鐗规畩澶勭悊锛氳绔犲埗搴� -> 瑙勭珷鍒跺害绠$悊
+ if (!matched && item.label === "瑙勭珷鍒跺害") {
+ matched = allowedMenuTitles.has("瑙勭珷鍒跺害绠$悊");
+ }
+ return matched;
+ });
+ collaborationItems.splice(0, collaborationItems.length, ...filteredCollaboration);
+
+ // 杩囨护閲囪喘绠$悊鑿滃崟
+ const originalPurchase = [
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "閲囪喘鍙拌处" },
+ { icon: "/static/images/icon/laipiaodengji@2x.png", label: "鏉ョエ鐧昏" },
+ { icon: "/static/images/icon/laipiaotaizhang@2x.png", label: "鏉ョエ鍙拌处" },
+ { icon: "/static/images/icon/fukuanjingji@2x.png", label: "浠樻鐧昏" },
+ { icon: "/static/images/icon/fukuanliushui@2x.png", label: "浠樻娴佹按" },
+ { icon: "/static/images/icon/gongyingshangwanglai@2x.png", label: "渚涘簲鍟嗗線鏉�" },
+ ];
+ const filteredPurchase = originalPurchase.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ purchaseItems.splice(0, purchaseItems.length, ...filteredPurchase);
+
+ // 杩囨护瀹夊叏鐢熶骇鑿滃崟
+ const originalSafety = [
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "瑙勭▼璧勮川" },
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "鍗遍櫓婧愬彴璐�" },
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "鍗遍櫓浣滀笟" },
+ { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "闅愭偅鎺掓煡" },
+ { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "鍗遍櫓鐗╂枡" },
+ { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "搴旀�ラ妗�" },
+ { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "浜嬫晠涓婃姤" },
+ { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "瀹夊叏鍩硅" },
+ ];
+ const filteredSafety = originalSafety.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ safetyItems.splice(0, safetyItems.length, ...filteredSafety);
+
+ // 杩囨护浜哄姏璧勬簮鑿滃崟
+ const originalHumanResources = [
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "鎵撳崱绛惧埌" },
+ { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "浜哄憳钖祫" },
+ ];
+ const filteredHumanResources = originalHumanResources.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ humanResourcesItems.splice(0, humanResourcesItems.length, ...filteredHumanResources);
+
+ // 杩囨护鐢熶骇绠℃帶鑿滃崟
+ const originalProduction = [
+ { icon: "/static/images/icon/shengchanbaogong@2x.png", label: "鐢熶骇鎶ュ伐", bgColor: "#673AB7" },
+ ];
+ const filteredProduction = originalProduction.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ productionItems.splice(0, productionItems.length, ...filteredProduction);
+
+ // 杩囨护璁惧绠$悊鑿滃崟
+ const originalEquipment = [
+ { icon: "/static/images/icon/shbeibaoxiu@2x.png", label: "杩愯绠$悊" },
+ { icon: "/static/images/icon/shbeibaoxiu@2x.png", label: "璁惧鎶ヤ慨" },
+ { icon: "/static/images/icon/shbeibaoyang@2x.png", label: "璁惧淇濆吇" },
+ { icon: "/static/images/icon/xunjianshangchuan@2x.png", label: "宸℃涓婁紶" },
+ ];
+ const filteredEquipment = originalEquipment.filter(item => {
+ return allowedMenuTitles.has(item.label);
+ });
+ equipmentItems.splice(0, equipmentItems.length, ...filteredEquipment);
+
+ console.log("杩囨护鍚� - 钀ラ攢绠$悊:", marketingItems.length, "閲囪喘绠$悊:", purchaseItems.length, "鍗忓悓鍔炲叕:", collaborationItems.length);
+ console.log("杩囨护鍚� - 瀹夊叏鐢熶骇:", safetyItems.length, "浜哄姏璧勬簮:", humanResourcesItems.length, "鐢熶骇绠℃帶:", productionItems.length, "璁惧绠$悊:", equipmentItems.length);
+ console.log("鐢熶骇绠℃帶鑿滃崟椤�:", productionItems.map(item => item.label));
+ };
+
+ // 妫�鏌ユā鍧楁槸鍚︽湁鑿滃崟椤归渶瑕佹樉绀�
+ const hasMarketingItems = computed(() => marketingItems.length > 0);
+ const hasPurchaseItems = computed(() => purchaseItems.length > 0);
+ const hasCollaborationItems = computed(() => collaborationItems.length > 0);
+ const hasSafetyItems = computed(() => safetyItems.length > 0);
+ const hasHumanResourcesItems = computed(() => humanResourcesItems.length > 0);
+ const hasProductionItems = computed(() => productionItems.length > 0);
+ const hasEquipmentItems = computed(() => equipmentItems.length > 0);
+
onMounted(() => {
- // 璁剧疆鐢ㄦ埛淇℃伅
- userStore.getInfo();
+ // 姣忔杩涘叆棣栭〉閮藉己鍒跺埛鏂扮敤鎴蜂俊鎭拰璺敱鏉冮檺锛屼笉鍋氭湰鍦扮紦瀛樺垽鏂�
+ userStore.getInfo().then(() => {
+ userStore.getRouters().then(() => {
+ filterMenuItemsByRoutes();
+ }).catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
+ });
getUserLoginFacotryList();
// 鍚姩閫氱煡鐘舵�佸畾鏃跺櫒
startStatusTimer();
diff --git a/src/pages/indexItem.vue b/src/pages/indexItem.vue
index 28940da..8a3a731 100644
--- a/src/pages/indexItem.vue
+++ b/src/pages/indexItem.vue
@@ -56,15 +56,46 @@
},
{
icon: "/static/images/icon/caigouguanli.png",
- label: "閲囪喘绠$悊",
+ label: "閲囪喘瀹℃壒",
},
{
icon: "/static/images/icon/baojiaguanli.png",
- label: "鎶ヤ环绠$悊",
+ label: "鎶ヤ环瀹℃壒",
},
{
icon: "/static/images/icon/chukuguanli@2x.png",
- label: "鍑哄簱绠$悊",
+ label: "鍙戣揣瀹℃壒",
+ },
+ ]);
+ // 鑰冨嫟璐㈠姟鍚堝苟鑿滃崟锛堣�冨嫟3涓� + 璐㈠姟4涓� = 7涓級
+ const kaoqinCaiwu = reactive([
+ {
+ icon: "/static/images/icon/gongchuguanli@2x.png",
+ label: "鍏嚭绠$悊",
+ },
+ {
+ icon: "/static/images/icon/qingjiaguanli@2x.png",
+ label: "璇峰亣绠$悊",
+ },
+ {
+ icon: "/static/images/icon/chuchaiguanli@2x.png",
+ label: "鍑哄樊绠$悊",
+ },
+ {
+ icon: "/static/images/icon/baoxiaoguanli.png",
+ label: "鎶ラ攢绠$悊",
+ },
+ {
+ icon: "/static/images/icon/caigouguanli.png",
+ label: "閲囪喘瀹℃壒",
+ },
+ {
+ icon: "/static/images/icon/baojiaguanli.png",
+ label: "鎶ヤ环瀹℃壒",
+ },
+ {
+ icon: "/static/images/icon/chukuguanli@2x.png",
+ label: "鍙戣揣瀹℃壒",
},
]);
@@ -183,17 +214,17 @@
url: "/pages/cooperativeOffice/collaborativeApproval/index4",
});
break;
- case "閲囪喘绠$悊":
+ case "閲囪喘瀹℃壒":
uni.navigateTo({
url: "/pages/cooperativeOffice/collaborativeApproval/index5",
});
break;
- case "鎶ヤ环绠$悊":
+ case "鎶ヤ环瀹℃壒":
uni.navigateTo({
url: "/pages/cooperativeOffice/collaborativeApproval/index6",
});
break;
- case "鍑哄簱绠$悊":
+ case "鍙戣揣瀹℃壒":
uni.navigateTo({
url: "/pages/cooperativeOffice/collaborativeApproval/index7",
});
@@ -350,6 +381,9 @@
commonItems.value = huiyi;
} else if (operationType.value === "璐㈠姟绠$悊") {
commonItems.value = caiwu;
+ } else if (operationType.value === "鍗忓悓瀹℃壒") {
+ commonItems.value = kaoqinCaiwu;
+ operationType.value = "鍗忓悓瀹℃壒";
}
}
console.log(operationType.value);
diff --git a/src/pages/login.vue b/src/pages/login.vue
index 9135392..f717c26 100644
--- a/src/pages/login.vue
+++ b/src/pages/login.vue
@@ -160,6 +160,12 @@
function loginSuccess(result) {
// 璁剧疆鐢ㄦ埛淇℃伅
userStore.getInfo().then(res => {
+ // 鑾峰彇璺敱鏉冮檺
+ userStore.getRouters().then(() => {
+ console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
+ }).catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
// 鐧诲綍鎴愬姛鍚庯紝灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
sendClientIdToServer();
uni.switchTab({
diff --git a/src/pages_template/pages/login/index2.vue b/src/pages_template/pages/login/index2.vue
index 0573fe5..f8bd3c4 100644
--- a/src/pages_template/pages/login/index2.vue
+++ b/src/pages_template/pages/login/index2.vue
@@ -199,9 +199,16 @@
// 鐧诲綍鎴愬姛鍚庯紝澶勭悊鍑芥暟
const loginSuccess = result => {
// 璁剧疆鐢ㄦ埛淇℃伅
- useUserStore()
+ const userStore = useUserStore();
+ userStore
.getInfo()
.then(res => {
+ // 鑾峰彇璺敱鏉冮檺
+ userStore.getRouters().then(() => {
+ console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
+ }).catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
// 鐧诲綍鎴愬姛鍚庯紝灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
sendClientIdToServer();
tab.reLaunch("/pages/index");
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 72722dd..140e0a3 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,4 +1,5 @@
import {logout, getInfo, loginCheckFactory} from "@/api/login";
+import { getRouters as getRoutersApi } from "@/api/menu";
import { getToken, setToken, removeToken } from "@/utils/auth";
import defAva from "@/static/images/profile.jpg";
import { defineStore } from "pinia";
@@ -22,6 +23,7 @@
currentLoginTime: "",
roles: Array(),
permissions: [],
+ routers: [], // 璺敱鏉冮檺鏁版嵁
}),
actions: {
// 閮ㄩ棬鐧诲綍
@@ -75,6 +77,7 @@
this.token = "";
this.roles = [];
this.permissions = [];
+ this.routers = [];
this.name = "";
this.avatar = "";
removeToken();
@@ -95,6 +98,20 @@
const seconds = String(now.getSeconds()).padStart(2, '0'); // 绉掓暟琛ラ浂
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
+ // 鑾峰彇璺敱鏉冮檺
+ getRouters() {
+ return new Promise((resolve, reject) => {
+ getRoutersApi()
+ .then((res: any) => {
+ // 瀛樺偍璺敱鏉冮檺鏁版嵁
+ this.routers = res.data || [];
+ resolve(res);
+ })
+ .catch((error) => {
+ reject(error);
+ });
+ });
+ },
},
});
--
Gitblit v1.9.3