/** 入驻小区 **/ (function (vc) { var DEFAULT_PAGE = 1; var DEFAULT_ROWS = 10; vc.extends({ data: { staffCommunityInfo: { staffs: [], communitys: [], orgId: '', orgName: '', curStaffId: '', } }, _initMethod: function () { $that._loadStaffs(); }, _initEvent: function () { vc.on('staffCommunity', 'listStaffCommunity', function () { $that._loadStaffCommunitys(DEFAULT_PAGE,DEFAULT_ROWS); }); vc.on('staffCommunity', 'switchOrg', function (_org) { $that.staffCommunityInfo.orgId = _org.orgId; $that.staffCommunityInfo.orgName = _org.allOrgName; $that._loadStaffs(); }); }, methods: { _loadStaffs: function () { let param = { params: { page: 1, row: 100, orgId: $that.staffCommunityInfo.orgId, staffName:$that.staffCommunityInfo.staffNameLike } } vc.http.apiGet('/query.staff.infos', param, function (json) { let _json = JSON.parse(json); // 员工列表 和 岗位列表匹配 let staffList = _json.staffs; $that.staffCommunityInfo.staffs = staffList; if (staffList && staffList.length > 0) { $that.staffCommunityInfo.curStaffId = staffList[0].userId; $that._loadStaffCommunitys(DEFAULT_PAGE,DEFAULT_ROWS); } }, function () { console.log('请求失败处理'); } ); }, _staffAttendanceChangeOrg: function () { vc.emit('chooseOrgTree', 'openOrgModal', {}); }, swatchStaff: function (_staff) { $that.staffCommunityInfo.curStaffId = _staff.userId; $that._loadStaffCommunitys(DEFAULT_PAGE,DEFAULT_ROWS); }, _loadStaffCommunitys:function(_page,_rows){ let param = { params: { page: _page, row: _rows, staffId: $that.staffCommunityInfo.curStaffId } }; //发送get请求 vc.http.apiGet('/role.listStaffCommunity', param, function (json, res) { let _json = JSON.parse(json); $that.staffCommunityInfo.total = _json.total; $that.staffCommunityInfo.records = _json.records; $that.staffCommunityInfo.communitys = _json.data; vc.emit('staffCommunity', 'paginationPlus', 'init', { total: $that.staffCommunityInfo.records, dataCount: $that.staffCommunityInfo.total, currentPage: _page }); }, function (errInfo, error) { console.log('请求失败处理'); } ); }, _openAddStaffCommunityModal:function(){ vc.emit('addStaffCommunity', 'openAddStaffCommunityModal',{ staffId:$that.staffCommunityInfo.curStaffId, }) }, _openDeleteRoleCommunityModel:function(staffCommunity){ vc.emit( 'deleteStaffCommunity','openDeleteStaffCommunityModal',staffCommunity) }, } }); })(window.vc);