You've already forked guangan
100 lines
2.6 KiB
PHP
100 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace plugin\ticket\controller;
|
|
|
|
use plugin\ticket\model\ApprovalProcess;
|
|
use think\admin\Controller;
|
|
use think\admin\helper\QueryHelper;
|
|
use think\admin\model\SystemUser;
|
|
|
|
/**
|
|
* 审核流程管理
|
|
*/
|
|
class Approval extends Controller
|
|
{
|
|
/**
|
|
* 审批流程管理页面
|
|
* @auth true
|
|
* @menu true
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @return void
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->title = '审批流程管理';
|
|
ApprovalProcess::mQuery()->layTable(function () {
|
|
$this->types = [
|
|
0 => '待提交',
|
|
1 => '进行中',
|
|
2 => '已通过',
|
|
3 => '已驳回',
|
|
4 => '已取消'
|
|
];
|
|
}, function (QueryHelper $query) {
|
|
$query->like('name')->equal('status');
|
|
$query->dateBetween('create_time');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 添加审批流程页面
|
|
* @auth true
|
|
* @menu true
|
|
* @return void
|
|
*/
|
|
public function add()
|
|
{
|
|
$this->title = '添加审批流程';
|
|
$this->users = SystemUser::query()->field('id,username,nickname')->select();
|
|
ApprovalProcess::mForm('form');
|
|
}
|
|
|
|
/**
|
|
* 编辑审批流程页面
|
|
* @auth true
|
|
* @menu true
|
|
* @return void
|
|
*/
|
|
public function edit()
|
|
{
|
|
$this->title = '编辑审批流程';
|
|
$this->id = $this->request->param('id');
|
|
$this->users = SystemUser::query()->field('id,username,nickname')->select();
|
|
ApprovalProcess::mForm('form', 'id');
|
|
}
|
|
|
|
/**
|
|
* 删除审批流程
|
|
* @auth true
|
|
* @menu true
|
|
* @return void
|
|
*/
|
|
public function remove()
|
|
{
|
|
ApprovalProcess::mDelete('id');
|
|
}
|
|
|
|
/**
|
|
* 表单数据处理
|
|
* @param array $data
|
|
*/
|
|
protected function _form_filter(array &$data)
|
|
{
|
|
if ($this->request->isPost()) {
|
|
// 解析步骤数据
|
|
$steps = json_decode($data['steps'], true);
|
|
foreach ($steps as &$step) {
|
|
$step['approver_type'] = intval($step['approver_type']);
|
|
}
|
|
$data['steps'] = json_encode($steps);
|
|
// 检查是否存在相同类型的审批流程,排除当前编辑的记录
|
|
$type = $this->request->post('type');
|
|
$id = $this->request->post('id');
|
|
if (ApprovalProcess::where('type', $type)->where('id', '<>', $id)->find()) {
|
|
$this->error('该类型的审批流程已经存在');
|
|
}
|
|
}
|
|
}
|
|
} |