diff --git a/app/home/controller/Personal.php b/app/home/controller/Personal.php new file mode 100644 index 0000000..5616eb3 --- /dev/null +++ b/app/home/controller/Personal.php @@ -0,0 +1,175 @@ +isAjax()) { + $param = get_params(); + if (!empty($param['keywords'])) { + $where['u.name|p.remark|a.title|b.title'] = ['like', '%' . $param['keywords'] . '%']; + } + $where['p.status'] = array('eq', 1); + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $list = DepartmentChange::where($where) + ->field('p.*,u.name as name,ad.name as admin,a.title as adepartment,b.title as bdepartment') + ->alias('p') + ->join('admin u', 'p.uid = u.id', 'LEFT') + ->join('admin ad', 'p.admin_id = ad.id', 'LEFT') + ->join('department a', 'p.from_did = a.id', 'LEFT') + ->join('department b', 'p.to_did = b.id', 'LEFT') + ->order('p.id desc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->move_time = date('Y-m-d', $item->move_time); + }); + return table_assign(0, '', $list); + } else { + return view(); + } + } + + //新增&编辑调部门 + public function change_add() + { + $param = get_params(); + if (request()->isAjax()) { + $param['move_time'] = isset($param['move_time']) ? strtotime($param['move_time']) : 0; + if ($param['id'] > 0) { + $param['update_time'] = time(); + $res = Db::name('DepartmentChange')->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); + } else { + $param['create_time'] = time(); + $param['admin_id'] = $this->uid; + $res = Db::name('DepartmentChange')->strict(false)->field(true)->insertGetId($param); + add_log('add', $res, $param); + } + if ($res!==false) { + Db::name('Admin')->where('id', $param['uid'])->update(['did' => $param['to_did']]); + } + return to_assign(); + } else { + $id = isset($param['id']) ? $param['id'] : 0; + $department = set_recursion(get_department()); + if ($id > 0) { + $detail = Db::name('DepartmentChange')->where(['id' => $id])->find(); + $detail['name'] = Db::name('Admin')->where(['id' => $detail['uid']])->value('name'); + $detail['from_department'] = Db::name('Department')->where(['id' => $detail['from_did']])->value('title'); + $detail['move_time'] = date('Y-m-d', $detail['move_time']); + View::assign('detail', $detail); + } + View::assign('department', $department); + View::assign('id', $id); + return view(); + } + } + + //离职 + public function leave() + { + if (request()->isAjax()) { + $param = get_params(); + $where = array(); + if (!empty($param['keywords'])) { + $where['u.name|p.remark'] = ['like', '%' . $param['keywords'] . '%']; + } + $where['p.status'] = array('eq', 1); + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $list = PersonalQuit::where($where) + ->field('p.*,u.name as name,d.title as department,ps.title as position') + ->alias('p') + ->join('admin u', 'p.uid = u.id', 'LEFT') + ->join('department d', 'u.did = d.id', 'LEFT') + ->join('position ps', 'u.position_id = ps.id', 'LEFT') + ->order('p.id desc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->quit_time = date('Y-m-d', $item->quit_time); + $item->lead_admin = Db::name('admin')->where(['id' => $item->lead_admin_id])->value('name'); + $this_uids_name = Db::name('admin')->where([['id','in', $item->connect_uids]])->column('name'); + $item->connect_names = implode(',', $this_uids_name); + }); + return table_assign(0, '', $list); + } else { + return view(); + } + } + + //添加离职档案 + public function leave_add() + { + $param = get_params(); + if (request()->isAjax()) { + $param['quit_time'] = isset($param['quit_time']) ? strtotime($param['quit_time']) : 0; + if ($param['id'] > 0) { + $param['update_time'] = time(); + $res = Db::name('PersonalQuit')->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); + } else { + $param['create_time'] = time(); + $param['admin_id'] = $this->uid; + $res = Db::name('PersonalQuit')->strict(false)->field(true)->insertGetId($param); + add_log('add', $res, $param); + } + if ($res!==false) { + Db::name('Admin')->where('id', $param['uid'])->update(['status' => 0]); + } + return to_assign(); + } else { + $id = isset($param['id']) ? $param['id'] : 0; + $where = array(); + if (!empty($id)) { + $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('id', $id); + View::assign('detail', $detail); + return view(); + } + } + + //删除离职档案 + public function leave_delete() + { + $id = get_params("id"); + $data['status'] = '-1'; + $data['id'] = $id; + $data['update_time'] = time(); + if (Db::name('PersonalQuit')->update($data) !== false) { + $uid = Db::name('PersonalQuit')->where('id', $id)->value('uid'); + Db::name('Admin')->where('id', $uid)->update(['status' => 1]); + add_log('delete', $id); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } +} diff --git a/app/home/model/DepartmentChange.php b/app/home/model/DepartmentChange.php new file mode 100644 index 0000000..ff83b9d --- /dev/null +++ b/app/home/model/DepartmentChange.php @@ -0,0 +1,7 @@ + +{block name="body"} +
+
+
+ +
+ +
+
+
+ + +{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="['rightpage']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/personal/change_add.html b/app/home/view/personal/change_add.html new file mode 100644 index 0000000..08d5a8f --- /dev/null +++ b/app/home/view/personal/change_add.html @@ -0,0 +1,166 @@ +{extend name="common/base"/} + +{block name="style"} + + +{/block} + + +{block name="body"} +
+

新增人事调动

+ {if condition="$id eq 0"} + + + + + + + + + + + + + + + + + +
调动员工* + + + 调出部门* + + +
调动日期* + 调入部门* + +
调动描述 + +
+ {else/} + + + + + + + + + + + + + + + + + +
调动员工* + + + 调出部门* + + +
调动日期* + 调入部门* + +
调动描述 + +
+ {/if} +
+ + + +
+
+{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['employeepicker']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/personal/department_quit_add2.html b/app/home/view/personal/department_quit_add2.html new file mode 100644 index 0000000..8cdba0e --- /dev/null +++ b/app/home/view/personal/department_quit_add2.html @@ -0,0 +1,183 @@ +{extend name="common/base"/} + +{block name="style"} + + + +{/block} + + +{block name="body"} +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ + + + +
+
+
+{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['employeepicker']" use="['form','employeepicker','layer','laydate']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/personal/leave.html b/app/home/view/personal/leave.html new file mode 100644 index 0000000..5f7bc1b --- /dev/null +++ b/app/home/view/personal/leave.html @@ -0,0 +1,107 @@ +{extend name="common/base"/} + +{block name="body"} +
+
+
+ +
+ +
+
+
+ + +{/block} + + + +{block name="script"} + +{include file="common/layui" base="base" extend="['rightpage']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/personal/leave_add.html b/app/home/view/personal/leave_add.html new file mode 100644 index 0000000..4a9bc9b --- /dev/null +++ b/app/home/view/personal/leave_add.html @@ -0,0 +1,202 @@ +{extend name="common/base"/} + +{block name="style"} + + +{/block} + + +{block name="body"} +
+

新增人事调动

+ {if condition="$id eq 0"} + + + + + + + + + + + + + + + + + + + + + +
离职员工* + + + 所在部门 + +
离职日期* + 部门负责人* + + +
交接人员* + + +
离职原因* + +
+ {else/} + + + + + + + + + + + + + + + + + + + + + +
离职员工* + + + 所在部门 + +
离职日期* + 部门负责人* + + +
交接人员* + + +
离职原因* + +
+ {/if} +
+ + + +
+
+{/block} + + + +{block name="script"} + +{include file="common/layui" base='base' extend="['employeepicker']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index bdbbc52..b9b05ff 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -139,8 +139,8 @@ INSERT INTO `oa_admin_menu` VALUES (21, 2, '发票主体设置', 'home/invoice/s INSERT INTO `oa_admin_menu` VALUES (22, 3, '部门架构', 'home/department/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (23, 3, '岗位职称', 'home/position/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (24, 3, '企业员工', 'home/admin/index', '', 1, 0, 0); -INSERT INTO `oa_admin_menu` VALUES (25, 3, '人事调动', 'home/personnel/change', '', 1, 0, 0); -INSERT INTO `oa_admin_menu` VALUES (26, 3, '离职档案', 'home/personnel/leave', '', 1, 0, 0); +INSERT INTO `oa_admin_menu` VALUES (25, 3, '人事调动', 'home/personal/change', '', 1, 0, 0); +INSERT INTO `oa_admin_menu` VALUES (26, 3, '离职档案', 'home/personal/leave', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (27, 4, '收件箱', 'home/mail/inbox', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (28, 4, '已发送', 'home/mail/sendbox', '', 1, 0, 0); @@ -261,12 +261,12 @@ INSERT INTO `oa_admin_rule` VALUES (59, 57, 'home/admin/view', '查看员工信 INSERT INTO `oa_admin_rule` VALUES (60, 57, 'home/admin/set', '设置员工状态','员工状态', 0, 0); INSERT INTO `oa_admin_rule` VALUES (61, 57, 'home/admin/reset_psw', '重设员工密码','员工密码', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (62, 3, 'home/personnel/index', '人事调动','人事调动', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (63, 62, 'home/personnel/add', '新增/编辑人事调动','人事调动', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (62, 3, 'home/personal/change', '人事调动','人事调动', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (63, 62, 'home/personal/change_add', '新增/编辑人事调动','人事调动', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (64, 3, 'home/personnel/index', '离职档案','离职档案', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (65, 64, 'home/personnel/add', '新增/编辑离职档案','离职档案', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (66, 64, 'home/personnel/delete', '删除离职档案','离职档案', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (64, 3, 'home/personal/leave', '离职档案','离职档案', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (65, 64, 'home/personal/leave_add', '新增/编辑离职档案','离职档案', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (66, 64, 'home/personal/leave_delete', '删除离职档案','离职档案', 0, 0); INSERT INTO `oa_admin_rule` VALUES (67, 4, 'home/mail/inbox', '收件箱','收件箱', 0, 0); INSERT INTO `oa_admin_rule` VALUES (68, 67, 'home/mail/add', '添加/修改消息','消息', 0, 0); @@ -470,6 +470,42 @@ INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark` INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (14, '客服一部', 7, 0, '13688888885', '', 1, 0, 0); INSERT INTO `oa_department`(`id`, `title`, `pid`, `leader_id`, `phone`, `remark`, `status`, `create_time`, `update_time`) VALUES (15, '客服二部', 7, 0, '13688888855', '', 1, 0, 0); +-- ---------------------------- +-- Table structure for oa_department_change +-- ---------------------------- +DROP TABLE IF EXISTS `oa_department_change`; +CREATE TABLE `oa_department_change` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户ID', + `from_did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '原部门id', + `to_did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调到部门id', + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注', + `admin_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用', + `move_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调到时间', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '人事调动部门记录表'; + +-- ---------------------------- +-- Table structure for oa_personal_quit +-- ---------------------------- +DROP TABLE IF EXISTS `oa_personal_quit`; +CREATE TABLE `oa_personal_quit` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户ID', + `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注', + `admin_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `lead_admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '部门负责人', + `connect_uids` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交接人', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用', + `quit_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '离职时间', + `create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '人事离职记录表'; + -- ---------------------------- -- Table structure for oa_expense -- ----------------------------