From 47adcda0181044d1e15e5d580c18aaa3c74269b5 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Tue, 3 Jun 2025 17:00:32 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/Logic/NoticeLogic.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/application/common/Logic/NoticeLogic.php b/application/common/Logic/NoticeLogic.php index d6cb024..8f95ad4 100644 --- a/application/common/Logic/NoticeLogic.php +++ b/application/common/Logic/NoticeLogic.php @@ -51,18 +51,25 @@ class NoticeLogic $log->status = -1; $log->content = 'TTSID为空'; $log->save(); + return; } - $reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time())); + $status = config('alibaba_dyvms.status'); - if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){ - $log->status = 1; - $log->callId = $reponse->body->callId; - $log->save(); + if($status){ + $reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time())); + + if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){ + $log->status = 1; + $log->callId = $reponse->body->callId; + $log->save(); + }else{ + $log->status = -1; + $log->content = $reponse->body->message; + $log->save(); + } }else{ - $log->status = -1; - $log->content = $reponse->body->message; - $log->save(); + throw new Exception('语音通知服务未开启'); } }catch (Exception $exception){ $log->status = -1; From ee2d779f7193c13ba20586f8db0f6b13d7c86012 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 17:29:50 +0800 Subject: [PATCH 02/16] =?UTF-8?q?feature:=20=E6=8C=89=E9=92=AE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/oa/Schedule.php | 2 +- application/admin/controller/salary/Detail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 038f61e..3458adb 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -117,7 +117,7 @@ class Schedule extends Backend $res[$adminId][$tmpDate] = '无'; $res[$adminId]['admin_id'] = $adminId; $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['editable'] = $this->auth->isSuperAdmin() ? 1 : 0; + $res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_manage') ? 1 : 0; } $dates[] = $tmpDate; diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index a50f77f..6c52194 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -154,7 +154,7 @@ class Detail extends Backend return json($result); } - $this->assignconfig("manage", $this->auth->isSuperAdmin()); + $this->assignconfig("manage", $this->auth->check('salary/custom_manage')); $this->view->assign("month", $month); $this->view->assign("salaryitem", json_encode($salaryItem)); return $this->view->fetch(); From cf39aa4326729681ac5995e41ed917aaf24a8c33 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 18:06:40 +0800 Subject: [PATCH 03/16] =?UTF-8?q?feature:=20=E6=8C=89=E9=92=AE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/salary/Detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index 6c52194..cfbb1e0 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -154,7 +154,7 @@ class Detail extends Backend return json($result); } - $this->assignconfig("manage", $this->auth->check('salary/custom_manage')); + $this->assignconfig("manage", $this->auth->check('salary/detail/custom_manage')); $this->view->assign("month", $month); $this->view->assign("salaryitem", json_encode($salaryItem)); return $this->view->fetch(); From 049f771ce43aa24aafdbbb59de15c412ddca637c Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 22:52:28 +0800 Subject: [PATCH 04/16] feature: salary auth --- application/admin/controller/salary/Detail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index cfbb1e0..0f909de 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -154,7 +154,7 @@ class Detail extends Backend return json($result); } - $this->assignconfig("manage", $this->auth->check('salary/detail/custom_manage')); + $this->assignconfig("manage", $this->auth->check('salary/detail/custom_edit')); $this->view->assign("month", $month); $this->view->assign("salaryitem", json_encode($salaryItem)); return $this->view->fetch(); From 5f2033f90c69c573aed4a9b4f5e46d7c4a6f20e2 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 22:55:52 +0800 Subject: [PATCH 05/16] feature: salary auth --- application/admin/controller/oa/Schedule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 3458adb..184095c 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -117,7 +117,7 @@ class Schedule extends Backend $res[$adminId][$tmpDate] = '无'; $res[$adminId]['admin_id'] = $adminId; $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_manage') ? 1 : 0; + $res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_edit') ? 1 : 0; } $dates[] = $tmpDate; From b456b03c0651c7642bc6b0d54bdbf7523b536984 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 23:21:49 +0800 Subject: [PATCH 06/16] feature: salary menu --- .../admin/controller/salary/CustomDetail.php | 347 ++++++++++++++++++ .../admin/view/salary/custom_detail/add.html | 36 ++ .../admin/view/salary/custom_detail/edit.html | 38 ++ .../view/salary/custom_detail/index.html | 66 ++++ .../assets/js/backend/salary/custom_detail.js | 127 +++++++ 5 files changed, 614 insertions(+) create mode 100644 application/admin/controller/salary/CustomDetail.php create mode 100644 application/admin/view/salary/custom_detail/add.html create mode 100644 application/admin/view/salary/custom_detail/edit.html create mode 100644 application/admin/view/salary/custom_detail/index.html create mode 100644 public/assets/js/backend/salary/custom_detail.js diff --git a/application/admin/controller/salary/CustomDetail.php b/application/admin/controller/salary/CustomDetail.php new file mode 100644 index 0000000..a93b948 --- /dev/null +++ b/application/admin/controller/salary/CustomDetail.php @@ -0,0 +1,347 @@ +model = new \app\admin\model\salary\Detail; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + + $items = Db::name('salary_item')->field('id,attr,type,name')->select(); + + $salaryItem = []; + foreach ($items as $item) { + $idAttr[$item['id']] = $item['attr']; + if ($item['attr'] == 'JXKHJL') { + $salaryItem[] = [ + 'id' => 'jx_total', + 'name' => '绩效提成', + ]; + } + $salaryItem[] = [ + 'id' => 'item_' . $item['id'], + 'name' => $item['name'], + ]; + } + $salaryItem[] = [ + 'id' => 'total', + 'name' => '总计', + ]; + + $month = date('Y-m-01'); + + if ($this->request->isAjax()) { + + + $filter = $this->request->param('filter'); + $filter = json_decode($filter, true); + + if (!empty($filter['month'])) { + $month = $filter['month'] . '-01'; + } + + $res = []; + + if (!$this->auth->isSuperAdmin()) { + $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); + } else{ + $admins = Db::name('admin')->field('id,nickname')->select(); + } + + $admins = array_column($admins, NULL, 'id'); + $adminIds = array_keys($admins); + + $adminNames = array_column($admins, 'nickname', 'id'); + + $builder = $this->model + ->where('salary_month', '=', $month); + if (!$this->auth->isSuperAdmin()) { + $builder = $builder->where('target_admin_id', $this->auth->id); + } + + $queryData = $builder->select(); + $queryRes = []; + foreach ($queryData as $queryDatum) { + $targetAdminId = $queryDatum['target_admin_id']; + $itemId = $queryDatum['item_id']; + $queryRes[$targetAdminId][$itemId] = $queryDatum['item_value']; + } + + $querySettleData = Db::name('salary_settle') + ->whereIn('target_admin_id', $adminIds) + ->where('salary_month', '=', $month) + ->field('id,target_admin_id,settle_status') + ->select(); + $querySettleRes = []; + foreach ($querySettleData as $querySettleDatum) { + $targetAdminId = $querySettleDatum['target_admin_id']; + $querySettleRes[$targetAdminId] = $querySettleDatum['settle_status']; + } + + + foreach ($adminIds as $adminId) { + $attrValue = []; + $total = 0; + foreach ($items as $item) { + + $res[$adminId]['target_admin_id'] = $adminId; + $res[$adminId]['name'] = $adminNames[$adminId]; + $res[$adminId]['month'] = $month; + + $itemKey = 'item_' . $item['id']; + + $value = 0; + + if (!empty($queryRes[$adminId][$item['id']])) { + $value = $this->clean_number($queryRes[$adminId][$item['id']]); + $total = $this->calc_total($total, $item['type'], $queryRes[$adminId][$item['id']]); + } + + $attrValue[$item['attr']] = $value; + if ($item['attr'] == 'TD') { + $value = $value . '%'; + } + $res[$adminId][$itemKey] = $value; + } + + $jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100; + $res[$adminId]['jx_total'] = $this->clean_number($jxTotal); + $res[$adminId]['total'] = $this->clean_number($total + $jxTotal); + $res[$adminId]['settle_status'] = $querySettleRes[$adminId] ?? 0; + } + + $res = array_values($res); + + $result = array("total" => count($res), "rows" => $res); + + + return json($result); + } + + $this->assignconfig("manage", $this->auth->check('salary/custom_detail/edit')); + $this->view->assign("month", $month); + $this->view->assign("salaryitem", json_encode($salaryItem)); + return $this->view->fetch(); + } + + public function calc_total($total, $type, $value){ + if ($type == 1) { + return $total + $value; + } + if ($type == 2) { + return $total - $value; + } + + return $total; + } + + public function clean_number($num): string { + return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.'); + } + + public function add() + { + + if (false === $this->request->isPost()) { + + $items = Db::name('salary_item')->field('id,type,name')->select(); + + $typeMap = [ + 1 => '应发工资', + 2 => '应扣款项', + 3 => '其他' + ]; + $groupedItems = []; + foreach ($items as $item) { + $type = $item['type']; + $label = $typeMap[$type]; + $groupedItems[$label][] = $item; + } + + $this->view->assign('groupedItems', $groupedItems); + $this->view->assign('items', $items); + return $this->view->fetch(); + } + + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + + + $month = $params['salary_month'] . '-01'; + $targetAdminId = $params['target_admin_id']; + $salaryDetails = []; + + foreach ($params as $k => $v) { + if (!str_contains($k, 'item')) { + continue; + } + $salaryDetails[] = [ + 'target_admin_id' => $targetAdminId, + 'salary_month' => $month, + 'item_id' => explode('_', $k)[1], + 'item_value' => $v, + ]; + } + + Db::name('salary_detail') + ->where('salary_month', $month) + ->where('target_admin_id', $targetAdminId) + ->delete(); + + Db::name('salary_detail') + ->insertAll($salaryDetails); + + $this->success(); + } + + + public function edit() + { + + if (false === $this->request->isPost()) { + + + $targetAdminId = $this->request->get('target_admin_id'); + $month = $this->request->get('month'); + + $row['salary_month'] = $month; + $row['target_admin_id'] = $targetAdminId; + + + $queryData = $this->model + ->where('salary_month', '=', $month) + ->where('target_admin_id', $targetAdminId) + ->select(); + $items = Db::name('salary_item')->field('id,name,type')->select(); + $queryData = array_column($queryData, NULL, 'item_id'); + + foreach ($items as $item) { + $itemKey = 'item_' . $item['id']; + $row[$itemKey] = !empty($queryData[$item['id']]) ? $queryData[$item['id']]['item_value'] : 0; + } + + $typeMap = [ + 1 => '应发工资', + 2 => '应扣款项', + 3 => '其他' + ]; + $groupedItems = []; + foreach ($items as $item) { + $type = $item['type']; + $label = $typeMap[$type]; + $groupedItems[$label][] = $item; + } + + $this->view->assign('groupedItems', $groupedItems); + $this->view->assign('items', $items); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + + + $month = $params['salary_month'] . '-01'; + $targetAdminId = $params['target_admin_id']; + $salaryDetails = []; + + foreach ($params as $k => $v) { + if (!str_contains($k, 'item')) { + continue; + } + $salaryDetails[] = [ + 'target_admin_id' => $targetAdminId, + 'salary_month' => $month, + 'item_id' => explode('_', $k)[1], + 'item_value' => $v, + ]; + } + + Db::name('salary_detail') + ->where('salary_month', $month) + ->where('target_admin_id', $targetAdminId) + ->delete(); + + Db::name('salary_detail') + ->insertAll($salaryDetails); + + $this->success(); + } + + + public function settle() + { + if (false === $this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + + $targetAdminId = $this->request->get('target_admin_id'); + $month = $this->request->get('month'); + + + $settle = Db::name('salary_settle') + ->where('salary_month', $month) + ->where('target_admin_id', $targetAdminId) + ->field('target_admin_id,salary_month')->find(); + if (!empty($settle)) { + Db::name('salary_settle') + ->where('salary_month', $month) + ->where('target_admin_id', $targetAdminId) + ->save([ + 'settle_status' => 1, + ]); + $this->success(); + } + + Db::name('salary_settle')->insert([ + 'target_admin_id' => $targetAdminId, + 'salary_month' => $month, + 'settle_status' => 1, + ]); + + $this->success(); + } + + +} diff --git a/application/admin/view/salary/custom_detail/add.html b/application/admin/view/salary/custom_detail/add.html new file mode 100644 index 0000000..25e6326 --- /dev/null +++ b/application/admin/view/salary/custom_detail/add.html @@ -0,0 +1,36 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ {foreach $groupedItems as $groupName => $group} +
+ +
+ + {foreach $group as $index => $item} + {if $index % 2 == 0}
{/if} + +
+ +
+ {if $index % 2 == 1 || $index == count($group) - 1}
{/if} + {/foreach} + {/foreach} + + +
diff --git a/application/admin/view/salary/custom_detail/edit.html b/application/admin/view/salary/custom_detail/edit.html new file mode 100644 index 0000000..5a2ad7b --- /dev/null +++ b/application/admin/view/salary/custom_detail/edit.html @@ -0,0 +1,38 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ {foreach $groupedItems as $groupName => $group} +
+ +
+ + {foreach $group as $index => $item} + {if $index % 2 == 0}
{/if} + +
+ +
+ {if $index % 2 == 1 || $index == count($group) - 1}
{/if} + {/foreach} + {/foreach} + + + + +
diff --git a/application/admin/view/salary/custom_detail/index.html b/application/admin/view/salary/custom_detail/index.html new file mode 100644 index 0000000..0f97a48 --- /dev/null +++ b/application/admin/view/salary/custom_detail/index.html @@ -0,0 +1,66 @@ +
+ {:build_heading()} + + + + + +
+
+
+
+
+ + {:__('Add')} + + + + + +
+ +
+
+
+ +
+
+
+ + diff --git a/public/assets/js/backend/salary/custom_detail.js b/public/assets/js/backend/salary/custom_detail.js new file mode 100644 index 0000000..0cc7872 --- /dev/null +++ b/public/assets/js/backend/salary/custom_detail.js @@ -0,0 +1,127 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { +// 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'salary/custom_detail/index' + location.search, + add_url: 'salary/custom_detail/add', + // del_url: 'oa/schedule/del', + // multi_url: 'oa/schedule/multi', + // import_url: 'oa/schedule/import', + table: 'salary', + } + }); + + var table = $("#table"); + + var defaultColumnArr = []; + defaultColumnArr.push({ + "title":"用户名", + "field":"name", + },{ + "title":"用户id", + "field":"target_admin_id", + "visible":false + }); + + + // 获取后端传入的字段定义(JSON 字符串) + + var columnJson = $('#salaryitem').val(); + var rawColumns = JSON.parse(columnJson); + rawColumns.forEach(function (item) { + // 可以加入格式化、样式控制等逻辑 + defaultColumnArr.push({ + field: item.id, + title: item.name, + }); + }); + + defaultColumnArr.push({ + field: 'operate', + title: __('Operate'), + table: table, + buttons: [ + { + name: 'edit', + text: '编辑', + title: '编辑', + classname: 'btn btn-xs btn-success btn-dialog', + icon: 'fa fa-edit', + url: function (row) { + // 注意这里拼接 admin_id 和 month + return 'salary/custom_detail/edit?target_admin_id=' + row.target_admin_id + '&month=' + row.month; + }, + extend: 'data-area=\'["800px", "600px"]\'', + visible:function(row){ + if (!Config.manage) { + return false; + } + return true; + } + }, + { + name: 'complete', + text:"结算", + title:"结算", + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-success btn-magic btn-ajax', + icon: 'fa fa-cny', + url: function (row) { + // 注意这里拼接 admin_id 和 month + return 'salary/detail/settle?target_admin_id=' + row.target_admin_id + '&month=' + row.month; + }, + confirm: '确认结算?', + refresh: true, + success: function (data, ret) { + $("#table").bootstrapTable('refresh'); + return false; + }, + error: function (data, ret) { + Layer.alert(ret.msg); + return false; + }, + visible: function (row) { + if (!Config.manage) { + return false; + } + //返回true时按钮显示,返回false隐藏 + if (row.settle_status != 1) { + return true; + } + return false; + } + }, + ], + events: Table.api.events.operate, + formatter: Table.api.formatter.operate + }); + + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + columns: defaultColumnArr, + searchFormVisible: true, + searchFormTemplate: 'customformtpl', + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); From 673751c5bdc15389041b7daffd885e0ac966276b Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 23:29:10 +0800 Subject: [PATCH 07/16] feature: salary menu --- application/admin/controller/salary/CustomDetail.php | 2 +- public/assets/js/backend/salary/custom_detail.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/salary/CustomDetail.php b/application/admin/controller/salary/CustomDetail.php index a93b948..ddad4b7 100644 --- a/application/admin/controller/salary/CustomDetail.php +++ b/application/admin/controller/salary/CustomDetail.php @@ -233,7 +233,7 @@ class CustomDetail extends Backend } - public function edit() + public function edit($ids = null) { if (false === $this->request->isPost()) { diff --git a/public/assets/js/backend/salary/custom_detail.js b/public/assets/js/backend/salary/custom_detail.js index 0cc7872..869dbb7 100644 --- a/public/assets/js/backend/salary/custom_detail.js +++ b/public/assets/js/backend/salary/custom_detail.js @@ -45,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin table: table, buttons: [ { - name: 'edit', + name: 'myedit', text: '编辑', title: '编辑', classname: 'btn btn-xs btn-success btn-dialog', From 137695c02a21572b5e6a25c2e832de7dcec3fa4e Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 23:30:42 +0800 Subject: [PATCH 08/16] feature: salary menu --- .../admin/lang/zh-cn/salary/custom_detail.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 application/admin/lang/zh-cn/salary/custom_detail.php diff --git a/application/admin/lang/zh-cn/salary/custom_detail.php b/application/admin/lang/zh-cn/salary/custom_detail.php new file mode 100644 index 0000000..ff16568 --- /dev/null +++ b/application/admin/lang/zh-cn/salary/custom_detail.php @@ -0,0 +1,12 @@ + 'ID', + 'Admin_id' => '创建人', + 'Target_admin_id' => '工资归属人', + 'Item_id' => '指标id', + 'Item_value' => '值', + 'Salary_month' => '工资月份', + 'Create_time' => '创建时间', + 'Update_time' => '编辑时间' +]; From 45172a0f6dd6d6de4dac5266ba13528f86b5ee74 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Tue, 3 Jun 2025 23:31:46 +0800 Subject: [PATCH 09/16] feature: salary menu --- application/admin/controller/salary/CustomDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/salary/CustomDetail.php b/application/admin/controller/salary/CustomDetail.php index ddad4b7..27207d2 100644 --- a/application/admin/controller/salary/CustomDetail.php +++ b/application/admin/controller/salary/CustomDetail.php @@ -78,7 +78,7 @@ class CustomDetail extends Backend $res = []; - if (!$this->auth->isSuperAdmin()) { + if (!$this->auth->check('salary/custom_detail/edit')) { $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); } else{ $admins = Db::name('admin')->field('id,nickname')->select(); From 4ead5dab34510c2bb8e777a7918443d4e98cde7e Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 09:21:04 +0800 Subject: [PATCH 10/16] feature: auth --- .../admin/controller/oa/CustomSchedule.php | 286 ++++++++++++++++++ .../admin/lang/zh-cn/custom_schedule.php | 30 ++ .../admin/view/oa/custom_schedule/add.html | 33 ++ .../admin/view/oa/custom_schedule/edit.html | 33 ++ .../admin/view/oa/custom_schedule/index.html | 52 ++++ .../assets/js/backend/oa/custom_schedule.js | 155 ++++++++++ 6 files changed, 589 insertions(+) create mode 100644 application/admin/controller/oa/CustomSchedule.php create mode 100644 application/admin/lang/zh-cn/custom_schedule.php create mode 100644 application/admin/view/oa/custom_schedule/add.html create mode 100644 application/admin/view/oa/custom_schedule/edit.html create mode 100644 application/admin/view/oa/custom_schedule/index.html create mode 100644 public/assets/js/backend/oa/custom_schedule.js diff --git a/application/admin/controller/oa/CustomSchedule.php b/application/admin/controller/oa/CustomSchedule.php new file mode 100644 index 0000000..c17f142 --- /dev/null +++ b/application/admin/controller/oa/CustomSchedule.php @@ -0,0 +1,286 @@ +model = new \app\admin\model\oa\Schedule; + $this->view->assign("typeList", $this->model->getTypeList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + + + $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 = []; + + if (!$this->auth->isSuperAdmin()) { + $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); + } else{ + $admins = Db::name('admin')->field('id,nickname')->select(); + } + + $admins = array_column($admins, NULL, 'id'); + $adminIds = array_keys($admins); + + $adminNames = array_column($admins, 'nickname', 'id'); + + $tmpDate = $startDate; + $dates = []; + while(true) { + + if ($tmpDate > $endDate) { + break; + } + + foreach ($adminIds as $adminId) { + $res[$adminId][$tmpDate] = '无'; + $res[$adminId]['admin_id'] = $adminId; + $res[$adminId]['name'] = $adminNames[$adminId]; + $res[$adminId]['editable'] = $this->auth->check('oa/custom_schedule/edit') ? 1 : 0; + } + + $dates[] = $tmpDate; + $tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400); + } + + $builder = $this->model + ->with([ + 'admin' + ]) + ->where('date', '>=', $startDate) + ->where('date', '<=', $endDate); + + if (!$this->auth->isSuperAdmin()) { + $builder = $builder->where('exec_admin_id', $this->auth->id); + } + + $queryData = $builder->select(); + foreach ($queryData as $queryDatum) { + $queryDatum = $queryDatum->toArray(); + + $adminId = $queryDatum['admin']['id']; + $date = $queryDatum['date']; + $type = $queryDatum['type']; + + if (isset($res[$adminId][$date])) { + $res[$adminId][$date] = $this->model->getTypeList()[$type]; + } + } + + + $res = array_values($res); + + $result = array("total" => count($res), "rows" => $res); + + return json($result); + } + + $timeType = [ + 1 => '本月排班', + 2 => '本周排班', + ]; + $this->view->assign("timetype", $timeType); + return $this->view->fetch(); + } + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + + + $params['create_time'] = date('Y-m-d H:i:s'); + $params['update_time'] = date('Y-m-d H:i:s'); + + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + + + $params['update_time'] = date('Y-m-d H:i:s'); + + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + + public function editable() + { + + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + + + $date = $params['field']; + $adminId = $params['admin_id']; + + $value = $params[$date] ?? '无'; + $valueMap = [ + '无' => 0, + '早班' => 1, + '中班' => 2, + '晚班' => 3, + '行政班' => 4, + ]; + + if ($value == '无') { + $this->model->where('exec_admin_id', $adminId)->delete(); + $this->success(); + } + + $dbValue = $valueMap[$value]; + + $data = $this->model + ->where('date', '=', $date) + ->where('exec_admin_id', '=', $adminId) + ->find(); + + $nowTime = date('Y-m-d H:i:s'); + if (!empty($data)) { + $data->save([ + "date" => $date, + "exec_admin_id" => $adminId, + "type" => $dbValue, + "update_time" => $nowTime, + ]); + } + + $this->model->insert([ + "date" => $date, + "exec_admin_id" => $adminId, + "type" => $dbValue, + "create_time" => $nowTime, + "update_time" => $nowTime, + ]); + + $this->success(); + } +} diff --git a/application/admin/lang/zh-cn/custom_schedule.php b/application/admin/lang/zh-cn/custom_schedule.php new file mode 100644 index 0000000..861d3ba --- /dev/null +++ b/application/admin/lang/zh-cn/custom_schedule.php @@ -0,0 +1,30 @@ + 'ID', + 'Admin_id' => '创建人', + 'Exec_admin_id' => '执行人', + 'Type' => '任务类型', + 'Type 1' => '早班', + 'Type 2' => '中班', + 'Type 3' => '晚班', + 'Type 4' => '行政班', + 'Date' => '日期', + 'Create_time' => '创建时间', + 'Update_time' => '编辑时间', + 'Admin.id' => 'ID', + 'Admin.username' => '用户名', + 'Admin.nickname' => '昵称', + 'Admin.password' => '密码', + 'Admin.salt' => '密码盐', + 'Admin.avatar' => '头像', + 'Admin.email' => '电子邮箱', + 'Admin.mobile' => '手机号码', + 'Admin.loginfailure' => '失败次数', + 'Admin.logintime' => '登录时间', + 'Admin.loginip' => '登录IP', + 'Admin.createtime' => '创建时间', + 'Admin.updatetime' => '更新时间', + 'Admin.token' => 'Session标识', + 'Admin.status' => '状态' +]; diff --git a/application/admin/view/oa/custom_schedule/add.html b/application/admin/view/oa/custom_schedule/add.html new file mode 100644 index 0000000..cd4d268 --- /dev/null +++ b/application/admin/view/oa/custom_schedule/add.html @@ -0,0 +1,33 @@ +
+ +
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/oa/custom_schedule/edit.html b/application/admin/view/oa/custom_schedule/edit.html new file mode 100644 index 0000000..1634edf --- /dev/null +++ b/application/admin/view/oa/custom_schedule/edit.html @@ -0,0 +1,33 @@ +
+ +
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/oa/custom_schedule/index.html b/application/admin/view/oa/custom_schedule/index.html new file mode 100644 index 0000000..9b6bbbb --- /dev/null +++ b/application/admin/view/oa/custom_schedule/index.html @@ -0,0 +1,52 @@ +
+ {:build_heading()} + +
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+ diff --git a/public/assets/js/backend/oa/custom_schedule.js b/public/assets/js/backend/oa/custom_schedule.js new file mode 100644 index 0000000..a09e540 --- /dev/null +++ b/public/assets/js/backend/oa/custom_schedule.js @@ -0,0 +1,155 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'oa/custom_schedule/index' + location.search, + // add_url: 'oa/schedule/add', + editable: 'oa/custom_schedule/editable', + // del_url: 'oa/schedule/del', + // multi_url: 'oa/schedule/multi', + // import_url: 'oa/schedule/import', + table: 'schedule', + } + }); + + var table = $("#table"); + + var defaultColumnArr = []; + defaultColumnArr.push({ + "title":"用户名", + "field":"name", + },{ + "title":"用户id", + "field":"admin_id", + "visible":false + }); + + const startDate = new Date(); + startDate.setDate(1); + startDate.setHours(0, 0, 0, 0); + + const endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0); + endDate.setHours(0, 0, 0, 0); + + for (let d = new Date(startDate); d <= endDate; ) { + const current = new Date(d); // 深拷贝 + const tmpDate = current.toLocaleDateString('sv-SE'); + + console.log('Current Date:', tmpDate); + defaultColumnArr.push({ + "title": tmpDate, + "field": tmpDate, + "editable" :{ + type: 'select', + pk: 1, + source: [ + {value: '无', text: '无'}, + {value: '早班', text: '早班'}, + {value: '中班', text: '中班'}, + {value: '晚班', text: '晚班'}, + {value: '行政班', text: '行政班'}, + ], + noeditFormatter: function (value, row, index) { + if (row.editable === 1) { + return false; + } else { + return value; + } + }, + } + }); + + d.setDate(d.getDate() + 1); // 最后再改 d 的值 + } + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + columns: defaultColumnArr, + searchFormVisible: true, + searchFormTemplate: 'customformtpl', + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + + $(document).on("click", ".btn-block", function () { + + let selectedValue = $('#c-flag').val(); + + let changeColumn = []; + if (selectedValue == 2) { + changeColumn = [{ + "title":"用户名", + "field":"name", + },{ + "title":"用户id", + "field":"admin_id", + "visible":false + }]; + + 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 + changeColumn.push({ + "title": tmpDate, + "field": tmpDate, + "editable" :{ + type: 'select', + pk: 1, + source: [ + {value: '无', text: '无'}, + {value: '早班', text: '早班'}, + {value: '中班', text: '中班'}, + {value: '晚班', text: '晚班'}, + {value: '行政班', text: '行政班'}, + ] + } + }); + } + + } else { + changeColumn = defaultColumnArr; + } + + var options = table.bootstrapTable('getOptions'); + var queryParams = options.queryParams; + options.queryParams = function (params) { + //这一行必须要存在,否则在点击下一页时会丢失搜索栏数据 + params = queryParams(params); + + var filter = params.filter ? JSON.parse(params.filter) : {}; + filter.timetype = selectedValue; + + params.filter = JSON.stringify(filter); + return params; + }; + + table.bootstrapTable('refreshOptions', { + columns: changeColumn, + }); + + $('#c-flag').val(selectedValue).change(); + return false; + }); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); From 32848f79e8f2f5ad9c1ee54ef1ff791265fe0b21 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 09:26:37 +0800 Subject: [PATCH 11/16] =?UTF-8?q?feature:=20=E6=8C=89=E9=92=AE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/oa/CustomSchedule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controller/oa/CustomSchedule.php b/application/admin/controller/oa/CustomSchedule.php index c17f142..b8ea402 100644 --- a/application/admin/controller/oa/CustomSchedule.php +++ b/application/admin/controller/oa/CustomSchedule.php @@ -60,7 +60,7 @@ class CustomSchedule extends Backend $res = []; - if (!$this->auth->isSuperAdmin()) { + if (!$this->auth->check('oa/custom_schedule/edit')) { $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); } else{ $admins = Db::name('admin')->field('id,nickname')->select(); From a339bdf316bd5326b22995e9526da830f3840426 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 09:29:26 +0800 Subject: [PATCH 12/16] feature: auth --- application/admin/controller/oa/Schedule.php | 147 ---------- .../admin/controller/salary/Detail.php | 258 ------------------ .../admin/view/oa/schedule/custom_index.html | 52 ---- .../admin/view/salary/detail/custom_add.html | 36 --- .../admin/view/salary/detail/custom_edit.html | 38 --- .../view/salary/detail/custom_index.html | 66 ----- public/assets/js/backend/oa/schedule.js | 138 ---------- public/assets/js/backend/salary/detail.js | 116 -------- 8 files changed, 851 deletions(-) delete mode 100644 application/admin/view/oa/schedule/custom_index.html delete mode 100644 application/admin/view/salary/detail/custom_add.html delete mode 100644 application/admin/view/salary/detail/custom_edit.html delete mode 100644 application/admin/view/salary/detail/custom_index.html diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 184095c..d4955db 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -72,98 +72,6 @@ class Schedule extends Backend return $this->view->fetch(); } - public function custom_index() - { - //当前是否为关联查询 - $this->relationSearch = true; - //设置过滤方法 - $this->request->filter(['strip_tags', 'trim']); - if ($this->request->isAjax()) { - - - $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 = []; - - if (!$this->auth->isSuperAdmin()) { - $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); - } else{ - $admins = Db::name('admin')->field('id,nickname')->select(); - } - - $admins = array_column($admins, NULL, 'id'); - $adminIds = array_keys($admins); - - $adminNames = array_column($admins, 'nickname', 'id'); - - $tmpDate = $startDate; - $dates = []; - while(true) { - - if ($tmpDate > $endDate) { - break; - } - - foreach ($adminIds as $adminId) { - $res[$adminId][$tmpDate] = '无'; - $res[$adminId]['admin_id'] = $adminId; - $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_edit') ? 1 : 0; - } - - $dates[] = $tmpDate; - $tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400); - } - - $builder = $this->model - ->with([ - 'admin' - ]) - ->where('date', '>=', $startDate) - ->where('date', '<=', $endDate); - - if (!$this->auth->isSuperAdmin()) { - $builder = $builder->where('exec_admin_id', $this->auth->id); - } - - $queryData = $builder->select(); - foreach ($queryData as $queryDatum) { - $queryDatum = $queryDatum->toArray(); - - $adminId = $queryDatum['admin']['id']; - $date = $queryDatum['date']; - $type = $queryDatum['type']; - - if (isset($res[$adminId][$date])) { - $res[$adminId][$date] = $this->model->getTypeList()[$type]; - } - } - - - $res = array_values($res); - - $result = array("total" => count($res), "rows" => $res); - - return json($result); - } - - $timeType = [ - 1 => '本月排班', - 2 => '本周排班', - ]; - $this->view->assign("timetype", $timeType); - return $this->view->fetch(); - } - /** * 添加 * @@ -262,59 +170,4 @@ class Schedule extends Backend } $this->success(); } - - - public function editable() - { - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $date = $params['field']; - $adminId = $params['admin_id']; - - $value = $params[$date] ?? '无'; - $valueMap = [ - '无' => 0, - '早班' => 1, - '中班' => 2, - '晚班' => 3, - '行政班' => 4, - ]; - - if ($value == '无') { - $this->model->where('exec_admin_id', $adminId)->delete(); - $this->success(); - } - - $dbValue = $valueMap[$value]; - - $data = $this->model - ->where('date', '=', $date) - ->where('exec_admin_id', '=', $adminId) - ->find(); - - $nowTime = date('Y-m-d H:i:s'); - if (!empty($data)) { - $data->save([ - "date" => $date, - "exec_admin_id" => $adminId, - "type" => $dbValue, - "update_time" => $nowTime, - ]); - } - - $this->model->insert([ - "date" => $date, - "exec_admin_id" => $adminId, - "type" => $dbValue, - "create_time" => $nowTime, - "update_time" => $nowTime, - ]); - - $this->success(); - } } diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index 0f909de..745ce72 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -36,130 +36,6 @@ class Detail extends Backend * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ - public function custom_index() - { - //当前是否为关联查询 - $this->relationSearch = true; - //设置过滤方法 - $this->request->filter(['strip_tags', 'trim']); - - $items = Db::name('salary_item')->field('id,attr,type,name')->select(); - - $salaryItem = []; - foreach ($items as $item) { - $idAttr[$item['id']] = $item['attr']; - if ($item['attr'] == 'JXKHJL') { - $salaryItem[] = [ - 'id' => 'jx_total', - 'name' => '绩效提成', - ]; - } - $salaryItem[] = [ - 'id' => 'item_' . $item['id'], - 'name' => $item['name'], - ]; - } - $salaryItem[] = [ - 'id' => 'total', - 'name' => '总计', - ]; - - $month = date('Y-m-01'); - - if ($this->request->isAjax()) { - - - $filter = $this->request->param('filter'); - $filter = json_decode($filter, true); - - if (!empty($filter['month'])) { - $month = $filter['month'] . '-01'; - } - - $res = []; - - if (!$this->auth->isSuperAdmin()) { - $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); - } else{ - $admins = Db::name('admin')->field('id,nickname')->select(); - } - - $admins = array_column($admins, NULL, 'id'); - $adminIds = array_keys($admins); - - $adminNames = array_column($admins, 'nickname', 'id'); - - $builder = $this->model - ->where('salary_month', '=', $month); - if (!$this->auth->isSuperAdmin()) { - $builder = $builder->where('target_admin_id', $this->auth->id); - } - - $queryData = $builder->select(); - $queryRes = []; - foreach ($queryData as $queryDatum) { - $targetAdminId = $queryDatum['target_admin_id']; - $itemId = $queryDatum['item_id']; - $queryRes[$targetAdminId][$itemId] = $queryDatum['item_value']; - } - - $querySettleData = Db::name('salary_settle') - ->whereIn('target_admin_id', $adminIds) - ->where('salary_month', '=', $month) - ->field('id,target_admin_id,settle_status') - ->select(); - $querySettleRes = []; - foreach ($querySettleData as $querySettleDatum) { - $targetAdminId = $querySettleDatum['target_admin_id']; - $querySettleRes[$targetAdminId] = $querySettleDatum['settle_status']; - } - - - foreach ($adminIds as $adminId) { - $attrValue = []; - $total = 0; - foreach ($items as $item) { - - $res[$adminId]['target_admin_id'] = $adminId; - $res[$adminId]['name'] = $adminNames[$adminId]; - $res[$adminId]['month'] = $month; - - $itemKey = 'item_' . $item['id']; - - $value = 0; - - if (!empty($queryRes[$adminId][$item['id']])) { - $value = $this->clean_number($queryRes[$adminId][$item['id']]); - $total = $this->calc_total($total, $item['type'], $queryRes[$adminId][$item['id']]); - } - - $attrValue[$item['attr']] = $value; - if ($item['attr'] == 'TD') { - $value = $value . '%'; - } - $res[$adminId][$itemKey] = $value; - } - - $jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100; - $res[$adminId]['jx_total'] = $this->clean_number($jxTotal); - $res[$adminId]['total'] = $this->clean_number($total + $jxTotal); - $res[$adminId]['settle_status'] = $querySettleRes[$adminId] ?? 0; - } - - $res = array_values($res); - - $result = array("total" => count($res), "rows" => $res); - - - return json($result); - } - - $this->assignconfig("manage", $this->auth->check('salary/detail/custom_edit')); - $this->view->assign("month", $month); - $this->view->assign("salaryitem", json_encode($salaryItem)); - return $this->view->fetch(); - } - public function calc_total($total, $type, $value){ if ($type == 1) { return $total + $value; @@ -175,140 +51,6 @@ class Detail extends Backend return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.'); } - public function custom_add() - { - - if (false === $this->request->isPost()) { - - $items = Db::name('salary_item')->field('id,type,name')->select(); - - $typeMap = [ - 1 => '应发工资', - 2 => '应扣款项', - 3 => '其他' - ]; - $groupedItems = []; - foreach ($items as $item) { - $type = $item['type']; - $label = $typeMap[$type]; - $groupedItems[$label][] = $item; - } - - $this->view->assign('groupedItems', $groupedItems); - $this->view->assign('items', $items); - return $this->view->fetch(); - } - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $month = $params['salary_month'] . '-01'; - $targetAdminId = $params['target_admin_id']; - $salaryDetails = []; - - foreach ($params as $k => $v) { - if (!str_contains($k, 'item')) { - continue; - } - $salaryDetails[] = [ - 'target_admin_id' => $targetAdminId, - 'salary_month' => $month, - 'item_id' => explode('_', $k)[1], - 'item_value' => $v, - ]; - } - - Db::name('salary_detail') - ->where('salary_month', $month) - ->where('target_admin_id', $targetAdminId) - ->delete(); - - Db::name('salary_detail') - ->insertAll($salaryDetails); - - $this->success(); - } - - - public function custom_edit() - { - - if (false === $this->request->isPost()) { - - - $targetAdminId = $this->request->get('target_admin_id'); - $month = $this->request->get('month'); - - $row['salary_month'] = $month; - $row['target_admin_id'] = $targetAdminId; - - - $queryData = $this->model - ->where('salary_month', '=', $month) - ->where('target_admin_id', $targetAdminId) - ->select(); - $items = Db::name('salary_item')->field('id,name,type')->select(); - $queryData = array_column($queryData, NULL, 'item_id'); - - foreach ($items as $item) { - $itemKey = 'item_' . $item['id']; - $row[$itemKey] = !empty($queryData[$item['id']]) ? $queryData[$item['id']]['item_value'] : 0; - } - - $typeMap = [ - 1 => '应发工资', - 2 => '应扣款项', - 3 => '其他' - ]; - $groupedItems = []; - foreach ($items as $item) { - $type = $item['type']; - $label = $typeMap[$type]; - $groupedItems[$label][] = $item; - } - - $this->view->assign('groupedItems', $groupedItems); - $this->view->assign('items', $items); - $this->view->assign('row', $row); - return $this->view->fetch(); - } - - $params = $this->request->post('row/a'); - if (empty($params)) { - $this->error(__('Parameter %s can not be empty', '')); - } - - - $month = $params['salary_month'] . '-01'; - $targetAdminId = $params['target_admin_id']; - $salaryDetails = []; - - foreach ($params as $k => $v) { - if (!str_contains($k, 'item')) { - continue; - } - $salaryDetails[] = [ - 'target_admin_id' => $targetAdminId, - 'salary_month' => $month, - 'item_id' => explode('_', $k)[1], - 'item_value' => $v, - ]; - } - - Db::name('salary_detail') - ->where('salary_month', $month) - ->where('target_admin_id', $targetAdminId) - ->delete(); - - Db::name('salary_detail') - ->insertAll($salaryDetails); - - $this->success(); - } - public function settle() { diff --git a/application/admin/view/oa/schedule/custom_index.html b/application/admin/view/oa/schedule/custom_index.html deleted file mode 100644 index 9b6bbbb..0000000 --- a/application/admin/view/oa/schedule/custom_index.html +++ /dev/null @@ -1,52 +0,0 @@ -
- {:build_heading()} - -
-
-
-
-
- -
- -
-
-
- -
-
-
- diff --git a/application/admin/view/salary/detail/custom_add.html b/application/admin/view/salary/detail/custom_add.html deleted file mode 100644 index 25e6326..0000000 --- a/application/admin/view/salary/detail/custom_add.html +++ /dev/null @@ -1,36 +0,0 @@ -
- -
- -
- -
-
-
- -
- -
-
- {foreach $groupedItems as $groupName => $group} -
- -
- - {foreach $group as $index => $item} - {if $index % 2 == 0}
{/if} - -
- -
- {if $index % 2 == 1 || $index == count($group) - 1}
{/if} - {/foreach} - {/foreach} - - -
diff --git a/application/admin/view/salary/detail/custom_edit.html b/application/admin/view/salary/detail/custom_edit.html deleted file mode 100644 index 5a2ad7b..0000000 --- a/application/admin/view/salary/detail/custom_edit.html +++ /dev/null @@ -1,38 +0,0 @@ -
- -
- -
- -
-
-
- -
- -
-
- {foreach $groupedItems as $groupName => $group} -
- -
- - {foreach $group as $index => $item} - {if $index % 2 == 0}
{/if} - -
- -
- {if $index % 2 == 1 || $index == count($group) - 1}
{/if} - {/foreach} - {/foreach} - - - - -
diff --git a/application/admin/view/salary/detail/custom_index.html b/application/admin/view/salary/detail/custom_index.html deleted file mode 100644 index 83776f6..0000000 --- a/application/admin/view/salary/detail/custom_index.html +++ /dev/null @@ -1,66 +0,0 @@ -
- {:build_heading()} - - - - - -
-
-
-
-
- - {:__('Add')} - - - - - -
- -
-
-
- -
-
-
- - diff --git a/public/assets/js/backend/oa/schedule.js b/public/assets/js/backend/oa/schedule.js index 777dd23..79aee53 100644 --- a/public/assets/js/backend/oa/schedule.js +++ b/public/assets/js/backend/oa/schedule.js @@ -39,144 +39,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function // 为表格绑定事件 Table.api.bindevent(table); }, - custom_index: function () { - // 初始化表格参数配置 - Table.api.init({ - extend: { - index_url: 'oa/schedule/custom_index' + location.search, - // add_url: 'oa/schedule/add', - editable: 'oa/schedule/editable', - // del_url: 'oa/schedule/del', - // multi_url: 'oa/schedule/multi', - // import_url: 'oa/schedule/import', - table: 'schedule', - } - }); - - var table = $("#table"); - - var defaultColumnArr = []; - defaultColumnArr.push({ - "title":"用户名", - "field":"name", - },{ - "title":"用户id", - "field":"admin_id", - "visible":false - }); - - const startDate = new Date(); - startDate.setDate(1); - startDate.setHours(0, 0, 0, 0); - - const endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0); - endDate.setHours(0, 0, 0, 0); - - for (let d = new Date(startDate); d <= endDate; ) { - const current = new Date(d); // 深拷贝 - const tmpDate = current.toLocaleDateString('sv-SE'); - - console.log('Current Date:', tmpDate); - defaultColumnArr.push({ - "title": tmpDate, - "field": tmpDate, - "editable" :{ - type: 'select', - pk: 1, - source: [ - {value: '无', text: '无'}, - {value: '早班', text: '早班'}, - {value: '中班', text: '中班'}, - {value: '晚班', text: '晚班'}, - {value: '行政班', text: '行政班'}, - ], - noeditFormatter: function (value, row, index) { - if (row.editable === 1) { - return false; - } else { - return value; - } - }, - } - }); - - d.setDate(d.getDate() + 1); // 最后再改 d 的值 - } - - // 初始化表格 - table.bootstrapTable({ - url: $.fn.bootstrapTable.defaults.extend.index_url, - columns: defaultColumnArr, - searchFormVisible: true, - searchFormTemplate: 'customformtpl', - }); - - // 为表格绑定事件 - Table.api.bindevent(table); - - $(document).on("click", ".btn-block", function () { - - let selectedValue = $('#c-flag').val(); - - let changeColumn = []; - if (selectedValue == 2) { - changeColumn = [{ - "title":"用户名", - "field":"name", - },{ - "title":"用户id", - "field":"admin_id", - "visible":false - }]; - - 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 - changeColumn.push({ - "title": tmpDate, - "field": tmpDate, - "editable" :{ - type: 'select', - pk: 1, - source: [ - {value: '无', text: '无'}, - {value: '早班', text: '早班'}, - {value: '中班', text: '中班'}, - {value: '晚班', text: '晚班'}, - {value: '行政班', text: '行政班'}, - ] - } - }); - } - - } else { - changeColumn = defaultColumnArr; - } - - var options = table.bootstrapTable('getOptions'); - var queryParams = options.queryParams; - options.queryParams = function (params) { - //这一行必须要存在,否则在点击下一页时会丢失搜索栏数据 - params = queryParams(params); - - var filter = params.filter ? JSON.parse(params.filter) : {}; - filter.timetype = selectedValue; - - params.filter = JSON.stringify(filter); - return params; - }; - - table.bootstrapTable('refreshOptions', { - columns: changeColumn, - }); - - $('#c-flag').val(selectedValue).change(); - return false; - }); - }, add: function () { Controller.api.bindevent(); }, diff --git a/public/assets/js/backend/salary/detail.js b/public/assets/js/backend/salary/detail.js index eebc6a8..7635019 100644 --- a/public/assets/js/backend/salary/detail.js +++ b/public/assets/js/backend/salary/detail.js @@ -41,125 +41,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格绑定事件 Table.api.bindevent(table); }, - custom_index: function () { - // 初始化表格参数配置 - Table.api.init({ - extend: { - index_url: 'salary/detail/custom_index' + location.search, - add_url: 'salary/detail/custom_add', - // del_url: 'oa/schedule/del', - // multi_url: 'oa/schedule/multi', - // import_url: 'oa/schedule/import', - table: 'salary', - } - }); - - var table = $("#table"); - - var defaultColumnArr = []; - defaultColumnArr.push({ - "title":"用户名", - "field":"name", - },{ - "title":"用户id", - "field":"target_admin_id", - "visible":false - }); - - - // 获取后端传入的字段定义(JSON 字符串) - - var columnJson = $('#salaryitem').val(); - var rawColumns = JSON.parse(columnJson); - rawColumns.forEach(function (item) { - // 可以加入格式化、样式控制等逻辑 - defaultColumnArr.push({ - field: item.id, - title: item.name, - }); - }); - - defaultColumnArr.push({ - field: 'operate', - title: __('Operate'), - table: table, - buttons: [ - { - name: 'custom_edit', - text: '编辑', - title: '编辑', - classname: 'btn btn-xs btn-success btn-dialog', - icon: 'fa fa-edit', - url: function (row) { - // 注意这里拼接 admin_id 和 month - return 'salary/detail/custom_edit?target_admin_id=' + row.target_admin_id + '&month=' + row.month; - }, - extend: 'data-area=\'["800px", "600px"]\'', - visible:function(row){ - if (!Config.manage) { - return false; - } - return true; - } - }, - { - name: 'complete', - text:"结算", - title:"结算", - extend: 'data-toggle="tooltip" data-container="body"', - classname: 'btn btn-xs btn-success btn-magic btn-ajax', - icon: 'fa fa-cny', - url: function (row) { - // 注意这里拼接 admin_id 和 month - return 'salary/detail/settle?target_admin_id=' + row.target_admin_id + '&month=' + row.month; - }, - confirm: '确认结算?', - refresh: true, - success: function (data, ret) { - $("#table").bootstrapTable('refresh'); - return false; - }, - error: function (data, ret) { - Layer.alert(ret.msg); - return false; - }, - visible: function (row) { - if (!Config.manage) { - return false; - } - //返回true时按钮显示,返回false隐藏 - if (row.settle_status != 1) { - return true; - } - return false; - } - }, - ], - events: Table.api.events.operate, - formatter: Table.api.formatter.operate - }); - - - // 初始化表格 - table.bootstrapTable({ - url: $.fn.bootstrapTable.defaults.extend.index_url, - columns: defaultColumnArr, - searchFormVisible: true, - searchFormTemplate: 'customformtpl', - }); - - // 为表格绑定事件 - Table.api.bindevent(table); - }, add: function () { Controller.api.bindevent(); }, - custom_add: function () { - Controller.api.bindevent(); - }, - custom_edit: function () { - Controller.api.bindevent(); - }, edit: function () { Controller.api.bindevent(); }, From b990c5d62ab1506eacb58cf9652a5ac821246475 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 09:59:37 +0800 Subject: [PATCH 13/16] feature: auth --- application/admin/controller/auth/Admin.php | 7 +++++++ application/admin/controller/salary/CustomDetail.php | 2 +- application/admin/view/oa/custom_schedule/add.html | 2 +- application/admin/view/oa/custom_schedule/edit.html | 2 +- application/admin/view/salary/custom_detail/add.html | 2 +- application/admin/view/salary/custom_detail/edit.html | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 16f46ca..97c88c6 100755 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -358,4 +358,11 @@ class Admin extends Backend } $this->success(); } + + public function norightselectpage() + { + $this->dataLimit = ''; + $this->dataLimitField = ''; + return parent::selectpage(); + } } diff --git a/application/admin/controller/salary/CustomDetail.php b/application/admin/controller/salary/CustomDetail.php index 27207d2..2f404a5 100644 --- a/application/admin/controller/salary/CustomDetail.php +++ b/application/admin/controller/salary/CustomDetail.php @@ -91,7 +91,7 @@ class CustomDetail extends Backend $builder = $this->model ->where('salary_month', '=', $month); - if (!$this->auth->isSuperAdmin()) { + if (!$this->auth->check('salary/custom_detail/edit')) { $builder = $builder->where('target_admin_id', $this->auth->id); } diff --git a/application/admin/view/oa/custom_schedule/add.html b/application/admin/view/oa/custom_schedule/add.html index cd4d268..2f2fe7d 100644 --- a/application/admin/view/oa/custom_schedule/add.html +++ b/application/admin/view/oa/custom_schedule/add.html @@ -3,7 +3,7 @@
- +
diff --git a/application/admin/view/oa/custom_schedule/edit.html b/application/admin/view/oa/custom_schedule/edit.html index 1634edf..fbf8f3e 100644 --- a/application/admin/view/oa/custom_schedule/edit.html +++ b/application/admin/view/oa/custom_schedule/edit.html @@ -3,7 +3,7 @@
- +
diff --git a/application/admin/view/salary/custom_detail/add.html b/application/admin/view/salary/custom_detail/add.html index 25e6326..a74728d 100644 --- a/application/admin/view/salary/custom_detail/add.html +++ b/application/admin/view/salary/custom_detail/add.html @@ -3,7 +3,7 @@
- +
diff --git a/application/admin/view/salary/custom_detail/edit.html b/application/admin/view/salary/custom_detail/edit.html index 5a2ad7b..e8f3f68 100644 --- a/application/admin/view/salary/custom_detail/edit.html +++ b/application/admin/view/salary/custom_detail/edit.html @@ -3,7 +3,7 @@
- +
From 28f3154a9edc9f684c93138f4f7b7780d437ed2b Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 10:06:46 +0800 Subject: [PATCH 14/16] feature: auth --- application/admin/controller/auth/Admin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 97c88c6..890eb1d 100755 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -30,6 +30,8 @@ class Admin extends Backend protected $childrenGroupIds = []; protected $childrenAdminIds = []; + protected $noNeedRight = ['norightselectpage']; + public function _initialize() { parent::_initialize(); @@ -361,8 +363,7 @@ class Admin extends Backend public function norightselectpage() { - $this->dataLimit = ''; - $this->dataLimitField = ''; + $this->dataLimit = null; return parent::selectpage(); } } From e02deb601db3bea95aed29733f97f936c0940b47 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Wed, 4 Jun 2025 10:14:53 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/command.php | 11 +++++++---- application/common/command/CheckOrdeRecordCommand.php | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/application/command.php b/application/command.php index 92c2963..20b7957 100755 --- a/application/command.php +++ b/application/command.php @@ -22,8 +22,11 @@ return [ 'app\admin\command\ImportServiceItems', 'app\admin\command\Test', - 'app\common\command\UpdateWorkerManCommand', //更新师傅评分 - 'app\common\command\CheckOrderDispatchCommand', //检测超时的任务 - 'app\common\command\CheckOrderDispatchGotCommand', //dispatch未接单通知 - 'app\common\command\CheckOrdeRecordCommand', //跟进记录 + 'app\common\command\UpdateWorkerManCommand', + 'app\common\command\CheckOrderDispatchCommand', + 'app\common\command\CheckOrdeRecordCommand', + 'app\common\command\CheckSmsPlantCommand', + 'app\common\command\CheckTTSOverTimeCommand', + 'app\common\command\CheckTTSTaskCommand', + 'app\common\command\UpdateWorkerManCommand', ]; diff --git a/application/common/command/CheckOrdeRecordCommand.php b/application/common/command/CheckOrdeRecordCommand.php index 70ad812..4c7f45e 100644 --- a/application/common/command/CheckOrdeRecordCommand.php +++ b/application/common/command/CheckOrdeRecordCommand.php @@ -23,7 +23,6 @@ class CheckOrdeRecordCommand extends Command protected function execute(Input $input, Output $output){ $Model = new OrderDispatchRecord(); $now = date('Y-m-d H:i:s'); - $Model->where('notice_time','<=',$now) ->where('status',0) ->chunk(100, function ($list) { @@ -44,7 +43,9 @@ class CheckOrdeRecordCommand extends Command } } OrderDispatchRecord::whereIn('id',$ids)->where('status',0)->update(['status'=>1]); - OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]); + $count = OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]); + + echo 'count:'.$count.PHP_EOL; }); $output->info('OVER'); From cc4180b27d1bf3d100cc327c15527e1299bafd79 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Wed, 4 Jun 2025 10:17:35 +0800 Subject: [PATCH 16/16] feature: auth --- application/admin/controller/oa/CustomSchedule.php | 5 ++++- application/admin/lang/zh-cn/{ => oa}/custom_schedule.php | 0 2 files changed, 4 insertions(+), 1 deletion(-) rename application/admin/lang/zh-cn/{ => oa}/custom_schedule.php (100%) diff --git a/application/admin/controller/oa/CustomSchedule.php b/application/admin/controller/oa/CustomSchedule.php index b8ea402..666b874 100644 --- a/application/admin/controller/oa/CustomSchedule.php +++ b/application/admin/controller/oa/CustomSchedule.php @@ -22,6 +22,9 @@ class CustomSchedule extends Backend */ protected $model = null; + protected $noNeedRight = ['editable']; + + public function _initialize() { parent::_initialize(); @@ -97,7 +100,7 @@ class CustomSchedule extends Backend ->where('date', '>=', $startDate) ->where('date', '<=', $endDate); - if (!$this->auth->isSuperAdmin()) { + if (!$this->auth->check('oa/custom_schedule/edit')) { $builder = $builder->where('exec_admin_id', $this->auth->id); } diff --git a/application/admin/lang/zh-cn/custom_schedule.php b/application/admin/lang/zh-cn/oa/custom_schedule.php similarity index 100% rename from application/admin/lang/zh-cn/custom_schedule.php rename to application/admin/lang/zh-cn/oa/custom_schedule.php