diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index d594740..b65b0ae 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -78,8 +78,16 @@ class Schedule extends Backend if ($this->request->isAjax()) { - $startDate = '2025-02-22'; - $endDate = '2025-03-22'; + $filter = $this->request->param('filter'); + $filter = json_decode($filter, true); + + $startDate = date('Y-m-01'); + $endDate = date('Y-m-t'); + + if (isset($filter['timetype']) && $filter['timetype'] == 2) { + $startDate = date('Y-m-d', strtotime('monday this week')); + $endDate = date('Y-m-d', strtotime('sunday this week')); + } $res = []; $admins = Db::name('admin')->field('id,nickname')->select(); @@ -127,13 +135,6 @@ class Schedule extends Backend $res = array_values($res); - - $filter = $this->request->param('filter'); - $filter = json_decode($filter, true); - if (isset($filter['timetype']) && $filter['timetype'] == 2) { - unset($res[2]); - } - $result = array("total" => count($res), "rows" => $res); return json($result); diff --git a/public/assets/js/backend/oa/schedule.js b/public/assets/js/backend/oa/schedule.js index 43fc936..0803dbd 100644 --- a/public/assets/js/backend/oa/schedule.js +++ b/public/assets/js/backend/oa/schedule.js @@ -71,18 +71,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin var table = $("#table"); - var columnArr = []; - columnArr.push({ + var defaultColumnArr = []; + defaultColumnArr.push({ "title":"username", "field":"name", }); - const startDate = new Date("2025-02-22"); - const endDate = new Date("2025-03-22"); + const startDate = new Date(new Date().setDate(1)); + const endDate = new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0); + + console.log('Start Date:', startDate); + console.log('End Date:', endDate); for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) { - let tmpDate = d.toISOString().split('T')[0]; // 使用 d,而不是 date - columnArr.push({ + let tmpDate = d.toISOString().split('T')[0]; + console.log('Current Date:', tmpDate); + defaultColumnArr.push({ "title": tmpDate, "field": tmpDate, }); @@ -91,7 +95,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, - columns: columnArr, + columns: defaultColumnArr, searchFormVisible: true, searchFormTemplate: 'customformtpl', }); @@ -109,13 +113,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin "title":"username", "field":"name", }]; - } else { - changeColumn = [{ - "title":"username", - "field":"name", - }]; - const startDate = new Date("2025-02-22"); - const endDate = new Date("2025-03-22"); + + const today = new Date(); + const startDate = new Date(today.setDate(today.getDate() - today.getDay() + 1)); // 星期一 + const endDate = new Date(today.setDate(today.getDate() - today.getDay() + 7)); // 星期天 for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) { let tmpDate = d.toISOString().split('T')[0]; // 使用 d,而不是 date @@ -124,6 +125,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin "field": tmpDate, }); } + + } else { + changeColumn = defaultColumnArr; } var options = table.bootstrapTable('getOptions');