From c338f12193ffea6922df314c4cb552ecea762fe3 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期二, 06 一月 2026 20:00:52 +0800
Subject: [PATCH] #

---
 pages/home/index.vue        |  497 ++++++++++++++++++++-----------------------------------
 pages/emptyTray/inBound.vue |   18 +
 2 files changed, 194 insertions(+), 321 deletions(-)

diff --git a/pages/emptyTray/inBound.vue b/pages/emptyTray/inBound.vue
index b5f06f6..eaa1675 100644
--- a/pages/emptyTray/inBound.vue
+++ b/pages/emptyTray/inBound.vue
@@ -65,8 +65,8 @@
 
 
 		<view class="cu-bar btn-group foot">
-			<button class="cu-btn text-blue line-blue shadow" @click="clear">娓呯┖</button>
-			<button class="cu-btn bg-blue shadow-blur" @click="confirm">鍥炲簱</button>
+			<button v-if="hasButtonPermission('reset')" class="cu-btn text-blue line-blue shadow" @click="clear">娓呯┖</button>
+			<button v-if="hasButtonPermission('submit')" class="cu-btn bg-blue shadow-blur" @click="confirm">鍥炲簱</button>
 		</view>
 
 		<uni-popup ref="popup" class="cu-popup">
@@ -113,13 +113,18 @@
 				container: '',
 				list: [],
 				range: [],
-				curCode: ''
+				curCode: '',
+				buttonPermissions: [] // 鎸夐挳鏉冮檺鍒楄〃
 			}
 		},
 		computed: {
 			...mapState('user', ['dynamicFields']),
 		},
-		mounted() {},
+		mounted() {
+			// 鑾峰彇鎸夐挳鏉冮檺
+			this.buttonPermissions = uni.getStorageSync('buttonPermissions') || [];
+			console.log('褰撳墠椤甸潰鎸夐挳鏉冮檺:', this.buttonPermissions);
+		},
 		methods: {
 			async search() {
 				const {
@@ -141,6 +146,11 @@
 					})
 				}
 			},
