app/user/controller/Attendance.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/user/model/Attendance.php | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/user/view/attendance/add.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/user/view/attendance/index.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/user/view/work_plan/index.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
public/static/assets/gougu/css/gougu.css | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/user/controller/Attendance.php
@@ -6,22 +6,71 @@ use app\base\BaseController; use app\user\validate\AttendanceCheck; use app\user\model\Attendance as AttendanceModel; use think\exception\ValidateException; use think\facade\Db; use think\facade\View; class Attendance extends BaseController { /** * 构造函数 */ protected $model; public function __construct() { parent::__construct(); // 调用父类构造函数 $this->model = new AttendanceModel(); } public function index() { if (request()->isAjax()) { $list = Db::name('AttendanceGroup')->where('is_del', '=', 0)->order('create_time asc')->select()->toArray(); // var_dump($list); // foreach ($list as &$val) { // $groupId = Db::name('PositionGroup')->where(['pid' => $val['id']])->column('group_id'); // $groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title'); // $val['groupName'] = implode(',', $groupName); // } $list = Db::name('AttendanceGroup')->where('is_del', '=', 0)->order('create_time asc')->select()->each(function ($item, $key) { $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); $item['update_time'] = $item['update_time'] > 0 ? date('Y-m-d H:i:s', $item['update_time']) : ""; // 获取关联时间 $mappingTimes = Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $item['id']])->column('special_date_id'); $times = Db::name('AttendanceSpecialDate')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $item['specialDate'] = $times; // 获取关联用户 $mappingUsers = Db::name('AttendanceUserLink')->where(['group_id' => $item['id']])->select()->toArray(); foreach ($mappingUsers as &$user) { $userInfo = Db::name('Admin')->where(['id' => $user['user_id']])->find(); $user['userInfo'] = $userInfo; } $item['linkUserDate'] = $mappingUsers; // 获取关联的班次 $map['mon_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['mon_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['mon_work_plan_id']])->column('work_time_id'); $map['mon_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['tue_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['tue_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['tue_work_plan_id']])->column('work_time_id'); $map['tue_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['wed_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['wed_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['wed_work_plan_id']])->column('work_time_id'); $map['wed_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['thur_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['thur_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['thur_work_plan_id']])->column('work_time_id'); $map['thur_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['fri_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['fri_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['fri_work_plan_id']])->column('work_time_id'); $map['fri_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['sat_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['sat_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['sat_work_plan_id']])->column('work_time_id'); $map['sat_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $map['sun_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $item['sun_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $item['sun_work_plan_id']])->column('work_time_id'); $map['sun_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $item['work_plan'] = $map; return $item; })->toArray(); $res['data'] = $list; return table_assign(0, '', $res); } else { @@ -81,87 +130,28 @@ 'type' => $param['type'], 'is_del' => 0, 'create_time' => time(), 'mon_work_plan_id' => isset($param['work1']) && $param['work1'] == "on" && isset($param['work_plan_id1']) ? intval($param['work_plan_id1']) : 0, 'tue_work_plan_id' => isset($param['work2']) && $param['work2'] == "on" && isset($param['work_plan_id2']) ? intval($param['work_plan_id1']) : 0, 'wed_work_plan_id' => isset($param['work3']) && $param['work3'] == "on" && isset($param['work_plan_id3']) ? intval($param['work_plan_id1']) : 0, 'thur_work_plan_id' => isset($param['work4']) && $param['work4'] == "on" && isset($param['work_plan_id4']) ? intval($param['work_plan_id1']) : 0, 'fri_work_plan_id' => isset($param['work5']) && $param['work5'] == "on" && isset($param['work_plan_id5']) ? intval($param['work_plan_id1']) : 0, 'sat_work_plan_id' => isset($param['work6']) && $param['work6'] == "on" && isset($param['work_plan_id6']) ? intval($param['work_plan_id1']) : 0, 'sun_work_plan_id' => isset($param['work7']) && $param['work7'] == "on" && isset($param['work_plan_id7']) ? intval($param['work_plan_id1']) : 0, 'mon_work_plan_id' => isset($param['work1']) && $param['work1'] == "on" && isset($param['mon_work_plan_id']) ? intval($param['mon_work_plan_id']) : 0, 'tue_work_plan_id' => isset($param['work2']) && $param['work2'] == "on" && isset($param['tue_work_plan_id']) ? intval($param['tue_work_plan_id']) : 0, 'wed_work_plan_id' => isset($param['work3']) && $param['work3'] == "on" && isset($param['wed_work_plan_id']) ? intval($param['wed_work_plan_id']) : 0, 'thur_work_plan_id' => isset($param['work4']) && $param['work4'] == "on" && isset($param['thur_work_plan_id']) ? intval($param['thur_work_plan_id']) : 0, 'fri_work_plan_id' => isset($param['work5']) && $param['work5'] == "on" && isset($param['fri_work_plan_id']) ? intval($param['fri_work_plan_id']) : 0, 'sat_work_plan_id' => isset($param['work6']) && $param['work6'] == "on" && isset($param['sat_work_plan_id']) ? intval($param['sat_work_plan_id']) : 0, 'sun_work_plan_id' => isset($param['work7']) && $param['work7'] == "on" && isset($param['sun_work_plan_id']) ? intval($param['sun_work_plan_id']) : 0, ]; $uid = Db::name('AttendanceGroup')->strict(false)->field(true)->insertGetId($setData); // 插入用户关联表 $attendance_participants_ids = explode(",", $param['attendance_participants_id']); $attendance_not_participants_id = explode(",", $param['attendance_not_participants_id']); foreach ($attendance_participants_ids as $key => $value) { if ($value != '') { $mappingData[$key] = [ 'group_id' => $uid, 'user_id' => intval($value), 'type' => "1", ]; Db::name('AttendanceUserLink')->strict(false)->field(true)->insertAll($mappingData); } } foreach ($attendance_not_participants_id as $key => $value) { if ($value != '') { $mappingData[$key] = [ 'group_id' => $uid, 'user_id' => intval($value), 'type' => "2", ]; Db::name('AttendanceUserLink')->strict(false)->field(true)->insertAll($mappingData); } } $this->model->insertUserLinks($uid, $param['attendance_participants_id'], 1); $this->model->insertUserLinks($uid, $param['attendance_not_participants_id'], 2); // 插入时间表 for ($i = 0; $i < count($param['necessaryTime']); $i++) { // 获取时间数据 $timeData1 = [ 'begin_data' => $param['necessaryTime'][$i] . " 00:00:00", 'end_data' => $param['necessaryTime'][$i] . " 23:59:59", 'type' => "1", ]; // 插入时间数据 $timeIds1[$i] = Db::name('AttendanceSpecialDate')->strict(false)->field(true)->insertGetId($timeData1); if (isset($param['necessaryTime'])) { $this->model->insertSpecialDates($uid, $param['necessaryTime'], 1); } if (isset($param['unNecessaryTime'])) { $this->model->insertSpecialDates($uid, $param['unNecessaryTime'], 2); } foreach ($timeIds1 as $key => $value) { $mappingData1[$key] = [ 'group_id' => $uid, 'special_date_id' => $value, ]; } Db::name('AttendanceGroupSpecialDateLink')->strict(false)->field(true)->insertAll($mappingData1); for ($i = 0; $i < count($param['unNecessaryTime']); $i++) { // 获取时间数据 $timeData2 = [ 'begin_data' => $param['unNecessaryTime'][$i] . " 00:00:00", 'end_data' => $param['unNecessaryTime'][$i] . " 23:59:59", 'type' => "2", ]; // 插入时间数据 $timeIds2[$i] = Db::name('AttendanceSpecialDate')->strict(false)->field(true)->insertGetId($timeData2); } foreach ($timeIds2 as $key => $value) { $mappingData2[$key] = [ 'group_id' => $uid, 'special_date_id' => $value, ]; } Db::name('AttendanceGroupSpecialDateLink')->strict(false)->field(true)->insertAll($mappingData2); // foreach ($param['group_id'] as $k => $v) { // $data[$k] = [ // 'pid' => $uid, // 'group_id' => $v, // 'create_time' => time(), // ]; // } // Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data); add_log('add', $uid, $param); // 提交事务 Db::commit(); @@ -174,23 +164,95 @@ return to_assign(); } else { $id = isset($param['id']) ? $param['id'] : 0; // $group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray(); if ($id > 0) { $detail = Db::name('AttendanceGroup')->where(['id' => $id])->find(); // $detail['group_id'] = Db::name('PositionGroup')->where(['pid' => $id])->column('group_id'); // foreach ($group as &$val) { // if (in_array($val['id'], $detail['group_id'])) { // $val['checked'] = 1; // } else { // $val['checked'] = 0; // } // } // 获取关联时间 $mappingTimes = Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $detail['id']])->column('special_date_id'); $times = Db::name('AttendanceSpecialDate')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $time1 = array_values(array_filter($times, function ($item) { return $item['type'] == 1; })); $detail['necessaryTime'] = []; foreach ($time1 as $key => $value) { $timeData['time'] = str_split($value['begin_data'], 10)[0]; $timeData['id'] = $value['id']; $detail['necessaryTime'][] = $timeData; } $time2 = array_values(array_filter($times, function ($item) { return $item['type'] == 2; })); $detail['unNecessaryTime'] = []; foreach ($time2 as $key => $value) { $timeData['time'] = str_split($value['begin_data'], 10)[0]; $timeData['id'] = $value['id']; $detail['unNecessaryTime'][] = $timeData; } // 获取关联用户 $mappingUsers = Db::name('AttendanceUserLink')->where(['group_id' => $detail['id']])->select()->toArray(); foreach ($mappingUsers as &$user) { $userInfo = Db::name('Admin')->where(['id' => $user['user_id']])->find(); $user['userInfo'] = $userInfo; } $user1 = array_values(array_filter($mappingUsers, function ($item) { return $item['type'] == 1; })); $userName1 = []; $userId1 = []; foreach ($user1 as $key => $value) { $userName1[] = $value['userInfo']['name']; $userId1[] = $value['userInfo']['id']; } $detail['attendance_participants'] = implode(",",$userName1); $detail['attendance_participants_id'] = implode(",",$userId1); $user2 = array_values(array_filter($mappingUsers, function ($item) { return $item['type'] == 2; })); $userName2 = []; $userId2 = []; foreach ($user2 as $key => $value) { $userName2[] = $value['userInfo']['name']; $userName2[] = $value['userInfo']['id']; } $detail['attendance_not_participants'] = implode(",",$userName2); $detail['attendance_not_participants_id'] = implode(",",$userId2); // 获取关联的班次 $detail['mon_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['mon_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['mon_work_plan_id']])->column('work_time_id'); $detail['mon_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['tue_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['tue_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['tue_work_plan_id']])->column('work_time_id'); $detail['tue_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['wed_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['wed_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['wed_work_plan_id']])->column('work_time_id'); $detail['wed_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['thur_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['thur_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['thur_work_plan_id']])->column('work_time_id'); $detail['thur_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['fri_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['fri_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['fri_work_plan_id']])->column('work_time_id'); $detail['fri_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['sat_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['sat_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['sat_work_plan_id']])->column('work_time_id'); $detail['sat_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); $detail['sun_work_plan'] = Db::name('AttendanceWorkPlan')->where(['id' => $detail['sun_work_plan_id']])->find(); $mappingTimes = Db::name('AttendanceWorkPlanWorkTimeLink')->where(['work_plan_id' => $detail['sun_work_plan_id']])->column('work_time_id'); $detail['sun_work_plan']['times'] = Db::name('AttendanceWorkTime')->where('id', 'in', $mappingTimes)->where('is_del', '=', 0)->select()->toArray(); View::assign('detail', $detail); } // View::assign('group', $group); View::assign('id', $id); return view(); } } } app/user/model/Attendance.php
New file @@ -0,0 +1,74 @@ <?php /** +----------------------------------------------------------------------------------------------- * GouGuOPEN [ 左手研发,右手开源,未来可期!] +----------------------------------------------------------------------------------------------- * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved. +----------------------------------------------------------------------------------------------- * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息 +----------------------------------------------------------------------------------------------- * @Author 勾股工作室 <hdm58@qq.com> +----------------------------------------------------------------------------------------------- */ namespace app\user\model; use think\model; use think\facade\Db; class Attendance extends Model { /** * 插入用户关联表 * * @param int $groupId 组ID * @param string $userIdString 用户ID字符串 * @param int $type 类型 */ public function insertUserLinks(int $groupId, string $userIdString, int $type): void { $userIds = explode(",", $userIdString); $mappingData = []; foreach ($userIds as $userId) { if (!empty($userId)) { $mappingData[] = [ 'group_id' => $groupId, 'user_id' => intval($userId), 'type' => $type, ]; } } if (!empty($mappingData)) { Db::name('AttendanceUserLink')->strict(false)->field(true)->insertAll($mappingData); } } /** * 插入特殊日期 * * @param int $groupId 组ID * @param array $dates 日期数组 * @param int $type 类型 */ public function insertSpecialDates(int $groupId, array $dates, int $type): void { $timeIds = []; foreach ($dates as $date) { $timeData = [ 'begin_data' => $date . " 00:00:00", 'end_data' => $date . " 23:59:59", 'type' => $type, ]; $timeIds[] = Db::name('AttendanceSpecialDate')->strict(false)->field(true)->insertGetId($timeData); } $mappingData = []; foreach ($timeIds as $timeId) { $mappingData[] = [ 'group_id' => $groupId, 'special_date_id' => $timeId, ]; } if (!empty($mappingData)) { Db::name('AttendanceGroupSpecialDateLink')->strict(false)->field(true)->insertAll($mappingData); } } } app/user/view/attendance/add.html
@@ -117,7 +117,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id1" value="" /> <input type="hidden" name="mon_work_plan_id" value="" /> </td> </tr> <tr> @@ -130,7 +130,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id2" value="" /> <input type="hidden" name="tue_work_plan_id" value="" /> </td> </tr> <tr> @@ -143,7 +143,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id3" value="" /> <input type="hidden" name="wed_work_plan_id" value="" /> </td> </tr> <tr> @@ -156,7 +156,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id4" value="" /> <input type="hidden" name="thur_work_plan_id" value="" /> </td> </tr> <tr> @@ -169,7 +169,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id5" value="" /> <input type="hidden" name="fri_work_plan_id" value="" /> </td> </tr> <tr> @@ -182,7 +182,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id6" value="" /> <input type="hidden" name="sat_work_plan_id" value="" /> </td> </tr> <tr> @@ -195,7 +195,7 @@ <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="work_plan_id7" value="" /> <input type="hidden" name="sun_work_plan_id" value="" /> </td> </tr> </table> @@ -240,7 +240,7 @@ {else/} <table class="layui-table layui-table-form"> <tr> <td class="layui-td-gray">考勤组名称<font>*</font></td> <td class="layui-td-gray-3">考勤组名称<font>*</font></td> <td> <input type="text" @@ -253,6 +253,278 @@ class="layui-input" /> </td> <td class="layui-td-gray-3">考勤类型<font>*</font></td> <td> <select name="type" lay-verify="required" lay-reqText="请选择"> <option value="" >请选择</option> <option value="1" {eq name="1" value="$detail.type"} selected{/eq}>固定班制</option> <option value="2" {eq name="2" value="$detail.type"} selected{/eq}>自由工时</option> </select> </td> </tr> <tr> <td class="layui-td-gray-3">参与考勤人员<font>*</font></td> <td> <input type="text" name="attendance_participants" autocomplete="off" readonly lay-verify="required" lay-reqText="请选择参与考勤人员" placeholder="请选择参与考勤人员" class="layui-input picker-diy" value="{$detail.attendance_participants}" /> <input type="hidden" name="attendance_participants_id" value="{$detail.attendance_participants_id}" /> </td> <td class="layui-td-gray-3">无需考勤人员</td> <td> <input type="text" name="attendance_not_participants" autocomplete="off" readonly lay-reqText="请选择无需考勤人员" placeholder="请选择无需考勤人员" class="layui-input picker-diy" value="{$detail.attendance_not_participants}" /> <input type="hidden" name="attendance_not_participants_id" value="{$detail.attendance_not_participants_id}" /> </td> </tr> <tr> <td class="layui-td-gray">工作日设置<font>*</font></td> <td colspan="5"> <table id="timeBox" class="layui-table layui-table-min" style="margin: 0" > <tr> <th width="50"></th> <th width="100">工作日</th> <th>班次时间段</th> <th width="60">操作</th> </tr> <tr> <td> <input type="checkbox" name="work1" lay-skin="primary" {notempty name="$detail.mon_work_plan_id"} checked {/notempty} /> </td> <td>周一</td> <td style="text-align: left"> {notempty name="$detail.mon_work_plan.id"} <span>{$detail.mon_work_plan.name}:</span> {notempty name="$detail.mon_work_plan.times"} {volist name="$detail.mon_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="mon_work_plan_id" value="{$detail.mon_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work2" lay-skin="primary" {notempty name="$detail.tue_work_plan_id"} checked {/notempty} /> </td> <td>周二</td> <td style="text-align: left"> {notempty name="$detail.tue_work_plan.id"} <span>{$detail.tue_work_plan.name}:</span> {notempty name="$detail.tue_work_plan.times"} {volist name="$detail.tue_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="tue_work_plan_id" value="{$detail.tue_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work3" lay-skin="primary" {notempty name="$detail.wed_work_plan_id"} checked {/notempty} /> </td> <td>周三</td> <td style="text-align: left"> {notempty name="$detail.wed_work_plan.id"} <span>{$detail.wed_work_plan.name}:</span> {notempty name="$detail.wed_work_plan.times"} {volist name="$detail.wed_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="wed_work_plan_id" value="{$detail.wed_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work4" lay-skin="primary" {notempty name="$detail.thur_work_plan_id"} checked {/notempty} /> </td> <td>周四</td> <td style="text-align: left"> {notempty name="$detail.thur_work_plan.id"} <span>{$detail.thur_work_plan.name}:</span> {notempty name="$detail.thur_work_plan.times"} {volist name="$detail.thur_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="thur_work_plan_id" value="{$detail.thur_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work5" lay-skin="primary" {notempty name="$detail.fri_work_plan_id"} checked {/notempty} /> </td> <td>周五</td> <td style="text-align: left"> {notempty name="$detail.fri_work_plan.id"} <span>{$detail.fri_work_plan.name}:</span> {notempty name="$detail.fri_work_plan.times"} {volist name="$detail.fri_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="fri_work_plan_id" value="{$detail.fri_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work6" lay-skin="primary" {notempty name="$detail.sat_work_plan_id"} checked {/notempty} /> </td> <td>周六</td> <td style="text-align: left"> {notempty name="$detail.sat_work_plan.id"} <span>{$detail.sat_work_plan.name}:</span> {notempty name="$detail.sat_work_plan.times"} {volist name="$detail.sat_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="sat_work_plan_id" value="{$detail.sat_work_plan_id}" /> </td> </tr> <tr> <td> <input type="checkbox" name="work7" lay-skin="primary" {notempty name="$detail.sun_work_plan_id"} checked {/notempty} /> </td> <td>周日</td> <td style="text-align: left"> {notempty name="$detail.sun_work_plan.id"} <span>{$detail.sun_work_plan.name}:</span> {notempty name="$detail.sun_work_plan.times"} {volist name="$detail.sun_work_plan.times" id="vo"} <span style='margin-right: 30px'>{$vo.begin_time} - {$vo.end_time}</span> {/volist} {/notempty} {/notempty} </td> <td> <a class="layui-btn layui-btn-xs picker-oa" data-types="workPlan" >设置班次</a > <input type="hidden" name="sun_work_plan_id" value="{$detail.sun_work_plan_id}" /> </td> </tr> </table> </td> </tr> <tr> <td class="layui-td-gray-3">特殊日期</td> <td colspan="5"> <div style="margin-bottom: 10px"> <div id="showNecessaryTimeBox"> <p>必须打卡日期:</p> <div id="showNecessaryTimeList"> {notempty name="$detail.necessaryTime"} {volist name="$detail.necessaryTime" id="vo"} <div class='timeItem'> <span class='timeValue'> {$vo.time} </span> <input type='hidden' name='necessaryTime[]' value="{$vo.time}" /> <input type='hidden' name='necessaryTime_id[]' value="{$vo.id}" /> <span class='closeBtn layui-icon'>ဆ</span> </div> {/volist} {/notempty} </div> </div> </div> <div style="margin-bottom: 10px"> <button class="layui-btn layui-btn-sm" type="button" id="addNecessaryTimeBtn" > + 新增必须打卡的日期 </button> </div> <div style="margin-bottom: 10px"> <div id="showUnNecessaryTimeBox"> <p>无需打卡日期:</p> <div id="showUnNecessaryTimeList"> {notempty name="$detail.unNecessaryTime"} {volist name="$detail.unNecessaryTime" id="vo"} <div class='timeItem'> <span class='timeValue'> {$vo.time} </span> <input type='hidden' name='unNecessaryTime[]' value="{$vo.time}" /> <input type='hidden' name='unNecessaryTime_id[]' value="{$vo.id}" /> <span class='closeBtn layui-icon'>ဆ</span> </div> {/volist} {/notempty} </div> </div> </div> <div style="margin-bottom: 10px"> <button class="layui-btn layui-btn-sm" type="button" id="addUnNecessaryTimeBtn" > + 新增无需打卡的日期 </button> </div> </td> </tr> </table> {/if} app/user/view/attendance/index.html
@@ -5,11 +5,6 @@ <table class="layui-hide" id="test" lay-filter="test"></table> </div> <script type="text/html" id="status"> <i class="layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}yellow layui-icon-close{{# } }}" ></i> </script> <script type="text/html" id="toolbarDemo"> <div class="layui-btn-container"> <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加考勤组</button> @@ -44,23 +39,91 @@ cols: [ [ { field: "title", field: "name", title: "名称", align: "center" align: "center", width: 300 }, { field: "peopleNum", title: "人数", width: 120 width: 120, templet: function (d) { var users = d.linkUserDate.filter((item) => item.type == "1"); return users.length; } }, { field: "type", title: "类型", width: 120 width: 120, templet: function (d) { if (d.type == "1") { return "固定班制"; } if (d.type == "2") { return "自由工时"; } } }, { field: "time", title: "考勤时间" title: "考勤时间", templet: function (d) { // 按照班次分组 var planMap = {}; Object.keys(d.work_plan).forEach((key) => { var item = d.work_plan[key]; var showTxt = ""; if (key.indexOf("mon_") > -1) { showTxt = "周一"; } if (key.indexOf("tue_") > -1) { showTxt = "周二"; } if (key.indexOf("wed_") > -1) { showTxt = "周三"; } if (key.indexOf("thur_") > -1) { showTxt = "周四"; } if (key.indexOf("fri_") > -1) { showTxt = "周五"; } if (key.indexOf("sat_") > -1) { showTxt = "周六"; } if (key.indexOf("sun_") > -1) { showTxt = "周日"; } if (item.id) { if (!planMap[item.id]) planMap[item.id] = { showTxt: [] }; planMap[item.id].times = item.times; planMap[item.id].showTxt.push(showTxt); } else { if (!planMap["null"]) planMap["null"] = { showTxt: [] }; planMap.null.showTxt.push(showTxt); } }); console.log(planMap, "planMap"); // 根据班次分类显示时间 var html_ = ""; Object.keys(planMap).forEach((key) => { html_ += "<p>" + planMap[key].showTxt.join("、") + ":" + (planMap[key].times && planMap[key].times.length > 0 ? planMap[key].times.map( (item) => item.begin_time + " - " + item.end_time ) : "休息") + "</p>"; }); console.log(html_); return html_; } }, { field: "right", @@ -101,7 +164,11 @@ obj.del(); } }; tool.delete("/user/attendance/delete", { id: obj.data.id }, callback); tool.delete( "/user/attendance/delete", { id: obj.data.id }, callback ); layer.close(index); } ); app/user/view/work_plan/index.html
@@ -5,11 +5,6 @@ <table class="layui-hide" id="test" lay-filter="test"></table> </div> <script type="text/html" id="status"> <i class="layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}yellow layui-icon-close{{# } }}" ></i> </script> <script type="text/html" id="toolbarDemo"> <div class="layui-btn-container"> <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加班次</button> public/static/assets/gougu/css/gougu.css
@@ -10,7 +10,7 @@ .gougu-picker .layui-layer-btn2{background-color:#EAFAFF} .picker-table{padding:8px 8px 0;} .picker-table .layui-table-cell {padding:4px; line-height: 24px;} .layui-table-cell{padding:6px;} .layui-table-cell{padding:6px; height: auto;} .layui-table-box{background-color:#fff;} .layui-table-page{background-color:#fff;border-bottom:1px solid #eeeeee;} .layui-table-tool{box-shadow: 0 0 0 rgb(0 0 0 / 1%);padding:10px 12px; background-color:#fff;}