Browse Source

增加校区

seimin 2 years ago
parent
commit
9260dd0e8f
2 changed files with 97 additions and 37 deletions
  1. 35 36
      index.html
  2. 62 1
      js/index.js

+ 35 - 36
index.html

@@ -239,14 +239,15 @@
239
       </div>
239
       </div>
240
     </div>
240
     </div>
241
     {{else}}
241
     {{else}}
242
-    <!-- 区域地点 -->
242
+    <!-- 校区区域地点 -->
243
     <div class="formItem">
243
     <div class="formItem">
244
-      <div class="label"><span class="required">*</span>区域地点:</div>
244
+      <div class="label"><span class="required">*</span>校区区域地点:</div>
245
       <div>
245
       <div>
246
         <div class="areaplace">
246
         <div class="areaplace">
247
           <div class="areaBox clearfix">
247
           <div class="areaBox clearfix">
248
-            <select class="fl" id="area_list" style="font-size: 12px"></select>
249
-            <select class="fr" id="place_list" style="font-size: 12px"></select>
248
+            <select class="fl" id="branch_list" style="font-size: 12px;width: 115px;margin-right: 8px;"></select>
249
+            <select class="fl" id="area_list" style="font-size: 12px;width: 115px;margin-right: 8px;"></select>
250
+            <select class="fr" id="place_list" style="font-size: 12px;width: 115px;"></select>
250
           </div>
251
           </div>
251
         </div>
252
         </div>
252
       </div>
253
       </div>
@@ -417,6 +418,12 @@
417
       </div>
418
       </div>
418
     </div>
419
     </div>
419
   </script>
420
   </script>
421
+  <!-- 校区 -->
422
+  <script id="branch_list_temp" type="text/html">
423
+    {{each list}}
424
+    <option value="{{$value.id}}">{{$value.hosName}}</option>
425
+    {{/each}}
426
+  </script>
420
   <!-- 区域 -->
427
   <!-- 区域 -->
421
   <script id="area_list_temp" type="text/html">
428
   <script id="area_list_temp" type="text/html">
422
     {{each list}}
429
     {{each list}}
@@ -700,10 +707,9 @@
700
           </li>
707
           </li>
701
           <li class="pop1-hd__itemList">
708
           <li class="pop1-hd__itemList">
702
             <strong>报修地址:</strong>
709
             <strong>报修地址:</strong>
703
-            <span
704
-              >{{incident.place ? incident.place.area.area +
705
-              incident.place.place : ''}}{{address}}</span
706
-            >
710
+            <span>
711
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
712
+            </span>
707
           </li>
713
           </li>
708
           {{if wxIncidentWithCmdb == 1}}
714
           {{if wxIncidentWithCmdb == 1}}
709
           <li class="pop1-hd__itemList">
715
           <li class="pop1-hd__itemList">
@@ -812,10 +818,9 @@
812
           </li>
818
           </li>
813
           <li class="pop1-hd__itemList">
819
           <li class="pop1-hd__itemList">
814
             <strong>报修地址:</strong>
820
             <strong>报修地址:</strong>
815
-            <span
816
-              >{{incident.place ? incident.place.area.area +
817
-              incident.place.place : ''}}{{address}}</span
818
-            >
821
+            <span>
822
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
823
+            </span>
819
           </li>
824
           </li>
820
           {{if wxIncidentWithCmdb == 1}}
825
           {{if wxIncidentWithCmdb == 1}}
821
           <li class="pop1-hd__itemList">
826
           <li class="pop1-hd__itemList">
@@ -930,10 +935,9 @@
930
           </li>
935
           </li>
931
           <li class="pop1-hd__itemList">
936
           <li class="pop1-hd__itemList">
932
             <strong>报修地址:</strong>
937
             <strong>报修地址:</strong>
933
-            <span
934
-              >{{incident.place ? incident.place.area.area +
935
-              incident.place.place : ''}}{{address}}</span
936
-            >
938
+            <span>
939
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
940
+            </span>
937
           </li>
941
           </li>
938
           {{if wxIncidentWithCmdb == 1}}
942
           {{if wxIncidentWithCmdb == 1}}
939
           <li class="pop1-hd__itemList">
943
           <li class="pop1-hd__itemList">
@@ -1054,10 +1058,9 @@
1054
           </li>
1058
           </li>
1055
           <li class="pop1-hd__itemList">
1059
           <li class="pop1-hd__itemList">
1056
             <strong>报修地址:</strong>
1060
             <strong>报修地址:</strong>
1057
-            <span
1058
-              >{{incident.place ? incident.place.area.area +
1059
-              incident.place.place : ''}}{{address}}</span
1060
-            >
1061
+            <span>
1062
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
1063
+            </span>
1061
           </li>
1064
           </li>
1062
           {{if wxIncidentWithCmdb == 1}}
1065
           {{if wxIncidentWithCmdb == 1}}
1063
           <li class="pop1-hd__itemList">
1066
           <li class="pop1-hd__itemList">
@@ -1184,10 +1187,9 @@
1184
           </li>
1187
           </li>
1185
           <li class="pop1-hd__itemList">
1188
           <li class="pop1-hd__itemList">
1186
             <strong>报修地址:</strong>
1189
             <strong>报修地址:</strong>
1187
-            <span
1188
-              >{{incident.place ? incident.place.area.area +
1189
-              incident.place.place : ''}}{{address}}</span
1190
-            >
1190
+            <span>
1191
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
1192
+            </span>
1191
           </li>
1193
           </li>
1192
           {{if wxIncidentWithCmdb == 1}}
1194
           {{if wxIncidentWithCmdb == 1}}
1193
           <li class="pop1-hd__itemList">
1195
           <li class="pop1-hd__itemList">
@@ -1312,10 +1314,9 @@
1312
           </li>
1314
           </li>
1313
           <li class="pop1-hd__itemList">
1315
           <li class="pop1-hd__itemList">
1314
             <strong>报修地址:</strong>
1316
             <strong>报修地址:</strong>
1315
-            <span
1316
-              >{{incident.place ? incident.place.area.area +
1317
-              incident.place.place : ''}}{{address}}</span
1318
-            >
1317
+            <span>
1318
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
1319
+            </span>
1319
           </li>
1320
           </li>
1320
           {{if wxIncidentWithCmdb == 1}}
1321
           {{if wxIncidentWithCmdb == 1}}
1321
           <li class="pop1-hd__itemList">
1322
           <li class="pop1-hd__itemList">
@@ -1440,10 +1441,9 @@
1440
           </li>
1441
           </li>
1441
           <li class="pop1-hd__itemList">
1442
           <li class="pop1-hd__itemList">
1442
             <strong>报修地址:</strong>
1443
             <strong>报修地址:</strong>
1443
-            <span
1444
-              >{{incident.place ? incident.place.area.area +
1445
-              incident.place.place : ''}}{{address}}</span
1446
-            >
1444
+            <span>
1445
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
1446
+            </span>
1447
           </li>
1447
           </li>
1448
           {{if wxIncidentWithCmdb == 1}}
1448
           {{if wxIncidentWithCmdb == 1}}
1449
           <li class="pop1-hd__itemList">
1449
           <li class="pop1-hd__itemList">
@@ -1642,10 +1642,9 @@
1642
           </li>
1642
           </li>
1643
           <li class="pop1-hd__itemList">
1643
           <li class="pop1-hd__itemList">
1644
             <strong>报修地址:</strong>
1644
             <strong>报修地址:</strong>
1645
-            <span
1646
-              >{{incident.place ? incident.place.area.area +
1647
-              incident.place.place : ''}}{{address}}</span
1648
-            >
1645
+            <span>
1646
+              {{branch?branch.hosName:''}} {{place ? place.area.area + ' ' + place.place : ''}} {{address}}
1647
+            </span>
1649
           </li>
1648
           </li>
1650
           {{if wxIncidentWithCmdb == 1}}
1649
           {{if wxIncidentWithCmdb == 1}}
1651
           <li class="pop1-hd__itemList">
1650
           <li class="pop1-hd__itemList">

+ 62 - 1
js/index.js

@@ -19,6 +19,7 @@ $(function () {
19
   );
19
   );
20
   $("#areaPlaceRoom").html(template("areaPlaceRoom_temp", { ifRoom: ifRoom }));
20
   $("#areaPlaceRoom").html(template("areaPlaceRoom_temp", { ifRoom: ifRoom }));
21
   // repairMain.valueconfig = '2';
21
   // repairMain.valueconfig = '2';
22
+  var areaList = []; //获取到的区域列表
22
   var placeList = []; //获取到的地点列表
23
   var placeList = []; //获取到的地点列表
23
   var roomList = []; //获取到的房间号列表
24
   var roomList = []; //获取到的房间号列表
24
   var wxId = ""; //微信报修ID
25
   var wxId = ""; //微信报修ID
@@ -86,6 +87,8 @@ $(function () {
86
     sum: 10,
87
     sum: 10,
87
     solution: { title: "", status: { id: 72 }, solutionRange: 1 },
88
     solution: { title: "", status: { id: 72 }, solutionRange: 1 },
88
   });
89
   });
90
+  // 获取校区列表
91
+  getBranchList({ idx: 0, sum: 1000 });
89
   // 获取区域列表
92
   // 获取区域列表
90
   getAreaList({ idx: 0, sum: 1000, area: { wechatArea: true } });
93
   getAreaList({ idx: 0, sum: 1000, area: { wechatArea: true } });
