更新人事离职

This commit is contained in:
yaooo 2023-10-30 14:12:14 +08:00
parent 3cdab12c95
commit b0a044009b
1 changed files with 30 additions and 40 deletions

View File

@ -116,47 +116,37 @@ class UserPersonal extends ApiController
public function leave_add() public function leave_add()
{ {
$param = get_params(); $param = get_params();
if (request()->isAjax()) { if (empty($param['uid'])) {
$this->apiError("请选择离职人员");
}
if (empty($param['lead_admin_id'])) {
$this->apiError("请选择部门负责人");
}
if (empty($param['connect_uids'])) {
$this->apiError("请选择交接人员");
}
if (empty($param['quit_time'])) {
$this->apiError("请选择离职时间");
}
$count = Db::name('Department')->where(['leader_id' => $param['uid']])->count(); $count = Db::name('Department')->where(['leader_id' => $param['uid']])->count();
if($count>0){ if($count>0){
return to_assign(1,'请先撤销该员工的部门负责人头衔再添加离职档案'); $this->apiError("请先撤销该员工的部门负责人头衔再添加离职档案");
} }
$param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0; $param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0;
if ($param['id'] > 0) { if (!empty($param['id']) && $param['id'] > 0) {
$param['update_time'] = time(); $param['update_time'] = time();
$res = Db::name('PersonalQuit')->strict(false)->field(true)->update($param); $res = Db::name('PersonalQuit')->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param); add_log('edit', $param['id'], $param);
} else { } else {
$param['create_time'] = time(); $param['create_time'] = time();
$param['admin_id'] = $this->uid; $param['admin_id'] = JWT_UID;
$res = Db::name('PersonalQuit')->strict(false)->field(true)->insertGetId($param); $res = Db::name('PersonalQuit')->strict(false)->field(true)->insertGetId($param);
add_log('add', $res, $param); add_log('add', $res, $param);
} }
if ($res!==false) { if ($res!==false) {
Db::name('Admin')->where('id', $param['uid'])->update(['status' => 2]); Db::name('Admin')->where('id', $param['uid'])->update(['status' => 2]);
} }
return to_assign(); $this->apiError("操作成功");
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$where = array();
if ($id>0) {
$where['p.id'] = array('eq', $id);
$detail = Db::name('PersonalQuit')
->field('p.*,u.name as name,l.name as lead_admin_name,d.title as department')
->alias('p')
->join('admin u', 'p.uid = u.id', 'LEFT')
->join('admin l', 'p.lead_admin_id = l.id', 'LEFT')
->join('department d', 'u.did = d.id', 'LEFT')
->where($where)
->find();
$this_uids_name = Db::name('Admin')->where([['id','in', $detail['connect_uids']]])->column('name');
$detail['connect_names'] = implode(',', $this_uids_name);
$detail['quit_time'] = date('Y-m-d', $detail['quit_time']);
View::assign('detail', $detail);
}
View::assign('id', $id);
return view();
}
} }
//删除离职档案 //删除离职档案