From 6608a6839d771d38640988e3ee496ecdd91765a4 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 09 四月 2024 15:12:59 +0800
Subject: [PATCH] 代码合并

---
 packageDomain/pages/sampleBookList/index.js |  190 ++++++++++++++++++++++++++++-------------------
 1 files changed, 113 insertions(+), 77 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index 746250a..6861e0e 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -50,6 +50,30 @@
     stairCode: '', // 涓�绾у垎绫婚�変腑椤�
     secondCode: '', // 浜岀骇鍒嗙被閫変腑椤�
     sort: '', // 鎺掑簭
+    sortList: {
+      value: "default",
+      options: [{
+          value: "default",
+          label: "榛樿鎺掑簭",
+        },
+        {
+          value: "name-asc",
+          label: "鍚嶇О姝e簭",
+        },
+        {
+          value: "name-desc",
+          label: "鍚嶇О鍊掑彊",
+        },
+        {
+          value: "time-asc",
+          label: "鍑虹増鏃堕棿姝e簭",
+        },
+        {
+          value: "time-desc",
+          label: "鍑虹増鏃堕棿鍊掑彊",
+        },
+      ],
+    },
     //鍒嗛〉
     page: 1,
     limit: 10,
@@ -145,11 +169,7 @@
       this.setData({
         userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
       })
-      this.getAlreadyPBookList()
-      this.getAlreadyEBookList()
-      // 鑾峰彇鐢宠娆℃暟
-      this.getSelectPaperBookCount()
-      this.getSelectBookCount()
+
     }
   },
 
@@ -164,19 +184,31 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
-    if (wx.getStorageSync("paperBookList")) {
-      this.setData({
-        paperBookList: wx.getStorageSync("paperBookList"),
-      })
-    }
-    if (wx.getStorageSync("electronicBookList")) {
-      this.setData({
-        electronicBookList: wx.getStorageSync("electronicBookList"),
-      })
-    }
     this.setData({
-      num: this.data.paperBookList.length + this.data.electronicBookList.length
+      page: 1,
+      paperBookList: [],
+      electronicBookList: []
     })
+    this.getAlreadyPBookList()
+    this.getAlreadyEBookList()
+    // 鑾峰彇鐢宠娆℃暟
+    this.getSelectPaperBookCount()
+    this.getSelectBookCount()
+    if (wx.getStorageSync("paperBookList") || wx.getStorageSync("electronicBookList")) {
+      if (wx.getStorageSync("paperBookList")) {
+        this.setData({
+          paperBookList: wx.getStorageSync("paperBookList"),
+        })
+      }
+      if (wx.getStorageSync("electronicBookList")) {
+        this.setData({
+          electronicBookList: wx.getStorageSync("electronicBookList"),
+        })
+      }
+      this.setData({
+        num: this.data.paperBookList.length + this.data.electronicBookList.length
+      })
+    }
     this.getBookList(false);
   },
   goBack() {
@@ -184,7 +216,7 @@
   },
 
   // 鑾峰彇绾歌川涔﹀墿浣欐鏁�
