更新
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\finance;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\finance\DeptPerformanceTargetLogic;
|
||||
use app\adminapi\validate\finance\DeptPerformanceTargetValidate;
|
||||
|
||||
/**
|
||||
* 制定业绩:按部门、按自然月维护目标金额(元)
|
||||
*
|
||||
* - GET finance.dept_performance_target/monthMatrix
|
||||
* - POST finance.dept_performance_target/batchSave
|
||||
*/
|
||||
class DeptPerformanceTargetController extends BaseAdminController
|
||||
{
|
||||
public function monthMatrix()
|
||||
{
|
||||
$params = (new DeptPerformanceTargetValidate())->goCheck('monthMatrix');
|
||||
$ym = (string) $params['year_month'];
|
||||
|
||||
return $this->data(DeptPerformanceTargetLogic::monthMatrix($ym));
|
||||
}
|
||||
|
||||
public function batchSave()
|
||||
{
|
||||
$params = (new DeptPerformanceTargetValidate())->post()->goCheck('batchSave');
|
||||
$ym = (string) $params['year_month'];
|
||||
$items = $params['items'] ?? [];
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('目标数据格式错误');
|
||||
}
|
||||
|
||||
$result = DeptPerformanceTargetLogic::batchSave(
|
||||
$ym,
|
||||
$items,
|
||||
$this->adminId,
|
||||
(string) ($this->adminInfo['name'] ?? '')
|
||||
);
|
||||
if ($result === false) {
|
||||
return $this->fail(DeptPerformanceTargetLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('保存成功', DeptPerformanceTargetLogic::monthMatrix($ym), 1, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user