mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 05:46:03 +08:00
优化代码
This commit is contained in:
parent
088fadf275
commit
fecd1d5749
@ -9,6 +9,7 @@
|
||||
data: {
|
||||
orgManageInfo: {
|
||||
staffs: [],
|
||||
relCds:[],
|
||||
orgName: '',
|
||||
conditions: {
|
||||
orgId: '',
|
||||
@ -16,18 +17,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
_initMethod: function() {},
|
||||
_initMethod: function() {
|
||||
vc.getDict('u_org_staff_rel', "rel_cd", function (_data) {
|
||||
$that.orgManageInfo.relCds = _data;
|
||||
});
|
||||
},
|
||||
_initEvent: function() {
|
||||
vc.on('org', 'switchOrg', function(_param) {
|
||||
$that.orgManageInfo.conditions.orgId = _param.orgId;
|
||||
$that.orgManageInfo.orgName = _param.orgName;
|
||||
vc.component._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$that._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
});
|
||||
vc.on('orgManage', 'notice', function() {
|
||||
vc.component._listStaffs(1, DEFAULT_ROWS);
|
||||
$that._listStaffs(1, DEFAULT_ROWS);
|
||||
});
|
||||
vc.on('pagination', 'page_event', function(_currentPage) {
|
||||
vc.component._listStaffs(_currentPage, DEFAULT_ROWS);
|
||||
$that._listStaffs(_currentPage, DEFAULT_ROWS);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
@ -44,13 +49,22 @@
|
||||
vc.http.apiGet('/query.staff.infos',
|
||||
param,
|
||||
function(json, res) {
|
||||
var _orgManageInfo = JSON.parse(json);
|
||||
vc.component.orgManageInfo.total = _orgManageInfo.total;
|
||||
vc.component.orgManageInfo.records = _orgManageInfo.records;
|
||||
vc.component.orgManageInfo.staffs = _orgManageInfo.staffs;
|
||||
let _json = JSON.parse(json);
|
||||
$that.orgManageInfo.total = _json.total;
|
||||
$that.orgManageInfo.records = _json.records;
|
||||
let staffList = _json.staffs;
|
||||
let relCdsList = $that.orgManageInfo.relCds;
|
||||
staffList.forEach((staff) => {
|
||||
relCdsList.forEach((rel) => {
|
||||
if (staff.relCd == rel.statusCd) {
|
||||
staff.relCdName = rel.name;
|
||||
}
|
||||
})
|
||||
})
|
||||
$that.orgManageInfo.staffs = staffList;
|
||||
vc.emit('pagination', 'init', {
|
||||
total: vc.component.orgManageInfo.records,
|
||||
dataCount: vc.component.orgManageInfo.total,
|
||||
total: $that.orgManageInfo.records,
|
||||
dataCount: $that.orgManageInfo.total,
|
||||
currentPage: _page
|
||||
});
|
||||
},
|
||||
@ -61,18 +75,18 @@
|
||||
},
|
||||
//查询
|
||||
_queryOrgMethod: function() {
|
||||
vc.component._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$that._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
},
|
||||
//重置
|
||||
_resetOrgMethod: function() {
|
||||
vc.component.orgManageInfo.conditions.staffName = "";
|
||||
vc.component._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$that.orgManageInfo.conditions.staffName = "";
|
||||
$that._listStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
},
|
||||
_moreCondition: function() {
|
||||
if (vc.component.orgManageInfo.moreCondition) {
|
||||
vc.component.orgManageInfo.moreCondition = false;
|
||||
if ($that.orgManageInfo.moreCondition) {
|
||||
$that.orgManageInfo.moreCondition = false;
|
||||
} else {
|
||||
vc.component.orgManageInfo.moreCondition = true;
|
||||
$that.orgManageInfo.moreCondition = true;
|
||||
}
|
||||
},
|
||||
_openOrgRelStaff: function() {
|
||||
|
||||
@ -27,18 +27,18 @@
|
||||
watch: {
|
||||
"staffInfo.conditions.branchOrgId": { //深度监听,可监听到对象、数组的变化
|
||||
handler(val, oldVal) {
|
||||
vc.component._getOrgsByOrgLevelStaff(DEFAULT_PAGE, DEFAULT_ROWS, 3, val);
|
||||
vc.component.staffInfo.conditions.branchOrgId = val;
|
||||
vc.component.staffInfo.conditions.parentOrgId = val;
|
||||
vc.component.staffInfo.conditions.departmentOrgId = '';
|
||||
vc.component.loadData(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$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) {
|
||||
vc.component.staffInfo.conditions.orgId = val;
|
||||
vc.component.loadData(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
$that.staffInfo.conditions.orgId = val;
|
||||
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS);
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
@ -46,40 +46,40 @@
|
||||
_initMethod: function () {
|
||||
// 查询岗位列表
|
||||
vc.getDict('u_org_staff_rel', "rel_cd", function (_data) {
|
||||
vc.component.staffInfo.relCds = _data;
|
||||
$that.staffInfo.relCds = _data;
|
||||
// 岗位列表获取比较慢, 获取到岗位列表后再加载数据
|
||||
vc.component.loadData(1, 10);
|
||||
vc.component._getOrgsByOrgLevelStaff(DEFAULT_PAGE, DEFAULT_ROWS, 2, '');
|
||||
$that.loadData(1, 10);
|
||||
$that._getOrgsByOrgLevelStaff(DEFAULT_PAGE, DEFAULT_ROWS, 2, '');
|
||||
});
|
||||
},
|
||||
_initEvent: function () {
|
||||
// vc.component.$on('pagination_page_event', function (_currentPage) {
|
||||
// $that.$on('pagination_page_event', function (_currentPage) {
|
||||
// console.log(_currentPage);
|
||||
// vc.component.currentPage(_currentPage);
|
||||
// $that.currentPage(_currentPage);
|
||||
// });
|
||||
vc.on('pagination', 'page_event', function (_currentPage) {
|
||||
vc.component.loadData(_currentPage, DEFAULT_ROWS);
|
||||
$that.loadData(_currentPage, DEFAULT_ROWS);
|
||||
});
|
||||
vc.on('staff', 'notify', function () {
|
||||
vc.component.loadData(1, DEFAULT_ROWS);
|
||||
$that.loadData(1, DEFAULT_ROWS);
|
||||
});
|
||||
vc.component.$on('addStaff_reload_event', function () {
|
||||
vc.component.loadData(1, 10);
|
||||
$that.$on('addStaff_reload_event', function () {
|
||||
$that.loadData(1, 10);
|
||||
});
|
||||
vc.component.$on('editStaff_reload_event', function () {
|
||||
vc.component.loadData(1, 10);
|
||||
$that.$on('editStaff_reload_event', function () {
|
||||
$that.loadData(1, 10);
|
||||
});
|
||||
vc.component.$on('deleteStaff_reload_event', function () {
|
||||
vc.component.loadData(1, 10);
|
||||
$that.$on('deleteStaff_reload_event', function () {
|
||||
$that.loadData(1, 10);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
loadData: function (_page, _rows) {
|
||||
vc.component.staffInfo.conditions.page = _page;
|
||||
vc.component.staffInfo.conditions.rows = _rows;
|
||||
vc.component.staffInfo.conditions.row = _rows;
|
||||
$that.staffInfo.conditions.page = _page;
|
||||
$that.staffInfo.conditions.rows = _rows;
|
||||
$that.staffInfo.conditions.row = _rows;
|
||||
var param = {
|
||||
params: vc.component.staffInfo.conditions
|
||||
params: $that.staffInfo.conditions
|
||||
};
|
||||
param.params.name = param.params.name.trim();
|
||||
param.params.tel = param.params.tel.trim();
|
||||
@ -91,7 +91,7 @@
|
||||
let _staffInfo = JSON.parse(json);
|
||||
// 员工列表 和 岗位列表匹配
|
||||
let staffList = _staffInfo.staffs;
|
||||
let relCdsList = vc.component.staffInfo.relCds;
|
||||
let relCdsList = $that.staffInfo.relCds;
|
||||
staffList.forEach((staff) => {
|
||||
relCdsList.forEach((rel) => {
|
||||
if (staff.relCd == rel.statusCd) {
|
||||
@ -99,8 +99,8 @@
|
||||
}
|
||||
})
|
||||
})
|
||||
vc.component.staffData = staffList;
|
||||
vc.component.$emit('pagination_info_event', {
|
||||
$that.staffData = staffList;
|
||||
$that.$emit('pagination_info_event', {
|
||||
total: _staffInfo.records,
|
||||
dataCount: _staffInfo.total,
|
||||
currentPage: _page
|
||||
@ -112,19 +112,19 @@
|
||||
);
|
||||
},
|
||||
currentPage: function (_currentPage) {
|
||||
vc.component.loadData(_currentPage, 10);
|
||||
$that.loadData(_currentPage, 10);
|
||||
},
|
||||
openEditStaff: function (_staffInfo) {
|
||||
vc.component.$emit('edit_staff_event', _staffInfo);
|
||||
$that.$emit('edit_staff_event', _staffInfo);
|
||||
},
|
||||
openDeleteStaff: function (_staffInfo) {
|
||||
vc.component.$emit('delete_staff_event', _staffInfo);
|
||||
$that.$emit('delete_staff_event', _staffInfo);
|
||||
},
|
||||
_moreCondition: function () {
|
||||
if (vc.component.staffInfo.moreCondition) {
|
||||
vc.component.staffInfo.moreCondition = false;
|
||||
if ($that.staffInfo.moreCondition) {
|
||||
$that.staffInfo.moreCondition = false;
|
||||
} else {
|
||||
vc.component.staffInfo.moreCondition = true;
|
||||
$that.staffInfo.moreCondition = true;
|
||||
}
|
||||
},
|
||||
_getOrgsByOrgLevelStaff: function (_page, _rows, _orgLevel, _parentOrgId) {
|
||||
@ -142,9 +142,9 @@
|
||||
function (json, res) {
|
||||
let _orgInfo = JSON.parse(json);
|
||||
if (_orgLevel == 2) {
|
||||
vc.component.staffInfo.branchOrgs = _orgInfo.orgs;
|
||||
$that.staffInfo.branchOrgs = _orgInfo.orgs;
|
||||
} else {
|
||||
vc.component.staffInfo.departmentOrgs = _orgInfo.orgs;
|
||||
$that.staffInfo.departmentOrgs = _orgInfo.orgs;
|
||||
}
|
||||
},
|
||||
function (errInfo, error) {
|
||||
@ -157,17 +157,17 @@
|
||||
},
|
||||
//查询
|
||||
_queryStaffMethod: function () {
|
||||
vc.component.loadData(DEFAULT_PAGE, DEFAULT_ROWS)
|
||||
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS)
|
||||
},
|
||||
//重置
|
||||
_resetStaffMethod: function () {
|
||||
vc.component.staffInfo.conditions.branchOrgId = "";
|
||||
vc.component.staffInfo.conditions.orgId = "";
|
||||
vc.component.staffInfo.conditions.departmentOrgId = "";
|
||||
vc.component.staffInfo.conditions.name = "";
|
||||
vc.component.staffInfo.conditions.tel = "";
|
||||
vc.component.staffInfo.conditions.staffId = "";
|
||||
vc.component.loadData(DEFAULT_PAGE, DEFAULT_ROWS)
|
||||
$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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user