Selaa lähdekoodia

挂号默认自动选中

hurugang 5 vuotta sitten
vanhempi
commit
cf37be5da9

+ 4 - 1
src/main/java/cn/hnthyy/thmz/controller/MzyRequestController.java

@@ -136,11 +136,14 @@ public class MzyRequestController {
             if (mzyRequests != null && mzyRequests.size() > 0) {
                 mzyRequests.forEach(d -> {
                     if (d!=null) {
-                        Employee employee =null;
+                        Employee employee;
                         if (StringUtils.isNotBlank(d.getDoctorCode())) {
                             employee = employeeService.queryByUserCode(d.getDoctorCode());
                             if(employee==null){
                                 log.error("没有查询到对应的医生,医生编码是{}",d.getDoctorCode());
+                                employee = new Employee();
+                                employee.setEmployeeCode(d.getDoctorCode());
+                                employee.setEmployeeName(d.getDoctorCode());
                             }
                         }else {
                             employee = new Employee();

+ 17 - 5
src/main/resources/static/js/registration.js

@@ -360,20 +360,21 @@ function initEmployee() {
                 return;
             }
             var html = '';
-            var flag = false;
+            var defaultCode=null;
             $.each(res.data, function (commentIndex, comment) {
                 html += '<option value="' + comment.employee.employeeCode + '" data-chargeType="' + comment.chargeType + '"  data-checkFee="' + comment.checkFee + '" data-mzyRequestId="' + comment.mzyRequestId + '">' + comment.employee.employeeName + '</option>';
-                if (comment.employee.employeeCode == -1) {
-                    flag = true;
+                if(res.data.length==1){
+                    //如果只有一个号别,默认选中
+                    defaultCode=comment.employee.employeeCode;
                 }
             });
             $('#doctor').empty();
             $('#doctor').html(html);
             $('#doctor').selectpicker('refresh');
             validator.checkAll($("#regi_form"));
-            if (flag) {
+            if (defaultCode!=null) {
                 //如果有无需选择医生的选项,默认选择
-                $('#doctor').selectpicker('val', -1);
+                $('#doctor').selectpicker('val', defaultCode);
                 $('#doctor').selectpicker('refresh');
                 fitFee();
             }
@@ -434,12 +435,23 @@ function initChargeType() {
                 return;
             }
             var html = '';
+            var defaultCode=null;
             $.each(res.data, function (commentIndex, comment) {
+                if(res.data.length==1){
+                    //如果只有一个号别,默认选中
+                    defaultCode=comment.code;
+                }
                 html += '<option value="' + comment.code + '">' + comment.name + '</option>';
             });
             $('#chargeType').empty();   //清空resText里面的所有内容
             $('#chargeType').html(html);
             $('#chargeType').selectpicker('refresh');
+            if (defaultCode!=null) {
+                //如果有默认选项,默认选择
+                $('#chargeType').selectpicker('val', defaultCode);
+                $('#chargeType').selectpicker('refresh');
+                initEmployee();
+            }
             validator.checkAll($("#regi_form"));
             emptyInput();
         }