| | |
| | | (function(vc){ |
| | | var DEFAULT_PAGE = 1; |
| | | var DEFAULT_ROWS = 10; |
| | | var ALL_ROWS = 100; |
| | | vc.extends({ |
| | | data:{ |
| | | orgManageInfo:{ |
| | |
| | | records:1, |
| | | moreCondition:false, |
| | | orgName:'', |
| | | headOrg:[], |
| | | branchOrg:[], |
| | | orgTree:[], |
| | | conditions:{ |
| | | orgId:'', |
| | | orgName:'', |
| | | communityId:'', |
| | | orgLevel:'', |
| | | parentOrgId:'', |
| | | |
| | | } |
| | | } |
| | | }, |
| | | watch:{ |
| | | "orgManageInfo.conditions.headOrgId":{//深度监听,可监听到对象、数组的变化 |
| | | handler(val, oldVal){ |
| | | vc.component._getOrgsByOrgLevel(DEFAULT_PAGE, DEFAULT_ROWS,2,val); |
| | | |
| | | vc.component.orgManageInfo.conditions.parentOrgId = val; |
| | | |
| | | vc.component.orgManageInfo.conditions.branchOrgId = ''; |
| | | |
| | | vc.component._listOrgs(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | |
| | | }, |
| | | deep:true |
| | | }, |
| | | "orgManageInfo.conditions.branchOrgId":{//深度监听,可监听到对象、数组的变化 |
| | | handler(val, oldVal){ |
| | | if(val == ''){ |
| | | vc.component.orgManageInfo.conditions.parentOrgId = vc.component.orgManageInfo.conditions.headOrgId; |
| | | }else{ |
| | | vc.component.orgManageInfo.conditions.parentOrgId = val; |
| | | } |
| | | vc.component._listOrgs(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | }, |
| | | deep:true |
| | | } |
| | | }, |
| | | _initMethod:function(){ |
| | | vc.component._listOrgs(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | //只查 查询总公司级组织 |
| | | vc.component.orgManageInfo.orgTree = []; |
| | | vc.component._listOrgTrees(vc.component.orgManageInfo.orgTree,'1', '',function(){ |
| | | vc.component._loadBranchOrgTrees(); |
| | | }); |
| | | vc.component._getOrgsByOrgLevel(DEFAULT_PAGE, DEFAULT_ROWS,1,''); |
| | | |
| | | }, |
| | | _initEvent:function(){ |
| | | |
| | |
| | | }); |
| | | }, |
| | | methods:{ |
| | | _refreshOrgTree:function(){ |
| | | $('#orgTree').treeview({ |
| | | data: vc.component.orgManageInfo.orgTree |
| | | }); |
| | | }, |
| | | _loadBranchOrgTrees:function(){ |
| | | //默认查询分公司组织信息 |
| | | vc.component._listOrgTrees(vc.component.orgManageInfo.orgTree[0].nodes, |
| | | '2', |
| | | vc.component.orgManageInfo.orgTree[0].orgId, |
| | | function(){ |
| | | vc.component._refreshOrgTree(); |
| | | }); |
| | | }, |
| | | _listOrgTrees:function(_nodes,_orgLevel,_parentOrgId,_callback){ |
| | | var param = { |
| | | params:{ |
| | | page:DEFAULT_PAGE, |
| | | row:ALL_ROWS, |
| | | orgLevel:_orgLevel, |
| | | parentOrgId:_parentOrgId |
| | | } |
| | | }; |
| | | //发送get请求 |
| | | vc.http.get('orgManage', |
| | | 'list', |
| | | param, |
| | | function(json,res){ |
| | | var _tmpOrgs =JSON.parse(json).orgs; |
| | | _tmpOrgs.forEach(function (_item) { |
| | | _nodes.push({ |
| | | orgId:_item.orgId, |
| | | text:_item.orgName, |
| | | href:function(_item){}, |
| | | tags:[0], |
| | | nodes:[] |
| | | }); |
| | | _callback(); |
| | | }); |
| | | },function(errInfo,error){ |
| | | console.log('请求失败处理'); |
| | | } |
| | | ); |
| | | }, |
| | | _listOrgs:function(_page, _rows){ |
| | | |
| | | vc.component.orgManageInfo.conditions.page = _page; |
| | |
| | | }else{ |
| | | vc.component.orgManageInfo.moreCondition = true; |
| | | } |
| | | }, |
| | | |
| | | _getOrgsByOrgLevel:function(_page, _rows,_orgLevel,_parentOrgId){ |
| | | |
| | | var param = { |
| | | params:{ |
| | | page: _page, |
| | | row: _rows, |
| | | orgLevel:_orgLevel, |
| | | parentOrgId: _parentOrgId |
| | | } |
| | | }; |
| | | |
| | | //发送get请求 |
| | | vc.http.get('orgManage', |
| | | 'list', |
| | | param, |
| | | function(json,res){ |
| | | var _orgManageInfo=JSON.parse(json); |
| | | if(_orgLevel == 1){ |
| | | vc.component.orgManageInfo.headOrg = _orgManageInfo.orgs; |
| | | }else{ |
| | | vc.component.orgManageInfo.branchOrg = _orgManageInfo.orgs; |
| | | } |
| | | },function(errInfo,error){ |
| | | console.log('请求失败处理'); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | |