From 729e47e5aa77d73914de4353e95f56350611f820 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期一, 14 四月 2025 10:50:55 +0800
Subject: [PATCH] Merge branch 'main' of http://182.92.203.7:2001/r/OAManage

---
 app/user/view/attendance/index.html |   43 ++++++++++++++++-----
 app/user/controller/Attendance.php  |   64 +++++++++++++++++++++++--------
 2 files changed, 80 insertions(+), 27 deletions(-)

diff --git a/app/user/controller/Attendance.php b/app/user/controller/Attendance.php
index efff870..4a0457e 100644
--- a/app/user/controller/Attendance.php
+++ b/app/user/controller/Attendance.php
@@ -93,20 +93,38 @@
                 // 鍚姩浜嬪姟
                 Db::startTrans();
                 try {
-                    Db::name('AttendanceGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($param);
-                    // Db::name('PositionGroup')->where(['pid' => $param['id']])->delete();
-                    // foreach ($param['group_id'] as $k => $v) {
-                    //     $data[$k] = [
-                    //         'pid' => $param['id'],
-                    //         'group_id' => $v,
-                    //         'create_time' => time(),
-                    //     ];
-                    // }
-                    // Db::name('PositionGroup')->strict(false)->field(true)->insertAll($data);
+                    $setData = [
+                        'name' => $param['name'],
+                        'type' => $param['type'],
+                        'is_del' => 0,
+                        'create_time' => time(),
+                        '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,
+                    ];
+                    Db::name('AttendanceGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($setData);
+                    // 鍒犻櫎鐢ㄦ埛鍏宠仈
+                    Db::name('AttendanceUserLink')->where(['group_id' => $param['id']])->delete();
+                    // 鍒犻櫎鏃堕棿
+                    $specialDateIds = Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $param['id']])->column('special_date_id');
+                    Db::name('AttendanceSpecialDate')->where('id', 'in', $specialDateIds)->delete();
+                    Db::name('AttendanceGroupSpecialDateLink')->where(['group_id' => $param['id']])->delete();
+                    // 鎻掑叆鐢ㄦ埛鍏宠仈琛�
+                    $this->model->insertUserLinks(intval($param['id']), $param['attendance_participants_id'], 1);
+                    $this->model->insertUserLinks(intval($param['id']), $param['attendance_not_participants_id'], 2);
+
+                    // 鎻掑叆鏃堕棿琛�
+                    if (isset($param['necessaryTime'])) {
+                        $this->model->insertSpecialDates(intval($param['id']), $param['necessaryTime'], 1);
+                    }
+                    if (isset($param['unNecessaryTime'])) {
+                        $this->model->insertSpecialDates(intval($param['id']), $param['unNecessaryTime'], 2);
+                    }
                     add_log('edit', $param['id'], $param);
-                    //娓呴櫎鑿滃崟\鏉冮檺缂撳瓨
-                    // clear_cache('adminMenu');
-                    // clear_cache('adminRules');
                     // 鎻愪氦浜嬪姟
                     Db::commit();
                 } catch (\Exception $e) {
@@ -207,8 +225,8 @@
                     $userName1[] = $value['userInfo']['name'];
                     $userId1[] = $value['userInfo']['id'];
                 }
-                $detail['attendance_participants'] = implode(",",$userName1);
-                $detail['attendance_participants_id'] = implode(",",$userId1);
+                $detail['attendance_participants'] = implode(",", $userName1);
+                $detail['attendance_participants_id'] = implode(",", $userId1);
                 $user2 = array_values(array_filter($mappingUsers, function ($item) {
                     return $item['type'] == 2;
                 }));
@@ -219,8 +237,8 @@
                     $userName2[] = $value['userInfo']['name'];
                     $userName2[] = $value['userInfo']['id'];
                 }
-                $detail['attendance_not_participants'] = implode(",",$userName2);
-                $detail['attendance_not_participants_id'] = implode(",",$userId2);
+                $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');
@@ -255,4 +273,16 @@
             return view();
         }
     }
