wuxw лет назад: 6
Родитель
Сommit
a31deb5546

+ 1 - 1
Api/src/main/java/com/java110/api/listener/org/ListOrgNoCommunitysListener.java

@@ -28,7 +28,7 @@ import java.util.List;
 /**
  * 查询小区侦听类
  */
-@Java110Listener("listOrgCommunitysListener")
+@Java110Listener("listOrgNoCommunitysListener")
 public class ListOrgNoCommunitysListener extends AbstractServiceApiListener {
 
     @Autowired

+ 4 - 8
WebService/src/main/java/com/java110/web/components/org/AddOrgCommunityComponent.java

@@ -7,6 +7,8 @@ import com.java110.utils.constant.StateConstant;
 import com.java110.web.smo.ICommunityServiceSMO;
 import com.java110.web.smo.org.IAddOrgCommunitySMO;
 import com.java110.web.smo.org.IAddOrgSMO;
+import com.java110.web.smo.org.IListOrgCommunitysSMO;
+import com.java110.web.smo.org.IListOrgNoCommunitysSMO;
 import com.java110.web.smo.org.IListOrgsSMO;
 import com.java110.web.smo.org.IListParentOrgsSMO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +25,7 @@ public class AddOrgCommunityComponent {
     private IAddOrgCommunitySMO addOrgCommunitySMOImpl;
 
     @Autowired
-    private IListOrgsSMO listOrgsSMOImpl;
+    private IListOrgNoCommunitysSMO listOrgNoCommunitysSMOImpl;
 
     @Autowired
     private IListParentOrgsSMO listParentOrgsSMOImpl;
@@ -47,7 +49,7 @@ public class AddOrgCommunityComponent {
      * @return 返回 ResponseEntity 对象
      */
     public ResponseEntity<String> list(IPageData pd) {
-        return listOrgsSMOImpl.listOrgs(pd);
+        return listOrgNoCommunitysSMOImpl.listOrgNoCommunitys(pd);
     }
 
 
@@ -63,13 +65,7 @@ public class AddOrgCommunityComponent {
         this.listParentOrgsSMOImpl = listParentOrgsSMOImpl;
     }
 
-    public IListOrgsSMO getListOrgsSMOImpl() {
-        return listOrgsSMOImpl;
-    }
 
-    public void setListOrgsSMOImpl(IListOrgsSMO listOrgsSMOImpl) {
-        this.listOrgsSMOImpl = listOrgsSMOImpl;
-    }
 
     public ICommunityServiceSMO getCommunityServiceSMOImpl() {
         return communityServiceSMOImpl;

+ 5 - 5
WebService/src/main/resources/components/orgPackage/addOrgCommunity/addOrgCommunity.html

@@ -4,7 +4,7 @@
     <div class="modal-dialog modal-lg">
         <div class="modal-content">
             <div class="modal-header">
-                <h3 class="modal-title" id="addOrgCommunityModelLabel">绑定</h3>
+                <h3 class="modal-title" id="addOrgCommunityModelLabel">添加隶属小区</h3>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">&times;</span>
                 </button>
@@ -34,7 +34,7 @@
                                     <thead>
                                     <tr>
                                         <th class="text-center">
-                                            <input type="checkbox"  class="i-checks" name="input[]">
+                                            <input type="checkbox"  class="i-checks " @click="checkAll($event)" id="quan">
                                         </th>
                                         <th class="text-center">小区ID</th>
                                         <th class="text-center">小区名称</th>
@@ -45,17 +45,17 @@
                                     <tbody>
                                     <tr v-for="community in addOrgCommunityInfo.communitys">
                                         <td class="text-center">
-                                            <input type="checkbox"   class="i-checks" name="input[]">
+                                            <input type="checkbox" class="i-checks checkItem" v-bind:value="community.communityId" v-model="addOrgCommunityInfo.selectCommunitys" >
                                         </td>
                                         <td class="text-center">{{community.communityId}}</td>
-                                        <td class="text-center">{{community.communityName}}</td>
+                                        <td class="text-center">{{community.name}}</td>
                                         <td class="text-center">{{community.address}}</td>
                                     </tr>
                                     </tbody>
                                 </table>
                                 <div class="ibox-content">
                                     <button class="btn btn-primary float-right" type="button" v-on:click="addOrgCommunity()"><i
-                                            class="fa fa-check"></i>&nbsp;保存
+                                            class="fa fa-check"></i>&nbsp;提交
                                     </button>
                                     <button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
                                             data-dismiss="modal">取消

+ 75 - 12
WebService/src/main/resources/components/orgPackage/addOrgCommunity/addOrgCommunity.js

@@ -1,19 +1,37 @@
 (function(vc){
     vc.extends({
+        propTypes: {
+           emitListener:vc.propTypes.string,
+           emitFunction:vc.propTypes.string
+        },
         data:{
             addOrgCommunityInfo:{
                 communitys:[],
                 communityName:'',
+                orgId:'',
+                orgName:'',
                 selectCommunitys:[]
             }
         },
+        watch: { // 监视双向绑定的数据数组
+            checkData: {
+                handler(){ // 数据数组有变化将触发此函数
+                    if(vc.component.addOrgCommunityInfo.selectCommunitys.length == vc.component.addOrgCommunityInfo.communitys.length){
+                        document.querySelector('#quan').checked = true;
+                    }else {
+                        document.querySelector('#quan').checked = false;
+                    }
+                },
+                deep: true // 深度监视
+            }
+        },
         _initMethod:function(){
         },
         _initEvent:function(){
             vc.on('addOrgCommunity','openAddOrgCommunityModal',function(_param){
+                vc.component._refreshChooseOrgInfo();
                 $('#addOrgCommunityModel').modal('show');
                 vc.copyObject(_param,vc.component.addOrgCommunityInfo);
-                vc.component._refreshChooseOrgInfo();
                 vc.component._loadAllCommunityInfo(1,10,'');
             });
         },
@@ -23,10 +41,8 @@
                     params:{
                         page:_page,
                         row:_row,
-                        communityId:vc.getCurrentCommunity().communityId,
                         name:_name,
-                        orgLevel:vc.component.addOrgCommunityInfo.orgLevel,
-                        parentOrgId:vc.component.addOrgCommunityInfo.parentOrgId,
+                        orgId:vc.component.addOrgCommunityInfo.orgId
                     }
                 };
 
@@ -35,21 +51,54 @@
                             'list',
                              param,
                              function(json){
-                                var _orgInfo = JSON.parse(json);
-                                vc.component.addOrgCommunityInfo.orgs = _orgInfo.orgs;
+                                var _communityInfo = JSON.parse(json);
+                                vc.component.addOrgCommunityInfo.communitys = _communityInfo.communitys;
                              },function(){
                                 console.log('请求失败处理');
                              }
                            );
             },
             addOrgCommunity:function(_org){
-                if(_org.hasOwnProperty('name')){
-                     _org.orgName = _org.name;
+                var _selectCommunitys = vc.component.addOrgCommunityInfo.selectCommunitys;
+                var _tmpCommunitys = vc.component.addOrgCommunityInfo.communitys;
+                if(_selectCommunitys.length <1){
+                    vc.toast("请选择隶属小区");
+                    return ;
                 }
-                vc.emit($props.emitChooseOrg,'addOrgCommunity',_org);
-                vc.emit($props.emitLoadData,'listOrgData',{
-                    orgId:_org.orgId
-                });
+                var _communitys = [];
+                for(var _selectIndex = 0 ;_selectIndex <_selectCommunitys.length ;_selectIndex ++){
+                    for(var _communityIndex =0; _communityIndex < _tmpCommunitys.length;_communityIndex++){
+                        if(_selectCommunitys[_selectIndex] == _tmpCommunitys[_communityIndex].communityId){
+                            _communitys.push({
+                                communityId:_tmpCommunitys[_communityIndex].communityId,
+                                communityName:_tmpCommunitys[_communityIndex].name
+                            });
+                        }
+                    }
+                }
+                var _objData = {
+                    orgId:vc.component.addOrgCommunityInfo.orgId,
+                    orgName:vc.component.addOrgCommunityInfo.orgName,
+                    communitys:_communitys
+                }
+                vc.http.post('addOrgCommunity',
+                    'save',
+                    JSON.stringify(_objData),
+                    {
+                        emulateJSON: true
+                    },
+                 function(json,res){
+                    $('#addOrgCommunityModel').modal('hide');
+                    if(res.status == 200){
+                        vc.emit($props.emitListener,$props.emitFunction,{
+                        });
+                        return ;
+                    }
+                    vc.toast(json);
+                 },function(){
+                    console.log('请求失败处理');
+                 }
+               );
                 $('#addOrgCommunityModel').modal('hide');
             },
             queryCommunitys:function(){
@@ -59,8 +108,22 @@
                 vc.component.addOrgCommunityInfo={
                     communitys:[],
                     communityName:'',
+                    orgId:'',
+                    orgName:'',
                     selectCommunitys:[]
                 };
+            },
+            checkAll:function(e){
+                    var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
+                    if(e.target.checked){ // 判定全选checkbox的勾选状态
+                        for(var i=0;i<checkObj.length;i++){
+                            if(!checkObj[i].checked){ // 将未勾选的checkbox选项push到绑定数组中
+                                vc.component.addOrgCommunityInfo.selectCommunitys.push(checkObj[i].value);
+                            }
+                        }
+                    }else { // 如果是去掉全选则清空checkbox选项绑定数组
+                        vc.component.addOrgCommunityInfo.selectCommunitys = [];
+                    }
             }
         }
 

+ 1 - 1
WebService/src/main/resources/components/orgPackage/org-manage/orgManage.html

@@ -1,5 +1,5 @@
 <div id="component" class="wrapper wrapper-content animated fadeInRight ecommerce">
-    <div class="row" v-if="orgManageInfo.showBelongCommunity == false">
+    <div class="row" v-show="orgManageInfo.showBelongCommunity == false">
         <div class="col-lg-3">
             <div id="orgTree" class="" style="background: #fff;"></div>
         </div>

+ 3 - 0
WebService/src/main/resources/components/orgPackage/org-manage/orgManage.js

@@ -76,6 +76,9 @@
             vc.on('pagination', 'page_event', function (_currentPage) {
                 vc.component._listOrgs(_currentPage, DEFAULT_ROWS);
             });
+            vc.on('orgManage','onBack',function(_param){
+                 vc.component.orgManageInfo.showBelongCommunity = false;
+            })
 
         },
         methods: {

+ 6 - 0
WebService/src/main/resources/components/orgPackage/orgCommunityManage/orgCommunityManage.html

@@ -4,6 +4,10 @@
             <div class="ibox-title">
                 <h5>{{orgCommunityManageInfo.orgName}}隶属小区</h5>
                 <div class="ibox-tools" style="top:10px;">
+                    <button type="button" class="btn btn-primary btn-sm" v-on:click="_goBack()">
+                        <i class="glyphicon glyphicon-plus"></i>
+                        返回
+                    </button>
                     <button type="button" class="btn btn-primary btn-sm" v-on:click="_openAddOrgCommunityModal()">
                         <i class="glyphicon glyphicon-plus"></i>
                         添加
@@ -54,6 +58,8 @@
         </div>
     </div>
     <vc:create name="addOrgCommunity"
+               emitListener="orgCommunityManageInfo"
+               emitFunction="listOrgCommunity"
     ></vc:create>
     <vc:create name="deleteOrgCommunity"></vc:create>
 </div>

+ 3 - 0
WebService/src/main/resources/components/orgPackage/orgCommunityManage/orgCommunityManage.js

@@ -88,6 +88,9 @@
                     vc.component.orgCommunityManageInfo.moreCondition = true;
                 }
             },
+            _goBack:function(){
+                vc.emit('orgManage','onBack',{});
+            }