Browse Source

电话查号

seimin 3 years ago
parent
commit
f7fdd264a2
3 changed files with 152 additions and 53 deletions
  1. 20 0
      css/index.css
  2. 40 10
      index.html
  3. 92 43
      js/index.js

+ 20 - 0
css/index.css

@@ -455,6 +455,26 @@ article > .content .left {
455 455
   color: #333;
456 456
   margin-top: 1px;
457 457
   border-bottom: 1px solid #fff;
458
+  position: relative;
459
+}
460
+
461
+.right .r-list .ch-search{
462
+  cursor: pointer;
463
+}
464
+
465
+.right .r-list .r-icon {
466
+  float: left;
467
+  position: absolute;
468
+  top: 50%;
469
+  left: 0;
470
+  margin-top: -12px;
471
+  padding-left: 8px;
472
+  padding-right: 8px;
473
+}
474
+
475
+.right .r-list .r-icon-search {
476
+  float: left;
477
+  margin-left: 20px;
458 478
 }
459 479
 
460 480
 .right .r-list .r-item .r-item-title {

+ 40 - 10
index.html

@@ -202,20 +202,19 @@
202 202
         <!-- 最新报修 -->
203 203
         <div class="right fl opcBg">
204 204
           <div class="title opcBg_title clearfix">
205
-            <!-- <div class="opcBg_item fl active"> -->
206
-            <div class="opcBg_item fl" style="width: 100%;padding-left: 16px;text-align: left;">
205
+            <div class="opcBg_item fl active">
207 206
               <i class="iconfont dsit-wodebaoxiu"></i> 最新报修
208 207
             </div>
209
-            <!-- <div class="opcBg_item fr">
208
+            <div class="opcBg_item fr">
210 209
               <i class="iconfont dsit-sousuo"></i> 电话查号
211
-            </div> -->
210
+            </div>
212 211
           </div>
213 212
           <div class="searchBox opcBg_searchBox">
214 213
             <input
215 214
               class="searchPro"
216 215
               id="searchPro1"
217 216
               type="text"
218
-              value="请输入关键字"
217
+              value="可简拼、名称搜索"
219 218
             />
220 219
             <span class="icon" id="searchProSubmit1">
221 220
               <i class="iconfont dsit-sousuo"></i>
@@ -548,25 +547,56 @@
548 547
     </li>
549 548
     {{/each}} {{/if}}
550 549
   </script>
551
-  <!-- 电话查号列表 -->
550
+  <!-- 电话查号结果列表 -->
552 551
   <script id="ch_list_temp" type="text/html">
553 552
     {{if list.length == 0}}
554 553
     <li class="noContent">
555 554
       <img src="./imgs/img_wubaoxiu.png" alt="" />
556 555
       <p>暂无数据</p>
557 556
     </li>
558
-    {{else}} {{each list}}
557
+    {{else}}
558
+    {{each list}}
559 559
     <li class="r-item hauto">
560 560
       <div class="r-item-title twoline"><span>{{$value.dept}}</span></div>
561 561
       <p class="r-item-content hauto">
562
-        单位名称:{{$value.parent?$value.parent.dept:''}}
562
+        单位名称:{{$value.unit.unit}}
563 563
       </p>
564 564
       <p class="r-item-content hauto">单位电话:{{$value.phone}}</p>
565 565
       <p class="r-item-content hauto">
566
-        办公地址:{{$value.place?$value.place.area.area+$value.place.place:''}}
566
+        办公地址:{{$value.address}}
567 567
       </p>
568 568
     </li>
569
-    {{/each}} {{/if}}
569
+    {{/each}}
570
+    {{/if}}
571
+  </script>
572
+  <!-- 电话查号列表 -->
573
+  <script id="ch_search_list_temp" type="text/html">
574
+    {{if list.length == 0}}
575
+    <li class="noContent">
576
+      <img src="./imgs/img_wubaoxiu.png" alt="" />
577
+      <p>暂无数据</p>
578
+    </li>
579
+    {{else}}
580
+    {{each list}}
581
+    <li class="r-item hauto clearfix ch-search">
582
+      <i class="iconfont dsit-sousuo r-icon"></i>
583
+      <div class="r-icon-search">
584
+        {{if $value.unit.id}}
585
+        <p class="r-item-content hauto">
586
+          单位:{{$value.unit.unit}}
587
+        </p>
588
+        <p class="r-item-content hauto">
589
+          部门:{{$value.dept}}
590
+        </p>
591
+        {{else}}
592
+        <p class="r-item-content hauto">
593
+          单位{{$value.unit}}
594
+        </p>
595
+        {{/if}}
596
+      </div>
597
+    </li>
598
+    {{/each}}
599
+    {{/if}}
570 600
   </script>
571 601
   <!-- 申请(1)详情 -->
572 602
   <script id="bx1_detail_temp" type="text/html">

+ 92 - 43
js/index.js

@@ -633,6 +633,9 @@ $(function () {
633 633
   $("#bx_list").on(
634 634
     "scroll",
635 635
     debounce(function () {
636
+      if($.trim($('.opcBg_item.active').text()) === '电话查号'){
637
+        return;
638
+      }
636 639
       var itemLen = $(this).find(".r-item").length;
637 640
       var itemHeight = $(this).find(".r-item").outerHeight();
638 641
       var wrapHeight = $(this).outerHeight();
@@ -1052,6 +1055,76 @@ $(function () {
1052 1055
       },
1053 1056
     });
1054 1057
   }
1058
+  //处理查号
1059
+  function handlerCh(val,list){
1060
+    //触发
1061
+    $("#bx_list").getNiceScroll().resize();
1062
+    $("#bx_list").show().next(".loading").hide();
1063
+    // 回显
1064
+    $("#searchPro1").val(val === "" ? "可简拼、名称搜索" : val);
1065
+    //placeholder
1066
+    $("#searchPro1")
1067
+      .on("focus", function () {
1068
+        if ($(this).val() == "可简拼、名称搜索") {
1069
+          $(this).val("");
1070
+        }
1071
+      })
1072
+      .on("blur", function () {
1073
+        if ($(this).val() == "") {
1074
+          $(this).val("可简拼、名称搜索");
1075
+        }
1076
+      });
1077
+    //电话挂号搜索
1078
+    $("#searchProSubmit1").on("click", search1);
1079
+    $("#searchPro1").on("keyup", function (e) {
1080
+      if (e.keyCode == 13) {
1081
+        search1();
1082
+      }
1083
+    });
1084
+    //点击单位或部门
1085
+    $('.ch-search').click(function(e){
1086
+      console.log(list.list);
1087
+      console.log($(this).index());
1088
+      var index = $(this).index();
1089
+      var obj = list.list[index];
1090
+      var data = {};
1091
+      if(obj.unit.id){
1092
+        //部门
1093
+        data.list = [obj];
1094
+        var html = template("ch_list_temp", data);
1095
+        $("#bx_list").html(html);
1096
+        //处理
1097
+        handlerCh(val,data);
1098
+      }else{
1099
+        //单位
1100
+        $.ajax({
1101
+          type: "POST",
1102
+          contentType: "application/json;charset=UTF-8",
1103
+          url: baseUrl + "user/queryPhone",
1104
+          data: JSON.stringify({
1105
+            unitId: obj.id
1106
+          }),
1107
+          success: function (res) {
1108
+            if (res.state == 200) {
1109
+              data.list = res.data;
1110
+              var html = template("ch_list_temp", data);
1111
+              $("#bx_list").html(html);
1112
+              //处理
1113
+              handlerCh(val,data);
1114
+            }
1115
+          },
1116
+          error: function (err) {
1117
+            console.log(err);
1118
+          },
1119
+        });
1120
+      }
1121
+    })
1122
+  }
1123
+  function search1() {
1124
+    bx_pageNum = 0;
1125
+    isSearch1 = true;
1126
+    getNewBxList(currentBxOrCh);
1127
+  }
1055 1128
   //获取最新报修或查号列表,0是报修,1是查号
1056 1129
   function getNewBxList(type) {
1057 1130
     $("#bx_list").hide().next(".loading").show();
@@ -1069,18 +1142,22 @@ $(function () {
1069 1142
     } else if (type === 1) {
1070 1143
       $('.opcBg_searchBox').show();
1071 1144
       var val =
1072
-        $.trim($("#searchPro1").val()) == "请输入关键字"
1145
+        $.trim($("#searchPro1").val()) == "可简拼、名称搜索"
1073 1146
           ? ""
1074 1147
           : $.trim($("#searchPro1").val());
1075
-      postData = {
1076
-        idx: bx_pageNum,
1077
-        sum: 10,
1078
-        department: {
1079
-          selectType: "pinyin_qs",
1080
-          dept: val,
1081
-        },
1082
-      };
1083
-      url = "user/data/fetchDataList/department";
1148
+      postData = {};
1149
+      if(val){
1150
+        postData.keyword = val;
1151
+      }
1152
+      url = "user/queryPhone";
1153
+      //没有搜索内容的时候,返回空数组
1154
+      if($("#searchPro1").val() === '可简拼、名称搜索'){
1155
+        var html = template("ch_search_list_temp", {list:[]});
1156
+        $("#bx_list").html(html);
1157
+        //处理
1158
+        handlerCh(val,{list:[]});
1159
+        return;
1160
+      }
1084 1161
     }
1085 1162
     $.ajax({
1086 1163
       type: "POST",
@@ -1463,45 +1540,17 @@ $(function () {
1463 1540
             $("#bx_list").show().next(".loading").hide();
1464 1541
           }
1465 1542
         } else if (type === 1) {
1466
-          if (res.status == 200) {
1543
+          if (res.state == 200) {
1467 1544
             //搜索挂号
1468 1545
             if (isSearch1) {
1469 1546
               ch_arr.list = [];
1470 1547
             }
1471 1548
             //添加分页数据,汇总
1472
-            ch_arr.list = ch_arr.list.concat(res.list);
1473
-            var html = template("ch_list_temp", ch_arr);
1549
+            // ch_arr.list = ch_arr.list.concat(res.data);
1550
+            ch_arr.list = res.data;
1551
+            var html = template("ch_search_list_temp", ch_arr);
1474 1552
             $("#bx_list").html(html);
1475
-            //触发
1476
-            $("#bx_list").getNiceScroll().resize();
1477
-            $("#bx_list").show().next(".loading").hide();
1478
-            // 回显
1479
-            $("#searchPro1").val(val === "" ? "请输入关键字" : val);
1480
-            //placeholder
1481
-            $("#searchPro1")
1482
-              .on("focus", function () {
1483
-                if ($(this).val() == "请输入关键字") {
1484
-                  $(this).val("");
1485
-                }
1486
-              })
1487
-              .on("blur", function () {
1488
-                if ($(this).val() == "") {
1489
-                  $(this).val("请输入关键字");
1490
-                }
1491
-              });
1492
-            //电话挂号搜索
1493
-            $("#searchProSubmit1").on("click", search1);
1494
-            $("#searchPro1").on("keyup", function (e) {
1495
-              if (e.keyCode == 13) {
1496
-                search1();
1497
-              }
1498
-            });
1499
-
1500
-            function search1() {
1501
-              bx_pageNum = 0;
1502
-              isSearch1 = true;
1503
-              getNewBxList(currentBxOrCh);
1504
-            }
1553
+            handlerCh(val,ch_arr);
1505 1554
           }
1506 1555
         }
1507 1556
       },