From e17811c1d7b1e6318af32a366d23bd586750b6d2 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期三, 27 十一月 2024 11:32:48 +0800
Subject: [PATCH] 2024 11 27

---
 src/views/system/tijian/index.vue |  213 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 123 insertions(+), 90 deletions(-)

diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue
index da8a012..1ea1d2c 100644
--- a/src/views/system/tijian/index.vue
+++ b/src/views/system/tijian/index.vue
@@ -574,6 +574,9 @@
                   :data="packagedataList"
                   node-key="proId"
                   :props="defaultpackProps"
+                  :filter-node-method="filterpackage"
+                  @check-change="handlePackageChecked"
+                  :default-checked-keys="checkedListkey1"
                   :render-content="renderContent"
                 >
                 </el-tree>
@@ -1593,6 +1596,7 @@
       treedataList: [],
       checkedkey: [],
       checkedListkey: [],
+      checkedListkey1: [],
       defaultProps: {
         children: [],
         label: "proName",
@@ -2478,8 +2482,34 @@
               "$1-$2-$3"
             );
           }
-          _this.form.cusAddr = resultObj.data.addres;
           _this.form.cusIdcard = resultObj.data.card;
+          if (_this.form.cusIdcard) {
+            const reg =
+              /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
+            if (reg.test(_this.form.cusIdcard)) {
+              var org_birthday = _this.form.cusIdcard.substring(6, 14);
+              var birthday =
+                org_birthday.substring(0, 4) +
+                "-" +
+                org_birthday.substring(4, 6) +
+                "-" +
+                org_birthday.substring(6, 8);
+              var birthdays = new Date(birthday.replace(/-/g, "-"));
+              let d = new Date();
+              let age =
+                d.getFullYear() -
+                birthdays.getFullYear() -
+                (d.getMonth() < birthdays.getMonth() ||
+                (d.getMonth() == birthdays.getMonth() &&
+                  d.getDate() < birthdays.getDate())
+                  ? 1
+                  : 0);
+
+              _this.form.age = age;
+            }
+          }
+          _this.form.cusAddr = resultObj.data.addres;
+
           _this.cardreader = false;
         };
 
