wuhb 3 месяцев назад
Родитель
Сommit
51cadf2116
1 измененных файлов с 42 добавлено и 13 удалено
  1. 42 13
      pages/index/index.uvue

+ 42 - 13
pages/index/index.uvue

@@ -70,7 +70,7 @@
 <script setup lang="uts">
     import { ref, onMounted, onUnmounted } from 'vue'
     import { getUserInfo } from '../../utils/storage'
-    import { getPendingReceiveLines, signReceiveLine } from '../../api/out/index'
+    import { getPendingReceiveLines, signReceiveLine, getProductSalseList } from '../../api/out/index'
     type QuickFunction = {
         id: number
         title: string
@@ -101,7 +101,7 @@
             bgImage: '/static/images/workbench/2.png',
             icon: '',
             path: '/pages/out/index',
-			badge: 2
+			badge: 0
         },
         {
             id: 3,
@@ -235,15 +235,42 @@ const loadReceiveList = (): void => {
             timerLock = false
         }
     }
+
+	// 加载出库单 badge 数量
+	const loadOutstockBadge = (): void => {
+		if (currentUserId.length === 0) return
+		// 查询待签收的出库单
+		getProductSalseList(1, 100, '', currentUserId, 'PENDING').then((res: any) => {
+			const result = res as UTSJSONObject
+			const rows = result['rows']
+			if (rows != null) {
+				const data = rows as UTSJSONObject[]
+				// 统计待签收数量大于0的出库单个数
+				const pendingCount = data.filter((item: UTSJSONObject) => {
+					const unsignedCount = item['unsignedCount']
+					return unsignedCount != null && parseInt(unsignedCount.toString()) > 0
+				}).length
+				// 更新快捷功能中的出库单 badge
+				quickFunctions.value.forEach((functionItem) => {
+					if (functionItem.id === 2) {
+						functionItem.badge = pendingCount
+					}
+				})
+			}
+		}).catch((e) => {
+			console.error('加载出库单 badge 失败:', e)
+		})
+	}	
 	// 启动定时刷新
 	const startRefreshTimer = (): void => {
 	    stopRefreshTimer() // 先清除已有的定时器
 	    timerLock = true
 	    refreshTimer = setInterval(() => {
 	        if (currentUserId.length > 0) {
-	            loadReceiveList()
-	        }
-	    }, 5000) // 5秒刷新一次
+				loadReceiveList()
+				loadOutstockBadge()
+			}
+		}, 5000) // 5秒刷新一次
 	}
     // 初始化
     onMounted(() => {
@@ -255,6 +282,8 @@ const loadReceiveList = (): void => {
             currentUserId = userId != null ? userId.toString() : ''
             // 加载待签收列表
             loadReceiveList()
+            // 加载出库单 badge 数量
+            loadOutstockBadge()
             // 启动定时刷新,每5秒刷新一次
             startRefreshTimer()
         }
@@ -469,12 +498,12 @@ const loadReceiveList = (): void => {
         }
 
         .detail-link {
-            font-size: 24rpx;
+            font-size: 26rpx;
             color: #999999;
         }
 
         .item-type {
-            font-size: 20rpx;
+            font-size: 22rpx;
             color: #007aff;
             background-color: #e6f7ff;
             padding: 6rpx 12rpx;
@@ -484,10 +513,10 @@ const loadReceiveList = (): void => {
     }
     
     .item-address {
-        font-size: 22rpx;
+        font-size: 24rpx;
         color: #999999;
         margin-bottom: 12rpx;
-        line-height: 32rpx;
+        line-height: 36rpx;
     }
     
     .item-info {
@@ -509,7 +538,7 @@ const loadReceiveList = (): void => {
                 align-items: center;
 
                 .info-label {
-                    font-size: 22rpx;
+                    font-size: 28rpx;
                     color: #666666;
                     margin-right: 6rpx;
                     white-space: nowrap;
@@ -517,7 +546,7 @@ const loadReceiveList = (): void => {
 
                 .info-value {
                     flex: 1;
-                    font-size: 22rpx;
+                    font-size: 28rpx;
                     color: #333333;
                     
                     &.status-pending {
@@ -535,10 +564,10 @@ const loadReceiveList = (): void => {
     }
 
     .receive-btn {
-        padding: 10rpx 24rpx;
+        padding: 0rpx 20rpx;
         background-color: #007aff;
         color: #ffffff;
-        font-size: 22rpx;
+        font-size: 28rpx;
         border-radius: 6rpx;
         border: none;
     }