From 4fbdf4c6b13d19b9be54900b5dcff29e2ca7ef01 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 24 六月 2025 17:31:45 +0800
Subject: [PATCH] 巡查单据自动下载功能(待完成)

---
 src/views/fysp/check/ProCheckProxy.js |  240 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 196 insertions(+), 44 deletions(-)

diff --git a/src/views/fysp/check/ProCheckProxy.js b/src/views/fysp/check/ProCheckProxy.js
index 6487082..013e0c9 100644
--- a/src/views/fysp/check/ProCheckProxy.js
+++ b/src/views/fysp/check/ProCheckProxy.js
@@ -1,4 +1,4 @@
-import { $fysp } from '@/api/index'
+import { $fysp } from '@/api/index';
 
 //闂鐘舵��
 const proStatus = {
@@ -8,7 +8,7 @@
   change_unCheck: 'change_unCheck',
   change_fail: 'change_fail',
   change_pass: 'change_pass'
-}
+};
 
 export default {
   //缁熻闂
@@ -16,8 +16,12 @@
     const status = {
       //闂鏁伴噺
       proNum: proList.length,
+      // 闂瀹℃牳鏁�
+      proCheckedNum: 0,
       //鏁存敼鏁伴噺
       changeNum: 0,
+      //鏁存敼瀹℃牳鏁伴噺
+      changeCheckedNum: 0,
       //寰呭鏍告暟閲�
       uncheckNum: 0,
       //宸插鏍搁�氳繃鏁伴噺
@@ -25,61 +29,103 @@
       //鏈�氳繃鏁伴噺
       unpassNum: 0,
       //鏁存敼鐜�
-      changePer: '0%',
+      changePer: '--',
       //閫氳繃鐜�
       passPer: '0%',
       //瀹℃牳鐜�
       checkPer: '0%'
-    }
+    };
 
     proList.forEach((p) => {
-      if (p.ischanged) status.changeNum++
+      if (p.ischanged) status.changeNum++;
 
-      if (p.extension3 == 'fail' || p.extension3 == 'change_fail') status.unpassNum++
+      if (p.extension3 == 'fail' || p.extension3 == 'change_fail')
+        status.unpassNum++;
       else if (
         p.extension3 == 'unCheck' ||
         p.extension3 == 'change_unCheck' ||
         (p.extension3 == 'pass' && p.ischanged)
       )
-        status.uncheckNum++
-      else status.passNum++
+        status.uncheckNum++;
+      else status.passNum++;
+
+      if (p.extension3 != proStatus.unCheck) {
+        status.proCheckedNum++;
+      }
+      if (p.extension3 == proStatus.change_pass || p.extension3 == proStatus.change_fail) {
+        status.changeCheckedNum++;
+      }
 
       status.changePer =
         String(
           (status.changeNum / status.proNum) * 100
             ? ((status.changeNum / status.proNum) * 100).toFixed(1)
             : 0
-        ) + '%'
+        ) + '%';
       status.passPer =
         String(
           (status.passNum / status.proNum) * 100
             ? ((status.passNum / status.proNum) * 100).toFixed(1)
             : 0
-        ) + '%'
+        ) + '%';
       status.checkPer =
         String(
           ((status.passNum + status.unpassNum) / status.proNum) * 100
-            ? (((status.passNum + status.unpassNum) / status.proNum) * 100).toFixed(1)
+            ? (
+                ((status.passNum + status.unpassNum) / status.proNum) *
+                100
+              ).toFixed(1)
             : 0
-        ) + '%'
-    })
+        ) + '%';
+    });
 
-    return status
+    return status;
   },
 
   //缁熻闂锛岃繑鍥炴暟缁勫舰寮�
   proStatusArray(proList) {
-    const status = this.calProStatus(proList)
+    const status = this.calProStatus(proList);
     return [
-      { name: '闂鏁�', value: status.proNum },
-      { name: '鏁存敼鏁�', value: status.changeNum },
-      { name: '寰呭鏍�', value: status.uncheckNum },
-      { name: '宸插鏍�', value: status.passNum },
-      { name: '鏈�氳繃', value: status.unpassNum },
-      { name: '鏁存敼鐜�', value: status.changePer },
-      { name: '閫氳繃鐜�', value: status.passPer },
-      { name: '瀹℃牳鐜�', value: status.checkPer }
-    ]
+      { name: '闂鏁�', value: status.proNum, type: 'info' },
+      {
+        name: '鏁存敼鏁�',
+        value: status.changeNum,
+        type: status.changeNum < status.proNum ? 'danger' : 'info'
+      },
+      {
+        name: '寰呭鏍�',
+        value: status.uncheckNum,
+        type: status.uncheckNum > 0 ? 'danger' : 'info'
+      },
+      { name: '宸插鏍�', value: status.passNum, type: 'info' },
+      // {
+      //   name: '鏈�氳繃',
+      //   value: status.unpassNum,
+      //   type: status.unpassNum > 0 ? 'danger' : 'info'
+      // },
+      {
+        name: '鏁存敼鐜�',
+        value: status.changePer,
+        type:
+          status.proNum > 0 && status.changePer != '100.0%'
+            ? 'danger'
+            : 'success'
+      },
+      // {
+      //   name: '閫氳繃鐜�',
+      //   value: status.passPer,
+      //   type:
+      //     status.proNum > 0 && status.passPer != '100.0%' ? 'danger' : 'success'
+      // },
+      {
+        name: '瀹℃牳鐜�',
+        value: status.checkPer,
+        type:
+          status.proNum > 0 && status.checkPer != '100.0%'
+            ? 'danger'
+            : 'success'
+      }
+    ];
   },
 
   //闂鍥剧墖鍜屾暣鏀瑰浘鐗�
@@ -93,34 +139,118 @@
         title: '鏁存敼鍥剧墖',
         path: []
       }
-    ]
+    ];
     if (pro.mediafileList) {
       pro.mediafileList.forEach((m) => {
-        pics[m.ischanged ? 1 : 0].path.push(`${$fysp.imgUrl}${m.extension1}${m.guid}.jpg`)
-      })
+        pics[m.ischanged ? 1 : 0].path.push(
+          `${$fysp.imgUrl}${m.extension1}${m.guid}.jpg`
+        );
+      });
     }
 
-    return pics
+    return pics;
   },
 
   //闂瀹℃牳鐘舵�佽浆鎹腑鏂�
   proStatusMap(p) {
     switch (p) {
       case proStatus.unCheck:
-        return { name: '闂鏈鏍�', type: 'warning', index: 0, checkable: true, deletable: true, changeable: false }
+        return {
+          name: '闂鏈鏍�',
+          type: 'warning',
+          index: 0,
+          checkable: true,
+          deletable: true,
+          changeable: false
+        };
       case proStatus.pass:
-        return { name: '闂閫氳繃', type: 'success', index: 1, checkable: false, deletable: true, changeable: false }
+        return {
+          name: '闂閫氳繃',
+          type: 'success',
+          index: 1,
+          checkable: false,
+          deletable: true,
+          changeable: false
+        };
       case proStatus.fail:
-        return { name: '闂涓嶉�氳繃', type: 'danger', index: 1, checkable: false, deletable: true, changeable: false }
+        return {
+          name: '闂涓嶉�氳繃',
+          type: 'danger',
+          index: 1,
+          checkable: false,
+          deletable: true,
+          changeable: false
+        };
       case proStatus.change_unCheck:
-        return { name: '鏁存敼鏈鏍�', type: 'warning', index: 2, checkable: true, deletable: false, changeable: true }
+        return {
+          name: '鏁存敼鏈鏍�',
+          type: 'warning',
+          index: 2,
+          checkable: true,
+          deletable: false,
+          changeable: true
+        };
       case proStatus.change_fail:
-        return { name: '鏁存敼涓嶉�氳繃', type: 'danger', index: 3, checkable: false, deletable: false, changeable: true }
+        return {
+          name: '鏁存敼涓嶉�氳繃',
+          type: 'danger',
+          index: 3,
+          checkable: false,
+          deletable: false,
+          changeable: true
+        };
       case proStatus.change_pass:
-        return { name: '鏁存敼閫氳繃', type: 'success', index: 3, checkable: false, deletable: false, changeable: true }
+        return {
+          name: '鏁存敼閫氳繃',
+          type: 'success',
+          index: 3,
+          checkable: false,
+          deletable: false,
+          changeable: true
+        };
       default:
-        return { name: '闂鏈鏍�', type: 'warning', index: 0, checkable: true, deletable: true }
+        return {
+          name: '闂鏈鏍�',
+          type: 'warning',
+          index: 0,
+          checkable: true,
+          deletable: true
+        };
     }
+  },
+
+  //鑾峰彇浠诲姟闂鐨勫鏍告儏鍐�
+  getSubtaskType(s) {
+    let type = 0;
+    // 鏃犻棶棰�
+    if (s.proNum == 0) {
+      type = 0;
+    } 
+    // 闂鏈鏍�
+    else if (s.proCheckedNum == 0) {
+      type = 1;
+    }
+    // 闂閮ㄥ垎瀹℃牳
+    else if (s.proCheckedNum < s.proNum) {
+      type = 2;
+    }
+    // 鏁存敼鏈鏍�
+    else if (s.changeNum > 0 && s.changeCheckedNum == 0) {
+      type = 4;
+    }
+    // 鏁存敼閮ㄥ垎瀹℃牳
+    else if (s.changeNum > 0 && s.changeCheckedNum < s.changeNum) {
+      type = 5;
+    }
+    // 鏈暣鏀� 
+    else if (s.changeNum < s.proNum) {
+      type = 3;
+    }
+    // 瀹屽叏瀹℃牳
+    else {
+      type = 6;
+    }
+    return type;
   },
 
   /**
@@ -130,17 +260,39 @@
    * @returns 涓嬩竴涓棶棰樼姸鎬�
    */
   proNextStatus(s, isPass) {
-    let status, action
+    let status, action;
     switch (s) {
       case proStatus.unCheck:
-        status = isPass ? proStatus.pass : proStatus.fail
-        action = isPass ? 0 : 1
-        break
+        status = isPass ? proStatus.pass : proStatus.fail;
+        action = isPass ? 0 : 1;
+        break;
       case proStatus.change_unCheck:
-        status = isPass ? proStatus.change_pass : proStatus.change_fail
-        action = isPass ? 2 : 3
-        break
+        status = isPass ? proStatus.change_pass : proStatus.change_fail;
+        action = isPass ? 2 : 3;
+        break;
     }
-    return { status: status, action: action }
+    return { status: status, action: action };
+  },
+
+  /**
+   * 闂鎾ゅ洖鍚庣姸鎬佸彉鎹�
+   * @param {String} s 褰撳墠闂鐘舵��
+   * @returns 涓嬩竴涓棶棰樼姸鎬�
+   */
+  proBeforeStatus(s) {
+    let status, action;
+    switch (s) {
+      case proStatus.fail:
+      case proStatus.pass:
+        status = proStatus.unCheck;
+        action = 4;
+        break;
+      case proStatus.change_fail:
+      case proStatus.change_pass:
+        status = proStatus.change_unCheck;
+        action = 5;
+        break;
+    }
+    return { status: status, action: action };
   }
-}
+};

--
Gitblit v1.9.3