@@ -2489,7 +2519,7 @@
         };
       } else {
         // if (_this.inputSSS.indexOf(":1") != -1) {
-          
+
         //   var str1 = _this.inputSSS.indexOf(":1");
         //   var result1 = _this.inputSSS.substring(0, str1);
 
@@ -2501,7 +2531,7 @@
 
         //   _this.inputSSS = result1 + result2;
         // }
-        _this.inputSSS = _this.inputSSS.replace(":1","");
+        _this.inputSSS = _this.inputSSS.replace(":1", "");
         var websocket = null;
         var url = this.valueUrls;
         // var url = 'ws://'+ getIp() +':6789/websocket'
@@ -2552,17 +2582,49 @@
         websocket.onmessage = function (event) {
           var resultObj = JSON.parse(event.data);
           _this.form.cusName = resultObj.data.name;
-          _this.form.cusSex = resultObj.data.gender;
-          _this.form.cusNational = resultObj.data.nation;
-          // _this.form.cusBrithday = resultObj.data.csrq;
-          // if (_this.form.cusBrithday) {
-          //   _this.form.cusBrithday = _this.form.cusBrithday.replace(
-          //     /^(\d{4})(\d{2})(\d{2})$/,
-          //     "$1-$2-$3"
-          //   );
-          // }
+
+          if (resultObj.data.nation == "姹夋棌") {
+            _this.form.cusNational = "1";
+          }
+          if (resultObj.data.gender == "鐢�") {
+            _this.form.cusSex = 0;
+          } else {
+            _this.form.cusSex = 1;
+          }
+          _this.form.cusBrithday = resultObj.data.birthday;
+          if (_this.form.cusBrithday) {
+            _this.form.cusBrithday = _this.form.cusBrithday.replace(
+              /^(\d{4})(\d{2})(\d{2})$/,
+              "$1-$2-$3"
+            );
+          }
           _this.form.cusPhone = resultObj.data.phone;
           _this.form.cusIdcard = resultObj.data.idenno;
+          if (_this.form.cusIdcard) {
+            const reg =
+              /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
+            if (reg.test(_this.form.cusIdcard)) {
+              var org_birthday = _this.form.cusIdcard.substring(6, 14);
+              var birthday =
+                org_birthday.substring(0, 4) +
+                "-" +
+                org_birthday.substring(4, 6) +
+                "-" +
+                org_birthday.substring(6, 8);
+              var birthdays = new Date(birthday.replace(/-/g, "-"));
+              let d = new Date();
+              let age =
+                d.getFullYear() -
+                birthdays.getFullYear() -
+                (d.getMonth() < birthdays.getMonth() ||
+                (d.getMonth() == birthdays.getMonth() &&
+                  d.getDate() < birthdays.getDate())
+                  ? 1
+                  : 0);
+
+              _this.form.age = age;
+            }
+          }
           _this.cardreader = false;
         };
 
@@ -2857,33 +2919,6 @@
         getZhList().then((response) => {
           if (response.data) {
             this.packageList = response.data;
-            // this.checkedkeys.push(this.packageList[0].id);
-            // let datas = {
-            //   zhId: this.packageList[0].id,
-            // };
-            // getlistByZhId(datas).then((res) => {
-            //   this.packagedataList = res.data.tjProjectList;
-            //   for (var i = 0; i < this.packagedataList.length; i++) {
-            //     let proId = this.packagedataList[i].proId;
-            //     getProSonDxList(proId).then((res) => {
-            //       this.TreedataList = res.data.list;
-            //       this.TreedataList.forEach((item) => {
-            //         this.DataLists.push(item);
-            //         if (this.DataLists.length >= 1) {
-            //           this.marryalls = 0;
-            //           this.DataLists.forEach((item1) => {
-            //             this.marryalls += item1.proPrice;
-            //             this.packagedataList.forEach((item3) => {
-            //               if (item1.proParentId == item3.proId) {
-            //                 item1.propinName = item3.proName;
-            //               }
-            //             });
-            //           });
-            //         }
-            //       });
-            //     });
-            //   }
-            // });
           }
           this.loading = false;
         });
@@ -2901,6 +2936,8 @@
       this.loading = true;
       getProParentIdDxList().then((response) => {
         this.Treedata = response.data.list;
+        console.log(response, 77788);
+
         if (this.tableData[0]) {
           this.tableData[0].tjProjectList.forEach((selectionitem) => {
             this.Treedata.forEach((item) => {
@@ -2910,40 +2947,12 @@
             });
           });
         }
-        // if (this.DataLists.length != 0) {
-        //   this.DataLists.forEach((selectionitem) => {
-        //     this.Treedata.forEach((item) => {
-        //       if (selectionitem.propinName == item.proName) {
-        //         item.disabled = true;
-        //       }
-        //     });
-        //   });
-        // }
-        // this.checkedkey.push(this.Treedata[0].proId);
-        // let proId = this.Treedata[0].proId;
-        // getProSonDxList(proId).then((res) => {
-        //   this.TreedataList = res.data.list;
-        //   this.TreedataList.forEach((item) => {
-        //     this.checkedListkey.push(item.proId);
-        //     this.DataList.push(item);
-        //     this.DataList.forEach((item) => {
-        //       item.propinName = this.Treedata[0].proName;
-        //     });
-        //   });
-        //   this.TotalPrice1 = 0;
-        //   this.marryall = 0;
-        //   if (this.DataList.length != 0) {
-        //     this.list1 = false;
-        //     this.DataList.forEach((item) => {
-        //       this.TotalPrice1 = item.proPrice + this.TotalPrice1;
-        //       this.marryall += item.proPrice;
-        //     });
-        //   }
-        // });
         this.loading = false;
       });
     },
