优化日常工作模块
This commit is contained in:
parent
78b8faf044
commit
82006fe5e2
@ -87,8 +87,45 @@ class Schedule extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
function index() {
|
||||
if (request()->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.name', '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'];
|
||||
$schedule = ScheduleList::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, '', $schedule);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//工作记录
|
||||
public function index()
|
||||
public function calendar()
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
@ -155,45 +192,8 @@ class Schedule extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
function list() {
|
||||
if (request()->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.name', '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'];
|
||||
$schedule = ScheduleList::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, '', $schedule);
|
||||
} else {
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//保存日志数据
|
||||
public function save()
|
||||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
$admin_id = $this->uid;
|
||||
|
349
app/home/view/schedule/calendar.html
Normal file
349
app/home/view/schedule/calendar.html
Normal file
@ -0,0 +1,349 @@
|
||||
{extend name="common/base"/}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/core/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/daygrid/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/timegrid/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/list/main.css"/>
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/dtree.css">
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/font/dtreefont.css">
|
||||
<style>
|
||||
#calendar {padding: 5px 0;}
|
||||
.fc .fc-day-header{padding:8px 0; background-color:#f2f2f2;}
|
||||
.fc-week-number,.fc-axis{background-color:#f2f2f2;}
|
||||
.layui-tags-span {padding: 3px 6px;font-size: 12px; background-color:#fff; border-radius: 3px; margin:2px 0; margin-right: 5px; border: 1px solid #e6e6e6; display: inline-block;}
|
||||
.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;}
|
||||
</style>
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<script src="{__STATIC__}/fullcalendar/core/main.min.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/core/locales-all.min.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/interaction/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/daygrid/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/timegrid/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/list/main.js"></script>
|
||||
<div class="body-content">
|
||||
<div id="calendar"></div>
|
||||
<div class="calendar-add">
|
||||
<button class="layui-btn layui-btn-normal addLoan" style="padding:0 12px;">+新增工作记录</button>
|
||||
</div>
|
||||
<div class="calendar-select">
|
||||
<div class="layui-input-inline" style="width: 110px;"><input type="text" placeholder="请选择员工" class="layui-input" data-event="select" autocomplete="off"/></div>
|
||||
<button class="layui-btn" lay-filter="webform" style="padding:0 12px;">清空员工</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /主体 -->
|
||||
{/block}
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
var detail={},uid=0;
|
||||
|
||||
function init(layui){
|
||||
var layer = layui.layer
|
||||
,employeepicker = layui.employeepicker
|
||||
,form = layui.form
|
||||
,laydate = layui.laydate;
|
||||
|
||||
// 选择员工
|
||||
$('.body-content').on('click','[data-event="select"]',function(){
|
||||
var that = $(this);
|
||||
var names = that.val(), ids = $('[name="uid"]').val();
|
||||
employeepicker.init({
|
||||
ids: ids,
|
||||
names: names,
|
||||
type: 0,
|
||||
department_url:"{:url('/home/api/get_department_tree')}",
|
||||
employee_url:"{:url('/home/api/get_employee')}",
|
||||
callback: function (ids, names, dids, departments) {
|
||||
uid = ids;
|
||||
that.val(names);
|
||||
calendar.refetchEvents({
|
||||
url: '/home/schedule/index?uid='+uid
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
// 去除员工
|
||||
$('.body-content').on('click','[lay-filter="webform"]',function(){
|
||||
uid = 0;
|
||||
$('[data-event="select"]').val('');
|
||||
calendar.refetchEvents({
|
||||
url: '/home/schedule/index?uid='+uid
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('.body-content').on('click','.addLoan',function(){
|
||||
addEvent();
|
||||
});
|
||||
|
||||
function addEvent(){
|
||||
var detail={};
|
||||
detail['id']=0;
|
||||
detail['name']='';
|
||||
detail['start_time']='';
|
||||
detail['end_time']='';
|
||||
detail['start_time_1']='08:30';
|
||||
detail['end_time_1']='09:00';
|
||||
detail['remark']='';
|
||||
detail['labor_type']=0;
|
||||
var content='<form class="layui-form" style="width:868px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input id="start_time_a" name="start_time_a" style="width:100px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:3px; width: 80px;"><select lay-filter="start_time_1" id="start_time_1"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:100px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:3px; width: 80px;"><select lay-filter="end_time_1" id="end_time_1"></select></div>\
|
||||
</td>\
|
||||
<td class="layui-td-gray">工作类型 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input type="radio" name="labor_type" lay-filter="labor_type" value="1" title="案头工作"><input type="radio" name="labor_type" value="2" lay-filter="labor_type" title="外勤工作">\
|
||||
</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容 <span style="color: red">*</span></td>\
|
||||
<td colspan="3"><input name="name" class="layui-input" value="" lay-verify="required" lay-reqText="请完成工作内容"></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作详细描述</td>\
|
||||
<td colspan="3">\
|
||||
<textarea name="remark" form-input="remark" class="layui-textarea" style="min-height:120px;"></textarea>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'添加工作记录',
|
||||
area:['900px','390px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#start_time_a',
|
||||
type: 'date',
|
||||
min: -7,
|
||||
max: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;
|
||||
}
|
||||
});
|
||||
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#end_time_a',
|
||||
type: 'date',
|
||||
min: -7,
|
||||
max: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;
|
||||
}
|
||||
});
|
||||
$('#start_time_1,#end_time_1').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+':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 html_1='', html_2='',def_h1='08:30',def_h2='09:00';
|
||||
for(var s=0;s<hourArray.length;s++){
|
||||
var check_1='',check_2='';
|
||||
if(hourArray[s]==def_h1){
|
||||
check_1='selected';
|
||||
}
|
||||
if(hourArray[s]==def_h2){
|
||||
check_2='selected';
|
||||
}
|
||||
html_1 += '<option value="'+hourArray[s]+'" '+check_1+'>'+hourArray[s]+'</option>';
|
||||
html_2 += '<option value="'+hourArray[s]+'" '+check_2+'>'+hourArray[s]+'</option>';
|
||||
}
|
||||
|
||||
$('#start_time_1').append(html_1);
|
||||
$('#end_time_1').append(html_2);
|
||||
form.render();
|
||||
|
||||
$('[name="name"]').on('input',function(){
|
||||
var _val=$(this).val();
|
||||
detail.name=_val;
|
||||
});
|
||||
form.on('select(start_time_1)', function(data){
|
||||
detail.start_time_1=data.value;
|
||||
console.log(data);
|
||||
});
|
||||
form.on('select(end_time_1)', function(data){
|
||||
detail.end_time_1=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;
|
||||
});
|
||||
},
|
||||
btn: ['确定提交'],
|
||||
btnAlign:'c',
|
||||
yes: function(idx){
|
||||
if(detail.start_time=='' || detail.end_time==''){
|
||||
layer.msg('请选择工作时间范围');
|
||||
return;
|
||||
}
|
||||
if(detail.labor_type==0){
|
||||
layer.msg('请选择工作类型');
|
||||
return;
|
||||
}
|
||||
if(detail.name==''){
|
||||
layer.msg('请填写工作内容');
|
||||
return;
|
||||
}
|
||||
console.log(detail);
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/save')}",
|
||||
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(){
|
||||
var work_type='-';
|
||||
if(detail.labor_type==2){
|
||||
work_type='外勤工作';
|
||||
}
|
||||
else if(detail.labor_type==1){
|
||||
work_type='案头工作';
|
||||
}
|
||||
var content='<form class="layui-form" style="width:770px">\
|
||||
<table class="layui-table" style="margin:12px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容</td>\
|
||||
<td>'+detail.name+'</td>\
|
||||
<td class="layui-td-gray">工作类别</td>\
|
||||
<td>'+work_type+'</td>\
|
||||
</tr>\
|
||||
<tr id="tr_date_range">\
|
||||
<td class="layui-td-gray2">工作时间范围</td>\
|
||||
<td>'+detail.start_time+' '+detail.start_time_1+' 至 '+detail.end_time_1+',共'+detail.labor_time+'工时</td>\
|
||||
<td class="layui-td-gray">执行人</td>\
|
||||
<td>'+detail.user+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作描述</td>\
|
||||
<td colspan="3">'+detail.remark+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'工作记录',
|
||||
area:['800px','336px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
|
||||
},
|
||||
btn: ['关闭'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
layer.close(idx);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//请求事件api数据
|
||||
function eventApi(id){
|
||||
if(id==0){
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
type:'post',
|
||||
data:{id:id},
|
||||
success:function(res){
|
||||
detail=res.data;
|
||||
viewEvent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var calendarEl = document.getElementById('calendar');
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
|
||||
header: {
|
||||
//right: 'prev,next today',
|
||||
right: 'prev,next',
|
||||
center: 'title',
|
||||
left: 'dayGridMonth,timeGridWeek,listMonth'
|
||||
//left: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
|
||||
},
|
||||
defaultView:'dayGridMonth',
|
||||
locale: 'zh-cn',//语言
|
||||
buttonIcons: false, // prev/next是否图表
|
||||
weekNumbers: true,// 是否开启周数
|
||||
navLinks: true, // 点击day/week 跳转到相应的视图
|
||||
editable: true,
|
||||
eventLimit: false, // 当事件过多时是否显示更多按钮
|
||||
selectable: true,
|
||||
select: function(arg) {
|
||||
detail=default_detail;
|
||||
|
||||
var startTime=arg.start.getFullYear()+'-'+toNumer(arg.start.getMonth()+1)+'-'+toNumer(arg.start.getDate())+' '+toNumer(arg.start.getHours())+':'+toNumer(arg.start.getMinutes());
|
||||
var endTime=arg.end.getFullYear()+'-'+toNumer(arg.end.getMonth()+1)+'-'+toNumer(arg.end.getDate())+' '+toNumer(arg.end.getHours())+':'+toNumer(arg.end.getMinutes());
|
||||
|
||||
detail['start_time']=startTime;
|
||||
detail['end_time']= endTime;
|
||||
detail['date_time']= startTime;
|
||||
//addEvent();
|
||||
calendar.unselect()
|
||||
},
|
||||
eventClick: function(info) {
|
||||
console.log(info.event);
|
||||
eventApi(info.event.id);
|
||||
},
|
||||
events: function(fetchInfo, successCallback, failureCallback ){
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"/home/schedule/index",
|
||||
dataType:"json",
|
||||
data:{start:fetchInfo.startStr,end:fetchInfo.endStr,uid:uid},
|
||||
success:function(result){
|
||||
console.info(result);
|
||||
successCallback(result);
|
||||
},
|
||||
error:function(){
|
||||
failureCallback();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
calendar.render();
|
||||
}
|
||||
</script>
|
||||
{include file="common/layui" base='base' extend="['employeepicker','dtree']" callback="init" /}
|
||||
{/block}
|
||||
<!-- /脚本 -->
|
@ -1,51 +1,67 @@
|
||||
{extend name="common/base"/}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/core/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/daygrid/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/timegrid/main.css"/>
|
||||
<link rel="stylesheet" href="{__STATIC__}/fullcalendar/list/main.css"/>
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/dtree.css">
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/font/dtreefont.css">
|
||||
<style>
|
||||
#calendar {padding: 5px 0;}
|
||||
.fc .fc-day-header{padding:8px 0; background-color:#f2f2f2;}
|
||||
.fc-week-number,.fc-axis{background-color:#f2f2f2;}
|
||||
.layui-tags-span {padding: 3px 6px;font-size: 12px; background-color:#fff; border-radius: 3px; margin:2px 0; margin-right: 5px; border: 1px solid #e6e6e6; display: inline-block;}
|
||||
.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;}
|
||||
</style>
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<script src="{__STATIC__}/fullcalendar/core/main.min.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/core/locales-all.min.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/interaction/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/daygrid/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/timegrid/main.js"></script>
|
||||
<script src="{__STATIC__}/fullcalendar/list/main.js"></script>
|
||||
<div class="body-content">
|
||||
<div id="calendar"></div>
|
||||
<div class="calendar-add">
|
||||
<button class="layui-btn layui-btn-normal addLoan" style="padding:0 12px;">+新增工作记录</button>
|
||||
</div>
|
||||
<div class="calendar-select">
|
||||
<div class="layui-input-inline" style="width: 110px;"><input type="text" placeholder="请选择员工" class="layui-input" data-event="select" autocomplete="off"/></div>
|
||||
<button class="layui-btn" lay-filter="webform" style="padding:0 12px;">清空员工</button>
|
||||
<form class="layui-form">
|
||||
<div id="barDate" class="layui-input-inline">
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" class="layui-input" id="start_time" placeholder="选择时间区间" readonly name="start_time">
|
||||
</div>
|
||||
~
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" class="layui-input" id="end_time" placeholder="选择时间区间" readonly name="end_time">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" name="username" placeholder="请选择员工" class="layui-input" readonly data-event="select"/>
|
||||
<input type="text" name="uid" value="" style="display:none" />
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width:220px;">
|
||||
<input type="text" name="keywords" placeholder="输入工作内容" class="layui-input"/>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button><button type="reset" class="layui-btn layui-btn-danger" lay-filter="clear">清空搜索条件</button>
|
||||
</form>
|
||||
<div>
|
||||
<table class="layui-hide" id="test" lay-filter="test"></table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /主体 -->
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-normal layui-btn-sm addLoan" type="button">+ 新增工作记录</button>
|
||||
</div>
|
||||
</script>
|
||||
{/block}
|
||||
<!-- /主体 -->
|
||||
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
var detail={},uid=0;
|
||||
|
||||
function init(layui){
|
||||
var layer = layui.layer
|
||||
,employeepicker = layui.employeepicker
|
||||
,form = layui.form
|
||||
,laydate = layui.laydate;
|
||||
<script>
|
||||
function init(layui){
|
||||
var table = layui.table
|
||||
,form = layui.form
|
||||
,dtree = layui.dtree
|
||||
,employeepicker = layui.employeepicker
|
||||
,laydate = layui.laydate;
|
||||
|
||||
|
||||
//日期范围
|
||||
laydate.render({
|
||||
elem: '#barDate',
|
||||
range: ['#start_time', '#end_time']
|
||||
});
|
||||
|
||||
$('[lay-filter="clear"]').on('click',function(){
|
||||
setTimeout(function(){
|
||||
$('[lay-filter="webform"]').click();
|
||||
},10)
|
||||
})
|
||||
|
||||
// 选择员工
|
||||
$('.body-content').on('click','[data-event="select"]',function(){
|
||||
@ -58,24 +74,321 @@
|
||||
department_url:"{:url('/home/api/get_department_tree')}",
|
||||
employee_url:"{:url('/home/api/get_employee')}",
|
||||
callback: function (ids, names, dids, departments) {
|
||||
uid = ids;
|
||||
$('[name="uid"]').val(ids);
|
||||
that.val(names);
|
||||
calendar.refetchEvents({
|
||||
url: '/home/schedule/index?uid='+uid
|
||||
});
|
||||
$('[lay-filter="webform"]').click();
|
||||
}
|
||||
})
|
||||
});
|
||||
// 去除员工
|
||||
$('.body-content').on('click','[lay-filter="webform"]',function(){
|
||||
uid = 0;
|
||||
$('[data-event="select"]').val('');
|
||||
calendar.refetchEvents({
|
||||
url: '/home/schedule/index?uid='+uid
|
||||
});
|
||||
|
||||
//监听搜索提交
|
||||
form.on('submit(webform)', function(data){
|
||||
let f=data.field;
|
||||
tableIns.reload({where:{keywords:f.keywords,start_time:f.start_time,end_time:f.end_time,uid:f.uid},page:{curr:1}});
|
||||
return false;
|
||||
});
|
||||
|
||||
var tableIns = table.render({
|
||||
elem: '#test'
|
||||
,toolbar: '#toolbarDemo'
|
||||
,title:'工作记录列表'
|
||||
,url:"{:url('home/schedule/index')}"
|
||||
,page: true //开启分页
|
||||
,limit: 20
|
||||
,cellMinWidth: 80
|
||||
,cols: [[ //表头
|
||||
{field: 'id', title: '序号',fixed: 'left', width:80, align:'center'}
|
||||
,{field: 'labor_type', title: '工作类别', align:'center',width:90,templet:function(d){
|
||||
var html='';
|
||||
if(d.labor_type==0){
|
||||
html='<span class="span-color-'+d.labor_type+'">-</span>';
|
||||
}
|
||||
else if(d.labor_type == 1){
|
||||
html='<span class="span-color-'+d.labor_type+'">案头工作</span>';
|
||||
}
|
||||
else if(d.labor_type == 2){
|
||||
html='<span class="span-color-'+d.labor_type+'">外勤工作</span>';
|
||||
}
|
||||
return html;
|
||||
}}
|
||||
,{field: 'start_time', title: '工作时间范围', align:'center',width:186,templet:function(d){
|
||||
var html=d.start_time+'至'+d.end_time;
|
||||
return html;
|
||||
}}
|
||||
,{field: 'labor_time', title: '工时', align:'center',width:80}
|
||||
,{field: 'name', title: '工作内容'}
|
||||
,{field: 'create_time', title: '记录时间', align:'center',width:150}
|
||||
,{field: 'right', title: '操作',fixed:'right', width:150, align:'center',templet:function(d){
|
||||
var html='<div class="layui-btn-group">';
|
||||
html+='<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="time">调整工时</button><button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">查看</button>';
|
||||
if(d.admin_id==login_user){
|
||||
html+='<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>';
|
||||
}
|
||||
html+='</div>';
|
||||
return html;
|
||||
}}
|
||||
]]
|
||||
});
|
||||
|
||||
//更改工时
|
||||
table.on('tool(test)', function(obj){
|
||||
var data = obj.data;
|
||||
if(obj.event === 'time'){
|
||||
var content='<form class="layui-form" style="width:568px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input id="start_time_a" name="start_time_a" style="width:110px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 80px;"><select lay-filter="start_time_1" id="start_time_1"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:110px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 80px;"><select lay-filter="end_time_1" id="end_time_1"></select></div>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'调整工时',
|
||||
area:['600px','388px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#start_time_a',
|
||||
type: 'date',
|
||||
max:0,
|
||||
format: 'yyyy-MM-dd',
|
||||
showBottom: false,
|
||||
done:function(a,b,c){
|
||||
$('#end_time_a').val(a);
|
||||
}
|
||||
});
|
||||
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#end_time_a',
|
||||
type: 'date',
|
||||
max:0,
|
||||
format: 'yyyy-MM-dd',
|
||||
showBottom: false,
|
||||
done:function(a,b,c){
|
||||
$('#start_time_a').val(a);
|
||||
}
|
||||
});
|
||||
$('#start_time_1,#end_time_1').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+':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 html_1='', html_2='',def_h1='08:30',def_h2='09:00';
|
||||
for(var s=0;s<hourArray.length;s++){
|
||||
var check_1='',check_2='';
|
||||
if(hourArray[s]==def_h1){
|
||||
check_1='selected';
|
||||
}
|
||||
if(hourArray[s]==def_h2){
|
||||
check_2='selected';
|
||||
}
|
||||
html_1 += '<option value="'+hourArray[s]+'" '+check_1+'>'+hourArray[s]+'</option>';
|
||||
html_2 += '<option value="'+hourArray[s]+'" '+check_2+'>'+hourArray[s]+'</option>';
|
||||
}
|
||||
|
||||
$('#start_time_1').append(html_1);
|
||||
$('#end_time_1').append(html_2);
|
||||
form.render();
|
||||
|
||||
},
|
||||
btn: ['确定提交'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
let start_time = $('#start_time_a').val();
|
||||
let end_time = $('#end_time_a').val();
|
||||
let start_time_1 = $('#start_time_1').val();
|
||||
let end_time_1 = $('#end_time_1').val();
|
||||
if(start_time=='' || end_time==''){
|
||||
layer.msg('请选择工作时间范围');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/update_labor_time')}",
|
||||
type:'post',
|
||||
data:{
|
||||
id:data.id,
|
||||
admin_id:data.admin_id,
|
||||
start_time:start_time,
|
||||
end_time:end_time,
|
||||
start_time_1:start_time_1,
|
||||
end_time_1:end_time_1
|
||||
},
|
||||
success:function(e){
|
||||
layer.msg(e.msg);
|
||||
if(e.code==0){
|
||||
layer.close(idx);
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else if(obj.event === 'edit'){
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
data:{
|
||||
id:data.id
|
||||
},
|
||||
success:function(e){
|
||||
if(e.code==0){
|
||||
editEvent(e.data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
else if(obj.event === 'view'){
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
data:{
|
||||
id:data.id
|
||||
},
|
||||
success:function(e){
|
||||
if(e.code==0){
|
||||
viewEvent(e.data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
//编辑
|
||||
function editEvent(data){
|
||||
var detail={};
|
||||
detail['id']=data.id;
|
||||
detail['name']=data.name;
|
||||
detail['remark']=data.remark;
|
||||
detail['labor_type']=data.labor_type;
|
||||
var content='<form class="layui-form" style="width:868px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>'+data.start_time+' '+data.start_time_1+' 至 '+data.end_time_1+'</td>\
|
||||
<td class="layui-td-gray">工作类型 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input type="radio" name="labor_type" lay-filter="labor_type" value="1" title="案头工作"><input type="radio" name="labor_type" value="2" lay-filter="labor_type" title="外勤工作">\
|
||||
</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容 <span style="color: red">*</span></td>\
|
||||
<td colspan="3"><input name="name" class="layui-input" value="'+data.name+'" lay-verify="required" lay-reqText="请完成工作内容"></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作详细描述</td>\
|
||||
<td colspan="3">\
|
||||
<textarea name="remark" form-input="remark" class="layui-textarea" style="min-height:120px;">'+data.remark+'</textarea>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
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="name"]').on('input',function(){
|
||||
var _val=$(this).val();
|
||||
detail.name=_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.name==''){
|
||||
layer.msg('请填写工作内容');
|
||||
return;
|
||||
}
|
||||
console.log(detail);
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/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='外勤工作';
|
||||
}
|
||||
else if(detail.labor_type==1){
|
||||
work_type='案头工作';
|
||||
}
|
||||
var content='<form class="layui-form" style="width:770px">\
|
||||
<table class="layui-table" style="margin:12px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容</td>\
|
||||
<td>'+detail.name+'</td>\
|
||||
<td class="layui-td-gray">工作类别</td>\
|
||||
<td>'+work_type+'</td>\
|
||||
</tr>\
|
||||
<tr id="tr_date_range">\
|
||||
<td class="layui-td-gray2">工作时间范围</td>\
|
||||
<td>'+detail.start_time+' '+detail.start_time_1+' 至 '+detail.end_time_1+',共'+detail.labor_time+'工时</td>\
|
||||
<td class="layui-td-gray">执行人</td>\
|
||||
<td>'+detail.user+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作描述</td>\
|
||||
<td colspan="3">'+detail.remark+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'工作记录',
|
||||
area:['800px','336px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
|
||||
},
|
||||
btn: ['关闭'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
layer.close(idx);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$('.body-content').on('click','.addLoan',function(){
|
||||
addEvent();
|
||||
});
|
||||
@ -211,7 +524,7 @@
|
||||
}
|
||||
console.log(detail);
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/save')}",
|
||||
url:"{:url('home/schedule/add')}",
|
||||
type:'post',
|
||||
data:detail,
|
||||
success:function(e){
|
||||
@ -227,123 +540,10 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//查看工作记录
|
||||
function viewEvent(){
|
||||
var work_type='-';
|
||||
if(detail.labor_type==2){
|
||||
work_type='外勤工作';
|
||||
}
|
||||
else if(detail.labor_type==1){
|
||||
work_type='案头工作';
|
||||
}
|
||||
var content='<form class="layui-form" style="width:770px">\
|
||||
<table class="layui-table" style="margin:12px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容</td>\
|
||||
<td>'+detail.name+'</td>\
|
||||
<td class="layui-td-gray">工作类别</td>\
|
||||
<td>'+work_type+'</td>\
|
||||
</tr>\
|
||||
<tr id="tr_date_range">\
|
||||
<td class="layui-td-gray2">工作时间范围</td>\
|
||||
<td>'+detail.start_time+' '+detail.start_time_1+' 至 '+detail.end_time_1+',共'+detail.labor_time+'工时</td>\
|
||||
<td class="layui-td-gray">执行人</td>\
|
||||
<td>'+detail.user+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作描述</td>\
|
||||
<td colspan="3">'+detail.remark+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'工作记录',
|
||||
area:['800px','336px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
|
||||
},
|
||||
btn: ['关闭'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
layer.close(idx);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//请求事件api数据
|
||||
function eventApi(id){
|
||||
if(id==0){
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
type:'post',
|
||||
data:{id:id},
|
||||
success:function(res){
|
||||
detail=res.data;
|
||||
viewEvent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var calendarEl = document.getElementById('calendar');
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
|
||||
header: {
|
||||
//right: 'prev,next today',
|
||||
right: 'prev,next',
|
||||
center: 'title',
|
||||
left: 'dayGridMonth,timeGridWeek,listMonth'
|
||||
//left: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
|
||||
},
|
||||
defaultView:'dayGridMonth',
|
||||
locale: 'zh-cn',//语言
|
||||
buttonIcons: false, // prev/next是否图表
|
||||
weekNumbers: true,// 是否开启周数
|
||||
navLinks: true, // 点击day/week 跳转到相应的视图
|
||||
editable: true,
|
||||
eventLimit: false, // 当事件过多时是否显示更多按钮
|
||||
selectable: true,
|
||||
select: function(arg) {
|
||||
detail=default_detail;
|
||||
|
||||
var startTime=arg.start.getFullYear()+'-'+toNumer(arg.start.getMonth()+1)+'-'+toNumer(arg.start.getDate())+' '+toNumer(arg.start.getHours())+':'+toNumer(arg.start.getMinutes());
|
||||
var endTime=arg.end.getFullYear()+'-'+toNumer(arg.end.getMonth()+1)+'-'+toNumer(arg.end.getDate())+' '+toNumer(arg.end.getHours())+':'+toNumer(arg.end.getMinutes());
|
||||
|
||||
detail['start_time']=startTime;
|
||||
detail['end_time']= endTime;
|
||||
detail['date_time']= startTime;
|
||||
//addEvent();
|
||||
calendar.unselect()
|
||||
},
|
||||
eventClick: function(info) {
|
||||
console.log(info.event);
|
||||
eventApi(info.event.id);
|
||||
},
|
||||
events: function(fetchInfo, successCallback, failureCallback ){
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"/home/schedule/index",
|
||||
dataType:"json",
|
||||
data:{start:fetchInfo.startStr,end:fetchInfo.endStr,uid:uid},
|
||||
success:function(result){
|
||||
console.info(result);
|
||||
successCallback(result);
|
||||
},
|
||||
error:function(){
|
||||
failureCallback();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
calendar.render();
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
{include file="common/layui" base='base' extend="['employeepicker','dtree']" callback="init" /}
|
||||
{include file="common/layui" base='base' extend="['dtree','employeepicker']" use="[]" callback="init" /}
|
||||
{/block}
|
||||
<!-- /脚本 -->
|
@ -1,549 +0,0 @@
|
||||
{extend name="common/base"/}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/dtree.css">
|
||||
<link rel="stylesheet" href="{__JS__}/module/dtree/font/dtreefont.css">
|
||||
<style>
|
||||
.layui-unselect dl { max-height:188px; }
|
||||
</style>
|
||||
{/block}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<div class="body-content">
|
||||
<form class="layui-form">
|
||||
<div id="barDate" class="layui-input-inline">
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" class="layui-input" id="start_time" placeholder="选择时间区间" readonly name="start_time">
|
||||
</div>
|
||||
~
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" class="layui-input" id="end_time" placeholder="选择时间区间" readonly name="end_time">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width:110px;">
|
||||
<input type="text" name="username" placeholder="请选择员工" class="layui-input" readonly data-event="select"/>
|
||||
<input type="text" name="uid" value="" style="display:none" />
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width:220px;">
|
||||
<input type="text" name="keywords" placeholder="输入工作内容" class="layui-input"/>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button><button type="reset" class="layui-btn layui-btn-danger" lay-filter="clear">清空搜索条件</button>
|
||||
</form>
|
||||
<div>
|
||||
<table class="layui-hide" id="test" lay-filter="test"></table>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-normal layui-btn-sm addLoan" type="button">+ 新增工作记录</button>
|
||||
</div>
|
||||
</script>
|
||||
{/block}
|
||||
<!-- /主体 -->
|
||||
|
||||
<!-- 脚本 -->
|
||||
{block name="script"}
|
||||
<script>
|
||||
function init(layui){
|
||||
var table = layui.table
|
||||
,form = layui.form
|
||||
,dtree = layui.dtree
|
||||
,employeepicker = layui.employeepicker
|
||||
,laydate = layui.laydate;
|
||||
|
||||
|
||||
//日期范围
|
||||
laydate.render({
|
||||
elem: '#barDate',
|
||||
range: ['#start_time', '#end_time']
|
||||
});
|
||||
|
||||
$('[lay-filter="clear"]').on('click',function(){
|
||||
setTimeout(function(){
|
||||
$('[lay-filter="webform"]').click();
|
||||
},10)
|
||||
})
|
||||
|
||||
// 选择员工
|
||||
$('.body-content').on('click','[data-event="select"]',function(){
|
||||
var that = $(this);
|
||||
var names = that.val(), ids = $('[name="uid"]').val();
|
||||
employeepicker.init({
|
||||
ids: ids,
|
||||
names: names,
|
||||
type: 0,
|
||||
department_url:"{:url('/home/api/get_department_tree')}",
|
||||
employee_url:"{:url('/home/api/get_employee')}",
|
||||
callback: function (ids, names, dids, departments) {
|
||||
$('[name="uid"]').val(ids);
|
||||
that.val(names);
|
||||
$('[lay-filter="webform"]').click();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
//监听搜索提交
|
||||
form.on('submit(webform)', function(data){
|
||||
let f=data.field;
|
||||
tableIns.reload({where:{keywords:f.keywords,start_time:f.start_time,end_time:f.end_time,uid:f.uid},page:{curr:1}});
|
||||
return false;
|
||||
});
|
||||
|
||||
var tableIns = table.render({
|
||||
elem: '#test'
|
||||
,toolbar: '#toolbarDemo'
|
||||
,title:'工作记录列表'
|
||||
,url:"{:url('home/schedule/list')}"
|
||||
,page: true //开启分页
|
||||
,limit: 20
|
||||
,cellMinWidth: 80
|
||||
,cols: [[ //表头
|
||||
{field: 'id', title: '序号',fixed: 'left', width:80, align:'center'}
|
||||
,{field: 'labor_type', title: '工作类别', align:'center',width:90,templet:function(d){
|
||||
var html='';
|
||||
if(d.labor_type==0){
|
||||
html='<span class="span-color-'+d.labor_type+'">-</span>';
|
||||
}
|
||||
else if(d.labor_type == 1){
|
||||
html='<span class="span-color-'+d.labor_type+'">案头工作</span>';
|
||||
}
|
||||
else if(d.labor_type == 2){
|
||||
html='<span class="span-color-'+d.labor_type+'">外勤工作</span>';
|
||||
}
|
||||
return html;
|
||||
}}
|
||||
,{field: 'start_time', title: '工作时间范围', align:'center',width:186,templet:function(d){
|
||||
var html=d.start_time+'至'+d.end_time;
|
||||
return html;
|
||||
}}
|
||||
,{field: 'labor_time', title: '工时', align:'center',width:80}
|
||||
,{field: 'name', title: '工作内容'}
|
||||
,{field: 'create_time', title: '记录时间', align:'center',width:150}
|
||||
,{field: 'right', title: '操作',fixed:'right', width:150, align:'center',templet:function(d){
|
||||
var html='<div class="layui-btn-group">';
|
||||
html+='<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="time">调整工时</button><button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">查看</button>';
|
||||
if(d.admin_id==login_user){
|
||||
html+='<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>';
|
||||
}
|
||||
html+='</div>';
|
||||
return html;
|
||||
}}
|
||||
]]
|
||||
});
|
||||
|
||||
//更改工时
|
||||
table.on('tool(test)', function(obj){
|
||||
var data = obj.data;
|
||||
if(obj.event === 'time'){
|
||||
var content='<form class="layui-form" style="width:568px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input id="start_time_a" name="start_time_a" style="width:110px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 80px;"><select lay-filter="start_time_1" id="start_time_1"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:110px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:5px; width: 80px;"><select lay-filter="end_time_1" id="end_time_1"></select></div>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'调整工时',
|
||||
area:['600px','388px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#start_time_a',
|
||||
type: 'date',
|
||||
max:0,
|
||||
format: 'yyyy-MM-dd',
|
||||
showBottom: false,
|
||||
done:function(a,b,c){
|
||||
$('#end_time_a').val(a);
|
||||
}
|
||||
});
|
||||
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#end_time_a',
|
||||
type: 'date',
|
||||
max:0,
|
||||
format: 'yyyy-MM-dd',
|
||||
showBottom: false,
|
||||
done:function(a,b,c){
|
||||
$('#start_time_a').val(a);
|
||||
}
|
||||
});
|
||||
$('#start_time_1,#end_time_1').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+':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 html_1='', html_2='',def_h1='08:30',def_h2='09:00';
|
||||
for(var s=0;s<hourArray.length;s++){
|
||||
var check_1='',check_2='';
|
||||
if(hourArray[s]==def_h1){
|
||||
check_1='selected';
|
||||
}
|
||||
if(hourArray[s]==def_h2){
|
||||
check_2='selected';
|
||||
}
|
||||
html_1 += '<option value="'+hourArray[s]+'" '+check_1+'>'+hourArray[s]+'</option>';
|
||||
html_2 += '<option value="'+hourArray[s]+'" '+check_2+'>'+hourArray[s]+'</option>';
|
||||
}
|
||||
|
||||
$('#start_time_1').append(html_1);
|
||||
$('#end_time_1').append(html_2);
|
||||
form.render();
|
||||
|
||||
},
|
||||
btn: ['确定提交'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
let start_time = $('#start_time_a').val();
|
||||
let end_time = $('#end_time_a').val();
|
||||
let start_time_1 = $('#start_time_1').val();
|
||||
let end_time_1 = $('#end_time_1').val();
|
||||
if(start_time=='' || end_time==''){
|
||||
layer.msg('请选择工作时间范围');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/update_labor_time')}",
|
||||
type:'post',
|
||||
data:{
|
||||
id:data.id,
|
||||
admin_id:data.admin_id,
|
||||
start_time:start_time,
|
||||
end_time:end_time,
|
||||
start_time_1:start_time_1,
|
||||
end_time_1:end_time_1
|
||||
},
|
||||
success:function(e){
|
||||
layer.msg(e.msg);
|
||||
if(e.code==0){
|
||||
layer.close(idx);
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else if(obj.event === 'edit'){
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
data:{
|
||||
id:data.id
|
||||
},
|
||||
success:function(e){
|
||||
if(e.code==0){
|
||||
editEvent(e.data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
else if(obj.event === 'view'){
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/detail')}",
|
||||
data:{
|
||||
id:data.id
|
||||
},
|
||||
success:function(e){
|
||||
if(e.code==0){
|
||||
viewEvent(e.data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
//编辑
|
||||
function editEvent(data){
|
||||
var detail={};
|
||||
detail['id']=data.id;
|
||||
detail['name']=data.name;
|
||||
detail['remark']=data.remark;
|
||||
detail['labor_type']=data.labor_type;
|
||||
var content='<form class="layui-form" style="width:868px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>'+data.start_time+' '+data.start_time_1+' 至 '+data.end_time_1+'</td>\
|
||||
<td class="layui-td-gray">工作类型 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input type="radio" name="labor_type" lay-filter="labor_type" value="1" title="案头工作"><input type="radio" name="labor_type" value="2" lay-filter="labor_type" title="外勤工作">\
|
||||
</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容 <span style="color: red">*</span></td>\
|
||||
<td colspan="3"><input name="name" class="layui-input" value="'+data.name+'" lay-verify="required" lay-reqText="请完成工作内容"></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作详细描述</td>\
|
||||
<td colspan="3">\
|
||||
<textarea name="remark" form-input="remark" class="layui-textarea" style="min-height:120px;">'+data.remark+'</textarea>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
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="name"]').on('input',function(){
|
||||
var _val=$(this).val();
|
||||
detail.name=_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.name==''){
|
||||
layer.msg('请填写工作内容');
|
||||
return;
|
||||
}
|
||||
console.log(detail);
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/save')}",
|
||||
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='外勤工作';
|
||||
}
|
||||
else if(detail.labor_type==1){
|
||||
work_type='案头工作';
|
||||
}
|
||||
var content='<form class="layui-form" style="width:770px">\
|
||||
<table class="layui-table" style="margin:12px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容</td>\
|
||||
<td>'+detail.name+'</td>\
|
||||
<td class="layui-td-gray">工作类别</td>\
|
||||
<td>'+work_type+'</td>\
|
||||
</tr>\
|
||||
<tr id="tr_date_range">\
|
||||
<td class="layui-td-gray2">工作时间范围</td>\
|
||||
<td>'+detail.start_time+' '+detail.start_time_1+' 至 '+detail.end_time_1+',共'+detail.labor_time+'工时</td>\
|
||||
<td class="layui-td-gray">执行人</td>\
|
||||
<td>'+detail.user+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作描述</td>\
|
||||
<td colspan="3">'+detail.remark+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'工作记录',
|
||||
area:['800px','336px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
|
||||
},
|
||||
btn: ['关闭'],
|
||||
btnAlign: 'c',
|
||||
yes: function(idx){
|
||||
layer.close(idx);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$('.body-content').on('click','.addLoan',function(){
|
||||
addEvent();
|
||||
});
|
||||
|
||||
function addEvent(){
|
||||
var detail={};
|
||||
detail['id']=0;
|
||||
detail['name']='';
|
||||
detail['start_time']='';
|
||||
detail['end_time']='';
|
||||
detail['start_time_1']='08:30';
|
||||
detail['end_time_1']='09:00';
|
||||
detail['remark']='';
|
||||
detail['labor_type']=0;
|
||||
var content='<form class="layui-form" style="width:868px">\
|
||||
<table class="layui-table" style="margin:15px 15px 0;">\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作时间范围 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input id="start_time_a" name="start_time_a" style="width:100px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:3px; width: 80px;"><select lay-filter="start_time_1" id="start_time_1"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:100px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" lay-reqText="请选择"><div style="display: inline-block; margin-left:3px; width: 80px;"><select lay-filter="end_time_1" id="end_time_1"></select></div>\
|
||||
</td>\
|
||||
<td class="layui-td-gray">工作类型 <span style="color: red">*</span></td>\
|
||||
<td>\
|
||||
<input type="radio" name="labor_type" lay-filter="labor_type" value="1" title="案头工作"><input type="radio" name="labor_type" value="2" lay-filter="labor_type" title="外勤工作">\
|
||||
</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作内容 <span style="color: red">*</span></td>\
|
||||
<td colspan="3"><input name="name" class="layui-input" value="" lay-verify="required" lay-reqText="请完成工作内容"></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="layui-td-gray2">工作详细描述</td>\
|
||||
<td colspan="3">\
|
||||
<textarea name="remark" form-input="remark" class="layui-textarea" style="min-height:120px;"></textarea>\
|
||||
</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</form>';
|
||||
layer.open({
|
||||
type:1,
|
||||
title:'添加工作记录',
|
||||
area:['900px','390px'],
|
||||
content:content,
|
||||
success:function(){
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#start_time_a',
|
||||
type: 'date',
|
||||
min: -7,
|
||||
max: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;
|
||||
}
|
||||
});
|
||||
|
||||
//日期时间范围
|
||||
laydate.render({
|
||||
elem: '#end_time_a',
|
||||
type: 'date',
|
||||
min: -7,
|
||||
max: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;
|
||||
}
|
||||
});
|
||||
$('#start_time_1,#end_time_1').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+':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 html_1='', html_2='',def_h1='08:30',def_h2='09:00';
|
||||
for(var s=0;s<hourArray.length;s++){
|
||||
var check_1='',check_2='';
|
||||
if(hourArray[s]==def_h1){
|
||||
check_1='selected';
|
||||
}
|
||||
if(hourArray[s]==def_h2){
|
||||
check_2='selected';
|
||||
}
|
||||
html_1 += '<option value="'+hourArray[s]+'" '+check_1+'>'+hourArray[s]+'</option>';
|
||||
html_2 += '<option value="'+hourArray[s]+'" '+check_2+'>'+hourArray[s]+'</option>';
|
||||
}
|
||||
|
||||
$('#start_time_1').append(html_1);
|
||||
$('#end_time_1').append(html_2);
|
||||
form.render();
|
||||
|
||||
$('[name="name"]').on('input',function(){
|
||||
var _val=$(this).val();
|
||||
detail.name=_val;
|
||||
});
|
||||
form.on('select(start_time_1)', function(data){
|
||||
detail.start_time_1=data.value;
|
||||
console.log(data);
|
||||
});
|
||||
form.on('select(end_time_1)', function(data){
|
||||
detail.end_time_1=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;
|
||||
});
|
||||
},
|
||||
btn: ['确定提交'],
|
||||
btnAlign:'c',
|
||||
yes: function(idx){
|
||||
if(detail.start_time=='' || detail.end_time==''){
|
||||
layer.msg('请选择工作时间范围');
|
||||
return;
|
||||
}
|
||||
if(detail.labor_type==0){
|
||||
layer.msg('请选择工作类型');
|
||||
return;
|
||||
}
|
||||
if(detail.name==''){
|
||||
layer.msg('请填写工作内容');
|
||||
return;
|
||||
}
|
||||
console.log(detail);
|
||||
$.ajax({
|
||||
url:"{:url('home/schedule/save')}",
|
||||
type:'post',
|
||||
data:detail,
|
||||
success:function(e){
|
||||
layer.msg(e.msg);
|
||||
if(e.code==0){
|
||||
layer.close(idx);
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
{include file="common/layui" base='base' extend="['dtree','employeepicker']" use="[]" callback="init" /}
|
||||
{/block}
|
||||
<!-- /脚本 -->
|
@ -139,7 +139,7 @@ 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/chage', '', 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 (27, 4, '收件箱', 'home/mail/inbox', '', 1, 0, 0);
|
||||
@ -154,10 +154,10 @@ 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/list', '', 1, 0, 0);
|
||||
INSERT INTO `oa_admin_menu` VALUES (37, 7, '计划日历', 'home/plan/index', '', 1, 0, 0);
|
||||
INSERT INTO `oa_admin_menu` VALUES (38, 7, '工作记录', 'home/schedule/list', '', 1, 0, 0);
|
||||
INSERT INTO `oa_admin_menu` VALUES (39, 7, '工作日历', 'home/schedule/index', '', 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);
|
||||
|
||||
INSERT INTO `oa_admin_menu` VALUES (40, 8, '报销管理', 'home/expense/index', '', 1, 0, 0);
|
||||
INSERT INTO `oa_admin_menu` VALUES (41, 8, '发票管理', 'home/invoice/index', '', 1, 0, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user