소스 검색

优化小区楼选择功能开发完成

wuxw 6 년 전
부모
커밋
533e8602c3

+ 2 - 5
WebService/src/main/resources/components/floorPackage/floor-select2/floorSelect2.html

@@ -1,8 +1,5 @@
 <select class="form-control floorSelector">
-    <option value="">请选择区域</option>
-    <option value="1" selected="selected">珠海</option>
-    <option value="2">深圳</option>
-    <option value="3">澳门</option>
-    <option value="4">香港</option>
+    <option value="">请选择楼栋</option>
+
 
 </select>

+ 26 - 6
WebService/src/main/resources/components/floorPackage/floor-select2/floorSelect2.js

@@ -13,17 +13,18 @@
         },
         _initMethod:function(){
                 vc.component._initFloorSelect2();
-
         },
         _initEvent:function(){
             //监听 modal 打开
-            $('#'+$props.parentModal).on('show.bs.modal', function () {
+           /* $('#'+$props.parentModal).on('show.bs.modal', function () {
                  vc.component._initFloorSelect2();
-            })
+            })*/
         },
         methods: {
             _initFloorSelect2: function () {
                 console.log("调用_initFloorSelect2 方法");
+                $.fn.modal.Constructor.prototype.enforceFocus = function () {};
+                $.fn.select2.defaults.set('width', '100%');
                 $('.floorSelector').select2({
                     placeholder: '必填,请选择楼栋',
                     ajax: {
@@ -31,16 +32,22 @@
                         dataType: 'json',
                         delay: 250,
                         data: function (params) {
+                            console.log("param", params);
+                            var _term = "";
+                            if(params.hasOwnProperty("term")){
+                                _term = params.term;
+                            }
                             return {
-                                floorNum: vc.component.floorSelect2Info.floorNum,
+                                floorName: _term,
                                 page: 1,
                                 row:10,
                                 communityId:vc.getCurrentCommunity().communityId
                             };
                         },
                         processResults: function (data) {
+                            console.log(data, vc.component._filterFloorData(data.apiFloorDataVoList));
                             return {
-                                results: data
+                                results: vc.component._filterFloorData(data.apiFloorDataVoList)
                             };
                         },
                         cache: true
@@ -49,7 +56,9 @@
                 $('.floorSelector').on("select2:select", function (evt) {
                     //这里是选中触发的事件
                     //evt.params.data 是选中项的信息
-                    console.log('select',evt)
+                    console.log('select',evt);
+                    vc.component.floorSelect2Info.floorId = evt.params.data.id;
+                    vc.component.floorSelect2Info.floorName = evt.params.data.text;
                 });
 
                 $('.floorSelector').on("select2:unselect", function (evt) {
@@ -58,6 +67,17 @@
                     console.log('unselect',evt)
 
                 });
+            },
+            _filterFloorData:function (_floors) {
+                var _tmpFloors = [];
+                for (var i = 0; i < _floors.length; i++) {
+                    var _tmpFloor = {
+                        id:_floors[i].floorId,
+                        text:_floors[i].floorName
+                    };
+                    _tmpFloors.push(_tmpFloor);
+                }
+                return _tmpFloors;
             }
         }
     });

+ 2 - 2
WebService/src/main/resources/components/machinePackage/add-machine/addMachine.html

@@ -1,4 +1,4 @@
-<div id="addMachineModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
+<div id="addMachineModel" class="modal fade"  role="dialog" aria-labelledby="exampleModalLabel"
      aria-hidden="true">
     <div class="modal-dialog modal-lg">
         <div class="modal-content">
@@ -61,7 +61,7 @@
                             </div>
                         </div>
                         <div class="form-group row"
-                             v-if="addMachineInfo.locationTypeCd == '2000' || addMachineInfo.locationTypeCd == '3000'  ">
+                             v-show="addMachineInfo.locationTypeCd == '2000' || addMachineInfo.locationTypeCd == '3000'  ">
                             <label class="col-sm-2 col-form-label">归属楼栋</label>
                             <div class="col-sm-10">
                                 <vc:create name="floorSelect2"

+ 6 - 0
java110-db/src/main/resources/mapper/community/FloorServiceDaoImplMapper.xml

@@ -149,6 +149,9 @@
         <if test="name !=null and name != ''">
             and f.name like concat('%',#{name},'%')
         </if>
+        <if test="floorName !=null and floorName != ''">
+            and f.name like concat('%',#{floorName},'%')
+        </if>
         <if test="statusCd !=null and statusCd != ''">
             and f.status_cd= #{statusCd}
         </if>
@@ -189,6 +192,9 @@
         <if test="name !=null and name != ''">
             and f.name like concat('%',#{name},'%')
         </if>
+        <if test="floorName !=null and floorName != ''">
+            and f.name like concat('%',#{floorName},'%')
+        </if>
         <if test="statusCd !=null and statusCd != ''">
             and f.status_cd= #{statusCd}
         </if>

+ 1 - 0
java110-front/src/main/resources/static/css/common.css

@@ -82,6 +82,7 @@
     /*防止select2不会自动失去焦点*/
     .select2-container {
         z-index: 16000 !important;
+        width: 100%;
     }
 
     .select2-drop-mask {

+ 14 - 4
java110-front/src/main/resources/static/js/core.js

@@ -10,6 +10,7 @@
    var _component = {};
    var _destroyedMethod = [];
    var _timers = [];//定时器
+   var _map = [];// 共享数据存储
 
    _vmOptions = {
         el:'#component',
@@ -46,7 +47,8 @@
         component:_component,
         destroyedMethod:_destroyedMethod,
         debug:false,
-        timers:_timers
+        timers:_timers,
+        _map:{}
     };
    //通知window对象
    window.vc = vc;
@@ -268,18 +270,26 @@
            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
           }
          return str.join("&");
-    }
+    };
     //空判断 true 为非空 false 为空
     vc.notNull = function(_paramObj){
         if(_paramObj == null || _paramObj == undefined || _paramObj.trim() == ''){
             return false;
         }
         return true;
-    }
+    };
     //设置debug 模式
     vc.setDebug = function (_param) {
        vc.debug = _param;
-    }
+    };
+    //数据共享存放 主要为了组件间传递数据
+    vc.put = function (_key, _value) {
+        vc.map[_key] = _value;
+    };
+    //数据共享 获取 主要为了组件间传递数据
+    vc.get = function (_key) {
+        return vc.map[_key];
+    };