-  getSelectPaperBookCount(item) {
+  getSelectPaperBookCount() {
     app.MG.app
       .getTicketResult({
         ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
@@ -197,7 +229,7 @@
       })
   },
   // 鑾峰彇鐢靛瓙涔﹀墿浣欐鏁�
-  getSelectBookCount(item) {
+  getSelectBookCount() {
     app.MG.app
       .getTicketResult({
         ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
@@ -374,17 +406,43 @@
         queryType: '*',
       };
     }
-    if (that.data.sort) {
+    if (this.data.sortList.value == "name-asc") {
       sort = {
-        Name: that.data.sort,
-        BaseType: '',
+        Name: "Asc",
+        BaseType: "",
       };
-    } else {
+    } else if (this.data.sortList.value == "name-desc") {
       sort = {
-        type: 'Desc',
-        field: 'ViewCount',
+        Name: "Desc",
+        BaseType: "",
+      };
+    } else if (this.data.sortList.value == "time-asc") {
+      sort = {
+        PublicationDate: "Asc",
+        BaseType: "DateTime",
+      };
+    } else if (this.data.sortList.value == "time-desc") {
+      sort = {
+        PublicationDate: "Desc",
+        BaseType: "DateTime",
+      };
+    } else if (this.data.sortList.value == "default") {
+      sort = {
+        field: "order",
+        type: "Desc",
       };
     }
+    // if (that.data.sort) {
+    //   sort = {
+    //     Name: that.data.sort,
+    //     BaseType: '',
+    //   };
+    // } else {
+    //   sort = {
+    //     type: 'Desc',
+    //     field: 'ViewCount',
+    //   };
+    // }
     // 鎼滅储
     let searchObj = {};
     if (that.data.searchValue) {
@@ -429,26 +487,30 @@
             }
             if (that.data.alreadyPaperBookList.length > 0) {
               that.data.alreadyPaperBookList.forEach((pBook) => {
-                pBook.content.forEach((pBookItem) => {
-                  if (pBookItem.id === item.id && pBook.state == 'WaitAudit') {
-                    item.paperDisabled = true
-                    item.paperChecked = true
-                  }
-                  if (pBookItem.id === item.id && pBook.state == 'Normal') {
-                    item.paperDisabled = false
-                  }
-                })
+                if (pBook.content.length > 0) {
+                  pBook.content.forEach((pBookItem) => {
+                    if (pBookItem.id === item.id && pBook.state == 'WaitAudit') {
+                      item.paperDisabled = true
+                      item.paperChecked = true
+                    }
+                    if (pBookItem.id === item.id && pBook.state == 'Normal') {
+                      item.paperDisabled = false
+                    }
+                  })
+                }
               })
             }
 
             if (that.data.alreadyElectronicBookList.length > 0) {
               that.data.alreadyElectronicBookList.forEach((eBook) => {
-                eBook.content.forEach((eBookItem) => {
-                  if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') {
-                    item.electronDisabled = true
-                    item.electronChecked = true
-                  }
-                })
+                if (eBook.content.length > 0) {
+                  eBook.content.forEach((eBookItem) => {
+                    if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') {
+                      item.electronDisabled = true
+                      item.electronChecked = true
+                    }
+                  })
+                }
               })
             }
             if (that.data.paperBookList.length > 0) {
@@ -481,6 +543,8 @@
           })
         } else {
           that.setData({
+            bookList: [],
+            pageTotalCount: 0,
             skeletonLoding: false,
             loading: false
           })
@@ -539,60 +603,32 @@
   onConfirmSecond() {
     this.getBookList(false);
   },
-  // 閲嶇偣椤圭洰鏀瑰彉
-  changeMajorProject(e) {
+  onResetSecond() {
     this.setData({
-      'majorProjectList.value': e.detail.value,
+      'secondList.value': [],
     });
     this.getBookList(false);
   },
-  // 閲嶇偣椤圭洰閲嶇疆
-  resetMajorProject() {
+
+  // 鎺掑簭鍒囨崲
+  onSortChange(e) {
     this.setData({
-      'majorProjectList.value': [],
+      backTop: "#assort-title",
+      "sortList.value": e.detail.value,
     });
-    this.getBookList(false);
-  },
-  changeNewText(e) {
-    this.setData({
-      'newTextBook.value': e.detail.value,
-    });
-    this.getBookList(false);
-  },
-  resetNewText() {
-    this.setData({
-      'newTextBook.value': [],
-    });
-    this.getBookList(false);
-  },
-  // 鎺掑簭鎸夐挳
-  sortClick() {
-    if (!this.data.sort.length) {
-      this.setData({
-        sort: 'Desc',
-      });
-    } else if (this.data.sort == 'Desc') {
-      this.setData({
-        sort: 'Asc',
-      });
-    } else if (this.data.sort == 'Asc') {
-      this.setData({
-        sort: '',
-      });
-    }
+
     let path;
     if (this.data.secondCode) {
       path = this.data.secondCode;
     } else if (this.data.stairCode) {
-      path = `${this.data.assortCheck.code
-        }\\${this.data.stairCode}`;
+      path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
     } else {
       path = this.data.assortCheck.code;
     }
     this.setData({
       path: path,
     });
-    this.getBookList(false);
+    this.getBookList(path);
   },
   // 鎼滅储鍥句功
   searchBook(e) {

--
Gitblit v1.9.1