diff --git a/app/home/controller/Plan.php b/app/home/controller/Plan.php index a28423c..acb1611 100644 --- a/app/home/controller/Plan.php +++ b/app/home/controller/Plan.php @@ -44,9 +44,10 @@ class Plan extends BaseController ->order('a.id desc') ->paginate($rows, false) ->each(function ($item, $key) { + $item->remind_time = empty($item->remind_time) ? '-' : date('Y-m-d H:i', $item->remind_time); $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); + $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 { @@ -68,11 +69,12 @@ class Plan extends BaseController $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(); + $schedule = Db::name('Plan')->where($where)->field('id,title,type,start_time,end_time')->select()->toArray(); $events = []; + $color_array=['#393D49','#FF5722','#FFB800','#1E9FFF','#009688']; foreach ($schedule as $k => $v) { - $v['backgroundColor'] = $v['color']; - $v['borderColor'] = $v['color']; + $v['backgroundColor'] = $color_array[$v['type']]; + $v['borderColor'] = $color_array[$v['type']]; $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']); @@ -109,43 +111,35 @@ class Plan extends BaseController { $param = get_params(); $admin_id = $this->uid; + if (isset($param['start_time_a'])) { + $param['start_time'] = strtotime($param['start_time_a'] . '' . $param['start_time_b']); + } + if (isset($param['end_time_a'])) { + $param['end_time'] = strtotime($param['end_time_a'] . '' . $param['end_time_b']); + } + if ($param['end_time'] <= $param['start_time']) { + return to_assign(1, "结束时间需要大于开始时间"); + } + + if($param['remind_type']==1){ + $param['remind_time'] = $param['start_time']-5*60; + } + if($param['remind_type']==2){ + $param['remind_time'] = $param['start_time']-15*60; + } + if($param['remind_type']==3){ + $param['remind_time'] = $param['start_time']-30*60; + } + if($param['remind_type']==4){ + $param['remind_time'] = $param['start_time']-60*60; + } + if($param['remind_type']==5){ + $param['remind_time'] = $param['start_time']-120*60; + } + if($param['remind_type']==6){ + $param['remind_time'] = $param['start_time']-1440*60; + } 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(); @@ -160,7 +154,7 @@ class Plan extends BaseController $param['update_time'] = time(); $res = Db::name('Plan')->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, '操作失败'); @@ -188,6 +182,11 @@ class Plan extends BaseController $id = get_params('id'); $schedule = Db::name('Plan')->where(['id' => $id])->find(); if (!empty($schedule)) { + $schedule['remind_time'] = date('Y-m-d H:i', $schedule['remind_time']); + $schedule['start_time_a'] = date('Y-m-d', $schedule['start_time']); + $schedule['end_time_a'] = date('Y-m-d', $schedule['end_time']); + $schedule['start_time_b'] = date('H:i', $schedule['start_time']); + $schedule['end_time_b'] = date('H:i', $schedule['end_time']); $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']); diff --git a/app/home/view/plan/calendar.html b/app/home/view/plan/calendar.html index af7947d..45c6092 100644 --- a/app/home/view/plan/calendar.html +++ b/app/home/view/plan/calendar.html @@ -14,6 +14,7 @@ .layui-layer-content .layui-table-view .layui-table td,.layui-layer-content .layui-table-view .layui-table th{padding:1px 0;} .calendar-add{width:200px; height:38px; position:absolute; top:25px; left:180px; z-index:100;} .calendar-select{width:200px; height:38px; position:absolute; top:25px; right:153px; z-index:100;} +.layui-unselect dl {max-height:188px;} {/block} @@ -27,7 +28,7 @@
- +
@@ -39,11 +40,12 @@ {block name="script"} {/block} @@ -46,6 +46,7 @@ function init(layui){ var table = layui.table ,form = layui.form + ,dropdown = layui.dropdown ,dtree = layui.dtree ,employeepicker = layui.employeepicker ,laydate = layui.laydate; @@ -98,17 +99,32 @@ ,cellMinWidth: 80 ,cols: [[ //表头 {field: 'id', title: '序号',fixed: 'left', width:80, align:'center'} - ,{field: 'color', title: '优先级', align:'center',width:90,templet:function(d){ - var html='-'; + ,{field: 'type', title: '优先级', align:'center',width:80,templet:function(d){ + var html=''; + if(d.type==1){ + html = '紧急'; + } + else if(d.type==2){ + html = '重要'; + } + else if(d.type==3){ + html = '次要'; + } + else if(d.type==4){ + html = '不重要'; + } + else if(d.type==5){ + html = '无优先级'; + } return html; }} - ,{field: 'start_time', title: '工作时间范围', align:'center',width:186,templet:function(d){ + ,{field: 'start_time', title: '日程时间范围', align:'center',width:260,templet:function(d){ var html=d.start_time+'至'+d.end_time; return html; }} - ,{field: 'title', title: '工作内容'} - ,{field: 'create_time', title: '登记时间', align:'center',width:150} - ,{field: 'right', title: '操作',fixed:'right', width:120, align:'center',templet:function(d){ + ,{field: 'title', title: '日程安排内容'} + ,{field: 'remind_time', title: '提醒时间', align:'center',width:136} + ,{field: 'right', title: '操作',fixed:'right', width:100, align:'center',templet:function(d){ var html='
'; html+=''; if(d.admin_id==login_user){ @@ -120,7 +136,7 @@ ]] }); - //更改工时 + //操作 table.on('tool(test)', function(obj){ var data = obj.data; if(obj.event === 'edit'){ @@ -130,8 +146,18 @@ id:data.id }, success:function(e){ - if(e.code==0){ - editEvent(e.data); + if(e.code==0){ + var detail={}; + detail['id']=e.data.id; + detail['title']=e.data.title; + detail['start_time_a']=e.data.start_time_a; + detail['end_time_a']=e.data.end_time_a; + detail['start_time_b']=e.data.start_time_b; + detail['end_time_b']=e.data.end_time_b; + detail['remark']=e.data.remark; + detail['type']=e.data.type; + detail['remind_type']=e.data.remind_type; + addEvent(detail); } } }) @@ -150,115 +176,42 @@ }) } }); - - //编辑 - function editEvent(data){ - var detail={}; - detail['id']=data.id; - detail['title']=data.title; - detail['remark']=data.remark; - detail['labor_type']=data.labor_type; - var content='
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
工作时间范围 *'+data.start_time+' '+data.start_time_1+' 至 '+data.end_time_1+'工作类型 *\ - \ -
工作内容 *
工作详细描述\ - \ -
\ -
'; - layer.open({ - type:1, - title:'编辑日程安排', - area:['900px','390px'], - content:content, - success:function(){ - $("input[name=labor_type][value="+data.labor_type+"]").prop("checked","true"); - form.render(); - $('[name="title"]').on('input',function(){ - var _val=$(this).val(); - detail.title=_val; - }); - $('[form-input="remark"]').on('input',function(){ - var _val=$(this).val(); - detail.remark=_val; - }); - form.on('radio(labor_type)', function(data){ - detail.labor_type=data.value; - }); - }, - btn: ['确定提交'], - btnAlign:'c', - yes: function(idx){ - if(detail.labor_type==0){ - layer.msg('请选择工作类型'); - return; - } - if(detail.title==''){ - layer.msg('请填写工作内容'); - return; - } - console.log(detail); - $.ajax({ - url:"{:url('home/plan/add')}", - type:'post', - data:detail, - success:function(e){ - layer.msg(e.msg); - if(e.code==0){ - layer.close(idx); - setTimeout(function(){ - window.location.reload(); - },1000) - } - } - }) - } - }) - } - //查看工作记录 + //查看日程记录 function viewEvent(detail){ - var work_type='-'; - if(detail.labor_type==2){ - work_type='外勤工作'; + var work_type='无优先级'; + if(detail.type==1){ + work_type = '紧急'; } - else if(detail.labor_type==1){ - work_type='案头工作'; + else if(detail.type==2){ + work_type = '重要'; } - var content='
\ + else if(detail.type==3){ + work_type = '次要'; + } + else if(detail.type==4){ + work_type = '不重要'; + } + var content='
\ \ \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ + \ + \ + \ + \ \ \ - \ + \ + \ + \ + \ + \ + \ + \ \ \
工作内容'+detail.name+'工作类别'+work_type+'
工作时间范围'+detail.start_time+' '+detail.start_time_1+' 至 '+detail.end_time_1+',共'+detail.labor_time+'工时执行人'+detail.user+'日程时间范围'+detail.start_time+' 至 '+detail.end_time+'提醒时间'+detail.remind_time+'
工作描述日程安排内容'+detail.title+'优先级'+work_type+'
日程内容描述'+detail.remark+'
\ - '; +
'; layer.open({ type:1, title:'日程安排', @@ -276,61 +229,100 @@ } $('.body-content').on('click','.addLoan',function(){ - addEvent(); - }); - - function addEvent(){ var detail={}; detail['id']=0; detail['title']=''; - detail['start_time']=''; - detail['end_time']=''; - detail['start_time_1']='08:30'; - detail['end_time_1']='09:00'; + detail['start_time_a']=''; + detail['end_time_a']=''; + detail['start_time_b']='08:30'; + detail['end_time_b']='09:00'; detail['remark']=''; - detail['labor_type']=0; - var content='
\ + detail['type']=0; + detail['remind_type']=0; + addEvent(detail); + }); + + + function addEvent(detail){ + var type='请选择'; + if(detail.type==1){ + type = ' 紧急'; + } + else if(detail.type==2){ + type = ' 重要'; + } + else if(detail.type==3){ + type = ' 次要'; + } + else if(detail.type==4){ + type = ' 不重要'; + } + else if(detail.type==5){ + type = ' 无优先级'; + } + + var remind_type='不提醒'; + if(detail.remind_type==1){ + remind_type = '提前5分钟'; + } + else if(detail.remind_type==2){ + remind_type = '提前15分钟'; + } + else if(detail.remind_type==3){ + remind_type = '提前30分钟'; + } + else if(detail.remind_type==4){ + remind_type = '提前1小时'; + } + else if(detail.remind_type==5){ + remind_type = '提前2小时'; + }else if(detail.remind_type==6){ + remind_type = '提前1天'; + } + + var content='\ \ \ - \ + \ \ - \ + \ \ \ \ - \ - \ + \ + \ + \ + \ \ \ - \ + \ \ \
工作时间范围 *日程时间范围 *\ -
\ +
\
工作类型 *日程优先级 *\ - \ +
'+type+'
\
工作内容 *日程内容 *提醒 *\ +
'+remind_type+'
\ +
工作详细描述日程详细描述\ - \ + \
\
'; layer.open({ type:1, - title:'添加工作记录', - area:['900px','390px'], + title:'日程安排', + area:['860px','390px'], content:content, success:function(){ //日期时间范围 laydate.render({ elem: '#start_time_a', type: 'date', - min: -7, - max:0, + min: 0, format: 'yyyy-MM-dd', showBottom: false, done:function(a,b,c){ - $('#end_time_a').val(a); - detail.start_time=a; - detail.end_time=a; + detail.start_time_a=a; } }); @@ -338,26 +330,22 @@ laydate.render({ elem: '#end_time_a', type: 'date', - min: -7, - max:0, + min: 0, format: 'yyyy-MM-dd', showBottom: false, done:function(a,b,c){ - $('#start_time_a').val(a); - detail.start_time=a; - detail.end_time=a; + detail.end_time_a=a; } }); - $('#start_time_1,#end_time_1').empty(); + $('#start_time_a,#end_time_a').empty(); var hourArray=[]; for(var h=0;h<24;h++){ var t=h<10?'0'+h:h 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'; + } + var html_1='', html_2='',def_h1=detail.start_time_b,def_h2=detail.end_time_b; for(var s=0;s'+hourArray[s]+''; } - $('#start_time_1').append(html_1); - $('#end_time_1').append(html_2); + $('#start_time_b').append(html_1); + $('#end_time_b').append(html_2); form.render(); $('[name="title"]').on('input',function(){ var _val=$(this).val(); detail.title=_val; }); - form.on('select(start_time_1)', function(data){ - detail.start_time_1=data.value; - console.log(data); + form.on('select(start_time_b)', function(data){ + detail.start_time_b=data.value; }); - form.on('select(end_time_1)', function(data){ - detail.end_time_1=data.value; + form.on('select(end_time_b)', function(data){ + detail.end_time_b=data.value; }); $('[form-input="remark"]').on('input',function(){ var _val=$(this).val(); detail.remark=_val; - }); - form.on('radio(labor_type)', function(data){ - detail.labor_type=data.value; - }); + }); + + dropdown.render({ + elem: '#type' + ,data: [{ + title: ' 紧急', + id: 1 + },{ + title: ' 重要', + + id: 2 + },{ + title: ' 次要', + id: 3 + },{ + title: ' 不重要', + id: 4 + },{ + title: ' 无优先级', + id: 5 + }] + ,click: function(obj){ + this.elem.html(obj.title); + detail.type = obj.id; + } + ,style: 'width: 120px;' + }); + + dropdown.render({ + elem: '#remind_type' + ,data: [{ + title: '不提醒', + id: 0 + },{ + title: '提前5分钟', + id: 1 + },{ + title: '提前15分钟', + id: 2 + },{ + title: '提前30分钟', + id: 3 + },{ + title: '提前1小时', + id: 4 + },{ + title: '提前2小时', + id: 5 + },{ + title: '提前1天', + id:6 + }] + ,click: function(obj){ + this.elem.html(obj.title); + detail.remind_type = obj.id; + } + ,style: 'width: 120px;' + }); }, btn: ['确定提交'], btnAlign:'c', yes: function(idx){ - if(detail.start_time=='' || detail.end_time==''){ - layer.msg('请选择工作时间范围'); + if(detail.start_time_a=='' || detail.end_time_a==''){ + layer.msg('请完善日程时间范围'); return; } - if(detail.labor_type==0){ - layer.msg('请选择工作类型'); + if(detail.type==0){ + layer.msg('请选择日程优先级'); return; } if(detail.title==''){ - layer.msg('请填写工作内容'); + layer.msg('请填写日程内容'); return; } console.log(detail); diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index e44747e..69f5584 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -810,7 +810,7 @@ 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 '颜色', + `type` 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', @@ -818,6 +818,7 @@ CREATE TABLE `oa_plan` ( `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_type` 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启用',