mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-26 08:16:47 +08:00
180 lines
7.2 KiB
JavaScript
180 lines
7.2 KiB
JavaScript
(function (vc) {
|
|
var DEFAULT_PAGE = 1;
|
|
var DEFAULT_ROWS = 10;
|
|
vc.extends({
|
|
data: {
|
|
staffInfo: {
|
|
moreCondition: false,
|
|
branchOrgs: [],
|
|
departmentOrgs: [],
|
|
relCds: [],
|
|
conditions: {
|
|
branchOrgId: '',
|
|
departmentOrgId: '',
|
|
orgId: '',
|
|
orgName: '',
|
|
orgLevel: '2',
|
|
parentOrgId: '',
|
|
name: '',
|
|
tel: '',
|
|
staffId: '',
|
|
parentOrgName: '',
|
|
parentTwoOrgId: ''
|
|
}
|
|
},
|
|
staffData: [],
|
|
},
|
|
watch: {
|
|
"staffInfo.conditions.branchOrgId": { //深度监听,可监听到对象、数组的变化
|
|
handler(val, oldVal) {
|
|
$that._getOrgsByOrgLevelStaff(DEFAULT_PAGE, DEFAULT_ROWS, 3, val);
|
|
$that.staffInfo.conditions.branchOrgId = val;
|
|
$that.staffInfo.conditions.parentOrgId = val;
|
|
$that.staffInfo.conditions.departmentOrgId = '';
|
|
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS);
|
|
},
|
|
deep: true
|
|
},
|
|
"staffInfo.conditions.departmentOrgId": { //深度监听,可监听到对象、数组的变化
|
|
handler(val, oldVal) {
|
|
$that.staffInfo.conditions.orgId = val;
|
|
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS);
|
|
},
|
|
deep: true
|
|
}
|
|
},
|
|
_initMethod: function () {
|
|
// 查询岗位列表
|
|
vc.getDict('u_org_staff_rel', "rel_cd", function (_data) {
|
|
$that.staffInfo.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.staffInfo.conditions.page = _page;
|
|
$that.staffInfo.conditions.rows = _rows;
|
|
$that.staffInfo.conditions.row = _rows;
|
|
let param = {
|
|
params: $that.staffInfo.conditions
|
|
};
|
|
param.params.name = param.params.name.trim();
|
|
param.params.tel = param.params.tel.trim();
|
|
param.params.staffId = param.params.staffId.trim();
|
|
//发送get请求
|
|
vc.http.apiGet('/query.staff.infos',
|
|
param,
|
|
function (json) {
|
|
let _staffInfo = JSON.parse(json);
|
|
// 员工列表 和 岗位列表匹配
|
|
let staffList = _staffInfo.staffs;
|
|
let relCdsList = $that.staffInfo.relCds;
|
|
staffList.forEach((staff) => {
|
|
relCdsList.forEach((rel) => {
|
|
if (staff.relCd == rel.statusCd) {
|
|
staff.relCdName = rel.name;
|
|
}
|
|
})
|
|
})
|
|
$that.staffData = staffList;
|
|
$that.$emit('pagination_info_event', {
|
|
total: _staffInfo.records,
|
|
dataCount: _staffInfo.total,
|
|
currentPage: _page
|
|
});
|
|
},
|
|
function () {
|
|
console.log('请求失败处理');
|
|
}
|
|
);
|
|
},
|
|
currentPage: function (_currentPage) {
|
|
$that.loadData(_currentPage, 10);
|
|
},
|
|
openEditStaff: function (_staffInfo) {
|
|
$that.$emit('edit_staff_event', _staffInfo);
|
|
},
|
|
openDeleteStaff: function (_staffInfo) {
|
|
$that.$emit('delete_staff_event', _staffInfo);
|
|
},
|
|
_moreCondition: function () {
|
|
if ($that.staffInfo.moreCondition) {
|
|
$that.staffInfo.moreCondition = false;
|
|
} else {
|
|
$that.staffInfo.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.staffInfo.branchOrgs = _orgInfo.orgs;
|
|
} else {
|
|
$that.staffInfo.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.staffInfo.conditions.branchOrgId = "";
|
|
$that.staffInfo.conditions.orgId = "";
|
|
$that.staffInfo.conditions.departmentOrgId = "";
|
|
$that.staffInfo.conditions.name = "";
|
|
$that.staffInfo.conditions.tel = "";
|
|
$that.staffInfo.conditions.staffId = "";
|
|
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS)
|
|
},
|
|
_resetStaffPwd: function (_staff) {
|
|
vc.emit('resetStaffPwd', 'openResetStaffPwd', _staff);
|
|
},
|
|
openStaffDetail: function (_staff) {
|
|
vc.jumpToPage('/#/pages/staff/staffDetail?staffId=' + _staff.userId)
|
|
}
|
|
},
|
|
});
|
|
})(window.vc); |