You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.5 KiB
148 lines
4.5 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\personnel;
|
|
|
|
use core\base\BaseAdminController;
|
|
use app\service\admin\personnel\PersonnelService;
|
|
|
|
|
|
/**
|
|
* 人力资源-人员控制器
|
|
* Class Personnel
|
|
* @package app\adminapi\controller\personnel
|
|
*/
|
|
class Personnel extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取人力资源-人员列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists(){
|
|
$data = $this->request->params([
|
|
["name",""],
|
|
["gender",""],
|
|
["phone",""],
|
|
["address",""],
|
|
["education",""],
|
|
["employee_number",""],
|
|
["status",""],
|
|
["create_time",[]]
|
|
]);
|
|
return success((new PersonnelService())->getPage($data));
|
|
}
|
|
|
|
/**
|
|
* 人力资源-人员详情
|
|
* @param int $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info(int $id){
|
|
return success((new PersonnelService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加人力资源-人员
|
|
* @return \think\Response
|
|
*/
|
|
public function add(){
|
|
$data = $this->request->params([
|
|
["name",""],
|
|
["gender",0],
|
|
["phone",""],
|
|
["head_img",""],
|
|
["address",""],
|
|
["native_place",""],
|
|
["education",""],
|
|
["profile",""],
|
|
["emergency_contact_phone",""],
|
|
["id_card_front",""],
|
|
["id_card_back",""],
|
|
["status",0],
|
|
["is_sys_user",0],
|
|
["info",[]],
|
|
["use_approval", 0], // 是否使用审批流程
|
|
["approval_config_id", 0], // 审批配置ID
|
|
]);
|
|
// $this->validate($data, 'app\validate\personnel\Personnel.add');
|
|
|
|
// 检查是否使用审批流程
|
|
if ($data['use_approval'] && $data['approval_config_id'] > 0) {
|
|
// 使用审批流程
|
|
$approvalService = new \app\service\school_approval\SchoolApprovalProcessService();
|
|
$processId = $approvalService->createPersonnelApproval(
|
|
$data,
|
|
$this->request->uid(),
|
|
$data['approval_config_id']
|
|
);
|
|
return success('APPROVAL_CREATED_SUCCESS', ['process_id' => $processId]);
|
|
} else {
|
|
// 直接添加人员
|
|
$id = (new PersonnelService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 人力资源-人员编辑
|
|
* @param $id 人力资源-人员id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id){
|
|
$data = $this->request->params([
|
|
["name",""],
|
|
["gender",0],
|
|
["phone",""],
|
|
["head_img",""],
|
|
["address",""],
|
|
["native_place",""],
|
|
["education",""],
|
|
["profile",""],
|
|
["emergency_contact_phone",""],
|
|
["id_card_front",""],
|
|
["id_card_back",""],
|
|
["status",0],
|
|
["is_sys_user",0],
|
|
["info",[]],
|
|
|
|
]);
|
|
// $this->validate($data, 'app\validate\personnel\Personnel.edit');
|
|
(new PersonnelService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 人力资源-人员删除
|
|
* @param $id 人力资源-人员id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id){
|
|
(new PersonnelService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 获取可用的审批配置列表
|
|
* @return \think\Response
|
|
*/
|
|
public function getApprovalConfigs(){
|
|
$approvalConfigService = new \app\service\school_approval\SchoolApprovalConfigService();
|
|
$configs = $approvalConfigService->getList(['status' => 1]);
|
|
return success($configs);
|
|
}
|
|
|
|
|
|
public function to_lead_into(){
|
|
$data = $this->request->post();
|
|
return (new PersonnelService())->to_lead_into($data);
|
|
}
|
|
|
|
}
|
|
|