From 60960debe74f08ba53d83c72a934d5ba3c4f3ea0 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Thu, 29 May 2025 14:48:47 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=B7=A5=E8=B5=84=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/salary/Detail.php | 34 ++++++++++++++++--- public/assets/js/backend/salary/detail.js | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/application/admin/controller/salary/Detail.php b/application/admin/controller/salary/Detail.php index 9cf2acd..7a0ac7f 100644 --- a/application/admin/controller/salary/Detail.php +++ b/application/admin/controller/salary/Detail.php @@ -43,13 +43,29 @@ class Detail extends Backend //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); - $items = Db::name('salary_item')->field('id,name')->select(); + $items = Db::name('salary_item')->field('id,attr,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()) { @@ -89,6 +105,7 @@ class Detail extends Backend foreach ($adminIds as $adminId) { + $attrValue = []; foreach ($items as $item) { $res[$adminId]['admin_id'] = $adminId; @@ -99,11 +116,20 @@ class Detail extends Backend if (isset($queryRes[$adminId][$item['id']])) { $res[$adminId][$itemKey] = $this->clean_number($queryRes[$adminId][$item['id']]); + $attrValue[$idAttr[$item['id']]] = $queryRes[$adminId][$item['id']]; continue; } + $attrValue[$item['attr']] = 0; $res[$adminId][$itemKey] = 0; } + + + $jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD']; + + $res[$adminId]['jx_total'] = $this->clean_number($jxTotal); + $res[$adminId]['total'] = $this->clean_number(($attrValue['JBGZ'] + $attrValue['JBBZ'] + $attrValue['GWJT'] + $jxTotal + $attrValue['JXKHJL'] + $attrValue['QQ']) + - ($attrValue['SBJ'] + $attrValue['BX'] + $attrValue['KK'] + $attrValue['CDWDK'])); } $res = array_values($res); @@ -115,7 +141,7 @@ class Detail extends Backend $this->view->assign("month", $month); - $this->view->assign("salaryitem", json_encode($items)); + $this->view->assign("salaryitem", json_encode($salaryItem)); return $this->view->fetch(); } diff --git a/public/assets/js/backend/salary/detail.js b/public/assets/js/backend/salary/detail.js index 0ddfda8..8605e5d 100644 --- a/public/assets/js/backend/salary/detail.js +++ b/public/assets/js/backend/salary/detail.js @@ -75,7 +75,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin rawColumns.forEach(function (item) { // 可以加入格式化、样式控制等逻辑 defaultColumnArr.push({ - field: 'item_' + item.id, + field: item.id, title: item.name, }); });