update
This commit is contained in:
parent
4858f1def7
commit
2e32d9c111
43
app/adminapi/controller/jxgl/OaExamineAllController.php
Normal file
43
app/adminapi/controller/jxgl/OaExamineAllController.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\jxgl;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\jxgl\OaExamineAllLists;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录控制器
|
||||
* Class OaExamineController
|
||||
* @package app\adminapi\controller\jxgl
|
||||
*/
|
||||
class OaExamineAllController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OaExamineAllLists());
|
||||
}
|
||||
|
||||
}
|
125
app/adminapi/controller/jxgl/OaExamineController.php
Normal file
125
app/adminapi/controller/jxgl/OaExamineController.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\jxgl;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\jxgl\OaExamineLists;
|
||||
use app\adminapi\logic\jxgl\OaExamineLogic;
|
||||
use app\adminapi\validate\jxgl\OaExamineValidate;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录控制器
|
||||
* Class OaExamineController
|
||||
* @package app\adminapi\controller\jxgl
|
||||
*/
|
||||
class OaExamineController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OaExamineLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加考核下属记录
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new OaExamineValidate())->post()->goCheck('add');
|
||||
$result = OaExamineLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑考核下属记录
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OaExamineValidate())->post()->goCheck('edit');
|
||||
$result = OaExamineLogic::edit($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除考核下属记录
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OaExamineValidate())->post()->goCheck('delete');
|
||||
$result = OaExamineLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OaExamineValidate())->goCheck('detail');
|
||||
$result = OaExamineLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
public function delete_detail()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
if(empty($id)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = OaExamineDetail::where('id',$id)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return $this->fail('考核项信息不存在');
|
||||
}
|
||||
$result = OaExamineDetail::destroy($id);
|
||||
return $result ? $this->success('删除成功' ,[], 1, 1) : $this->fail('删除失败');
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\jxgl\OaSelfExamineLists;
|
||||
use app\adminapi\logic\jxgl\OaSelfExamineLogic;
|
||||
use app\adminapi\validate\jxgl\OaSelfExamineValidate;
|
||||
use app\common\model\jxgl\OaSelfExamineDetail;
|
||||
|
||||
|
||||
/**
|
||||
@ -107,5 +108,19 @@ class OaSelfExamineController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function delete_detail()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
if(empty($id)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = OaSelfExamineDetail::where('id',$id)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return $this->fail('考核项信息不存在');
|
||||
}
|
||||
$result = OaSelfExamineDetail::destroy($id);
|
||||
return $result ? $this->success('删除成功' ,[], 1, 1) : $this->fail('删除失败');
|
||||
}
|
||||
|
||||
|
||||
}
|
104
app/adminapi/lists/jxgl/OaExamineAllLists.php
Normal file
104
app/adminapi/lists/jxgl/OaExamineAllLists.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\jxgl;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录列表
|
||||
* Class OaExamineLists
|
||||
* @package app\adminapi\listsjxgl
|
||||
*/
|
||||
class OaExamineAllLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
private $where = [];
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['examine_type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
if(!empty($params['kh_user'])){
|
||||
$admin_ids = Admin::where('name','like','%'.$params['kh_user'].'%')->column('id');
|
||||
$this->where[] = ['kh_user_id','in',$admin_ids];
|
||||
}
|
||||
if(!empty($params['bkh_user'])){
|
||||
$admin_ids = Admin::where('name','like','%'.$params['bkh_user'].'%')->column('id');
|
||||
$this->where[] = ['bkh_user_id','in',$admin_ids];
|
||||
}
|
||||
if(!empty($params['examine_month'])){
|
||||
$examine_month = strtotime($params['examine_month']);
|
||||
$self_examine_ids = OaSelfExamine::where('examine_month','=',$examine_month)->column('id');
|
||||
$this->where[] = ['self_examine_id','in',$self_examine_ids];
|
||||
}
|
||||
return OaExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty();
|
||||
$data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name');
|
||||
$data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name');
|
||||
$data['examine_type_text'] = $data->examine_type_text;
|
||||
$data['examine_month'] = $self_examine['examine_month'];
|
||||
$data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score');
|
||||
$data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score');
|
||||
$data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score');
|
||||
$data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OaExamine::where($this->searchWhere)->where($this->where)->count();
|
||||
}
|
||||
|
||||
}
|
96
app/adminapi/lists/jxgl/OaExamineLists.php
Normal file
96
app/adminapi/lists/jxgl/OaExamineLists.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\jxgl;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录列表
|
||||
* Class OaExamineLists
|
||||
* @package app\adminapi\listsjxgl
|
||||
*/
|
||||
class OaExamineLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
private $where = [];
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['examine_type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
if(!empty($params['bkh_user'])){
|
||||
$admin_ids = Admin::where('name','like','%'.$params['bkh_user'].'%')->column('id');
|
||||
$this->where[] = ['bkh_user_id','in',$admin_ids];
|
||||
}
|
||||
$this->where[] = ['kh_user_id','=',$this->adminId];
|
||||
return OaExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty();
|
||||
$data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name');
|
||||
$data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name');
|
||||
$data['examine_type_text'] = $data->examine_type_text;
|
||||
$data['examine_month'] = $self_examine['examine_month'];
|
||||
$data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score');
|
||||
$data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score');
|
||||
$data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score');
|
||||
$data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OaExamine::where($this->searchWhere)->where($this->where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -63,7 +63,7 @@ class OaSelfExamineLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
if(!empty($params['examine_month'])){
|
||||
$this->where[] = ['examine_month','=',strtotime($params['examine_month'])];
|
||||
}
|
||||
return OaSelfExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where)
|
||||
return OaSelfExamine::withoutField('update_time,delete_time')->where('usr_id',$this->adminId)->where($this->searchWhere)->where($this->where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
@ -86,7 +86,7 @@ class OaSelfExamineLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OaSelfExamine::where($this->searchWhere)->where($this->where)->count();
|
||||
return OaSelfExamine::where('usr_id',$this->adminId)->where($this->searchWhere)->where($this->where)->count();
|
||||
}
|
||||
|
||||
}
|
174
app/adminapi/logic/jxgl/OaExamineLogic.php
Normal file
174
app/adminapi/logic/jxgl/OaExamineLogic.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\jxgl;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录逻辑
|
||||
* Class OaExamineLogic
|
||||
* @package app\adminapi\logic\jxgl
|
||||
*/
|
||||
class OaExamineLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加考核下属记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public static function add(array $params,$admin_id): bool
|
||||
{
|
||||
if($admin_id == $params['bkh_user_id']){
|
||||
self::setError('考核人与被考核人不能相同');
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = OaExamine::create([
|
||||
'kh_user_id' => $admin_id,
|
||||
'bkh_user_id' => $params['bkh_user_id'],
|
||||
'examine_type' => $params['examine_type'],
|
||||
'self_examine_id' => $params['self_examine_id'],
|
||||
'content' => $params['content'] ?? ''
|
||||
]);
|
||||
foreach($params['detail'] as &$v){
|
||||
$v['examine_id'] = $res['id'];
|
||||
$v['create_time'] = time();
|
||||
}
|
||||
(new OaExamineDetail)->saveAll($params['detail']);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑考核下属记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public static function edit(array $params,$admin_id): bool
|
||||
{
|
||||
$data = OaExamine::where('id',$params['id'])->findOrEmpty();
|
||||
if($data['kh_user_id'] != $admin_id){
|
||||
self::setError('你不是此数据的考核者,无权修改');
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaExamine::where('id', $params['id'])->update([
|
||||
'kh_user_id' => $admin_id,
|
||||
'bkh_user_id' => $params['bkh_user_id'],
|
||||
'examine_type' => $params['examine_type'],
|
||||
'self_examine_id' => $params['self_examine_id'],
|
||||
'content' => $params['content'] ?? ''
|
||||
]);
|
||||
foreach($params['detail'] as $v){
|
||||
if(!empty($v['id'])){
|
||||
OaExamineDetail::where('id',$v['id'])->update([
|
||||
'examine_id' => $params['id'],
|
||||
'examine_item' => $v['examine_item'],
|
||||
'score' => $v['score'],
|
||||
'examine_desc' => $v['examine_desc'],
|
||||
'self_score' => $v['self_score'],
|
||||
'superior_score' => $v['superior_score'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
}else{
|
||||
OaExamineDetail::create([
|
||||
'examine_id' => $params['id'],
|
||||
'examine_item' => $v['examine_item'],
|
||||
'score' => $v['score'],
|
||||
'examine_desc' => $v['examine_desc'],
|
||||
'self_score' => $v['self_score'],
|
||||
'superior_score' => $v['superior_score'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除考核下属记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaExamine::destroy($params['id']);
|
||||
OaExamineDetail::destroy(function($query)use($params){
|
||||
$query->where('examine_id','=',$params['id']);
|
||||
});
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核下属记录详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = OaExamine::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty();
|
||||
$data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name');
|
||||
$data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name');
|
||||
$data['examine_type_text'] = $data->examine_type_text;
|
||||
$data['examine_month'] = $self_examine['examine_month'];
|
||||
$data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score');
|
||||
$data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score');
|
||||
$data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score');
|
||||
$data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,9 +15,13 @@
|
||||
namespace app\adminapi\logic\jxgl;
|
||||
|
||||
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaExamineTemp;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\jxgl\OaExamineTempItem;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
use app\common\model\jxgl\OaSelfExamineDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -120,9 +124,31 @@ class OaExamineTempLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//删除考核模板
|
||||
OaExamineTemp::destroy($params['id']);
|
||||
//删除考核模板考核项
|
||||
OaExamineTempItem::destroy(function($query)use($params){
|
||||
$query->where('examine_temp_id','=',$params['id']);
|
||||
});
|
||||
//删除关联的自评记录
|
||||
OaSelfExamine::destroy(function($query)use($params){
|
||||
$query->where('examine_temp_id','=',$params['id']);
|
||||
});
|
||||
//删除关联的自评记录的考核项
|
||||
OaSelfExamineDetail::destroy(function($query)use($params){
|
||||
$self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id');
|
||||
$query->where('self_examine_id','in',$self_examine_ids);
|
||||
});
|
||||
//删除关联的考核记录
|
||||
OaExamine::destroy(function($query)use($params){
|
||||
$self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id');
|
||||
$query->where('self_examine_id','in',$self_examine_ids);
|
||||
});
|
||||
//删除关联的考核记录的考核项
|
||||
OaExamineDetail::destroy(function($query)use($params){
|
||||
$self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id');
|
||||
$examine_ids = OaExamine::where('self_examine_id','in',$self_examine_ids)->column('id');
|
||||
$query->where('examine_id','in',$examine_ids);
|
||||
});
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -16,6 +16,8 @@ namespace app\adminapi\logic\jxgl;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaExamineTemp;
|
||||
use app\common\model\jxgl\OaExamineTempItem;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
@ -129,9 +131,20 @@ class OaSelfExamineLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//删除自评记录
|
||||
OaSelfExamine::destroy($params['id']);
|
||||
//伤处自评记录考核项
|
||||
OaSelfExamineDetail::destroy(function($query)use($params){
|
||||
$query->where('self_examine_id','=',$params['id']);
|
||||
});
|
||||
//删除关联的考核记录
|
||||
OaExamine::destroy(function($query)use($params){
|
||||
$query->where('self_examine_id','=',$params['id']);
|
||||
});
|
||||
//删除关联的考核记录考核项
|
||||
OaExamineDetail::destroy(function($query)use($params){
|
||||
$examine_ids = OaExamine::where('self_examine_id','=',$params['id'])->column('id');
|
||||
$query->where('examine_id','in',$examine_ids);
|
||||
});
|
||||
Db::commit();
|
||||
return true;
|
||||
|
186
app/adminapi/validate/jxgl/OaExamineValidate.php
Normal file
186
app/adminapi/validate/jxgl/OaExamineValidate.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\jxgl;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\jxgl\OaExamine;
|
||||
use app\common\model\jxgl\OaExamineDetail;
|
||||
use app\common\model\jxgl\OaSelfExamine;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录验证器
|
||||
* Class OaExamineValidate
|
||||
* @package app\adminapi\validate\jxgl
|
||||
*/
|
||||
class OaExamineValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'bkh_user_id' => 'require|checkBkhUser',
|
||||
'examine_type' => 'require|checkExamineType',
|
||||
'self_examine_id' => 'require|checkSelfExamine',
|
||||
'detail' => 'require|checkDetail'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'bkh_user_id' => '被考核人',
|
||||
'examine_type' => '考核类别',
|
||||
'self_examine_id' => '自评记录',
|
||||
'detail' => '考核项'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return OaExamineValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['bkh_user_id','examine_type','self_examine_id','content','detail']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return OaExamineValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','bkh_user_id','examine_type','self_examine_id','content','detail']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return OaExamineValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return OaExamineValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/04 13:37
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = OaExamine::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkBkhUser($value): bool|string
|
||||
{
|
||||
$data = Admin::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '被考核人不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkExamineType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','jxgl_check_type')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '考核类别无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkSelfExamine($value,$rule,$data): bool|string
|
||||
{
|
||||
$self_examine = OaSelfExamine::where('id',$value)->where('examine_type',$data['examine_type'])->where('user_id',$data['bkh_user_id'])->findOrEmpty();
|
||||
if($self_examine->isEmpty()){
|
||||
return '自评记录数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDetail($value): bool|string
|
||||
{
|
||||
if(!is_array($value) || empty($value)){
|
||||
return '考核项数据格式错误';
|
||||
}
|
||||
foreach($value as $k => $v){
|
||||
if(isset($v['id']) && !empty($v['id'])){
|
||||
$data = OaExamineDetail::where('id',$v['id'])->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '第'.($k+1).'行数据不存在';
|
||||
}
|
||||
}
|
||||
if(empty($v['examine_item'])){
|
||||
return '第'.($k+1).'行考核项为空';
|
||||
}
|
||||
if(empty($v['score'])){
|
||||
return '第'.($k+1).'行分数为空';
|
||||
}else{
|
||||
if(!is_numeric($v['score']) || $v['score'] < 0){
|
||||
return '第'.($k+1).'行分数必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
if(empty($v['examine_desc'])){
|
||||
return '第'.($k+1).'行考核说明为空';
|
||||
}
|
||||
if(empty($v['self_score'])){
|
||||
return '第'.($k+1).'行自评评分为空';
|
||||
}else{
|
||||
if(!is_numeric($v['self_score']) || $v['self_score'] < 0){
|
||||
return '第'.($k+1).'行自评评分必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
if(empty($v['superior_score'])){
|
||||
return '第'.($k+1).'行上级评分为空';
|
||||
}else{
|
||||
if(!is_numeric($v['superior_score']) || $v['self_score'] < 0){
|
||||
return '第'.($k+1).'行上级评分必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
app/common/model/jxgl/OaExamine.php
Normal file
38
app/common/model/jxgl/OaExamine.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\jxgl;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录模型
|
||||
* Class OaExamine
|
||||
* @package app\common\model\jxgl
|
||||
*/
|
||||
class OaExamine extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'oa_examine';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getExamineTypeTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','jxgl_check_type')->column('name','value');
|
||||
return !empty($data['examine_type']) ? $dict[$data['examine_type']] : '';
|
||||
}
|
||||
}
|
34
app/common/model/jxgl/OaExamineDetail.php
Normal file
34
app/common/model/jxgl/OaExamineDetail.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\jxgl;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 考核下属记录明细模型
|
||||
* Class OaExamineDetail
|
||||
* @package app\common\model\jxgl
|
||||
*/
|
||||
class OaExamineDetail extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'oa_examine_detail';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user