pengjingzhao 15 hours ago
parent
commit
52a336fd28

+ 59 - 6
src/main/resources/static/js/jBox/common.js

@@ -92,8 +92,18 @@ function setCertificateData(result,zyFlag) {
     var birthday = result.Certificate.Birthday;
     var birthday = result.Certificate.Birthday;
     var sfzBirthDay = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6)
     var sfzBirthDay = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6)
     $("#birthDay").val(sfzBirthDay);
     $("#birthDay").val(sfzBirthDay);
-    var returnAge = jsGetAge($("#birthDay").val());
-    $("#age").val(returnAge);
+    // var ageResult = jsGetAge($("#birthDay").val());
+    // var returnAge = ageResult.age; //年龄
+    // var ageType = ageResult.type; // 年龄单位(岁/月)
+    // console.log('birthday2',birthday)
+    var ageResult = jsGetAge($("#birthDay").val());
+    $("#age").val(ageResult.age);
+    $("#ageDetail").val(ageResult.ageDetail);
+    $("#ageType").val(ageResult.type);
+    // console.log(ageResult,returnAge)
+
+    // $("#age").val(returnAge);
+    // $("#ageType").val(ageType);
     $("#idCard").val(result.Certificate.IDNumber);
     $("#idCard").val(result.Certificate.IDNumber);
     if(zyFlag == 1){
     if(zyFlag == 1){
         queryUserInfoBySocialNo(1);
         queryUserInfoBySocialNo(1);
@@ -430,10 +440,12 @@ function messageBox(paramsJson) {
 /**
 /**
  * 根据出生日期算出年龄
  * 根据出生日期算出年龄
  * @param strBirthday
  * @param strBirthday
- * @returns {number}
+ * @returns {{age: number, ageDetail: number, type: string}}
  */
  */
 function jsGetAge(strBirthday) {
 function jsGetAge(strBirthday) {
     var returnAge;
     var returnAge;
+    var ageDetail;
+    var ageType;
     var strBirthdayArr = strBirthday.split("-");
     var strBirthdayArr = strBirthday.split("-");
     var birthYear = strBirthdayArr[0];
     var birthYear = strBirthdayArr[0];
     var birthMonth = strBirthdayArr[1];
     var birthMonth = strBirthdayArr[1];
@@ -445,34 +457,70 @@ function jsGetAge(strBirthday) {
 
 
     if (nowYear == birthYear) {
     if (nowYear == birthYear) {
         returnAge = 0;//同年 则为0岁
         returnAge = 0;//同年 则为0岁
+        //不满一岁
+        if ((nowMonth - birthMonth) > 0) {
+            //满一个月
+            if (nowDay == birthDay) {
+                //1月
+                ageDetail = 1;
+                ageType = "月";
+            }
+            else {
+                //>1month
+                if ((nowDay - birthDay) < 0) {
+                    ageDetail = (nowMonth - birthMonth)-1;
+                    ageType = "月";
+                }
+                else {
+                    ageDetail =(nowMonth - birthMonth)
+                    ageType = "月";
+                }
+            }
+        }else{
+            //不满一个月
+            ageDetail = ( nowDay - birthDay)
+            ageType = "天";
+        }
     }
     }
     else {
     else {
+        ageType = "岁";
         var ageDiff = nowYear - birthYear; //年之差
         var ageDiff = nowYear - birthYear; //年之差
         if (ageDiff > 0) {
         if (ageDiff > 0) {
             if (nowMonth == birthMonth) {
             if (nowMonth == birthMonth) {
                 var dayDiff = nowDay - birthDay;//日之差
                 var dayDiff = nowDay - birthDay;//日之差
                 if (dayDiff < 0) {
                 if (dayDiff < 0) {
                     returnAge = ageDiff - 1;
                     returnAge = ageDiff - 1;
+                    ageDetail = ageDiff - 1;
                 }
                 }
                 else {
                 else {
                     returnAge = ageDiff;
                     returnAge = ageDiff;
+                    ageDetail = ageDiff;
                 }
                 }
             }
             }
             else {
             else {
                 var monthDiff = nowMonth - birthMonth;//月之差
                 var monthDiff = nowMonth - birthMonth;//月之差
                 if (monthDiff < 0) {
                 if (monthDiff < 0) {
                     returnAge = ageDiff - 1;
                     returnAge = ageDiff - 1;
+                    ageDetail = ageDiff - 1;
                 }
                 }
                 else {
                 else {
                     returnAge = ageDiff;
                     returnAge = ageDiff;
+                    ageDetail = ageDiff;
                 }
                 }
             }
             }
         }
         }
         else {
         else {
             returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
             returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
+            ageDetail = -1;
         }
         }
     }
     }
-    return returnAge;//返回周岁年龄
+    // console.log(returnAge,ageDetail, ageType);
+
+    return  {
+        age: returnAge,
+        ageDetail:ageDetail,
+        type: ageType
+    };
 }
 }
 
 
 
 
@@ -507,8 +555,13 @@ function queryUserInfoBySocialNo(flag) {
                         var birthday = idCard.substring(6, 14);
                         var birthday = idCard.substring(6, 14);
                         birthday = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
                         birthday = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
                         $("#birthDay").val(birthday);
                         $("#birthDay").val(birthday);
-                        var returnAge = jsGetAge(birthday);
-                        $("#age").val(returnAge);
+                        console.log('birthday',birthday);
+                        var ageResult = jsGetAge(birthday);
+                        $("#age").val(ageResult.age);
+                        $("#age").blur();
+                        $("#ageDetail").val(ageResult.ageDetail);
+                        $("#ageDetail").blur();
+                        $("#ageType").html(ageResult.type + ' <span class="caret"></span>');
                         var gender = idCard.substring(16, 17);
                         var gender = idCard.substring(16, 17);
                         if (gender % 2 == 0) {
                         if (gender % 2 == 0) {
                             $("#gender").val(2);
                             $("#gender").val(2);

+ 31 - 4
src/main/resources/static/js/mz/registration.js

@@ -306,6 +306,12 @@ $(function () {
         if (!checkDate(arr[0], arr[1], arr[2])) {
         if (!checkDate(arr[0], arr[1], arr[2])) {
             errorMesageSimaple("生日日期错误");
             errorMesageSimaple("生日日期错误");
         }
         }
+        // $("#editUserBirthDay").val(editUserBirthDay);
+        var editReturn = jsGetAge(editUserBirthDay);
+        // console.log('3333',editReturn)
+        $("#editUserAge").val(editReturn.age);
+        $("#editUserAge").blur();
+        $("#editAgeType").html(editReturn.type + ' <span class="caret"></span>');
         var returnAge = jsGetAge(editUserBirthDay);
         var returnAge = jsGetAge(editUserBirthDay);
         $("#editUserAge").val(returnAge);
         $("#editUserAge").val(returnAge);
     });
     });
@@ -314,6 +320,7 @@ $(function () {
         queryUserInfoBySocialNo(1);
         queryUserInfoBySocialNo(1);
     });
     });
     $("#editUserIdCard").change(function (e) {
     $("#editUserIdCard").change(function (e) {
+        //编辑修改患者触发
         var editUserIdCard = $("#editUserIdCard").val();
         var editUserIdCard = $("#editUserIdCard").val();
         if (editUserIdCard == null || editUserIdCard == "") {
         if (editUserIdCard == null || editUserIdCard == "") {
             return;
             return;
@@ -321,8 +328,13 @@ $(function () {
         var birthday = editUserIdCard.substring(6, 14);
         var birthday = editUserIdCard.substring(6, 14);
         birthday = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
         birthday = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
         $("#editUserBirthDay").val(birthday);
         $("#editUserBirthDay").val(birthday);
-        var returnAge = jsGetAge(birthday);
-        $("#editUserAge").val(returnAge);
+        var editRsturn = jsGetAge(birthday);
+        console.log('2222',editRsturn)
+        $("#editUserAge").val(editRsturn.age);
+        $("#editUserAge").blur();
+        $("#editUserAgeDetail").val(editRsturn.ageDetail);
+        $("#editUserAgeDetail").blur();
+        $("#editAgeType").html(editRsturn.type + ' <span class="caret"></span>');
         var gender = editUserIdCard.substring(16, 17);
         var gender = editUserIdCard.substring(16, 17);
         if (gender % 2 == 0) {
         if (gender % 2 == 0) {
             $("#editUserGender").val(2);
             $("#editUserGender").val(2);
@@ -1281,8 +1293,15 @@ function extracted(res) {
     $("#userName").val(res.data.name);
     $("#userName").val(res.data.name);
     $("#userName").blur();
     $("#userName").blur();
     $("#userNameReadOnly").val(res.data.name);
     $("#userNameReadOnly").val(res.data.name);
-    $("#age").val(res.data.age);
+    var ageResult = jsGetAge(res.data.birthDayStr);
+    // console.log('1111',ageResult)
+    $("#age").val(ageResult.age);
     $("#age").blur();
     $("#age").blur();
+    $("#ageDetail").val(ageResult.ageDetail);
+    $("#ageDetail").blur();
+    $("#ageType").html(ageResult.type + ' <span class="caret"></span>');
+    // $("#age").val(res.data.age);
+    // $("#age").blur();
     $("#gender").selectpicker('val', res.data.sex);
     $("#gender").selectpicker('val', res.data.sex);
     $("#gender").selectpicker('refresh');
     $("#gender").selectpicker('refresh');
     $("#gender").blur();
     $("#gender").blur();
@@ -1329,12 +1348,19 @@ function extracted(res) {
  * @param patinet
  * @param patinet
  */
  */
 function fillPlusPatinet(patinet) {
 function fillPlusPatinet(patinet) {
+    // console.log('patinet',patinet)
     if (patinet != null) {
     if (patinet != null) {
         $("#editUserCode").val(patinet.patientId);
         $("#editUserCode").val(patinet.patientId);
         $("#editUserName").val(patinet.name);
         $("#editUserName").val(patinet.name);
         $("#editUserName").blur();
         $("#editUserName").blur();
-        $("#editUserAge").val(patinet.age);
+        var editAgeResult = jsGetAge(patinet.birthDayStr);
+        $("#editUserAge").val(editAgeResult.age);
         $("#editUserAge").blur();
         $("#editUserAge").blur();
+        $("#editUserAgeDetail").val(editAgeResult.ageDetail);
+        $("#editUserAgeDetail").blur();
+        $("#editAgeType").html(editAgeResult.type + ' <span class="caret"></span>');
+        // $("#editUserAge").val(patinet.age);
+        // $("#editUserAge").blur();
         $("#editUserGender").selectpicker('val', patinet.sex);
         $("#editUserGender").selectpicker('val', patinet.sex);
         $("#editUserGender").selectpicker('refresh');
         $("#editUserGender").selectpicker('refresh');
         $("#editUserGender").blur();
         $("#editUserGender").blur();
@@ -1880,6 +1906,7 @@ function clearRegistration() {
     $("#cardNo").attr("title", null);
     $("#cardNo").attr("title", null);
     $("#userName").val(null);
     $("#userName").val(null);
     $("#age").val(null);
     $("#age").val(null);
+    $("#ageDetail").val(null);
     $("#gender").selectpicker('val', 1);
     $("#gender").selectpicker('val', 1);
     $("#gender").selectpicker('refresh');
     $("#gender").selectpicker('refresh');
     $("#birthDay").val(null);
     $("#birthDay").val(null);

+ 19 - 16
src/main/resources/templates/mz/registration.html

@@ -91,26 +91,28 @@
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="col-md-3 col-sm-3 col-xs-12 item thmz_group_alert">
                 <div class="col-md-3 col-sm-3 col-xs-12 item thmz_group_alert">
-                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="age">年龄
+                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="ageDetail">年龄
                     </label>
                     </label>
                     <div class="col-md-8 col-sm-8 col-xs-12">
                     <div class="col-md-8 col-sm-8 col-xs-12">
                         <div class="input-group input-group-own">
                         <div class="input-group input-group-own">
-                            <input id="age" class="form-control col-md-7 col-xs-12" type="number"
+                            <input id="ageDetail" class="form-control col-md-7 col-xs-12" type="number"
                                    data-validate-minmax="0,200" required="required"
                                    data-validate-minmax="0,200" required="required"
                                    placeholder="请输入">
                                    placeholder="请输入">
+                            <input type="number" id="age" style="display: none;">
                             <div class="input-group-btn">
                             <div class="input-group-btn">
-                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
-                                        aria-expanded="false" style="margin-right: 0px;">岁 <span class="caret"></span>
+                                <button id="ageType" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
+                                        aria-expanded="false" style="margin-right: 0px;">
+                                    岁
                                 </button>
                                 </button>
-                                <!--<ul class="dropdown-menu dropdown-menu-right" role="menu"
-                                    style="width: 50px;min-width: 50px;">
-                                    <li><a href="#">岁</a>
-                                    </li>
-                                    <li><a href="#">月</a>
-                                    </li>
-                                    <li><a href="#">天</a>
-                                    </li>
-                                </ul>-->
+<!--                                <ul class="dropdown-menu dropdown-menu-right" role="menu"-->
+<!--                                    style="width: 50px;min-width: 50px;">-->
+<!--                                    <li><a href="#">岁</a>-->
+<!--                                    </li>-->
+<!--                                    <li><a href="#">月</a>-->
+<!--                                    </li>-->
+<!--                                    <li><a href="#">天</a>-->
+<!--                                    </li>-->
+<!--                                </ul>-->
                             </div>
                             </div>
                             <!-- /btn-group -->
                             <!-- /btn-group -->
                         </div>
                         </div>
@@ -659,16 +661,17 @@
 
 
                     <div class="item form-group thmz_alert">
                     <div class="item form-group thmz_alert">
                         <div class="col-md-6 col-sm-6 col-xs-12 item">
                         <div class="col-md-6 col-sm-6 col-xs-12 item">
-                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="editUserAge">年龄 <span
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="editUserAgeDetail">年龄 <span
                                     class="required">*</span>
                                     class="required">*</span>
                             </label>
                             </label>
                             <div class="col-md-8 col-sm-8 col-xs-12">
                             <div class="col-md-8 col-sm-8 col-xs-12">
                                 <div class="input-group input-group-own">
                                 <div class="input-group input-group-own">
-                                    <input id="editUserAge" type="number" class="form-control"
+                                    <input id="editUserAgeDetail" type="number" class="form-control"
                                            data-validate-minmax="0,200"
                                            data-validate-minmax="0,200"
                                            placeholder="请输入" required="required">
                                            placeholder="请输入" required="required">
+                                    <input type="number" id="editUserAge" style="display: none;">
                                     <div class="input-group-btn">
                                     <div class="input-group-btn">
-                                        <button type="button" class="btn btn-default dropdown-toggle"
+                                        <button id="editAgeType" type="button" class="btn btn-default dropdown-toggle"
                                                 data-toggle="dropdown"
                                                 data-toggle="dropdown"
                                                 aria-expanded="false" style="margin-right: 0px;">岁 <span
                                                 aria-expanded="false" style="margin-right: 0px;">岁 <span
                                                 class="caret"></span>
                                                 class="caret"></span>