(function (vc) { var DEFAULT_PAGE = 1; var DEFAULT_ROWS = 10; vc.extends({ data: { aStaffInfo: { moreCondition: false, branchOrgs: [], departmentOrgs: [], relCds: [], staffs:[], conditions: { branchOrgId: '', departmentOrgId: '', orgId: '', orgName: '', orgLevel: '2', parentOrgId: '', name: '', tel: '', staffId: '', parentOrgName: '', parentTwoOrgId: '' } }, }, _initMethod: function () { // 查询岗位列表 vc.getDict('u_org_staff_rel', "rel_cd", function (_data) { $that.aStaffInfo.relCds = _data; // 岗位列表获取比较慢, 获取到岗位列表后再加载数据 $that.loadData(1, 10); $that._getOrgsByOrgLevelStaff(DEFAULT_PAGE, DEFAULT_ROWS, 2, ''); }); }, _initEvent: function () { // $that.$on('pagination_page_event', function (_currentPage) { // console.log(_currentPage); // $that.currentPage(_currentPage); // }); vc.on('pagination', 'page_event', function (_currentPage) { $that.loadData(_currentPage, DEFAULT_ROWS); }); vc.on('staff', 'notify', function () { $that.loadData(1, DEFAULT_ROWS); }); $that.$on('addStaff_reload_event', function () { $that.loadData(1, 10); }); $that.$on('editStaff_reload_event', function () { $that.loadData(1, 10); }); $that.$on('deleteStaff_reload_event', function () { $that.loadData(1, 10); }); }, methods: { loadData: function (_page, _rows) { $that.aStaffInfo.conditions.page = _page; $that.aStaffInfo.conditions.rows = _rows; $that.aStaffInfo.conditions.row = _rows; let param = { params: $that.aStaffInfo.conditions }; //发送get请求 vc.http.apiGet('/query.staff.infos', param, function (json) { let _json = JSON.parse(json); // 员工列表 和 岗位列表匹配 let staffList = _json.staffs; let relCdsList = $that.aStaffInfo.relCds; staffList.forEach((staff) => { relCdsList.forEach((rel) => { if (staff.relCd == rel.statusCd) { staff.relCdName = rel.name; } }) }) $that.aStaffInfo.staffs = staffList; $that.$emit('pagination_info_event', { total: _aStaffInfo.records, dataCount: _aStaffInfo.total, currentPage: _page }); }, function () { console.log('请求失败处理'); } ); }, currentPage: function (_currentPage) { $that.loadData(_currentPage, 10); }, openEditStaff: function (_aStaffInfo) { $that.$emit('edit_staff_event', _aStaffInfo); }, openDeleteStaff: function (_aStaffInfo) { $that.$emit('delete_staff_event', _aStaffInfo); }, _moreCondition: function () { if ($that.aStaffInfo.moreCondition) { $that.aStaffInfo.moreCondition = false; } else { $that.aStaffInfo.moreCondition = true; } }, _getOrgsByOrgLevelStaff: function (_page, _rows, _orgLevel, _parentOrgId) { let param = { params: { page: _page, row: _rows, orgLevel: _orgLevel, parentOrgId: _parentOrgId } }; //发送get请求 vc.http.apiGet('/org.listOrgs', param, function (json, res) { let _orgInfo = JSON.parse(json); if (_orgLevel == 2) { $that.aStaffInfo.branchOrgs = _orgInfo.orgs; } else { $that.aStaffInfo.departmentOrgs = _orgInfo.orgs; } }, function (errInfo, error) { console.log('请求失败处理'); } ); }, _openAddStaffStepPage: function () { vc.jumpToPage("/#/pages/frame/addStaff") }, //查询 _queryStaffMethod: function () { $that.loadData(DEFAULT_PAGE, DEFAULT_ROWS) }, //重置 _resetStaffMethod: function () { $that.aStaffInfo.conditions.branchOrgId = ""; $that.aStaffInfo.conditions.orgId = ""; $that.aStaffInfo.conditions.departmentOrgId = ""; $that.aStaffInfo.conditions.name = ""; $that.aStaffInfo.conditions.tel = ""; $that.aStaffInfo.conditions.staffId = ""; $that.loadData(DEFAULT_PAGE, DEFAULT_ROWS) }, _resetStaffPwd: function (_staff) { vc.emit('resetStaffPwd', 'openResetStaffPwd', _staff); }, openStaffDetail: function (_staff) { vc.jumpToPage('/#/pages/staff/aStaffDetail?staffId=' + _staff.userId) } }, }); })(window.vc);