diff --git a/app/home/controller/Plan.php b/app/home/controller/Plan.php new file mode 100644 index 0000000..a28423c --- /dev/null +++ b/app/home/controller/Plan.php @@ -0,0 +1,216 @@ +isAjax()) { + $param = get_params(); + //按时间检索 + $start_time = isset($param['start_time']) ? strtotime($param['start_time']) : 0; + $end_time = isset($param['end_time']) ? strtotime($param['end_time']) : 0; + $where = []; + if ($start_time > 0 && $end_time > 0) { + $where[] = ['a.start_time', 'between', [$start_time, $end_time]]; + } + if (!empty($param['keywords'])) { + $where[] = ['a.title', 'like', '%' . trim($param['keywords']) . '%']; + } + if (!empty($param['uid'])) { + $where[] = ['a.admin_id', '=', $param['uid']]; + } else { + $where[] = ['a.admin_id', '=', $this->uid]; + } + $where[] = ['a.status', '=', 1]; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $plan = PlanList::where($where) + ->field('a.*,u.name as create_admin') + ->alias('a') + ->join('admin u', 'u.id = a.admin_id', 'LEFT') + ->order('a.id desc') + ->paginate($rows, false) + ->each(function ($item, $key) { + $item->start_time = empty($item->start_time) ? '' : date('Y-m-d H:i', $item->start_time); + //$item->end_time = empty($item->end_time) ? '': date('Y-m-d H:i', $item->end_time); + $item->end_time = empty($item->end_time) ? '' : date('H:i', $item->end_time); + }); + return table_assign(0, '', $plan); + } else { + return view(); + } + } + + //工作记录 + public function calendar() + { + if (request()->isAjax()) { + $param = get_params(); + $uid = $this->uid; + if (!empty($param['uid'])) { + $uid = $param['uid']; + } + $where = []; + $where[] = ['start_time', '>=', strtotime($param['start'])]; + $where[] = ['end_time', '<=', strtotime($param['end'])]; + $where[] = ['admin_id', '=', $uid]; + $where[] = ['status', '=', 1]; + $schedule = Db::name('Plan')->where($where)->field('id,title,color,start_time,end_time')->select()->toArray(); + $events = []; + foreach ($schedule as $k => $v) { + $v['backgroundColor'] = $v['color']; + $v['borderColor'] = $v['color']; + $v['title'] = $v['title']; + $v['start'] = date('Y-m-d H:i', $v['start_time']); + $v['end'] = date('Y-m-d H:i', $v['end_time']); + unset($v['start_time']); + unset($v['end_time']); + $events[] = $v; + } + $input_arrays = $events; + $range_start = parseDateTime($param['start']); + $range_end = parseDateTime($param['end']); + $timeZone = null; + if (isset($_GET['timeZone'])) { + $timeZone = new DateTimeZone($_GET['timeZone']); + } + + // Accumulate an output array of event data arrays. + $output_arrays = array(); + foreach ($input_arrays as $array) { + // Convert the input array into a useful Event object + $event = new ScheduleIndex($array, $timeZone); + // If the event is in-bounds, add it to the output + if ($event->isWithinDayRange($range_start, $range_end)) { + $output_arrays[] = $event->toArray(); + } + } + return json($output_arrays); + } else { + return view(); + } + } + + //保存日志数据 + public function add() + { + $param = get_params(); + $admin_id = $this->uid; + if ($param['id'] == 0) { + if (isset($param['start_time'])) { + $param['start_time'] = strtotime($param['start_time'] . '' . $param['start_time_1']); + } + if (isset($param['end_time'])) { + $param['end_time'] = strtotime($param['end_time'] . '' . $param['end_time_1']); + } + if ($param['end_time'] <= $param['start_time']) { + return to_assign(1, "结束时间需要大于开始时间"); + } + $where1[] = ['status', '=', 1]; + $where1[] = ['admin_id', '=', $admin_id]; + $where1[] = ['start_time', 'between', [$param['start_time'], $param['end_time'] - 1]]; + + $where2[] = ['status', '=', 1]; + $where2[] = ['admin_id', '=', $admin_id]; + $where2[] = ['start_time', '<=', $param['start_time']]; + $where2[] = ['start_time', '>=', $param['end_time']]; + + $where3[] = ['status', '=', 1]; + $where3[] = ['admin_id', '=', $admin_id]; + $where3[] = ['end_time', 'between', [$param['start_time'] + 1, $param['end_time']]]; + + $record = Db::name('Plan') + ->where(function ($query) use ($where1) { + $query->where($where1); + }) + ->whereOr(function ($query) use ($where2) { + $query->where($where2); + }) + ->whereOr(function ($query) use ($where3) { + $query->where($where3); + }) + ->count(); + if ($record > 0) { + return to_assign(1, "您所选的时间区间已有日程安排,请重新选时间"); + } + $param['admin_id'] = $admin_id; + $param['did'] = get_admin($admin_id)['did']; + $param['create_time'] = time(); + $addid = Db::name('Plan')->strict(false)->field(true)->insertGetId($param); + if ($addid > 0) { + add_log('add', $addid, $param); + return to_assign(0, '操作成功'); + } else { + return to_assign(0, '操作失败'); + } + } else { + $param['update_time'] = time(); + $res = Db::name('Plan')->strict(false)->field(true)->update($param); + if ($res !== false) { + add_log('edit', $addid, $param); + return to_assign(0, '操作成功'); + } else { + return to_assign(0, '操作失败'); + } + } + } + + //删除工作记录 + public function delete() + { + $id = get_params("id"); + $data['status'] = '-1'; + $data['id'] = $id; + $data['update_time'] = time(); + if (Db::name('Plan')->update($data) !== false) { + add_log('delete', $data['id'], $data); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } + + public function detail($id) + { + $id = get_params('id'); + $schedule = Db::name('Plan')->where(['id' => $id])->find(); + if (!empty($schedule)) { + $schedule['start_time'] = date('Y-m-d H:i', $schedule['start_time']); + $schedule['end_time'] = date('Y-m-d H:i', $schedule['end_time']); + $schedule['create_time'] = date('Y-m-d H:i:s', $schedule['create_time']); + $schedule['user'] = Db::name('Admin')->where(['id' => $schedule['admin_id']])->value('name'); + } + if (request()->isAjax()) { + return to_assign(0, "", $schedule); + } else { + return $schedule; + } + } + + //读取日程弹层详情 + public function view() + { + $id = get_params('id'); + $schedule = $this->detail($id); + if ($schedule) { + View::assign('schedule', $schedule); + return view(); + } else { + echo '该日程安排不存在'; + } + } + +} diff --git a/app/home/controller/Schedule.php b/app/home/controller/Schedule.php index 682da18..21c018d 100644 --- a/app/home/controller/Schedule.php +++ b/app/home/controller/Schedule.php @@ -98,7 +98,7 @@ class Schedule extends BaseController $where[] = ['a.start_time', 'between', [$start_time, $end_time]]; } if (!empty($param['keywords'])) { - $where[] = ['a.name', 'like', '%' . trim($param['keywords']) . '%']; + $where[] = ['a.title', 'like', '%' . trim($param['keywords']) . '%']; } if (!empty($param['uid'])) { $where[] = ['a.admin_id', '=', $param['uid']]; @@ -138,13 +138,13 @@ class Schedule extends BaseController $where[] = ['end_time', '<=', strtotime($param['end'])]; $where[] = ['admin_id', '=', $uid]; $where[] = ['status', '=', 1]; - $schedule = Db::name('Schedule')->where($where)->field('id,name,labor_time,start_time,end_time')->select()->toArray(); + $schedule = Db::name('Schedule')->where($where)->field('id,title,labor_time,start_time,end_time')->select()->toArray(); $events = []; $countEvents = []; foreach ($schedule as $k => $v) { $v['backgroundColor'] = '#009688'; $v['borderColor'] = '#009688'; - $v['title'] = '[' . $v['labor_time'] . '工时] ' . $v['name']; + $v['title'] = '[' . $v['labor_time'] . '工时] ' . $v['title']; $v['start'] = date('Y-m-d H:i', $v['start_time']); $v['end'] = date('Y-m-d H:i', $v['end_time']); $temData = date('Y-m-d', $v['start_time']); @@ -154,7 +154,6 @@ class Schedule extends BaseController $countEvents[$temData]['times'] = $v['labor_time']; $countEvents[$temData]['start'] = date('Y-m-d', $v['start_time']); } - unset($v['name']); unset($v['start_time']); unset($v['end_time']); $events[] = $v; @@ -238,9 +237,9 @@ class Schedule extends BaseController $param['admin_id'] = $admin_id; $param['did'] = get_admin($admin_id)['did']; $param['create_time'] = time(); - $addid = Db::name('Schedule')->strict(false)->field(true)->insertGetId($param); - if ($addid > 0) { - add_log('add', $addid, $param); + $sid = Db::name('Schedule')->strict(false)->field(true)->insertGetId($param); + if ($sid > 0) { + add_log('add', $sid, $param); return to_assign(0, '操作成功'); } else { return to_assign(0, '操作失败'); @@ -249,7 +248,7 @@ class Schedule extends BaseController $param['update_time'] = time(); $res = Db::name('Schedule')->strict(false)->field(true)->update($param); if ($res !== false) { - add_log('edit', $addid, $param); + add_log('edit', $param['id'], $param); return to_assign(0, '操作成功'); } else { return to_assign(0, '操作失败'); @@ -357,12 +356,4 @@ class Schedule extends BaseController } } - //个人年度工作情况 - public function user() - { - $this_year = date("Y"); - $admin_did = \think\Session::get('vae_admin'); - return view('', ['this_year' => $this_year, 'this_uid' => $admin_did['id'], 'username' => $admin_did['nickname']]); - } - } diff --git a/app/home/model/Plan.php b/app/home/model/Plan.php new file mode 100644 index 0000000..16ee3c0 --- /dev/null +++ b/app/home/model/Plan.php @@ -0,0 +1,8 @@ + + + + + + + +{/block} + +{block name="body"} + + + + + + +
+
+
+ +
+
+
+ +
+
+ +{/block} + +{block name="script"} + + {include file="common/layui" base='base' extend="['employeepicker','dtree']" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/plan/index.html b/app/home/view/plan/index.html new file mode 100644 index 0000000..428b1c4 --- /dev/null +++ b/app/home/view/plan/index.html @@ -0,0 +1,435 @@ +{extend name="common/base"/} +{block name="style"} + + + +{/block} + +{block name="body"} +
+
+
+
+ +
+ ~ +
+ +
+
+
+ + +
+
+ +
+ +
+
+
+
+
+ +{/block} + + + +{block name="script"} + + {include file="common/layui" base='base' extend="['dtree','employeepicker']" use="[]" callback="init" /} +{/block} + \ No newline at end of file diff --git a/app/home/view/schedule/calendar.html b/app/home/view/schedule/calendar.html index 41daa1b..8dec3e1 100644 --- a/app/home/view/schedule/calendar.html +++ b/app/home/view/schedule/calendar.html @@ -154,8 +154,8 @@ var hourArray=[]; for(var h=0;h<24;h++){ var t=h<10?'0'+h:h - var t_1=t+':00',t_2=t+':10',t_3=t+':20',t_4=t+':30',t_5=t+':40',t_6=t+':50'; - hourArray.push(t_1,t_2,t_3,t_4,t_5,t_6); + var t_1=t+':00',t_2=t+':15',t_3=t+':30',t_4=t+':45'; + hourArray.push(t_1,t_2,t_3,t_4); } var html_1='', html_2='',def_h1='08:30',def_h2='09:00'; diff --git a/app/home/view/schedule/index.html b/app/home/view/schedule/index.html index dc64717..b105764 100644 --- a/app/home/view/schedule/index.html +++ b/app/home/view/schedule/index.html @@ -116,7 +116,7 @@ return html; }} ,{field: 'labor_time', title: '工时', align:'center',width:80} - ,{field: 'name', title: '工作内容'} + ,{field: 'title', title: '工作内容'} ,{field: 'create_time', title: '记录时间', align:'center',width:150} ,{field: 'right', title: '操作',fixed:'right', width:150, align:'center',templet:function(d){ var html='
'; @@ -178,8 +178,8 @@ var hourArray=[]; for(var h=0;h<24;h++){ var t=h<10?'0'+h:h - var t_1=t+':00',t_2=t+':10',t_3=t+':20',t_4=t+':30',t_5=t+':40',t_6=t+':50'; - hourArray.push(t_1,t_2,t_3,t_4,t_5,t_6); + var t_1=t+':00',t_2=t+':15',t_3=t+':30',t_4=t+':45'; + hourArray.push(t_1,t_2,t_3,t_4); } var html_1='', html_2='',def_h1='08:30',def_h2='09:00'; @@ -267,7 +267,7 @@ function editEvent(data){ var detail={}; detail['id']=data.id; - detail['name']=data.name; + detail['title']=data.title; detail['remark']=data.remark; detail['labor_type']=data.labor_type; var content='
\ @@ -282,7 +282,7 @@ \ \ 工作内容 *\ - \ + \ \ \ 工作详细描述\ @@ -298,13 +298,11 @@ area:['900px','390px'], content:content, success:function(){ - $("input[name=labor_type][value="+data.labor_type+"]").prop("checked","true"); - - form.render(); - - $('[name="name"]').on('input',function(){ + $("input[name=labor_type][value="+data.labor_type+"]").prop("checked","true"); + form.render(); + $('[name="title"]').on('input',function(){ var _val=$(this).val(); - detail.name=_val; + detail.title=_val; }); $('[form-input="remark"]').on('input',function(){ var _val=$(this).val(); @@ -321,7 +319,7 @@ layer.msg('请选择工作类型'); return; } - if(detail.name==''){ + if(detail.title==''){ layer.msg('请填写工作内容'); return; } @@ -396,7 +394,7 @@ function addEvent(){ var detail={}; detail['id']=0; - detail['name']=''; + detail['title']=''; detail['start_time']=''; detail['end_time']=''; detail['start_time_1']='08:30'; @@ -417,7 +415,7 @@ \ \ 工作内容 *\ - \ + \ \ \ 工作详细描述\ @@ -467,8 +465,8 @@ var hourArray=[]; for(var h=0;h<24;h++){ var t=h<10?'0'+h:h - var t_1=t+':00',t_2=t+':10',t_3=t+':20',t_4=t+':30',t_5=t+':40',t_6=t+':50'; - hourArray.push(t_1,t_2,t_3,t_4,t_5,t_6); + var t_1=t+':00',t_2=t+':15',t_3=t+':30',t_4=t+':45'; + hourArray.push(t_1,t_2,t_3,t_4); } var html_1='', html_2='',def_h1='08:30',def_h2='09:00'; @@ -488,9 +486,9 @@ $('#end_time_1').append(html_2); form.render(); - $('[name="name"]').on('input',function(){ + $('[name="title"]').on('input',function(){ var _val=$(this).val(); - detail.name=_val; + detail.title=_val; }); form.on('select(start_time_1)', function(data){ detail.start_time_1=data.value; @@ -518,7 +516,7 @@ layer.msg('请选择工作类型'); return; } - if(detail.name==''){ + if(detail.title==''){ layer.msg('请填写工作内容'); return; } diff --git a/app/home/view/schedule/view.html b/app/home/view/schedule/view.html index 3d4b38c..c3f1653 100644 --- a/app/home/view/schedule/view.html +++ b/app/home/view/schedule/view.html @@ -14,7 +14,7 @@ 工作内容 - {$schedule.name} + {$schedule.title} 创建时间 {$schedule.create_time} diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index 3956ffd..bdbbc52 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -154,8 +154,8 @@ INSERT INTO `oa_admin_menu` VALUES (33, 6, '知识类别', 'home/article/cate', INSERT INTO `oa_admin_menu` VALUES (34, 6, '共享知识', 'home/article/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (35, 6, '个人知识', 'home/article/list', '', 1, 0, 0); -INSERT INTO `oa_admin_menu` VALUES (36, 7, '工作计划', 'home/plan/index', '', 1, 0, 0); -INSERT INTO `oa_admin_menu` VALUES (37, 7, '计划日历', 'home/plan/calendar', '', 1, 0, 0); +INSERT INTO `oa_admin_menu` VALUES (36, 7, '日程安排', 'home/plan/index', '', 1, 0, 0); +INSERT INTO `oa_admin_menu` VALUES (37, 7, '日程日历', 'home/plan/calendar', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (38, 7, '工作记录', 'home/schedule/index', '', 1, 0, 0); INSERT INTO `oa_admin_menu` VALUES (39, 7, '工作日历', 'home/schedule/calendar', '', 1, 0, 0); @@ -300,11 +300,11 @@ INSERT INTO `oa_admin_rule` VALUES (90, 87, 'home/article/view', '查看知识 INSERT INTO `oa_admin_rule` VALUES (91, 6, 'home/article/list', '个人知识','知识文章', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (92, 7, 'home/plan/index', '工作计划','工作计划', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (93, 92, 'home/plan/calendar', '工作计划日历','工作计划', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (94, 92, 'home/plan/add', '添加/编辑工作计划','工作计划', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (95, 92, 'home/plan/delete', '删除工作计划','工作计划', 0, 0); -INSERT INTO `oa_admin_rule` VALUES (96, 92, 'home/plan/detail', '查看工作计划','工作计划', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (92, 7, 'home/plan/index', '日程安排','日程安排', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (93, 92, 'home/plan/calendar', '日程日历','日程安排', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (94, 92, 'home/plan/add', '添加/编辑日程安排','日程安排', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (95, 92, 'home/plan/delete', '删除日程安排','日程安排', 0, 0); +INSERT INTO `oa_admin_rule` VALUES (96, 92, 'home/plan/detail', '查看日程安排','日程安排', 0, 0); INSERT INTO `oa_admin_rule` VALUES (97, 7, 'home/schedule/index', '工作记录','工作记录', 0, 0); INSERT INTO `oa_admin_rule` VALUES (98, 97, 'home/schedule/calendar', '工作记录日历','工作日历', 0, 0); @@ -766,22 +766,45 @@ CREATE TABLE `oa_position_group` ( -- ---------------------------- INSERT INTO `oa_position_group`(`pid`, `group_id`, `create_time`, `update_time`) VALUES (1, 1, 1635755739, 0); +-- ---------------------------- +-- Table structure for oa_plan +-- ---------------------------- +DROP TABLE IF EXISTS `oa_plan`; +CREATE TABLE `oa_plan` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '工作安排主题', + `color` varchar(100) NOT NULL DEFAULT '' COMMENT '颜色', + `cid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联工作内容类型ID', + `cmid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联客户ID', + `ptid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联项目ID', + `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联创建员工ID', + `did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '所属部门', + `start_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '开始时间', + `end_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '结束时间', + `remind_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '提醒时间', + `remark` text NOT NULL COMMENT '描述', + `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用', + `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_schedule -- ---------------------------- DROP TABLE IF EXISTS `oa_schedule`; CREATE TABLE `oa_schedule` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL DEFAULT '' COMMENT '工作记录主题', + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '工作记录主题', `cid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联工作内容类型ID', `cmid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联客户ID', `ptid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联项目ID', - `plid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联任务计划ID', + `taid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预设字段:关联任务ID', `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联创建员工ID', `did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '所属部门', `start_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '开始时间', `end_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '结束时间', - `labor_time` decimal(15, 1) NOT NULL DEFAULT 0.0 COMMENT '工时', + `labor_time` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '工时', `labor_type` int(1) NOT NULL DEFAULT 0 COMMENT '工作类型:1案头2外勤', `remark` text NOT NULL COMMENT '描述', `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除 0禁用 1启用',