增加组织架构
This commit is contained in:
1 parent
74ab6c4c6d
commit
d6bba226d0
41 files changed
+6128
-5218
No files matched your search
+207
-277
@@ -1,285 +1,215 @@
|
||||
import request from '@/utils/request'
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 组织架构相关接口
|
||||
/**
|
||||
* 组织架构接口(组织 / 员工 / 职位)
|
||||
*
|
||||
* 组织架构是租户端通用基础数据:进销存(erp)与办公自动化(oa)两个模块各自有独立界面,
|
||||
* 但读写的是同一份数据,后端按登录租户自动隔离。两端接口路径只有模块前缀不同,
|
||||
* 因此这里用工厂函数按模块生成一套接口。
|
||||
*/
|
||||
|
||||
// 获取组织架构列表
|
||||
export function getOrganizationList(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getOrganization',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
const MODULES = ['erp', 'oa'];
|
||||
|
||||
function normalizeModule(module) {
|
||||
const value = String(module || '').toLowerCase();
|
||||
return MODULES.includes(value) ? value : 'erp';
|
||||
}
|
||||
|
||||
// 获取组织架构详情
|
||||
export function getOrganizationDetail(id) {
|
||||
return request({
|
||||
url: `/backend/erp/getOrganizationDetail/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
export function createOrganizationApi(module) {
|
||||
const base = `/backend/${normalizeModule(module)}`;
|
||||
|
||||
return {
|
||||
module: normalizeModule(module),
|
||||
|
||||
/* ------------------------------- 组织机构 ------------------------------- */
|
||||
|
||||
getOrganizationList(params) {
|
||||
return request({ url: `${base}/getOrganization`, method: 'get', params });
|
||||
},
|
||||
|
||||
getOrganizationTree(params) {
|
||||
return request({ url: `${base}/getOrganizationTree`, method: 'get', params });
|
||||
},
|
||||
|
||||
getOrganizationDetail(id) {
|
||||
return request({ url: `${base}/getOrganizationDetail/${id}`, method: 'get' });
|
||||
},
|
||||
|
||||
createOrganization(data) {
|
||||
return request({ url: `${base}/createOrganization`, method: 'post', data });
|
||||
},
|
||||
|
||||
updateOrganization(id, data) {
|
||||
return request({ url: `${base}/editOrganization/${id}`, method: 'post', data });
|
||||
},
|
||||
|
||||
deleteOrganization(id) {
|
||||
return request({ url: `${base}/deleteOrganization/${id}`, method: 'delete' });
|
||||
},
|
||||
|
||||
getCompanyList(params) {
|
||||
return request({ url: `${base}/getCompanys`, method: 'get', params });
|
||||
},
|
||||
|
||||
getDepartmentList(parentId) {
|
||||
return request({
|
||||
url: `${base}/getDepartments`,
|
||||
method: 'get',
|
||||
params: parentId ? { parent_id: parentId } : {},
|
||||
});
|
||||
},
|
||||
|
||||
searchOrganizations(keyword) {
|
||||
return request({ url: `${base}/searchOrganizations`, method: 'get', params: { keyword } });
|
||||
},
|
||||
|
||||
getOrganizationHierarchy(orgId) {
|
||||
return request({ url: `${base}/getOrganizationHierarchy/${orgId}`, method: 'get' });
|
||||
},
|
||||
|
||||
getOrganizationStats() {
|
||||
return request({ url: `${base}/getOrganizationStats`, method: 'get' });
|
||||
},
|
||||
|
||||
/** 移动组织节点到新的上级(拖拽调整层级) */
|
||||
moveOrganization(orgId, parentId, sort) {
|
||||
const data = { org_id: orgId, parent_id: parentId || 0 };
|
||||
if (sort !== undefined && sort !== null) {
|
||||
data.sort = sort;
|
||||
}
|
||||
return request({ url: `${base}/moveOrganization`, method: 'post', data });
|
||||
},
|
||||
|
||||
/** 批量操作组织,action 取 enable / disable / delete */
|
||||
batchOrganizeOrganizations(ids, action) {
|
||||
return request({
|
||||
url: `${base}/batchOrganizeOrganizations`,
|
||||
method: 'post',
|
||||
data: { ids, action },
|
||||
});
|
||||
},
|
||||
|
||||
checkOrgCodeUnique(orgCode, excludeId) {
|
||||
return request({
|
||||
url: `${base}/checkOrgCodeUnique`,
|
||||
method: 'get',
|
||||
params: { org_code: orgCode, exclude_id: excludeId || '' },
|
||||
});
|
||||
},
|
||||
|
||||
/* --------------------------------- 员工 --------------------------------- */
|
||||
|
||||
getEmployeeList(params) {
|
||||
return request({ url: `${base}/getEmployee`, method: 'get', params });
|
||||
},
|
||||
|
||||
getEmployeeDetail(id) {
|
||||
return request({ url: `${base}/getEmployeeDetail/${id}`, method: 'get' });
|
||||
},
|
||||
|
||||
createEmployee(data) {
|
||||
return request({ url: `${base}/createEmployee`, method: 'post', data });
|
||||
},
|
||||
|
||||
updateEmployee(id, data) {
|
||||
return request({ url: `${base}/editEmployee/${id}`, method: 'post', data });
|
||||
},
|
||||
|
||||
deleteEmployee(id) {
|
||||
return request({ url: `${base}/deleteEmployee/${id}`, method: 'delete' });
|
||||
},
|
||||
|
||||
getOrganizationEmployees(orgId) {
|
||||
return request({ url: `${base}/getOrganizationEmployees/${orgId}`, method: 'get' });
|
||||
},
|
||||
|
||||
/** 员工调岗:支持单个或批量 */
|
||||
moveEmployeeToOrg(employeeIds, orgId, position) {
|
||||
const ids = Array.isArray(employeeIds) ? employeeIds : [employeeIds];
|
||||
const data = { employee_ids: ids, org_id: orgId };
|
||||
if (position !== undefined && position !== null) {
|
||||
data.position = position;
|
||||
}
|
||||
return request({ url: `${base}/moveEmployeeToOrg`, method: 'post', data });
|
||||
},
|
||||
|
||||
checkEmployeeAccountUnique(account, excludeId) {
|
||||
return request({
|
||||
url: `${base}/checkEmployeeAccountUnique`,
|
||||
method: 'get',
|
||||
params: { account, exclude_id: excludeId || '' },
|
||||
});
|
||||
},
|
||||
|
||||
/* --------------------------------- 职位 --------------------------------- */
|
||||
|
||||
getPositionList(params) {
|
||||
return request({ url: `${base}/getPosition`, method: 'get', params });
|
||||
},
|
||||
|
||||
getPositionDetail(id) {
|
||||
return request({ url: `${base}/getPositionDetail/${id}`, method: 'get' });
|
||||
},
|
||||
|
||||
createPosition(data) {
|
||||
return request({ url: `${base}/createPosition`, method: 'post', data });
|
||||
},
|
||||
|
||||
updatePosition(id, data) {
|
||||
return request({ url: `${base}/editPosition/${id}`, method: 'post', data });
|
||||
},
|
||||
|
||||
deletePosition(id) {
|
||||
return request({ url: `${base}/deletePosition/${id}`, method: 'delete' });
|
||||
},
|
||||
|
||||
checkPositionCodeUnique(positionCode, excludeId) {
|
||||
return request({
|
||||
url: `${base}/checkPositionCodeUnique`,
|
||||
method: 'get',
|
||||
params: { position_code: positionCode, exclude_id: excludeId || '' },
|
||||
});
|
||||
},
|
||||
|
||||
/* ----------------------------- 设置与导入导出 ----------------------------- */
|
||||
|
||||
getOrgSettings() {
|
||||
return request({ url: `${base}/getOrgSettings`, method: 'get' });
|
||||
},
|
||||
|
||||
saveOrgSettings(data) {
|
||||
return request({ url: `${base}/saveOrgSettings`, method: 'post', data });
|
||||
},
|
||||
|
||||
exportOrganization() {
|
||||
return request({ url: `${base}/exportOrganization`, method: 'get', responseType: 'blob' });
|
||||
},
|
||||
|
||||
downloadImportTemplate() {
|
||||
return request({
|
||||
url: `${base}/organizationImportTemplate`,
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
});
|
||||
},
|
||||
|
||||
importOrganization(file) {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
return request({
|
||||
url: `${base}/importOrganization`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// 创建组织架构
|
||||
export function createOrganization(data) {
|
||||
return request({
|
||||
url: '/backend/erp/createOrganization',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
/** 进销存模块的组织架构接口 */
|
||||
export const erpOrganizationApi = createOrganizationApi('erp');
|
||||
|
||||
// 更新组织架构
|
||||
export function updateOrganization(id, data) {
|
||||
return request({
|
||||
url: `/backend/erp/editOrganization/${id}`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
/** 办公自动化模块的组织架构接口 */
|
||||
export const oaOrganizationApi = createOrganizationApi('oa');
|
||||
|
||||
// 删除组织架构
|
||||
export function deleteOrganization(id) {
|
||||
return request({
|
||||
url: `/backend/erp/deleteOrganization/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取企业单位列表
|
||||
export function getCompanyList(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getCompanys',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取部门列表
|
||||
export function getDepartmentList(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getDepartments',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 员工相关接口
|
||||
|
||||
// 获取员工列表
|
||||
export function getEmployeeList(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getEmployee',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取员工详情
|
||||
export function getEmployeeDetail(id) {
|
||||
return request({
|
||||
url: `/backend/erp/getEmployeeDetail/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 创建员工
|
||||
export function createEmployee(data) {
|
||||
return request({
|
||||
url: '/backend/erp/createEmployee',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新员工
|
||||
export function updateEmployee(id, data) {
|
||||
return request({
|
||||
url: `/backend/erp/editEmployee/${id}`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除员工
|
||||
export function deleteEmployee(id) {
|
||||
return request({
|
||||
url: `/backend/erp/deleteEmployee/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 职位相关接口
|
||||
|
||||
// 获取职位列表
|
||||
export function getPositionList(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getPosition',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 获取职位详情
|
||||
export function getPositionDetail(id) {
|
||||
return request({
|
||||
url: `/backend/erp/getPositionDetail/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 创建职位
|
||||
export function createPosition(data) {
|
||||
return request({
|
||||
url: '/backend/erp/createPosition',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新职位
|
||||
export function updatePosition(id, data) {
|
||||
return request({
|
||||
url: `/backend/erp/editPosition/${id}`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除职位
|
||||
export function deletePosition(id) {
|
||||
return request({
|
||||
url: `/backend/erp/deletePosition/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 组织设置相关接口
|
||||
|
||||
// 获取组织设置
|
||||
export function getOrgSettings() {
|
||||
return request({
|
||||
url: '/backend/erp/getOrgSettings',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 保存组织设置
|
||||
export function saveOrgSettings(data) {
|
||||
return request({
|
||||
url: '/backend/erp/saveOrgSettings',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 组织架构导出
|
||||
export function exportOrganization(params) {
|
||||
return request({
|
||||
url: '/backend/erp/exportOrganization',
|
||||
method: 'get',
|
||||
params,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 组织架构导入
|
||||
export function importOrganization(data) {
|
||||
return request({
|
||||
url: '/backend/erp/importOrganization',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 批量操作组织
|
||||
export function batchOrganizeOrganizations(ids, action) {
|
||||
return request({
|
||||
url: '/backend/erp/batchOrganizeOrganizations',
|
||||
method: 'post',
|
||||
data: {
|
||||
ids,
|
||||
action
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取组织架构统计信息
|
||||
export function getOrganizationStats() {
|
||||
return request({
|
||||
url: '/backend/erp/getOrganizationStats',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取组织架构树形结构
|
||||
export function getOrganizationTree(params) {
|
||||
return request({
|
||||
url: '/backend/erp/getOrganizationTree',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 搜索组织架构
|
||||
export function searchOrganizations(keyword) {
|
||||
return request({
|
||||
url: '/backend/erp/searchOrganizations',
|
||||
method: 'get',
|
||||
params: { keyword }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取组织架构下的所有员工
|
||||
export function getOrganizationEmployees(orgId) {
|
||||
return request({
|
||||
url: `/backend/erp/getOrganizationEmployees/${orgId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 移动员工到其他组织
|
||||
export function moveEmployeeToOrg(employeeId, orgId) {
|
||||
return request({
|
||||
url: '/backend/erp/moveEmployeeToOrg',
|
||||
method: 'post',
|
||||
data: {
|
||||
employee_id: employeeId,
|
||||
org_id: orgId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取组织架构层级关系
|
||||
export function getOrganizationHierarchy(orgId) {
|
||||
return request({
|
||||
url: `/backend/erp/getOrganizationHierarchy/${orgId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 验证组织编码唯一性
|
||||
export function checkOrgCodeUnique(orgCode, excludeId) {
|
||||
return request({
|
||||
url: '/backend/erp/checkOrgCodeUnique',
|
||||
method: 'get',
|
||||
params: {
|
||||
org_code: orgCode,
|
||||
exclude_id: excludeId || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 验证员工账号唯一性
|
||||
export function checkEmployeeAccountUnique(account, excludeId) {
|
||||
return request({
|
||||
url: '/backend/erp/checkEmployeeAccountUnique',
|
||||
method: 'get',
|
||||
params: {
|
||||
account,
|
||||
exclude_id: excludeId || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
export default erpOrganizationApi;
|
||||
Reference in new issue
Block a user