From 0e5553e2390bb336e589e5b7f0fa890d59aed735 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期二, 27 十月 2026 01:09:44 +0800
Subject: [PATCH] 统计、绩效模块

---
 src/views/project/donationdetails/index.vue |  127 +++++++++++++++++++++--------------------
 1 files changed, 65 insertions(+), 62 deletions(-)

diff --git a/src/views/project/donationdetails/index.vue b/src/views/project/donationdetails/index.vue
index be05831..00d7057 100644
--- a/src/views/project/donationdetails/index.vue
+++ b/src/views/project/donationdetails/index.vue
@@ -2811,18 +2811,6 @@
         contacttime: "",
         reporttime: ""
       },
-      organOrder: [
-        "鑲濊剰",
-        "宸﹁偩",
-        "鍙宠偩",
-        "蹇冭剰",
-        "宸﹁偤",
-        "鍙宠偤",
-        "鑳拌吅",
-        "灏忚偁",
-        "宸︾溂瑙掕啘",
-        "鍙崇溂瑙掕啘"
-      ], // 鎸囧畾鐨勫櫒瀹橀『搴�
       isSorting: false, // 鏍囧織浣嶏紝琛ㄧず鏄惁姝e湪鎺掑簭
       tableKey: 0,
       istb: false,
@@ -3182,7 +3170,8 @@
     // 鐩戝惉 procureddata 鐨勫彉鍖栵紝鏁版嵁鏇存柊鍚庨噸鏂版帓搴�
     procureddata: {
       handler(newVal) {
-        if (this.procureddata[0].organgettime) {
+        // 鍒ょ┖锛氬彇娑堟渶鍚庝竴涓櫒瀹樻椂鏁扮粍浼氬彉鎴愮┖锛岀洿鎺ュ彇 [0] 浼氭姏 TypeError
+        if (this.procureddata[0] && this.procureddata[0].organgettime) {
           this.organgettimetrue = true;
         }
         if (this.isSorting) {
@@ -3342,7 +3331,8 @@
         listDonateorgan(searchParam).then(res => {
           if (res.code == 200) {
             if (res.rows[0]) {
-              this.allocateddata = res.rows;
+              // 2026-10-23锛氭寜鍣ㄥ畼鎺掗槦搴忓彿鎺掑簭鍚庡啀娓叉煋
+              this.allocateddata = this.sortOrganRows(res.rows);
               console.log("this.allocateddata", this.allocateddata);
               this.allocateddataform.allocateddata = this.allocateddata;
             }
@@ -3383,6 +3373,8 @@
               });
               // this.procureddata.infoid = this.infoid;
             }
+            // 2026-10-23锛氭寜鍣ㄥ畼鎺掗槦搴忓彿鎺掑簭鍚庡啀娓叉煋
+            this.procureddata = this.sortOrganRows(this.procureddata);
             this.organList.organprocured = [];
             for (let i = 0; i < this.procureddata.length; i++) {
               this.organList.organprocured.push(this.procureddata[i].organno);
@@ -3437,6 +3429,8 @@
 
               this.transplantdata.infoid = this.infoid;
             }
+            // 2026-10-23锛氭寜鍣ㄥ畼鎺掗槦搴忓彿鎺掑簭鍚庡啀娓叉煋
+            this.transplantdata = this.sortOrganRows(this.transplantdata);
             for (let i = 0; i < this.transplantdata.length; i++) {
               this.organList.organtransplant.push(
                 this.transplantdata[i].organno
@@ -3703,6 +3697,8 @@
               item.transplanthospitalname = objs.organizationname;
             }
           });
+          // 2026-10-23锛氭彁浜ゅ墠鎸夊櫒瀹樻帓闃熷簭鍙锋帓搴忥紝淇濊瘉鍏ュ簱椤哄簭涓庡睍绀轰竴鑷�
+          this.sortOrganRows(this.allocateddata);
           saveDonateorgan(this.allocateddata).then(res => {
             // 鍥炲~涓婚敭锛氬悗绔凡鎸�"鍚屼竴妗堜緥鍚屼竴鍣ㄥ畼"鍋� upsert锛屽洖濉悗鍓嶇涓嶄細鍐嶈鍒や负鏂板
             if (res && res.data && res.data.length === this.allocateddata.length) {
@@ -3757,6 +3753,8 @@
                   }
                 });
                 //淇濆瓨鍣ㄥ畼鑾峰彇琛ㄦ暟鎹�
+                // 2026-10-23锛氭彁浜ゅ墠鎸夊櫒瀹樻帓闃熷簭鍙锋帓搴�
+                this.sortOrganRows(this.procureddata);
                 saveDonationwitnessorgan(this.procureddata).then(res => {
                   if (res && res.data && res.data.length === this.procureddata.length) {
                     res.data.forEach((row, i) => {
@@ -3793,6 +3791,8 @@
                     this.Processvalidation();
                   });
                   //淇濆瓨鍣ㄥ畼鑾峰彇琛ㄦ暟鎹�
+                  // 2026-10-23锛氭彁浜ゅ墠鎸夊櫒瀹樻帓闃熷簭鍙锋帓搴�
+                  this.sortOrganRows(this.procureddata);
                   saveDonationwitnessorgan(this.procureddata).then(res => {
                     if (res && res.data && res.data.length === this.procureddata.length) {
                       res.data.forEach((row, i) => {
@@ -3833,6 +3833,8 @@
             if (this.accomplishform.id) {
               updateDonatecompletioninfo(this.accomplishform).then(response => {
                 this.$modal.msgSuccess("瀹屾垚鐧昏淇℃伅淇敼鎴愬姛");
+                // 2026-10-23锛氭彁浜ゅ墠鎸夊櫒瀹樻帓闃熷簭鍙锋帓搴�
+                this.sortOrganRows(this.transplantdata);
                 saveDonatecomporgan(this.transplantdata).then(res => {
                   if (res && res.data && res.data.length === this.transplantdata.length) {
                     res.data.forEach((row, i) => {
@@ -3854,6 +3856,8 @@
                   this.accomplishform.id = response.data.id;
                 }
                 this.$modal.msgSuccess("瀹屾垚鐧昏鎴愬姛");
+                // 2026-10-23锛氭彁浜ゅ墠鎸夊櫒瀹樻帓闃熷簭鍙锋帓搴�
+                this.sortOrganRows(this.transplantdata);
                 saveDonatecomporgan(this.transplantdata).then(res => {
                   if (res && res.data && res.data.length === this.transplantdata.length) {
                     res.data.forEach((row, i) => {
@@ -3886,35 +3890,48 @@
       }
     },
 
-    customOrganSort() {
-      console.log("璋冪敤");
+    /**
+     * 鍙栧櫒瀹樼殑鎺掗槦搴忓彿锛氬瓧鍏� sys_Organ 鐨� dict_sort 鍘熷��
+     * 瀛楀吀閲屾病鏈夎鍣ㄥ畼鏃惰繑鍥� null锛堟帓搴忔椂鎺掓渶鍚庯級
+     */
+    getOrganSort(organno) {
+      const list =
+        (this.dict && this.dict.type && this.dict.type.sys_Organ) || [];
+      const item = list.find(d => d.value === organno);
+      if (item && item.raw) {
+        const s = item.raw.dictSort;
+        if (s !== null && s !== undefined && s !== "") {
+          return Number(s);
+        }
+      }
+      return null;
+    },
 
+    /**
+     * 鎸夊櫒瀹樻帓闃熷簭鍙峰崌搴忔帓搴忥紙鍘熷湴锛�
+     * sort 涓虹┖/0 瑙嗕负鏈煡锛屾帓鏈�鍚庯紱鐩稿悓搴忓彿鎸� id 鍏滃簳锛屼繚璇侀『搴忕ǔ瀹�
+     */
+    sortOrganRows(rows) {
+      if (!rows || !rows.length) {
+        return rows;
+      }
+      const weight = r => {
+        const s = Number(r.sort);
+        if (r.sort === null || r.sort === undefined || isNaN(s) || s === 0) {
+          return 999999;
+        }
+        return s;
+      };
+      rows.sort((a, b) => weight(a) - weight(b) || (a.id || 0) - (b.id || 0));
+      return rows;
+    },
+
+    customOrganSort() {
       // 1. 鍔犻攣锛岄樆姝㈢洃鍚櫒鎵ц
       this.isSorting = true;
       this.loading = true;
-      // 鑷畾涔夋帓搴忓嚱鏁�
-      this.procureddata.sort((a, b) => {
-        const indexA = this.organOrder.indexOf(a.organname);
-        const indexB = this.organOrder.indexOf(b.organname);
-
-        // 濡傛灉涓や釜閮藉湪鍒楄〃涓紝鎸夊垪琛ㄤ腑鐨勯『搴忔帓搴�
-        if (indexA !== -1 && indexB !== -1) {
-          return indexA - indexB;
-        }
-        // 濡傛灉 a 鍦ㄥ垪琛ㄤ腑锛宐 涓嶅湪锛宎 鎺掑墠闈�
-        if (indexA !== -1) {
-          return -1;
-        }
-        // 濡傛灉 b 鍦ㄥ垪琛ㄤ腑锛宎 涓嶅湪锛宐 鎺掑墠闈�
-        if (indexB !== -1) {
-          return 1;
-        }
-        // 涓や釜閮戒笉鍦ㄥ垪琛ㄤ腑锛屼繚鎸佸師椤哄簭锛堟垨鎸夊叾浠栬鍒欙紝姣斿鎸夊瓧姣嶆帓搴忥紝杩欓噷鎸夊師濮嬮『搴忥級
-        return 0;
-      });
-      console.log(this.procureddata, "椤哄簭");
+      this.sortOrganRows(this.procureddata);
       this.tableKey += 1; // 鏀瑰彉 key 杩娇琛ㄦ牸閲嶆柊娓叉煋
-      // 浣犲彲浠ヤ娇鐢� this.$forceUpdate() 鎴栬�呴噸鏂拌祴鍊兼暟缁勬潵瑙﹀彂鏇存柊
       this.procureddata = [...this.procureddata];
       this.$nextTick(() => {
         this.isSorting = false;
@@ -3922,33 +3939,10 @@
       });
     },
     allocateddataSort() {
-      console.log("璋冪敤");
-
       // 1. 鍔犻攣锛岄樆姝㈢洃鍚櫒鎵ц
       this.isSorting = true;
-      // 鑷畾涔夋帓搴忓嚱鏁�
-      this.allocateddata.sort((a, b) => {
-        const indexA = this.organOrder.indexOf(a.organname);
-        const indexB = this.organOrder.indexOf(b.organname);
-
-        // 濡傛灉涓や釜閮藉湪鍒楄〃涓紝鎸夊垪琛ㄤ腑鐨勯『搴忔帓搴�
-        if (indexA !== -1 && indexB !== -1) {
-          return indexA - indexB;
-        }
-        // 濡傛灉 a 鍦ㄥ垪琛ㄤ腑锛宐 涓嶅湪锛宎 鎺掑墠闈�
-        if (indexA !== -1) {
-          return -1;
-        }
-        // 濡傛灉 b 鍦ㄥ垪琛ㄤ腑锛宎 涓嶅湪锛宐 鎺掑墠闈�
-        if (indexB !== -1) {
-          return 1;
-        }
-        // 涓や釜閮戒笉鍦ㄥ垪琛ㄤ腑锛屼繚鎸佸師椤哄簭锛堟垨鎸夊叾浠栬鍒欙紝姣斿鎸夊瓧姣嶆帓搴忥紝杩欓噷鎸夊師濮嬮『搴忥級
-        return 0;
-      });
-      console.log(this.allocateddata, "椤哄簭");
+      this.sortOrganRows(this.allocateddata);
       this.tableKey += 1; // 鏀瑰彉 key 杩娇琛ㄦ牸閲嶆柊娓叉煋
-      // 浣犲彲浠ヤ娇鐢� this.$forceUpdate() 鎴栬�呴噸鏂拌祴鍊兼暟缁勬潵瑙﹀彂鏇存柊
       this.allocateddata = [...this.allocateddata];
       this.$nextTick(() => {
         this.isSorting = false;
@@ -4028,6 +4022,8 @@
             this.allocateddata.push({
               organname: temporganname,
               organno: value,
+              // 2026-10-23锛氬啓鍏ュ櫒瀹樻帓闃熷簭鍙凤紙瀛楀吀 dict_sort锛�
+              sort: this.getOrganSort(value),
               id: null,
               infoid: this.infoid,
               donorno: this.form.donorno,
@@ -4098,6 +4094,8 @@
             this.procureddata.push({
               organname: temporganname,
               organno: value,
+              // 2026-10-23锛氬啓鍏ュ櫒瀹樻帓闃熷簭鍙凤紙瀛楀吀 dict_sort锛�
+              sort: this.getOrganSort(value),
               id: null,
               infoid: this.infoid,
               donorno: this.form.donorno,
@@ -4174,12 +4172,17 @@
             this.transplantdata.push({
               organname: temporganname,
               organno: value,
+              // 2026-10-23锛氬啓鍏ュ櫒瀹樻帓闃熷簭鍙凤紙瀛楀吀 dict_sort锛�
+              sort: this.getOrganSort(value),
               id: null,
               infoid: this.infoid,
               donorno: this.form.donorno,
               organstate: 1,
               transplantstate: 1
             });
+            // 2026-10-23锛氬畬鎴愮櫥璁板師鍏堟病鏈� watch锛屾柊澧炲櫒瀹樹細鍋滃湪琛ㄦ牸鏈�鍚庯紱
+            // 杩欓噷绔嬪嵆鎸夋帓闃熷簭鍙峰綊浣嶏紙鍘熷湴鎺掑簭鍚庡繀椤婚噸鏂拌祴鍊硷紝鍚﹀垯琛ㄦ牸涓嶉噸娓叉煋锛�
+            this.transplantdata = this.sortOrganRows([...this.transplantdata]);
           }
         } else {
           this.$modal.msgWarning("璇ュ櫒瀹樺凡缁忛�夋嫨锛岃鍕块噸澶嶉�夋嫨锛�");

--
Gitblit v1.9.3