feature: 工资管理

This commit is contained in:
zhuyu 2025-05-29 14:48:47 +08:00
parent c7ee06d512
commit 60960debe7
2 changed files with 31 additions and 5 deletions

View File

@ -43,13 +43,29 @@ class Detail extends Backend
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'trim']); $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'); $month = date('Y-m-01');
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
@ -89,6 +105,7 @@ class Detail extends Backend
foreach ($adminIds as $adminId) { foreach ($adminIds as $adminId) {
$attrValue = [];
foreach ($items as $item) { foreach ($items as $item) {
$res[$adminId]['admin_id'] = $adminId; $res[$adminId]['admin_id'] = $adminId;
@ -99,11 +116,20 @@ class Detail extends Backend
if (isset($queryRes[$adminId][$item['id']])) { if (isset($queryRes[$adminId][$item['id']])) {
$res[$adminId][$itemKey] = $this->clean_number($queryRes[$adminId][$item['id']]); $res[$adminId][$itemKey] = $this->clean_number($queryRes[$adminId][$item['id']]);
$attrValue[$idAttr[$item['id']]] = $queryRes[$adminId][$item['id']];
continue; continue;
} }
$attrValue[$item['attr']] = 0;
$res[$adminId][$itemKey] = 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); $res = array_values($res);
@ -115,7 +141,7 @@ class Detail extends Backend
$this->view->assign("month", $month); $this->view->assign("month", $month);
$this->view->assign("salaryitem", json_encode($items)); $this->view->assign("salaryitem", json_encode($salaryItem));
return $this->view->fetch(); return $this->view->fetch();
} }

View File

@ -75,7 +75,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
rawColumns.forEach(function (item) { rawColumns.forEach(function (item) {
// 可以加入格式化、样式控制等逻辑 // 可以加入格式化、样式控制等逻辑
defaultColumnArr.push({ defaultColumnArr.push({
field: 'item_' + item.id, field: item.id,
title: item.name, title: item.name,
}); });
}); });