update
This commit is contained in:
parent
8b044cce46
commit
d181f4f809
108
app/adminapi/controller/works/bgsp/OaFlowTypeController.php
Normal file
108
app/adminapi/controller/works/bgsp/OaFlowTypeController.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?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\works\bgsp;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\works\bgsp\OaFlowTypeLists;
|
||||
use app\adminapi\logic\works\bgsp\OaFlowTypeLogic;
|
||||
use app\adminapi\validate\works\bgsp\OaFlowTypeValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 审批类型控制器
|
||||
* Class OaFlowTypeController
|
||||
* @package app\adminapi\controller\works\bgsp
|
||||
*/
|
||||
class OaFlowTypeController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取审批类型列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OaFlowTypeLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加审批类型
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new OaFlowTypeValidate())->post()->goCheck('add');
|
||||
$result = OaFlowTypeLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaFlowTypeLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑审批类型
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new OaFlowTypeValidate())->post()->goCheck('edit');
|
||||
$result = OaFlowTypeLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OaFlowTypeLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除审批类型
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new OaFlowTypeValidate())->post()->goCheck('delete');
|
||||
OaFlowTypeLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取审批类型详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OaFlowTypeValidate())->goCheck('detail');
|
||||
$result = OaFlowTypeLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
86
app/adminapi/lists/works/bgsp/OaFlowTypeLists.php
Normal file
86
app/adminapi/lists/works/bgsp/OaFlowTypeLists.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?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\works\bgsp;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\works\bgsp\OaFlowType;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 审批类型列表
|
||||
* Class OaFlowTypeLists
|
||||
* @package app\adminapi\listsworks\bgsp
|
||||
*/
|
||||
class OaFlowTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type'],
|
||||
'%like%' => ['title', 'name'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取审批类型列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return OaFlowType::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
if(!empty($data['department_ids'])){
|
||||
$dept = Dept::where('id','in',$data['department_ids'])->column('name');
|
||||
$data['department_names'] = implode(',',$dept);
|
||||
}else{
|
||||
$data['department_names'] = '全公司';
|
||||
}
|
||||
$data['type_text'] = $data->type_text;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取审批类型数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OaFlowType::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
123
app/adminapi/logic/works/bgsp/OaFlowTypeLogic.php
Normal file
123
app/adminapi/logic/works/bgsp/OaFlowTypeLogic.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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\works\bgsp;
|
||||
|
||||
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\works\bgsp\OaFlowType;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 审批类型逻辑
|
||||
* Class OaFlowTypeLogic
|
||||
* @package app\adminapi\logic\works\bgsp
|
||||
*/
|
||||
class OaFlowTypeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加审批类型
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaFlowType::create([
|
||||
'type' => $params['type'],
|
||||
'title' => $params['title'],
|
||||
'name' => $params['name'],
|
||||
'icon' => $params['icon'] ?? '',
|
||||
'department_ids' => $params['department_ids'] ?? ''
|
||||
]);
|
||||
|
||||
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/05/24 13:34
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
OaFlowType::where('id', $params['id'])->update([
|
||||
'type' => $params['type'],
|
||||
'title' => $params['title'],
|
||||
'name' => $params['name'],
|
||||
'icon' => $params['icon'] ?? '',
|
||||
'department_ids' => $params['department_ids'] ?? ''
|
||||
]);
|
||||
|
||||
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/05/24 13:34
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return OaFlowType::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取审批类型详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = OaFlowType::findOrEmpty($params['id']);
|
||||
if(!empty($data['department_ids'])){
|
||||
$dept = Dept::where('id','in',$data['department_ids'])->column('name');
|
||||
$data['department_names'] = implode(',',$dept);
|
||||
}else{
|
||||
$data['department_names'] = '全公司';
|
||||
}
|
||||
$data['type_text'] = $data->type_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
130
app/adminapi/validate/works/bgsp/OaFlowTypeValidate.php
Normal file
130
app/adminapi/validate/works/bgsp/OaFlowTypeValidate.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?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\works\bgsp;
|
||||
|
||||
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 审批类型验证器
|
||||
* Class OaFlowTypeValidate
|
||||
* @package app\adminapi\validate\works\bgsp
|
||||
*/
|
||||
class OaFlowTypeValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'type' => 'require|checkType',
|
||||
'title' => 'require',
|
||||
'name' => 'require',
|
||||
'department_ids' => 'checkDept',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'type' => '所属分类',
|
||||
'title' => '审批名称',
|
||||
'name' => '审批标识',
|
||||
'department_ids' => '应用部门',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return OaFlowTypeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['type','title','name','icon','department_ids']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return OaFlowTypeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','type','title','name','icon','department_ids']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return OaFlowTypeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return OaFlowTypeValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/24 13:34
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value', 'oa_approve_cate')->column('value');
|
||||
if (!in_array($value, $dict)) {
|
||||
return '所属分类数据值无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value): bool|string
|
||||
{
|
||||
if(!empty($value)){
|
||||
$data = explode(',',$value);
|
||||
if(empty($data)){
|
||||
return '应用部门数据错误';
|
||||
}
|
||||
foreach($data as $v){
|
||||
$dept = Dept::where('id',$v)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '应用部门信息不存在';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
app/common/model/works/bgsp/OaFlowType.php
Normal file
38
app/common/model/works/bgsp/OaFlowType.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\works\bgsp;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 审批类型模型
|
||||
* Class OaFlowType
|
||||
* @package app\common\model\works\bgsp
|
||||
*/
|
||||
class OaFlowType extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'oa_flow_type';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getTypeTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value', 'oa_approve_cate')->column('name','value');
|
||||
return !empty($data['type']) ? $dict[$data['type']] : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user