first commit

This commit is contained in:
2025-06-25 10:53:11 +08:00
commit 9f374011ae
1240 changed files with 181139 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* @copyright Copyright (c) 2023-2024 美天智能科技
* @author 李志强
* @link http://www.meteteme.com
*/
/**
======================
*模块数据获取公共文件
======================
*/
use think\facade\Db;
+319
View File
@@ -0,0 +1,319 @@
<?php
/**
* @copyright Copyright (c) 2023-2024 美天智能科技
* @author 李志强
* @link http://www.meteteme.com
*/
declare(strict_types=1);
namespace app\schedule\controller;
use app\base\BaseController;
use app\model\Schedule as ScheduleList;
use schedule\Schedule as ScheduleIndex;
use think\facade\Db;
use think\facade\View;
class Index extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['a.title', 'like', '%' . $param['keywords'] . '%'];
}
if (empty($param['uid'])) {
$param['uid'] = $this->uid;
}
$where[] = ['a.admin_id', 'in', $param['uid']];
if (!empty($param['project_id'])) {
$task_ids = Db::name('Task')->where(['delete_time' => 0, 'project_id' => $param['project_id']])->column('id');
$where[] = ['a.tid', 'in', $task_ids];
}
if (!empty($param['cate'])) {
$where[] = ['t.cate', '=', $param['cate']];
}
if (!empty($param['type'])) {
$where[] = ['t.type', '=', $param['type']];
}
$where[] = ['a.delete_time', '=', 0];
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$list = ScheduleList::where($where)
->field('a.*,u.name,d.title as department,t.title as task,p.name as project,w.title as work_cate')
->alias('a')
->join('Admin u', 'a.admin_id = u.id', 'LEFT')
->join('Department d', 'u.did = d.id', 'LEFT')
->join('Task t', 'a.tid = t.id', 'LEFT')
->join('WorkCate w', 'w.id = t.cate', 'LEFT')
->join('Project p', 't.project_id = p.id', 'LEFT')
->order('a.end_time desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
// $item->start_time_a = empty($item->start_time) ? '' : date('Y-m-d', $item->start_time);
// $item->start_time_b = empty($item->start_time) ? '' : date('H:i', $item->start_time);
// $item->end_time_a = empty($item->end_time) ? '' : date('Y-m-d', $item->end_time);
// $item->end_time_b = empty($item->end_time) ? '' : date('H:i', $item->end_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('H:i', $item->end_time);
});
return table_assign(0, '', $list);
} else {
View::assign('cate', get_work_cate());
View::assign('project', get_project($this->uid));
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('Schedule')->where($where)->field('id,title,labor_time')->select()->toArray();
$events = [];
$countEvents = [];
foreach ($schedule as $k => $v) {
$v['backgroundColor'] = '#12bb37';
$v['borderColor'] = '#12bb37';
$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']);
// if (array_key_exists($temData, $countEvents)) {
// $countEvents[$temData]['times'] += $v['labor_time'];
// } else {
// $countEvents[$temData]['times'] = $v['labor_time'];
// $countEvents[$temData]['start'] = date('Y-m-d', $v['start_time']);
// }
// unset($v['start_time']);
// unset($v['end_time']);
$events[] = $v;
}
foreach ($countEvents as $kk => $vv) {
$vv['backgroundColor'] = '#eeeeee';
$vv['borderColor'] = '#eeeeee';
$vv['title'] = '【当天总工时:' . $vv['times'] . '】';
$vv['end'] = $vv['start'];
$vv['id'] = 0;
unset($vv['times']);
$events[] = $vv;
}
$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();
if (request()->isPost()) {
// 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['start_time'] > time()) {
// return to_assign(1, "开始时间不能大于现在时间");
// }
// if ($param['end_time'] <= $param['start_time']) {
// return to_assign(1, "结束时间需要大于开始时间");
// }
$where = [];
$where1 = [];
$where2 = [];
$where[] = ['delete_time', '=', 0];
$where[] = ['admin_id', '=', $this->uid];
if ($param['id'] > 0) {
$where[] = ['id', '<>', $param['id']];
}
// $where1 = $where;
// $where1[] = ['start_time', '<=', $param['start_time']];
// $where1[] = ['end_time', '>', $param['start_time']];
// $where2 = $where;
// $where2[] = ['start_time', '<', $param['end_time']];
// $where2[] = ['end_time', '>=', $param['end_time']];
// $record = Db::name('Schedule')
// ->where(function ($query) use ($where1) {
// $query->where($where1);
// })
// ->whereOr(function ($query) use ($where2) {
// $query->where($where2);
// })->count();
// if ($record > 0) {
// return to_assign(1, "您所选的时间区间已有工作记录,请重新选时间");
// }
// $param['labor_time'] = ($param['end_time'] - $param['start_time']) / 3600;
if ($param['id'] == 0) {
$param['admin_id'] = $this->uid;
$param['create_time'] = time();
$sid = Db::name('Schedule')->strict(false)->field(true)->insertGetId($param);
if ($sid > 0) {
add_log('add', $sid, $param);
return to_assign();
} else {
return to_assign(1, '操作失败');
}
} else {
$admin_id = Db::name('Schedule')->where('id', $param['id'])->value('admin_id');
if ($admin_id != $this->uid) {
return to_assign(1, '不能编辑他人的工作记录');
}
$param['update_time'] = time();
$res = Db::name('Schedule')->strict(false)->field(true)->update($param);
if ($res !== false) {
add_log('edit', $param['id'], $param);
return to_assign();
} else {
return to_assign(1, '操作失败');
}
}
} else {
return to_assign(1, "错误的请求");
}
}
//更改工时
// public function update_labor_time()
// {
// $param = get_params();
// 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['start_time'] > time()) {
// return to_assign(1, "开始时间不能大于当前时间");
// }
// if ($param['end_time'] <= $param['start_time']) {
// return to_assign(1, "结束时间需要大于开始时间");
// }
// $where1[] = ['status', '=', 1];
// $where1[] = ['id', '<>', $param['id']];
// $where1[] = ['admin_id', '=', $param['admin_id']];
// // $where1[] = ['start_time', 'between', [$param['start_time'], $param['end_time'] - 1]];
// $where2[] = ['status', '=', 1];
// $where2[] = ['id', '<>', $param['id']];
// $where2[] = ['admin_id', '=', $param['admin_id']];
// // $where2[] = ['start_time', '<=', $param['start_time']];
// // $where2[] = ['start_time', '>=', $param['end_time']];
// $where3[] = ['status', '=', 1];
// $where3[] = ['id', '<>', $param['id']];
// $where3[] = ['admin_id', '=', $param['admin_id']];
// // $where3[] = ['end_time', 'between', [$param['start_time'] + 1, $param['end_time']]];
// // $record = Db::name('Schedule')
// // ->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['labor_time'] = ($param['end_time'] - $param['start_time']) / 3600;
// $res = Db::name('Schedule')->strict(false)->field(true)->update($param);
// if ($res !== false) {
// return to_assign(0, "操作成功");
// add_log('edit', $param['id'], $param);
// } else {
// return to_assign(1, "操作失败");
// }
// }
//删除工作记录
public function delete()
{
if (request()->isDelete()) {
$id = get_params("id");
$data['id'] = $id;
$data['delete_time'] = time();
if (Db::name('schedule')->update($data) !== false) {
add_log('delete', $data['id'], $data);
return to_assign(0, "删除成功");
} else {
return to_assign(1, "删除失败");
}
} else {
return to_assign(1, "错误的请求");
}
}
//查看工作记录详情
public function detail($id)
{
$id = get_params('id');
$schedule = Db::name('Schedule')->where(['id' => $id])->find();
if (!empty($schedule)) {
$schedule['start_time_1'] = date('H:i', $schedule['start_time']);
$schedule['end_time_1'] = date('H:i', $schedule['end_time']);
$schedule['start_time'] = date('Y-m-d', $schedule['start_time']);
$schedule['end_time'] = date('Y-m-d', $schedule['end_time']);
$schedule['create_time'] = date('Y-m-d H:i:s', $schedule['create_time']);
$user = Db::name('Admin')->where(['id' => $schedule['admin_id']])->find();
$schedule['user'] = $user['name'];
$schedule['department'] = Db::name('Department')->where(['id' => $user['did']])->value('title');
$task = Db::name('Task')->where(['id' => $schedule['t_id']])->find();
$schedule['task'] = $task['title'];
$schedule['work_cate'] = Db::name('WorkCate')->where(['id' => $task['cate']])->value('title');
$schedule['project'] = '-';
if ($task['project_id'] > 0) {
$schedule['project'] = Db::name('Project')->where(['id' => $task['project_id']])->value('name');
}
}
if (request()->isAjax()) {
return to_assign(0, "", $schedule);
} else {
return $schedule;
}
}
}
+5
View File
@@ -0,0 +1,5 @@
<?php
// 这是系统自动生成的event定义文件
return [
];
+13
View File
@@ -0,0 +1,13 @@
<?php
/**
* @copyright Copyright (c) 2023-2024 美天智能科技
* @author 李志强
* @link http://www.meteteme.com
*/
// 这是系统自动生成的middleware定义文件
return [
//开启session中间件
//'think\middleware\SessionInit',
\app\home\middleware\Install::class,
];
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace app\task\validate;
use think\Validate;
class TaskCheck extends Validate
{
protected $rule = [
'title' => 'require',
'plan_hours' => 'require|regex:/^[0-9]+(.[0-9]{1,1})?$/',
'id' => 'require',
];
protected $message = [
'title.require' => '任务主题不能为空',
'plan_hours.require' => '预估工时不能为空',
'plan_hours.regex' => '预估工时只能是整数或者1位小数的数字',
'id.require' => '缺少更新条件',
];
protected $scene = [
'add' => ['title'],
'hours' => ['plan_hours'],
'edit' => ['id'],
];
}
+555
View File
@@ -0,0 +1,555 @@
{extend name="../../base/view/common/base" /}
{block name="style"}
<link rel="stylesheet" href="{__METE__}/third_party/fullcalendar/main.min.css"/>
<style>
#calendar {width: 100%;margin: 0 auto;
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;}
.fc .fc-toolbar.fc-header-toolbar{margin-bottom:0;border:1px solid #ddd; border-bottom:none;padding:15px 12px;background-color:#fafafa;}
.fc-col-header{background-color:#fafafa;}
.fc .fc-button-primary {
color: #fff;
background-color: #1E9FFF;
border-color: #1E9FFF;
}
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active {
color: #fff;
background-color: #FBBC05;
border-color: #FBBC05;
}
.fc .fc-button-primary:focus, .fc .fc-button-primary:not(:disabled).fc-button-active:focus, .fc .fc-button-primary:not(:disabled):active:focus {
box-shadow: 0 0 0 0;
}
.fc .fc-button-primary:hover{color:#fff; background-color:#52B5FF; border-color:#52B5FF;}
.fc-daygrid-event-harness{cursor:pointer;}
.fc .fc-daygrid-week-number{font-size:12px;}
/*今天背景色和字体颜色 */
.fc .fc-daygrid-day.fc-day-today .fc-event-title,.fc .fc-daygrid-day.fc-day-today .fc-event-time,.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number{
font-weight:800;
color:#FF5722;
}
/*星期六,星期天背景色和字体颜色
.fc-day-sat,.fc-day-sun{
background-color: #fafafa;
}
*/
.calendar-select{width:100px; height:38px; position:absolute; top:31px; right:255px; z-index:100;}
.calendar-select .layui-input{height: 36px; line-height: 1.2;}
.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;}
.layui-unselect dl {max-height:188px;}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<script src="{__METE__}/third_party/fullcalendar/main.min.js"></script>
<div class="body-table">
<div id="calendar"></div>
<div class="calendar-select">
<div class="layui-input-inline" style="width: 90px;"><input type="text" placeholder="请选择员工" class="layui-input" data-event="select" autocomplete="off"/></div>
</div>
</div>
<!-- /主体 -->
{/block}
<!-- 脚本 -->
{block name="script"}
<script type="text/javascript">
var uid=0;
function addZero(num){
if(num<10){
num='0'+num;
}
return num;
}
const moduleInit = ['tool','employeepicker'];
function gouguInit() {
var layer = layui.layer
,employeepicker = layui.employeepicker
,dropdown = layui.dropdown
,form = layui.form
,laydate = layui.laydate;
// 选择员工
$('.body-table').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: "/api/index/get_department_tree",
employee_url: "/api/index/get_employee",
callback: function (ids, names, dids, departments) {
uid = ids;
that.val(names);
calendar.refetchEvents({
url: '/oa/plan/index?uid='+uid
});
}
})
});
function addEvent(detail){
var type='<span style="color:#aaa">请选择</span>';
if(detail.type==1){
type = '<span class="layui-badge-dot"></span> 紧急';
}
else if(detail.type==2){
type = '<span class="layui-badge-dot layui-bg-orange"></span> 重要';
}
else if(detail.type==3){
type = '<span class="layui-badge-dot layui-bg-blue"></span> 次要';
}
else if(detail.type==4){
type = '<span class="layui-badge-dot layui-bg-green"></span> 不重要';
}
else if(detail.type==5){
type = '<span class="layui-badge-dot layui-bg-black"></span> 无优先级';
}
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='<form class="layui-form" style="width:828px">\
<table class="layui-table" style="margin:15px 15px 0;">\
<tr>\
<td class="layui-td-gray-2">日程时间范围 <span style="color: red">*</span></td>\
<td>\
<input id="start_time_a" name="start_time_a" style="width:120px; display:inline-block;" autocomplete="off" class="layui-input" value="'+detail.start_time_a+'" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间"><div style="display: inline-block; margin-left:3px; width: 86px;"><select lay-filter="start_time_b" id="start_time_b"></select></div> 至 <input id="end_time_a" name="end_time_a" style="width:120px; display:inline-block;" autocomplete="off" class="layui-input" value="" readonly lay-verify="required" placeholder="请选择时间" lay-reqText="请选择时间"><div style="display: inline-block; margin-left:3px; width: 86px;"><select lay-filter="end_time_b" id="end_time_b"></select></div>\
</td>\
<td class="layui-td-gray">提醒 <span style="color: red">*</span></td>\
<td>\
<div class="layui-input" id="remind_type" style="width:120px; line-height:35px;">'+remind_type+'</div>\
</td>\
</tr>\
<tr>\
<td class="layui-td-gray-2">日程内容 <span style="color: red">*</span></td>\
<td><input name="title" class="layui-input" value="'+detail.title+'" lay-verify="required" placeholder="请完成日程内容" lay-reqText="请完成日程内容"></td>\
<td class="layui-td-gray">日程优先级 <span style="color: red">*</span></td>\
<td>\
<div class="layui-input" id="type" style="width:120px; line-height:35px;">'+type+'</div>\
</td>\
</tr>\
<tr>\
<td class="layui-td-gray-2">日程详细描述</td>\
<td colspan="3">\
<textarea name="remark" form-input="remark" class="layui-textarea" style="min-height:120px;">'+detail.remark+'</textarea>\
</td>\
</tr>\
</table>\
</form>';
layer.open({
type:1,
title:'创建日程安排',
area:['860px','390px'],
content:content,
success:function(){
//日期时间范围
laydate.render({
elem: '#start_time_a',
type: 'date',
min: 0,
format: 'yyyy-MM-dd',
showBottom: false,
done:function(a,b,c){
detail.start_time_a=a;
}
});
//日期时间范围
laydate.render({
elem: '#end_time_a',
type: 'date',
min: 0,
format: 'yyyy-MM-dd',
showBottom: false,
done:function(a,b,c){
detail.end_time_a=a;
}
});
$('#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=detail.start_time_b=detail.start_time_b,def_h2='';
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_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_b)', function(data){
detail.start_time_b=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;
});
dropdown.render({
elem: '#type'
,data: [{
title: '<span class="layui-badge-dot"></span> 紧急',
id: 1
},{
title: '<span class="layui-badge-dot layui-bg-orange"></span> 重要',
id: 2
},{
title: '<span class="layui-badge-dot layui-bg-blue"></span> 次要',
id: 3
},{
title: '<span class="layui-badge-dot layui-bg-green"></span> 不重要',
id: 4
},{
title: '<span class="layui-badge-dot layui-bg-black"></span> 无优先级',
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_a=='' || detail.end_time_a==''){
layer.msg('请完善日程时间范围');
return;
}
if(detail.title==''){
layer.msg('请填写日程内容');
return;
}
if(detail.type==0){
layer.msg('请选择日程优先级');
return;
}
console.log(detail);
$.ajax({
url: "/oa/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='<span style="color:#393D49">无优先级</span>';
if(detail.type==1){
work_type = '<span style="color:#FF5722">紧急</span>';
}
else if(detail.type==2){
work_type = '<span style="color:#FFB800">重要</span>';
}
else if(detail.type==3){
work_type = '<span style="color:#1E9FFF">次要</span>';
}
else if(detail.type==4){
work_type = '<span style="color:#009688">不重要</span>';
}
var content='<div style="width:770px">\
<table class="layui-table" style="margin:12px 15px 0;">\
<tr>\
<td class="layui-td-gray-2">日程时间范围</td>\
<td>'+detail.start_time+' 至 '+detail.end_time+'</td>\
<td class="layui-td-gray">提醒时间</td>\
<td>'+detail.remind_time+'</td>\
</tr>\
<tr>\
<td class="layui-td-gray-2">日程安排内容</td>\
<td>'+detail.title+'</td>\
<td class="layui-td-gray">优先级</td>\
<td>'+work_type+'</td>\
</tr>\
<tr>\
<td class="layui-td-gray-2">日程内容描述</td>\
<td colspan="3">'+detail.remark+'</td>\
</tr>\
</table>\
</div>';
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: "/oa/plan/detail",
type:'post',
data:{id:id},
success:function(res){
var detail=res.data;
viewEvent(detail);
}
});
}
//日历
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
views: {
dayGrid: {
viewDidMount:function(arg){
calendar.setOption('height', window.innerHeight-30);
}
},
timeGrid: {
viewDidMount:function(arg){
calendar.setOption('height', 'auto');
}
},
week: {
viewDidMount:function(arg){
calendar.setOption('height', 'auto');
}
},
day: {
viewDidMount:function(arg){
calendar.setOption('height', 'auto');
}
}
},
//initialDate: '2020-09-12',//默认显示日期
initialView: 'dayGridMonth',//默认显示月视图
customButtons: {
clear: {
text: '清空员工', click: function () {
uid = 0;
$('[data-event="select"]').val('');
calendar.refetchEvents({
url: '/oa/plan/index?uid='+uid
});
}
}
},
headerToolbar: {
left: 'prev,next',//prev,next today add
center: 'title',
right: 'clear dayGridMonth,timeGridWeek,listWeek' //clear dayGridMonth,timeGridWeek,timeGridDay,listWeek
},
height: 'auto',//自动高度
viewRender:function(view,element){
console.log(view);
console.log(element);
},
navLinks: true, // can click day/week names to navigate views
editable: true,//确定是否可以拖拉调整日历事件的时间。
eventResize:function(ev) {
var arg = ev.event
console.log(arg);
var detail={};
detail['id']=arg.id;
detail['start_time_a']=arg.start.getFullYear()+'-'+addZero(arg.start.getMonth()+1)+'-'+addZero(arg.start.getDate());
detail['end_time_a']=arg.end.getFullYear()+'-'+addZero(arg.end.getMonth()+1)+'-'+addZero(arg.end.getDate());
detail['start_time_b']=addZero(arg.start.getHours())+':'+addZero(arg.start.getMinutes());
detail['end_time_b']=addZero(arg.end.getHours())+':'+addZero(arg.end.getMinutes());
console.log(detail);
$.ajax({
url: "/home/plan/add",
type:'post',
data:detail,
success:function(e){
layer.msg(e.msg);
if(e.code==1){
ev.revert();
}
}
})
},
eventDrop:function(ev) {
var arg = ev.event
console.log(arg);
var detail={};
detail['id']=arg.id;
detail['start_time_a']=arg.start.getFullYear()+'-'+addZero(arg.start.getMonth()+1)+'-'+addZero(arg.start.getDate());
detail['end_time_a']=arg.end.getFullYear()+'-'+addZero(arg.end.getMonth()+1)+'-'+addZero(arg.end.getDate());
detail['start_time_b']=addZero(arg.start.getHours())+':'+addZero(arg.start.getMinutes());
detail['end_time_b']=addZero(arg.end.getHours())+':'+addZero(arg.end.getMinutes());
console.log(detail);
$.ajax({
url: "/oa/plan/add",
type:'post',
data:detail,
success:function(e){
layer.msg(e.msg);
if(e.code==1){
ev.revert();
}
}
})
},
selectable: true,//拖拉选择日期
selectMirror: true,//是否在用户拖动时绘制"占位符"事件。
select: function(arg) {
var detail={};
detail['id']=0;
detail['title']='';
detail['start_time_a']=arg.start.getFullYear()+'-'+addZero(arg.start.getMonth()+1)+'-'+addZero(arg.start.getDate());
detail['end_time_a']="";
detail['start_time_b']="09:00";
detail['end_time_b']="00:00";
detail['remark']='';
detail['type']=0;
detail['remind_type']=0;
console.log(detail);
addEvent(detail);
},
nowIndicator: true,
firstDay: 1,
weekNumbers: true,// 是否开启周数
displayEventEnd: false, //所有视图显示结束时间
eventTimeFormat: { // 事件的时间格式,like '14:30:00'
hour: '2-digit',
minute: '2-digit',
//second: '2-digit',
meridiem: false,
hour12: false //设置时间为24小时
},
slotLabelFormat: { // 列表视图左边的时间格式,like '14:30:00'
hour: '2-digit',
minute: '2-digit',
//second: '2-digit',
meridiem: false,
hour12: false //设置时间为24小时
},
locale: 'zh-cn',//语言
buttonText: {
//按钮文本
today: '今天',
month: '月',
week: '周',
day: '日',
list: '日程列表',
},
weekText: '周',
allDayText: '全天',
moreLinkText: function(n) {
return '另外 ' + n + ' 个'
},
noEventsText: '没有事件显示',
events: function(fetchInfo, successCallback, failureCallback ){
$.ajax({
type:"POST",
url: "/oa/plan/calendar",
dataType:"json",
data:{start:fetchInfo.startStr,end:fetchInfo.endStr,uid:uid},
success:function(result){
//console.info(result);
successCallback(result);
},
error:function(){
failureCallback();
}
})
},
eventClick: function(info) {
//console.log(info.event);
eventApi(info.event.id);
}
});
calendar.render();
}
</script>
{/block}
<!-- /脚本 -->
+208
View File
@@ -0,0 +1,208 @@
{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="style"}
<style>
.layui-unselect dl {
max-height: 188px;
}
</style>
{/block} {block name="breadcrumb"}
<span class="layui-breadcrumb">
<a href="http://www.meteteme.com/" target="_blank">江苏美天科技</a>
<a><cite>工作记录</cite></a>
</span>
{/block} {block name="body"}
<div id="scheduleList" class="table-content p-3">
<div class="layui-form-bar border-t border-x">
<form class="layui-form">
<div class="layui-input-inline" style="width: 100px">
<select name="cate_id" lay-filter="cate">
<option value="">工作类型</option>
{volist name="cate" id="vo"}
<option value="{$vo.id}">{$vo.title}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline" style="width: 180px">
<select name="project_id" lay-filter="project">
<option value="">所属项目</option>
{volist name="project" id="vo"}
<option value="{$vo.id}">{$vo.name}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline" style="width: 220px">
<input name="uid" style="display: none" value="" />
<input
type="text"
name="user"
placeholder="执行员工,可多选,默认是自己"
readonly
class="layui-input employeepicker"
autocomplete="off"
/>
</div>
<div class="layui-input-inline" style="width: 240px">
<input
type="text"
name="keywords"
placeholder="工作内容"
class="layui-input"
autocomplete="off"
/>
</div>
<button
class="layui-btn layui-btn-normal"
lay-submit=""
lay-filter="webform"
>
搜索
</button>
<button type="reset" class="gougu-clear" lay-filter="clear">清空</button>
</form>
</div>
<table class="layui-hide" id="scheduleTable" lay-filter="schedule"></table>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = [
"tool",
"gouguEdit",
"gouguComment",
"gouguSchedule",
"employeepicker",
];
function gouguInit() {
var table = layui.table,
form = layui.form,
tool = layui.tool,
employeepicker = layui.employeepicker,
schedule = layui.gouguSchedule;
layui.pageTable = table.render({
elem: "#scheduleTable",
title: "工作记录列表",
cellMinWidth: 80,
url: "/schedule/index/index", //数据接口
page: true, //开启分页
limit: 20,
where: { uid: 0 },
page: true, //开启分页
limit: 20,
height: "full-140",
cols: [
[
//表头
{ field: "id", title: "序号", width: 80, align: "center" },
{
field: "work_cate",
title: "工作类型",
align: "center",
width: 100,
},
{ field: "title", title: "工作内容" },
{ field: "name", title: "执行员工", align: "center", width: 80 },
{
field: "department",
title: "所在部门",
align: "center",
width: 100,
},
{
field: "create_time",
title: "记录时间",
align: "center",
width: 150,
},
{
title: "操作",
align: "center",
width: 100,
templet: function (d) {
return '<div class="layui-btn-group"><span class="layui-btn layui-btn-xs" lay-event="edit">修改</span><span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">详细</span></div>';
},
},
],
],
});
table.on("tool(schedule)", function (obj) {
if (obj.event === "edit") {
schedule.add(0, obj.data);
}
if (obj.event === "view") {
schedule.view(obj.data);
}
return false;
});
//选择人弹窗
$("#scheduleList").on("click", ".employeepicker", function () {
let that = $(this);
var ids = $('[name="uid"]').val(),
names = that.val(),
id_array = [],
name_array = [];
if (ids.length > 0) {
id_array = ids.split(",");
name_array = names.split(",");
}
employeepicker.init({
ids: id_array,
names: name_array,
department_url: "/api/index/get_department_tree",
employee_url: "/api/index/get_employee",
callback: function (ids, names, dids, departments) {
$('[name="uid"]').val(ids);
that.val(names);
tableReload();
},
});
});
//新增
$("#scheduleList").on("click", ".add-new", function () {
tool.open("/task/index/add");
});
form.on("select(type)", function (data) {
tableReload();
});
form.on("select(cate)", function (data) {
tableReload();
});
form.on("select(project)", function (data) {
tableReload();
});
//监听搜索提交
form.on("submit(webform)", function (data) {
if (data.field.keywords == "") {
return false;
}
tableReload();
return false;
});
$("#scheduleList").on("click", '[lay-filter="clear"]', function () {
setTimeout(function () {
tableReload();
}, 10);
});
function tableReload() {
let postData = {
type: $("#scheduleList").find('[name="type"]').val(),
cate: $("#scheduleList").find('[name="cate_id"]').val(),
uid: $("#scheduleList").find('[name="uid"]').val(),
project_id: $("#scheduleList").find('[name="project_id"]').val(),
keywords: $("#scheduleList").find('[name="keywords"]').val(),
};
layui.pageTable.reload({ where: postData });
}
}
</script>
{/block}
<!-- /脚本 -->