+
+    // 鍒犻櫎
+    public function delete()
+    {
+        $id = get_params("id");
+        if (Db::name('AttendanceGroup')->where('id', $id)->update(['is_del' => 1]) !== false) {
+            add_log('delete', $id, [], '鑰冨嫟缁�');
+            return to_assign(0, "鍒犻櫎鎴愬姛");
+        } else {
+            return to_assign(1, "鍒犻櫎澶辫触");
+        }
+    }
 }
diff --git a/app/user/view/attendance/index.html b/app/user/view/attendance/index.html
index b6726a7..62914e5 100644
--- a/app/user/view/attendance/index.html
+++ b/app/user/view/attendance/index.html
@@ -75,53 +75,76 @@
               Object.keys(d.work_plan).forEach((key) => {
                 var item = d.work_plan[key];
                 var showTxt = "";
+                var index = 0;
                 if (key.indexOf("mon_") > -1) {
                   showTxt = "鍛ㄤ竴";
+                  index = 1;
                 }
                 if (key.indexOf("tue_") > -1) {
                   showTxt = "鍛ㄤ簩";
+                  index = 2;
                 }
                 if (key.indexOf("wed_") > -1) {
                   showTxt = "鍛ㄤ笁";
+                  index = 3;
                 }
                 if (key.indexOf("thur_") > -1) {
                   showTxt = "鍛ㄥ洓";
+                  index = 4;
                 }
                 if (key.indexOf("fri_") > -1) {
                   showTxt = "鍛ㄤ簲";
+                  index = 5;
                 }
                 if (key.indexOf("sat_") > -1) {
                   showTxt = "鍛ㄥ叚";
+                  index = 6;
                 }
                 if (key.indexOf("sun_") > -1) {
                   showTxt = "鍛ㄦ棩";
+                  index = 7;
                 }
                 if (item.id) {
-                  if (!planMap[item.id]) planMap[item.id] = { showTxt: [] };
+                  if (!planMap[item.id])
+                    planMap[item.id] = { showTxt: [], index: null };
                   planMap[item.id].times = item.times;
                   planMap[item.id].showTxt.push(showTxt);
+                  if (planMap[item.id].index) {
+                    if (planMap[item.id].index > index)
+                      planMap[item.id].index = index;
+                  } else {
+                    planMap[item.id].index = index;
+                  }
                 } else {
-                  if (!planMap["null"]) planMap["null"] = { showTxt: [] };
+                  if (!planMap["null"]) planMap["null"] = { showTxt: [], index: 999 };
                   planMap.null.showTxt.push(showTxt);
                 }
               });
-              console.log(planMap, "planMap");
-              // 鏍规嵁鐝鍒嗙被鏄剧ず鏃堕棿
-              var html_ = "";
+              
+              // 鏍规嵁鐝鍒嗙被鏄剧ず鏃堕棿锛屽苟涓旀牴鎹懆涓�鍒板懆鏃ユ帓搴忥紝浼戞伅鏀惧湪鏈�鍚�
+              var infoList = [];
               Object.keys(planMap).forEach((key) => {
+                infoList.push(planMap[key])
+              });
+              infoList.sort((a, b) => a.index - b.index);
+              console.log(infoList, "infoList");
+              var html_ = "";
+              for (let i = 0; i < infoList.length; i++) {
+                const infoItem = infoList[i];
                 html_ +=
                   "<p>" +
-                  planMap[key].showTxt.join("銆�") +
+                    infoItem.showTxt.join("銆�") +
                   "锛�" +
-                  (planMap[key].times && planMap[key].times.length > 0
-                    ? planMap[key].times.map(
+                  (infoItem.times && infoItem.times.length > 0
+                    ? infoItem.times.map(
                         (item) => item.begin_time + " - " + item.end_time
                       )
                     : "浼戞伅") +
                   "</p>";
-              });
-              console.log(html_);
+              }
               
+              console.log(html_);
+
               return html_;
             }
           },

--
Gitblit v1.9.1