qinxianzhangyao
2024-07-12 f169a06cea16bc6215743a7be07febdb1d4fdc38
src/views/system/tijian/index.vue
@@ -2478,8 +2478,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 +2515,7 @@
        };
      } else {
        // if (_this.inputSSS.indexOf(":1") != -1) {
        //   var str1 = _this.inputSSS.indexOf(":1");
        //   var result1 = _this.inputSSS.substring(0, str1);
@@ -2501,7 +2527,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 +2578,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;
        };