From 3bd8985e73fa326454ed8b8e1b1b60245caff89b Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期五, 28 三月 2025 16:32:04 +0800
Subject: [PATCH] 考勤组

---
 app/user/view/attendance/index.html      |   89 ++++++
 app/user/view/work_plan/index.html       |    5 
 public/static/assets/gougu/css/gougu.css |    2 
 app/user/view/attendance/add.html        |  288 +++++++++++++++++++++++
 app/user/controller/Attendance.php       |  246 ++++++++++++-------
 app/user/model/Attendance.php            |   74 ++++++
 6 files changed, 587 insertions(+), 117 deletions(-)

diff --git a/app/user/controller/Attendance.php b/app/user/controller/Attendance.php
index 0222bab..efff870 100644
--- a/app/user/controller/Attendance.php
+++ b/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();
         }
     }
-
 }
diff --git a/app/user/model/Attendance.php b/app/user/model/Attendance.php
new file mode 100644
index 0000000..bc20fc4
--- /dev/null
+++ b/app/user/model/Attendance.php
@@ -0,0 +1,74 @@
+<?php
+/**
++-----------------------------------------------------------------------------------------------
+* GouGuOPEN [ 宸︽墜鐮斿彂锛屽彸鎵嬪紑婧愶紝鏈潵鍙湡锛乚
++-----------------------------------------------------------------------------------------------
+* @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
++-----------------------------------------------------------------------------------------------
+* @Licensed 鍕捐偂OA锛屽紑婧愪笖鍙厤璐逛娇鐢紝浣嗗苟涓嶆槸鑷敱杞欢锛屾湭缁忔巿鏉冭鍙笉鑳藉幓闄ゅ嬀鑲A鐨勭浉鍏崇増鏉冧俊鎭�
++-----------------------------------------------------------------------------------------------
+* @Author 鍕捐偂宸ヤ綔瀹� <hdm58@qq.com>
++-----------------------------------------------------------------------------------------------
+*/
+namespace app\user\model;
+use think\model;
+use think\facade\Db;
+class Attendance extends Model
+{
+    /**
+     * 鎻掑叆鐢ㄦ埛鍏宠仈琛�
+     *
+     * @param int $groupId 缁処D
+     * @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 缁処D
+     * @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);
+        }
+    }
+}
+
diff --git a/app/user/view/attendance/add.html b/app/user/view/attendance/add.html
index e07203a..f1d6537 100644
--- a/app/user/view/attendance/add.html
+++ b/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,7 +253,279 @@
           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'>&#x1006;</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'>&#x1006;</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}
   <div class="pt-4">
diff --git a/app/user/view/attendance/index.html b/app/user/view/attendance/index.html
index 5bdd46c..b6726a7 100644
--- a/app/user/view/attendance/index.html
+++ b/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);
           }
         );
diff --git a/app/user/view/work_plan/index.html b/app/user/view/work_plan/index.html
index 4ab9698..4aceb9f 100644
--- a/app/user/view/work_plan/index.html
+++ b/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>
diff --git a/public/static/assets/gougu/css/gougu.css b/public/static/assets/gougu/css/gougu.css
index 67965be..f0c0aa5 100644
--- a/public/static/assets/gougu/css/gougu.css
+++ b/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;}

--
Gitblit v1.9.1