This commit is contained in:
weiz 2024-02-01 18:00:29 +08:00
parent d0f8f90862
commit 5086034044
16 changed files with 1310 additions and 0 deletions

@ -0,0 +1,62 @@
<?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\oa;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\oa\FlowApproveLists;
use app\adminapi\logic\oa\FlowApproveLogic;
use app\adminapi\validate\oa\FlowApproveValidate;
/**
* 日常审批控制器
* Class FlowApproveController
* @package app\adminapi\controller\oa
*/
class FlowApproveController extends BaseAdminController
{
/**
* @notes 获取日常审批列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists()
{
$res = addApprove('项目出差申请',9,'app\common\model\project\ProjectTripApply','app\adminapi\logic\project\ProjectTripApplyLogic',1,1,2);
halt($res);
return $this->dataLists(new FlowApproveLists());
}
/**
* @notes 获取日常审批详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function detail()
{
$params = (new FlowApproveValidate())->goCheck('detail');
$result = FlowApproveLogic::detail($params);
return $this->data($result);
}
}

@ -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\oa;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\oa\FlowRecordLists;
use app\adminapi\logic\oa\FlowRecordLogic;
use app\adminapi\validate\oa\FlowRecordValidate;
/**
* 审批记录控制器
* Class FlowRecordController
* @package app\adminapi\controller\oa
*/
class FlowRecordController extends BaseAdminController
{
/**
* @notes 获取审批记录列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists()
{
return $this->dataLists(new FlowRecordLists());
}
/**
* @notes 添加审批记录
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function add()
{
$params = (new FlowRecordValidate())->post()->goCheck('add');
$result = FlowRecordLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FlowRecordLogic::getError());
}
/**
* @notes 编辑审批记录
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function edit()
{
$params = (new FlowRecordValidate())->post()->goCheck('edit');
$result = FlowRecordLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FlowRecordLogic::getError());
}
/**
* @notes 删除审批记录
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function delete()
{
$params = (new FlowRecordValidate())->post()->goCheck('delete');
FlowRecordLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取审批记录详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function detail()
{
$params = (new FlowRecordValidate())->goCheck('detail');
$result = FlowRecordLogic::detail($params);
return $this->data($result);
}
}

@ -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\oa;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\oa\FlowStepLists;
use app\adminapi\logic\oa\FlowStepLogic;
use app\adminapi\validate\oa\FlowStepValidate;
/**
* 审批步骤控制器
* Class FlowStepController
* @package app\adminapi\controller\oa
*/
class FlowStepController extends BaseAdminController
{
/**
* @notes 获取审批步骤列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists()
{
return $this->dataLists(new FlowStepLists());
}
/**
* @notes 添加审批步骤
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function add()
{
$params = (new FlowStepValidate())->post()->goCheck('add');
$result = FlowStepLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FlowStepLogic::getError());
}
/**
* @notes 编辑审批步骤
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function edit()
{
$params = (new FlowStepValidate())->post()->goCheck('edit');
$result = FlowStepLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FlowStepLogic::getError());
}
/**
* @notes 删除审批步骤
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function delete()
{
$params = (new FlowStepValidate())->post()->goCheck('delete');
FlowStepLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取审批步骤详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function detail()
{
$params = (new FlowStepValidate())->goCheck('detail');
$result = FlowStepLogic::detail($params);
return $this->data($result);
}
}

@ -0,0 +1,77 @@
<?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\oa;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\oa\FlowApprove;
use app\common\lists\ListsSearchInterface;
/**
* 日常审批列表
* Class FlowApproveLists
* @package app\adminapi\listsoa
*/
class FlowApproveLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function setSearch(): array
{
return [
];
}
/**
* @notes 获取日常审批列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists(): array
{
return FlowApprove::where($this->searchWhere)
->field(['id', 'flow_type_id', 'flow_id', 'content_id', 'content_model', 'create_user'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取日常审批数量
* @return int
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function count(): int
{
return FlowApprove::where($this->searchWhere)->count();
}
}

@ -0,0 +1,77 @@
<?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\oa;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\oa\FlowRecord;
use app\common\lists\ListsSearchInterface;
/**
* 审批记录列表
* Class FlowRecordLists
* @package app\adminapi\listsoa
*/
class FlowRecordLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function setSearch(): array
{
return [
];
}
/**
* @notes 获取审批记录列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists(): array
{
return FlowRecord::where($this->searchWhere)
->field(['id', 'approve_id', 'step_id', 'check_user_id', 'check_time', 'status', 'content', 'is_invalid'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取审批记录数量
* @return int
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function count(): int
{
return FlowRecord::where($this->searchWhere)->count();
}
}

@ -0,0 +1,77 @@
<?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\oa;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\oa\FlowStep;
use app\common\lists\ListsSearchInterface;
/**
* 审批步骤列表
* Class FlowStepLists
* @package app\adminapi\listsoa
*/
class FlowStepLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function setSearch(): array
{
return [
'=' => ['approve_id'],
];
}
/**
* @notes 获取审批步骤列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function lists(): array
{
return FlowStep::where($this->searchWhere)
->field(['id', 'approve_id', 'flow_name', 'flow_step', 'flow_user', 'sort'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取审批步骤数量
* @return int
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function count(): int
{
return FlowStep::where($this->searchWhere)->count();
}
}

@ -0,0 +1,69 @@
<?php
namespace app\adminapi\logic\oa;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowApprove;
use app\common\logic\BaseLogic;
use app\common\model\oa\FlowRecord;
use app\common\model\oa\FlowStep;
/**
* 日常审批逻辑
* Class FlowApproveLogic
* @package app\adminapi\logic\oa
*/
class FlowApproveLogic extends BaseLogic
{
/**
* @notes 获取日常审批详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/01 11:26
*/
public static function detail($params): array
{
$data = FlowApprove::field('id,title,flow_id,content_id,content_model,content_logic,create_user,check_status')->findOrEmpty($params['id']);
//获取审批内容信息
$content = $data['content_logic']::detail(['id'=>$data['content_id']]);
//获取创建人信息
$create_user = Admin::field('name,dept_id')->where('id',$data['create_user'])->findOrEmpty();
//获取审批流程信息
$flow = Flow::field('name,copy_uids')->where('id',$data['flow_id'])-> findOrEmpty();
//获取抄送人信息
$copy = Admin::where('id','in',$flow['copy_uids'])->column('name');
//获取审核步骤
$step = FlowStep::field('flow_step,flow_user')->where('approve_id',$data['id'])->order('sort asc')->select()->each(function($item)use($create_user){
$item['flow_step_text'] = $item->flow_step_text;
if($item['flow_step'] == 0){
$item['flow_step_text'] = $create_user['name'].'创建';
$item['flow_user'] = '';
}else if($item['flow_step'] == 1){
$item['flow_step_text'] = $item->flow_step_text;
$dept = Dept::field('leader')->where('id',$create_user['dept_id'])->findOrEmpty();
$flow_user = Admin::field('name')->where('id',$dept['leader'])->findOrEmpty();
$item['flow_user'] = $flow_user['name'];
}else{
$item['flow_step_text'] = $item->flow_step_text;
$flow_user = Admin::where('id','in',$item['flow_user'])->column('name');
$item['flow_user'] = implode(',',$flow_user);
}
})->toArray();
//获取审批记录
$record = FlowRecord::field('title,content,check_time,status')->where('approve_id',$data['id'])->select()->each(function($item){
$item['status_text'] = $item->status_text;
})->toArray();
$data['flow_name'] = $flow['name'];
$data['check_status_text'] = $data->check_status_text;
$data['create_user_name'] = $create_user['name'];
$data['copy_user'] = implode(',',$copy);
$data['content'] = $content;
$data['step'] = $step;
$data['record'] = $record;
unset($data['flow_id'],$data['content_id'],$data['content_model'],$data['content_logic']);
return $data->toArray();
}
}

@ -0,0 +1,118 @@
<?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\oa;
use app\common\model\oa\FlowRecord;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 审批记录逻辑
* Class FlowRecordLogic
* @package app\adminapi\logic\oa
*/
class FlowRecordLogic extends BaseLogic
{
/**
* @notes 添加审批记录
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/01 11:26
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FlowRecord::create([
'approve_id' => $params['approve_id'],
'step_id' => $params['step_id'],
'check_user_id' => $params['check_user_id'],
'check_time' => $params['check_time'],
'status' => $params['status'],
'content' => $params['content'],
'is_invalid' => $params['is_invalid'],
]);
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/02/01 11:26
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FlowRecord::where('id', $params['id'])->update([
'approve_id' => $params['approve_id'],
'step_id' => $params['step_id'],
'check_user_id' => $params['check_user_id'],
'check_time' => $params['check_time'],
'status' => $params['status'],
'content' => $params['content'],
'is_invalid' => $params['is_invalid'],
]);
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/02/01 11:26
*/
public static function delete(array $params): bool
{
return FlowRecord::destroy($params['id']);
}
/**
* @notes 获取审批记录详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/01 11:26
*/
public static function detail($params): array
{
return FlowRecord::findOrEmpty($params['id'])->toArray();
}
}

@ -0,0 +1,114 @@
<?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\oa;
use app\common\model\oa\FlowStep;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 审批步骤逻辑
* Class FlowStepLogic
* @package app\adminapi\logic\oa
*/
class FlowStepLogic extends BaseLogic
{
/**
* @notes 添加审批步骤
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/01 11:26
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FlowStep::create([
'approve_id' => $params['approve_id'],
'flow_name' => $params['flow_name'],
'flow_step' => $params['flow_step'],
'flow_user' => $params['flow_user'],
'sort' => $params['sort'],
]);
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/02/01 11:26
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FlowStep::where('id', $params['id'])->update([
'approve_id' => $params['approve_id'],
'flow_name' => $params['flow_name'],
'flow_step' => $params['flow_step'],
'flow_user' => $params['flow_user'],
'sort' => $params['sort'],
]);
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/02/01 11:26
*/
public static function delete(array $params): bool
{
return FlowStep::destroy($params['id']);
}
/**
* @notes 获取审批步骤详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/01 11:26
*/
public static function detail($params): array
{
return FlowStep::findOrEmpty($params['id'])->toArray();
}
}

@ -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\validate\oa;
use app\common\validate\BaseValidate;
/**
* 日常审批验证器
* Class FlowApproveValidate
* @package app\adminapi\validate\oa
*/
class FlowApproveValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'flow_type_id' => 'require',
'flow_id' => 'require',
'content_id' => 'require',
'content_model' => 'require',
'create_user' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'flow_type_id' => '审批类型id',
'flow_id' => '审批流程id',
'content_id' => '提交内容id',
'content_model' => '提交内容数据模型',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return FlowApproveValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneAdd()
{
return $this->only(['flow_type_id','flow_id','content_id','content_model','create_user']);
}
/**
* @notes 编辑场景
* @return FlowApproveValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneEdit()
{
return $this->only(['id','flow_type_id','flow_id','content_id','content_model','create_user']);
}
/**
* @notes 删除场景
* @return FlowApproveValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FlowApproveValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

@ -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\validate\oa;
use app\common\validate\BaseValidate;
/**
* 审批记录验证器
* Class FlowRecordValidate
* @package app\adminapi\validate\oa
*/
class FlowRecordValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'approve_id' => 'require',
'step_id' => 'require',
'check_user_id' => 'require',
'check_time' => 'require',
'status' => 'require',
'content' => 'require',
'is_invalid' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'approve_id' => '审批内容ID',
'step_id' => '审批步骤ID',
'check_user_id' => '审批人ID',
'check_time' => '审批时间',
'status' => '审批状态 0发起审批1审核通过2审核拒绝3撤销',
'content' => '审核意见',
'is_invalid' => '审批失效1标记为无效',
];
/**
* @notes 添加场景
* @return FlowRecordValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneAdd()
{
return $this->only(['approve_id','step_id','check_user_id','check_time','status','content','is_invalid']);
}
/**
* @notes 编辑场景
* @return FlowRecordValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneEdit()
{
return $this->only(['id','approve_id','step_id','check_user_id','check_time','status','content','is_invalid']);
}
/**
* @notes 删除场景
* @return FlowRecordValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FlowRecordValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

@ -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\validate\oa;
use app\common\validate\BaseValidate;
/**
* 审批步骤验证器
* Class FlowStepValidate
* @package app\adminapi\validate\oa
*/
class FlowStepValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'approve_id' => 'require',
'flow_name' => 'require',
'flow_step' => 'require',
'flow_user' => 'require',
'sort' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'approve_id' => '审批内容ID',
'flow_name' => '流程名称',
'flow_step' => '流程步骤',
'flow_user' => '审批人',
'sort' => '排序ID',
];
/**
* @notes 添加场景
* @return FlowStepValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneAdd()
{
return $this->only(['approve_id','flow_name','flow_step','flow_user','sort']);
}
/**
* @notes 编辑场景
* @return FlowStepValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneEdit()
{
return $this->only(['id','approve_id','flow_name','flow_step','flow_user','sort']);
}
/**
* @notes 删除场景
* @return FlowStepValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FlowStepValidate
* @author likeadmin
* @date 2024/02/01 11:26
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

@ -1,6 +1,13 @@
<?php
// 应用公共文件
use app\common\model\auth\Admin;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowApprove;
use app\common\model\oa\FlowRecord;
use app\common\model\oa\FlowStep;
use app\common\service\FileService;
use think\facade\Db;
use think\helper\Str;
/**
@ -351,3 +358,62 @@ function daysBetweenDates($start_date,$end_date): bool|int
$interval = $start->diff($end);
return $interval->days;
}
function addApprove($title,$content_id,$content_model,$content_logic,$flow_type_id,$flow_id,$create_user_id){
$createUser = Admin::field('name')->where('id',$create_user_id)->findOrEmpty();
//获取审批流程信息
$flowData = Flow::where('id',$flow_id)->findOrEmpty();
Db::startTrans();
try {
//添加审批内容
$approveRes = FlowApprove::create([
'title' => $title,
'content_id' => $content_id,
'content_model' => $content_model,
'content_logic' => $content_logic,
'flow_type_id' => $flow_type_id,
'flow_id' => $flow_id,
'create_user' => $create_user_id,
'check_status' => 0,
'current_step' => 0,
'total_step' => count($flowData['flow_list']) + 1
]);
$flowStepData = [];
foreach($flowData['flow_list'] as $k=>$v){
$flowStepData[] = [
'approve_id' => $approveRes->id,
'flow_name' => $flowData['name'],
'flow_step' => $v['flow_step'],
'flow_user' => $v['flow_step'] != 1 ? implode(',',$v['flow_user']) : 0,
'sort' => $k+1,
];
}
array_unshift($flowStepData, [
'approve_id' => $approveRes->id,
'flow_name' => $flowData['name'],
'flow_step' => 0,
'flow_user' => 0,
'sort' => 0,
]);
//添加审批步骤
foreach($flowStepData as $v){
FlowStep::create($v);
}
//添加审批记录
FlowRecord::create([
'approve_id' => $approveRes->id,
'step_id' => 0,
'check_user_id' => 0,
'check_time' => time(),
'status' => 0,
'title' => $createUser['name'].'提交了此申请',
'content' => '提交申请',
'is_invalid' => 0
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
return false;
}
}

@ -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\oa;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 日常审批模型
* Class FlowApprove
* @package app\common\model\oa
*/
class FlowApprove extends BaseModel
{
use SoftDelete;
protected $name = 'flow_approve';
protected $deleteTime = 'delete_time';
public function getCheckStatusTextAttr($value,$data){
$dict = DictData::where('type_value','check_status')->column('name','value');
return $dict[$data['check_status']];
}
}

@ -0,0 +1,42 @@
<?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\oa;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 审批记录模型
* Class FlowRecord
* @package app\common\model\oa
*/
class FlowRecord extends BaseModel
{
use SoftDelete;
protected $name = 'flow_record';
protected $deleteTime = 'delete_time';
public function getStatusTextAttr($value,$data){
$dict = DictData::where('type_value','check_status')->column('name','value');
return $dict[$data['status']];
}
public function getCheckTimeAttr($value){
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

@ -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\oa;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 审批步骤模型
* Class FlowStep
* @package app\common\model\oa
*/
class FlowStep extends BaseModel
{
use SoftDelete;
protected $name = 'flow_step';
protected $deleteTime = 'delete_time';
public function getFlowStepTextAttr($value,$data){
$dict = DictData::where('type_value','flow_step_flow_type')->column('name','value');
return !empty($data['flow_step']) ? $dict[$data['flow_step']] : '';
}
}