update
This commit is contained in:
parent
61801f0a36
commit
0fe30a5b7d
111
app/adminapi/controller/jxgl/OaExamineTempController.php
Normal file
111
app/adminapi/controller/jxgl/OaExamineTempController.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?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\OaExamineTempLists;
|
||||
use app\adminapi\logic\jxgl\OaExamineTempLogic;
|
||||
use app\adminapi\validate\jxgl\OaExamineTempValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 考核模板控制器
|
||||
* Class OaExamineTempController
|
||||
* @package app\adminapi\controller\jxgl
|
||||
*/
|
||||
class OaExamineTempController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核模板列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OaExamineTempLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加考核模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new OaExamineTempValidate())->post()->goCheck('add');
|
||||
$result = OaExamineTempLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineTempLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑考核模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OaExamineTempValidate())->post()->goCheck('edit');
|
||||
$result = OaExamineTempLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineTempLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除考核模板
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OaExamineTempValidate())->post()->goCheck('delete');
|
||||
$result = OaExamineTempLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaExamineTempLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核模板详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OaExamineTempValidate())->goCheck('detail');
|
||||
$result = OaExamineTempLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
81
app/adminapi/lists/jxgl/OaExamineTempLists.php
Normal file
81
app/adminapi/lists/jxgl/OaExamineTempLists.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?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\jxgl\OaExamineTemp;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\jxgl\OaExamineTempItem;
|
||||
|
||||
|
||||
/**
|
||||
* 考核模板列表
|
||||
* Class OaExamineTempLists
|
||||
* @package app\adminapi\listsjxgl
|
||||
*/
|
||||
class OaExamineTempLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['examine_type'],
|
||||
'%like%' => ['temp_name'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核模板列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return OaExamineTemp::withoutField('update_time,delete_time')->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$data['examine_type_text'] = $data->examine_type_text;
|
||||
$data['total_score'] = OaExamineTempItem::where('examine_temp_id',$data['id'])->sum('score');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取考核模板数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OaExamineTemp::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
141
app/adminapi/logic/jxgl/OaExamineTempLogic.php
Normal file
141
app/adminapi/logic/jxgl/OaExamineTempLogic.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?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\jxgl\OaExamineTemp;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\jxgl\OaExamineTempItem;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 考核模板逻辑
|
||||
* Class OaExamineTempLogic
|
||||
* @package app\adminapi\logic\jxgl
|
||||
*/
|
||||
class OaExamineTempLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加考核模板
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = OaExamineTemp::create([
|
||||
'examine_type' => $params['examine_type'],
|
||||
'temp_name' => $params['temp_name'],
|
||||
'create_user' => $params['create_user'],
|
||||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : 0
|
||||
]);
|
||||
foreach($params['detail'] as &$v){
|
||||
$v['examine_temp_id'] = $res['id'];
|
||||
$v['create_time'] = time();
|
||||
}
|
||||
(new OaExamineTempItem)->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/03 13:35
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaExamineTemp::where('id', $params['id'])->update([
|
||||
'examine_type' => $params['examine_type'],
|
||||
'temp_name' => $params['temp_name'],
|
||||
'create_user' => $params['create_user'],
|
||||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : 0,
|
||||
'update_time' => time()
|
||||
]);
|
||||
//删除原数据
|
||||
OaExamineTempItem::destroy(function($query)use($params){
|
||||
$query->where('examine_temp_id','=',$params['id']);
|
||||
});
|
||||
foreach($params['detail'] as &$v){
|
||||
$v['examine_temp_id'] = $params['id'];
|
||||
$v['create_time'] = time();
|
||||
}
|
||||
(new OaExamineTempItem)->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/03 13:35
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaExamineTemp::destroy($params['id']);
|
||||
OaExamineTempItem::destroy(function($query)use($params){
|
||||
$query->where('examine_temp_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/03 13:35
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = OaExamineTemp::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$data['examine_type_text'] = $data->examine_type_text;
|
||||
$data['detail'] = OaExamineTempItem::field('id,examine_item,score,examine_desc')->where('examine_temp_id',$params['id'])->select()->toArray();
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
144
app/adminapi/validate/jxgl/OaExamineTempValidate.php
Normal file
144
app/adminapi/validate/jxgl/OaExamineTempValidate.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?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\dict\DictData;
|
||||
use app\common\model\jxgl\OaExamineTempItem;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 考核模板验证器
|
||||
* Class OaExamineTempValidate
|
||||
* @package app\adminapi\validate\jxgl
|
||||
*/
|
||||
class OaExamineTempValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'examine_type' => 'require|checkExamineType',
|
||||
'temp_name' => 'require',
|
||||
'create_user' => 'require',
|
||||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||||
'detail' => 'require|checkDetail'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'examine_type' => '考核类别',
|
||||
'temp_name' => '模板名称',
|
||||
'create_user' => '创建人',
|
||||
'create_time' => '创建时间',
|
||||
'detail' => '考核项'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return OaExamineTempValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['examine_type','temp_name','create_user','create_time','detail']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return OaExamineTempValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','examine_type','temp_name','create_user','create_time','detail']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return OaExamineTempValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return OaExamineTempValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/06/03 13:35
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
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 checkDetail($value): bool|string
|
||||
{
|
||||
if(!is_array($value) || empty($value)){
|
||||
return '考核项数据格式错误';
|
||||
}
|
||||
foreach($value as $k => $v){
|
||||
if(isset($v['id']) && !empty($v['id'])){
|
||||
$data = OaExamineTempItem::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).'行考核说明为空';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
app/common/model/jxgl/OaExamineTemp.php
Normal file
38
app/common/model/jxgl/OaExamineTemp.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 OaExamineTemp
|
||||
* @package app\common\model\jxgl
|
||||
*/
|
||||
class OaExamineTemp extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'oa_examine_temp';
|
||||
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/OaExamineTempItem.php
Normal file
34
app/common/model/jxgl/OaExamineTempItem.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 OaExamineTempItem
|
||||
* @package app\common\model\jxgl
|
||||
*/
|
||||
class OaExamineTempItem extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'oa_examine_temp_item';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user