91
   // 获取地点列表
94
   // 获取地点列表
@@ -489,7 +492,34 @@ $(function () {
489
       solution: { title: val, status: { id: 72 } },
492
       solution: { title: val, status: { id: 72 } },
490
     });
493
     });
491
   }
494
   }
492
-
495
+  //选择框联动-选校区
496
+  $("#branch_list").on("change", function () {
497
+    //获取id
498
+    var id = $(this).val();
499
+    // 过滤数据
500
+    var resFilter = { list: [] };
501
+    for (var i = 0; i < areaList.length; i++) {
502
+      if (areaList[i]["branch"] == id) {
503
+        resFilter.list.push(areaList[i]);
504
+      }
505
+    }
506
+    //填充数据
507
+    var html = template("area_list_temp", resFilter);
508
+    $("#area_list").html(html);
509
+    // 过滤数据
510
+    var resFilter1 = { list: [] };
511
+    for (var i = 0; i < placeList.length; i++) {
512
+      if (placeList[i]["area"]["id"] == resFilter.list[0].id) {
513
+        resFilter1.list.push(placeList[i]);
514
+      }
515
+    }
516
+    //填充数据
517
+    var html = template("place_list_temp", resFilter1);
518
+    $("#place_list").html(html);
519
+    if (resFilter1.list.length) {
520
+      $("#bx_address").val(resFilter1.list[0].place);
521
+    }
522
+  });
493
   //选择框联动-选区域
523
   //选择框联动-选区域
494
   $("#area_list").on("change", function () {
524
   $("#area_list").on("change", function () {
495
     //获取id
525
     //获取id
@@ -577,6 +607,13 @@ $(function () {
577
         $("#bx_name").val("");
607
         $("#bx_name").val("");
578
       }
608
       }
579
     }
609
     }
610
+    if ($("#branch_list").val() < 1) {
611
+      alert("校区不能为空");
612
+      //按钮禁止取消
613
+      $(this).removeProp("disabled");
614
+      $(this).removeClass("f-submit--disable");
615
+      return;
616
+    }
580
     if ($("#area_list").val() < 1) {
617
     if ($("#area_list").val() < 1) {
581
       alert("区域不能为空");
618
       alert("区域不能为空");
582
       //按钮禁止取消
619
       //按钮禁止取消
@@ -625,6 +662,7 @@ $(function () {
625
     var data = { verification: "true" };
662
     var data = { verification: "true" };
626
     data.incident = {
663
     data.incident = {
627
       address: $.trim($("#bx_address").val()),
664
       address: $.trim($("#bx_address").val()),
665
+      branch: {id: $.trim($("#branch_list").val())},
628
       areaId: $.trim($("#area_list").val()),
666
       areaId: $.trim($("#area_list").val()),
629
       bxcode: wxId,
667
       bxcode: wxId,
630
       contacts: $.trim($("#bx_name").val()),
668
       contacts: $.trim($("#bx_name").val()),
@@ -1030,6 +1068,25 @@ $(function () {
1030
       },
1068
       },
1031
     });
1069
     });
1032
   }
1070
   }
1071
+  //获取校区列表
1072
+  function getBranchList(data) {
1073
+    $.ajax({
1074
+      type: "POST",
1075
+      contentType: "application/json;charset=UTF-8",
1076
+      url: baseUrl + "user/data/fetchDataList/branch",
1077
+      data: JSON.stringify(data),
1078
+      success: function (res) {
1079
+        if (res.status == 200) {
1080
+          var html = template("branch_list_temp", res);
1081
+          $("#branch_list").html(html);
1082
+          $("#branch_list").val(loginUser.branch.id);
1083
+        }
1084
+      },
1085
+      error: function (err) {
1086
+        console.log(err);
1087
+      },
1088
+    });
1089
+  }
1033
   //获取区域列表
1090
   //获取区域列表
1034
   function getAreaList(data) {
1091
   function getAreaList(data) {
1035
     $.ajax({
1092
     $.ajax({
@@ -1039,6 +1096,10 @@ $(function () {
1039
       data: JSON.stringify(data),
1096
       data: JSON.stringify(data),
1040
       success: function (res) {
1097
       success: function (res) {
1041
         if (res.status == 200) {
1098
         if (res.status == 200) {
1099
+          areaList = JSON.parse(JSON.stringify(res.list));
1100
+          res.list = res.list.filter((v) => {
1101
+            return v.branch == loginUser.branch.id;
1102
+          });
1042
           var html = template("area_list_temp", res);
1103
           var html = template("area_list_temp", res);
1043
           $("#area_list").html(html);
1104
           $("#area_list").html(html);
1044
           $("#area_list").val(loginUser.place.area.id);
1105
           $("#area_list").val(loginUser.place.area.id);