+
     handlepackage(data, checked, checkedNodes) {
+      this.dataObj = data;
       if (checked.checkedNodes.length != 0) {
         this.$refs.treas.setCheckedKeys([data.id]);
         let datas = {
@@ -2951,16 +2960,27 @@
         };
         getlistByZhId(datas).then((res) => {
           this.packagedataList = res.data.tjProjectList;
+          console.log(this.packagedataList, 1122);
+          this.DataLists = [];
+          this.checkedListkey1 = [];
           for (var i = 0; i < this.packagedataList.length; i++) {
             let proId = this.packagedataList[i].proId;
-            getProSonDxList(proId).then((res) => {
+            this.checkedListkey1.push(proId);
+            // this.DataLists.push(this.packagedataList[i]);
+              getProSonDxList(proId).then((res) => {
               this.TreedataList = res.data.list;
+              console.log(this.TreedataList,888);
+              
               this.TreedataList.forEach((item) => {
+                // this.checkedListkey1.push(item.proId);
+
                 this.DataLists.push(item);
+                // console.log(this.DataLists,556644);
                 if (this.DataLists.length >= 1) {
                   this.marryalls = 0;
                   this.DataLists.forEach((item1) => {
                     this.marryalls += item1.proPrice;
+                    
                     this.packagedataList.forEach((item3) => {
                       if (item1.proParentId == item3.proId) {
                         item1.propinName = item3.proName;
@@ -2973,25 +2993,12 @@
           }
         });
       } else if (checked.checkedNodes.length == 0) {
-        // for (var i = 0; i < data.tjProjectList.length; i++) {
-        //   let proId = data.tjProjectList[i].proId;
-        //   getProSonDxList(proId).then((res) => {
-        //     this.TreedataList = res.data.list;
-        //     this.TreedataList.forEach((item) => {
-        //       this.DataLists.forEach((item1, index) => {
-        //         if (item.proId == item1.proId) {
-        //           this.DataLists.splice(index, 1);
-        //         }
-        //       });
-        //     });
-        //     this.marryalls = 0
-        //     if(this.DataLists.length != 0){
-        //       this.DataLists.forEach((item1, index) => {
-        //       this.marryalls += item1.proPrice;
-        //       })
-        //     }
-        //   });
-        // }
+        this.DataLists = [];
+        this.marryalls = 0; // 娓呴浂鎬讳环
+        this.checkedListkey1 = [];
+
+        // 浣犲彲浠ュ湪姝ゅ鏍规嵁闇�瑕佽繘琛屽叾浠栨搷浣滐紝濡傛洿鏂� UI
+        console.log("鍙栨秷閫変腑锛屾暟鎹凡娓呯┖锛屾�讳环宸查噸缃�");
       }
     },
     objectspanmethod({ row, column, rowIndex, columnIndex }) {
@@ -3024,17 +3031,43 @@
       //   return [rowspan, 1];
       // }
     },
-
+    handlePackageChecked(data, checked, checkedNodes) {
+      if (checked == false) {
+        this.DataLists.forEach((item, index) => {
+          if (item.proId == data.proId) {
+            this.DataLists.splice(index, 1);
+            this.marryalls = 0; // 閲嶇疆鍚堣閲戦
+            this.DataLists.forEach((item1) => {
+              this.marryalls += item1.proPrice; // 閲嶆柊璁$畻鍚堣閲戦
+            });
+          }
+        });
+      } else if (checked == true) {
+        this.DataLists.push(data); // 娣诲姞鏁版嵁鍒板凡閫夊垪琛�
+        this.DataLists.forEach((item1) => {
+          if (item1.proParentId == this.dataObj.proId) {
+            item1.propinName = this.dataObj.proName; // 璁剧疆鐖剁骇鍚嶇О
+          }
+        });
+        // this.spliceData();
+        this.marryalls = 0; // 閲嶇疆鍚堣閲戦
+        this.DataLists.forEach((item1) => {
+          this.marryalls += item1.proPrice; // 閲嶆柊璁$畻鍚堣閲戦
+        });
+      }
+    },
     // 鐐瑰嚮鑾峰彇姣忎釜鏍戣妭鐐�
     handleCurrentChecked(data, checked, checkedNodes) {
       this.dataObj = data;
       if (checked.checkedNodes.length != 0) {
         this.$refs.tree.setCheckedKeys([data.proId]);
+
         let proId = data.proId;
         getProSonDxList(proId).then((res) => {
           this.TreedataList = res.data.list;
           this.TreedataList.forEach((item) => {
             this.checkedListkey.push(item.proId);
+
             this.DataList.push(item);
             this.spliceData();
             this.DataList.forEach((item1) => {

--
Gitblit v1.8.0