Quellcode durchsuchen

物料申请统计功能

wuhb vor 5 Tagen
Ursprung
Commit
fb81d3b664
2 geänderte Dateien mit 45 neuen und 15 gelöschten Zeilen
  1. 11 0
      api/apply/index.uts
  2. 34 15
      pages/index/index.uvue

+ 11 - 0
api/apply/index.uts

@@ -172,3 +172,14 @@ export const getPendingReceiveApplyCount = (userId: string): Promise<any> => {
 		method: 'GET'
 	})
 }
+
+/**
+ * 获取已确认单据数量
+ * @returns 
+ */
+export const getConfirmedApplyCount = (): Promise<any> => {
+	return request({
+		url: '/mes/wm/purchaseApply/countConfirmed',
+		method: 'GET'
+	})
+}

+ 34 - 15
pages/index/index.uvue

@@ -70,8 +70,9 @@
 <script setup lang="uts">
     import { ref, onMounted, onUnmounted } from 'vue'
     import { getUserInfo } from '../../utils/storage'
+    import { checkPermission } from '../../utils/permission'
     import { getPendingReceiveLines, signReceiveLine, getProductSalseList } from '../../api/out/index'
-    import { getPendingReceiveApplyCount } from '../../api/apply/index'
+    import { getPendingReceiveApplyCount, getConfirmedApplyCount } from '../../api/apply/index'
     type QuickFunction = {
         id: number
         title: string
@@ -264,22 +265,40 @@ const loadReceiveList = (): void => {
 		})
 	}
 	
-	// 加载物料申请待领取 badge 数量
+	// 加载物料申请 badge 数量
 	const loadApplyBadge = (): void => {
-		if (currentUserId.length === 0) return
-		// 查询物料申请待领取数量
-		getPendingReceiveApplyCount(currentUserId).then((res: any) => {
-			const result = res as UTSJSONObject
-			const count = result['data']
-			// 更新快捷功能中的物料申请 badge
-			quickFunctions.value.forEach((functionItem) => {
-				if (functionItem.id === 1) {
-					functionItem.badge = count != null ? parseInt(count.toString()) : 0
-				}
+		const hasPurchasePermission = checkPermission('mes:wm:mergePurchase:add')
+		
+		if (hasPurchasePermission) {
+			// 有采购权限,统计已确认单据数量
+			getConfirmedApplyCount().then((res: any) => {
+				const result = res as UTSJSONObject
+				const count = result['data']
+				// 更新快捷功能中的物料申请 badge
+				quickFunctions.value.forEach((functionItem) => {
+					if (functionItem.id === 1) {
+						functionItem.badge = count != null ? parseInt(count.toString()) : 0
+					}
+				})
+			}).catch((e) => {
+				console.error('加载物料申请 badge 失败:', e)
 			})
-		}).catch((e) => {
-			console.error('加载物料申请 badge 失败:', e)
-		})
+		} else {
+			// 没有采购权限,统计待领取数量(保持现状)
+			if (currentUserId.length === 0) return
+			getPendingReceiveApplyCount(currentUserId).then((res: any) => {
+				const result = res as UTSJSONObject
+				const count = result['data']
+				// 更新快捷功能中的物料申请 badge
+				quickFunctions.value.forEach((functionItem) => {
+					if (functionItem.id === 1) {
+						functionItem.badge = count != null ? parseInt(count.toString()) : 0
+					}
+				})
+			}).catch((e) => {
+				console.error('加载物料申请 badge 失败:', e)
+			})
+		}
 	}
 	// 启动定时刷新
 	const startRefreshTimer = (): void => {