+			
+			// 妫�鏌ユ寜閽潈闄�
+			hasButtonPermission(route) {
+				return this.buttonPermissions.includes(route);
+			},
 
 			remove(index) {
 				this.list.splice(index, 1);
diff --git a/pages/home/index.vue b/pages/home/index.vue
index 14543a6..ce43617 100644
--- a/pages/home/index.vue
+++ b/pages/home/index.vue
@@ -11,335 +11,188 @@
 			<view class="cu-btn bg-red margin-tb-sm lg round" style="position: absolute; right: 20px; width: 30%; height: 50%;" @click="equit">{{$t('index.outLogin')}}</view>
 		</view>
 		
-		<view class="cu-bar bg-white solid-bottom margin-top-sm">
-			<view class="action">
-				<text class="cuIcon-title text-orange "></text> 鍏ュ簱
-			</view>
-		</view>		
-		<view class="cu-list grid col-4 no-border">
-			<!-- 绌烘墭鍏ュ簱 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/emptyTray/inBound" navigateTo>
-					<view class="cuIcon-pulldown text-blue"></view>
-					<text>{{$t('index.emptyInBound')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/rece/standard" navigateTo>
-					<view class="cuIcon-apps text-blue">
-					</view>
-					<text>鏍囧噯鏀惰揣</text>
-				</navigator>
-			</view> 
-			<!-- 鍗曟嵁缁勬墭 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/listing/matnrPalletising" navigateTo>
-					<view class="cuIcon-cardboard text-blue"></view>
-					<text>{{$t('index.palletizing')}}</text>
-				</navigator>
-			</view>
-			<!-- 缁勬墭瑙g粦 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/listing/unPakin" navigateTo>
-					<view class="cuIcon-cardboardforbid text-blue"></view>
-					<text>{{$t('index.palletBuilding')}}</text>
-				</navigator>
-			</view>
-			<!-- 鍚姩鍏ュ簱 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/AGV/StartInTask" navigateTo>
-					<view class="cuIcon-pulldown text-blue"></view>
-					<text>{{$t('index.inboundInitiation')}}</text>
-				</navigator>
-			</view>
-			<!-- 鍏ュ簱璁㈠崟 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/inbound/orderIn" navigateTo>
-					<view class="cuIcon-addressbook text-blue"></view>
-					<text>{{$t('index.orderIn')}}</text>
-				</navigator>
-			</view>
-			<!-- 浜哄伐涓婃灦 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/listing/labour" navigateTo>
-					<view class="cuIcon-friendadd text-blue"></view>
-					<text>{{$t('index.manualPutaway')}}</text>
-				</navigator>
-			</view>
-			<!-- 鐏屾《鍏ュ簱锛氱紦瀛樺尯琚嬭濉戞枡绮掑瓙鐏屾《鍚庡叆搴� -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/inbound/buffStore" navigateTo>
-					<view class="cuIcon-all text-blue"></view>
-					<text>{{$t('index.buffStore')}}</text>
-				</navigator>
-			</view>
-			
-<!-- 			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/rece/other" navigateTo>
-					<view class="cuIcon-taoxiaopu text-blue">
-					</view>
-					<text>{{$t('index.GR')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/inspect/report" navigateTo>
-					<view class="cuIcon-edit text-blue">
-					</view>
-					<text>{{$t('index.inspectionRequest')}}</text>
-				</navigator>
-			</view>
-			
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/listing/disc" navigateTo>
-					<view class="cuIcon-cardboard text-blue">
-					</view>
-					<text>缁勭洏</text>
-				</navigator>
-			</view> -->
+		<!-- 鍔犺浇涓彁绀� -->
+		<view v-if="loading" class="loading-container">
+			<text>鍔犺浇涓�...</text>
 		</view>
 		
+		<!-- 鍔ㄦ�佽彍鍗曞尯鍩� -->
+		<block v-for="category in filteredMenus" :key="category.id">
+			<view class="cu-bar bg-white solid-bottom margin-top-sm">
+				<view class="action">
+					<text class="cuIcon-title text-orange "></text> {{category.name}}
+				</view>
+			</view>
+			<view class="cu-list grid col-4 no-border">
+				<view class="cu-item" v-for="menu in category.menus" :key="menu.id" @click="goToPage(menu)">
+					<view :class="'cuIcon-' + menu.icon + ' text-blue'"></view>
+					<text>{{menu.name}}</text>
+				</view>
+			</view>
+		</block>
 		
-		<view class="cu-bar bg-white solid-bottom margin-top-sm">
-			<view class="action">
-				<text class="cuIcon-title text-orange "></text> 鍑哄簱
-			</view>
-		</view>		
-		<view class="cu-list grid col-4 no-border">
-			<!-- 绌烘墭鍑哄簱 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/emptyTray/outBound" navigateTo>
-					<view class="cuIcon-pullup text-blue"></view>
-					<text>{{$t('index.emptyOutBound')}}</text>
-				</navigator>
-			</view>
-			<!-- 璁㈠崟鍑哄簱 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/orderPick" navigateTo>
-					<view class="cuIcon-addressbook text-blue"></view>
-					<text>{{$t('index.orderPick')}}</text>
-				</navigator>
-			</view>			
-			<!-- 鐢熶骇鐩撮�侊細鍘熸潗鏂欎笉鍏ュ簱鐩存帴閫佷骇绾� -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/matDirectDelivery" navigateTo>
-					<view class="cuIcon-deliver text-blue"></view>
-					<text>{{$t('index.matDirectDelivery')}}</text>
-				</navigator>
-			</view>
-			<!-- 鎴愬搧鐩村嚭锛氭垚鍝佷笉鍏ョ珛搴撶洿鎺ュ嚭搴� -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/productDirectDelivery" navigateTo>
-					<view class="cuIcon-deliver_fill text-blue"></view>
-					<text>{{$t('index.productDirectDelivery')}}</text>
-				</navigator>
-			</view>			
-			<!-- 鍑哄簱璁㈠崟 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/orderOut" navigateTo>
-					<view class="cuIcon-addressbook text-blue"></view>
-					<text>{{$t('index.orderPickGroup')}}</text>
-				</navigator>
-			</view>
-			<!-- 鐢熶骇澶囨枡 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/matPreparation" navigateTo>
-					<view class="cuIcon-present text-blue"></view>
-					<text>{{$t('index.matPreparation')}}</text>
-				</navigator>
-			</view>
-			
-			<!-- 鐢熶骇鍙枡 -->
-<!-- 			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/productionMatCall" navigateTo>
-					<view class="cuIcon-apps text-blue">
-					</view>
-					<text>{{$t('index.productionMatCall')}}</text>
-				</navigator>
-			</view> -->
+		<!-- 鏃犺彍鍗曟潈闄愭椂鏄剧ず鎻愮ず -->
+		<view v-if="!loading && filteredMenus.length === 0" class="no-permission">
+			<text>鏆傛棤鍙敤鑿滃崟</text>
 		</view>
-		
-		
-		<view class="cu-bar bg-white solid-bottom margin-top-sm">
-			<view class="action">
-				<text class="cuIcon-title text-orange "></text> 缁煎悎
-			</view>
-		</view>		
-		<view class="cu-list grid col-4 no-border">
-			<!-- 璋冩嫧璁㈠崟 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/transfer/transferType" navigateTo>
-					<view class="cuIcon-addressbook text-blue"></view>
-					<text>{{$t('index.orderTransfer')}}</text>
-				</navigator>
-			</view>
-			<!-- 绉诲簱 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/transfer/matTransfer" navigateTo>
-					<view class="cuIcon-location text-blue"></view>
-					<text>{{$t('index.matTransfer')}}</text>
-				</navigator>
-			</view>
-			<!-- 鐩樼偣 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/check/checkOrder" navigateTo>
-					<view class="cuIcon-roundcheck text-blue"></view>
-					<text>{{$t('index.checkOrder')}}</text>
-				</navigator>
-			</view>
-			<!-- 璐ㄦ涓婇攣 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/inspect/bad" navigateTo>
-					<view class="cuIcon-lock text-blue"></view>
-					<text>{{$t('index.defectiveMarking')}}</text>
-				</navigator>
-			</view>
-			<!-- 璐ㄦ瑙i攣 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/inspect/check" navigateTo>
-					<view class="cuIcon-unlock text-blue"></view>
-					<text>{{$t('index.qualityInspection')}}</text>
-				</navigator>
-			</view>
-			<!-- 宸ヤ綔浠诲姟 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/workInfo/taskInfo" navigateTo>
-					<view class="cuIcon-tagfill text-blue"></view>
-					<text>{{$t('index.taskInfo')}}</text>
-				</navigator>
-			</view>
-			<!-- 绔欑偣缁存姢 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/workInfo/stationInfo" navigateTo>
-					<view class="cuIcon-service text-blue"></view>
-					<text>{{$t('index.stationInfo')}}</text>
-				</navigator>
-			</view>
-			<!-- 搴撲綅缁存姢 -->
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/workInfo/locInfo" navigateTo>
-					<view class="cuIcon-servicefill text-blue"></view>
-					<text>{{$t('index.locInfo')}}</text>
-				</navigator>
-			</view>
-				
-			<!-- <view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/fastPicking" navigateTo>
-					<view class="cuIcon-apps text-blue">
-					</view>
-					<text>{{$t('index.quickPicking')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/outbound/wavePickItem" navigateTo>
-					<view class="cuIcon-apps text-blue">
-					</view>
-					<text>{{$t('index.wavePick')}}</text>
-				</navigator>
-			</view> -->
-<!-- 			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/check/firstCheck" navigateTo>
-					<view class="cuIcon-apps text-blue"></view>
-					<text>{{$t('index.checkOrder')}}</text>
-				</navigator>
-			</view> -->
-		</view>
-		
-		
-		<!-- <view class="cu-bar bg-white solid-bottom margin-top-sm">
-			<view class="action">
-				<text class="cuIcon-title text-orange "></text> AGV
-			</view>
-		</view>
-		
-		<view class="cu-list grid col-4 no-border">
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/AGV/AGVStaBind" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationBinding')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/AGV/StartInTask" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.inboundInitiation')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/AGV/StaUnBind" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationUnbinding')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/AGV/BindAndInTask" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.bindAndInbound')}}</text>
-				</navigator>
-			</view>		
-		</view> -->
-
-
-		<!-- <view class="cu-bar bg-white solid-bottom margin-top-sm">
-			<view class="action">
-				<text class="cuIcon-title text-orange "></text> 寮�鍙�
-			</view>
-		</view>
-		
-		<view class="cu-list grid col-4 no-border">
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/phyz/stationManage/stationManage" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationBinding')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/home/orderManage" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationBinding')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/home/locMastManage" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationBinding')}}</text>
-				</navigator>
-			</view>
-			<view class="cu-item">
-				<navigator hover-class='none' url="/pages/home/wrkMastManage" navigateTo>
-					<view class="cuIcon-punch text-blue">
-					</view>
-					<text>{{$t('index.stationBinding')}}</text>
-				</navigator>
-			</view> -->
-		</view>
-		
-
-<!-- 		<view class="padding flex flex-direction">
-			<view class="cu-btn bg-red margin-tb-sm lg round" @click="equit">{{$t('index.outLogin')}}</view>
-		</view> -->
-	</view>
 	</view>
 </template>
 
 <script>
+	import {
+		request
+	} from '../../common/request2.js'
+	
 	export default {
 		data() {
 			return {
-				user:{					
-				}
+				user: {},
+				menuTree: [],        // 瀹屾暣鑿滃崟鏍�
+				permissionIds: new Set(), // 鐢ㄦ埛鏉冮檺ID闆嗗悎
+				filteredMenus: [],   // 鎸夊垎绫荤粍缁囩殑杩囨护鍚庤彍鍗�
+				loading: true        // 鍔犺浇鐘舵��
 			}
 		},
 		onShow() {
-			this.user = uni.getStorageSync('userData');			
+			this.user = uni.getStorageSync('userData');
+			this.loadMenusAndPermissions();
 		},
 		methods: {
+			// 骞惰鑾峰彇鑿滃崟鍜屾潈闄愭暟鎹�
+			async loadMenusAndPermissions() {
+				this.loading = true;
+				try {
+					const [menuRes, permRes] = await Promise.all([
+						this.fetchMenuTree(),
+						this.fetchPermissions()
+					]);
+					this.menuTree = menuRes;
+					this.permissionIds = new Set(permRes);
+					this.filterMenus();
+				} catch (e) {
+					console.error('鍔犺浇鑿滃崟鏉冮檺澶辫触:', e);
+					uni.showToast({
+						title: '鍔犺浇鑿滃崟澶辫触',
+						icon: 'none'
+					});
+				} finally {
+					this.loading = false;
+				}
+			},
+			
+			// 鑾峰彇鑿滃崟鏍�
+			async fetchMenuTree() {
+				const { code, data, msg } = await request('/menuPda/tree', {});
+				if (code === 200) {
+					return data || [];
+				} else if (code === 403) {
+					uni.showToast({
+						title: msg,
+						icon: 'none'
+					});
+					setTimeout(() => {
+						uni.reLaunch({
+							url: '/pages/login/index'
+						});
+					}, 1000);
+					throw new Error(msg);
+				} else {
+					throw new Error(msg || '鑾峰彇鑿滃崟澶辫触');
+				}
+			},
+			
+			// 鑾峰彇鏉冮檺锛堟敮鎸佸瑙掕壊锛�
+			async fetchPermissions() {				
+				const roleIds = this.user.userRoleIds || [];
+				console.log('roleIds:', roleIds);
+				if (roleIds.length === 0) {
+					console.warn('鐢ㄦ埛娌℃湁瑙掕壊ID');
+					return [];
+				}
+				const allIds = [];
+				for (const roleId of roleIds) {
+					console.log('璇锋眰瑙掕壊鏉冮檺, roleId:', roleId);
+					const ids = await this.fetchRolePermission(roleId);
+					console.log('瑙掕壊鏉冮檺缁撴灉:', ids);
+					allIds.push(...ids);
+				}
+				return [...new Set(allIds)]; // 鍘婚噸鍚堝苟
+			},
+			
+			// 鑾峰彇鍗曚釜瑙掕壊鐨勬潈闄�
+			async fetchRolePermission(roleId) {
+				try {
+					const { code, data } = await request('/rolePda/scope/list', { roleId: roleId },'GET');
+					if (code === 200) {
+						return data || [];
+					}
+					return [];
+				} catch (e) {
+					return [];
+				}
+			},
+			
+			// 杩囨护鑿滃崟骞舵寜鍒嗙被缁勭粐
+			filterMenus() {
+				this.filteredMenus = [];
+				for (const category of this.menuTree) {
+					if (category.type === 1) continue; // 璺宠繃鎸夐挳
+					
+					const menus = this.filterChildren(category.children || []);
+					// 鍙湁褰撳垎绫绘湁鍙瀛愯彍鍗曟椂鎵嶆樉绀鸿鍒嗙被
+					if (menus.length > 0) {
+						this.filteredMenus.push({
+							id: category.id,
+							name: category.name,
+							menus: menus
+						});
+					}
+				}
+			},
+			
+			// 杩囨护瀛愯彍鍗�
+			filterChildren(children) {
+				return children.filter(item => {
+					if (item.type === 1) return false; // 杩囨护鎸夐挳
+					return this.permissionIds.has(item.id);
+				}).map(item => ({
+					id: item.id,
+					name: item.name,
+					route: '/pages' + item.route,
+					icon: item.component || 'apps', // 榛樿鍥炬爣
+					buttons: this.getButtons(item.children || [])
+				}));
+			},
+			
+			// 鑾峰彇鎸夐挳鏉冮檺
+			getButtons(children) {
+				return children.filter(item => item.type === 1 && this.permissionIds.has(item.id))
+					.map(btn => ({
+						id: btn.id,
+						name: btn.name,
+						route: btn.route
+					}));
+			},
+			
+			// 妫�鏌ユ潈闄愶紙渚涘叾浠栧湴鏂逛娇鐢級
+			hasPermission(id) {
+				return this.permissionIds.has(id);
+			},
+			
+			// 璺宠浆椤甸潰骞朵紶閫掓寜閽潈闄�
+			goToPage(menu) {
+				// 灏嗘寜閽潈闄愬瓨鍏� storage锛屼互 route 涓� key
+				const buttonRoutes = (menu.buttons || []).map(btn => btn.route);
+				uni.setStorageSync('buttonPermissions', buttonRoutes);
+				console.log('鎸夐挳鏉冮檺:', buttonRoutes);
+				
+				// 璺宠浆椤甸潰
+				uni.navigateTo({
+					url: menu.route
+				});
+			},
+			
+			// 閫�鍑虹櫥褰�
 			equit() {
 				uni.showToast({
 					title: '娉ㄩ攢鎴愬姛',
@@ -357,10 +210,6 @@
 </script>
 
 <style>
-	/* .container {
-		background-color: #fff;
-	} */
-
 	.user-bg {
 		display: flex;
 		flex-direction: row;
@@ -387,4 +236,18 @@
 		height: 160rpx;
 		border-radius: 50%;
 	}
+	.loading-container {
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		padding: 40rpx;
+		color: #999;
+	}
+	.no-permission {
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		padding: 80rpx;
+		color: #999;
+	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1