|
@@ -2,18 +2,21 @@
|
|
|
|
|
|
|
|
|
|
namespace app\admin\controller;
|
|
namespace app\admin\controller;
|
|
|
|
+
|
|
use app\BaseController;
|
|
use app\BaseController;
|
|
use think\App;
|
|
use think\App;
|
|
use think\facade\Db;
|
|
use think\facade\Db;
|
|
|
|
+use think\facade\Validate;
|
|
|
|
+use app\admin\model\Process as ProcessModel;
|
|
|
|
|
|
//流程单
|
|
//流程单
|
|
class Process extends Base
|
|
class Process extends Base
|
|
{
|
|
{
|
|
|
|
|
|
- public function __construct(App $app)
|
|
|
|
- {
|
|
|
|
- parent::__construct($app);
|
|
|
|
- }
|
|
|
|
|
|
+ public function __construct(App $app)
|
|
|
|
+ {
|
|
|
|
+ parent::__construct($app);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return \think\response\Json|void
|
|
* @return \think\response\Json|void
|
|
@@ -21,16 +24,17 @@ class Process extends Base
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
*/
|
|
- public function list(){
|
|
|
|
- $page =isset($this->post['page']) &&$this->post['page']!="" ? intval($this->post['page']) : 1;
|
|
|
|
- $size =isset($this->post['size']) &&$this->post['size']!="" ? intval($this->post['size']) : 10;
|
|
|
|
|
|
+ public function list()
|
|
|
|
+ {
|
|
|
|
+ $page = isset($this->post['page']) && $this->post['page'] != "" ? intval($this->post['page']) : 1;
|
|
|
|
+ $size = isset($this->post['size']) && $this->post['size'] != "" ? intval($this->post['size']) : 10;
|
|
|
|
|
|
- $count = Db::name("process")->where('is_del',0)->count();
|
|
|
|
- $total = ceil($count/$size);
|
|
|
|
- $page = $page>$total ? $total:$page;
|
|
|
|
- $list = Db::name("process")->where('is_del', 0)->page($page, $size)->select();
|
|
|
|
- return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
|
|
|
|
- }
|
|
|
|
|
|
+ $count = Db::name("process")->where('is_del', 0)->count();
|
|
|
|
+ $total = ceil($count / $size);
|
|
|
|
+ $page = $page > $total ? $total : $page;
|
|
|
|
+ $list = Db::name("process")->where('is_del', 0)->page($page, $size)->select();
|
|
|
|
+ return app_show(0, "获取成功", ["list" => $list, "count" => $count]);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return \think\response\Json|void
|
|
* @return \think\response\Json|void
|
|
@@ -38,19 +42,20 @@ class Process extends Base
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
*/
|
|
- public function info(){
|
|
|
|
- $id =isset($this->post['id']) &&$this->post['id']!="" ? intval($this->post['id']) : "";
|
|
|
|
- if($id==""){
|
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
|
- }
|
|
|
|
- $info = Db::name("process")->where(['id'=>$id,"is_del"=>0])->find();
|
|
|
|
- if(empty($info)){
|
|
|
|
- return error_show(1004,"流程信息未找到");
|
|
|
|
|
|
+ public function info()
|
|
|
|
+ {
|
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] != "" ? intval($this->post['id']) : "";
|
|
|
|
+ if ($id == "") {
|
|
|
|
+ return error_show(1004, "参数id 不能为空");
|
|
|
|
+ }
|
|
|
|
+ $info = Db::name("process")->where(['id' => $id, "is_del" => 0])->find();
|
|
|
|
+ if (empty($info)) {
|
|
|
|
+ return error_show(1004, "流程信息未找到");
|
|
|
|
+ }
|
|
|
|
+ $list = Db::name("action_process")->where(["pid" => $id, "is_del" => 0])->order("weight,id")->select();
|
|
|
|
+ $info['item'] = empty($list) ? [] : $list;
|
|
|
|
+ return app_show(0, "获取成功", $info);
|
|
}
|
|
}
|
|
- $list=Db::name("action_process")->where(["pid"=>$id,"is_del"=>0])->order("weight,id")->select();
|
|
|
|
- $info['item'] = empty($list) ? []:$list;
|
|
|
|
- return app_show(0,"获取成功",$info);
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @return \think\response\Json|void
|
|
* @return \think\response\Json|void
|
|
@@ -80,8 +85,8 @@ class Process extends Base
|
|
->where(["order_type" => $process_type])
|
|
->where(["order_type" => $process_type])
|
|
->whereIn('action_process', $order_process_s)
|
|
->whereIn('action_process', $order_process_s)
|
|
->field('id,action_uid,action_name,addtime,action_process,order_type');
|
|
->field('id,action_uid,action_name,addtime,action_process,order_type');
|
|
- if(is_numeric($orderCode)) $rs->where('order_id',$orderCode);
|
|
|
|
- else $rs->where('order_code',$orderCode);
|
|
|
|
|
|
+ if (is_numeric($orderCode)) $rs->where('order_id', $orderCode);
|
|
|
|
+ else $rs->where('order_code', $orderCode);
|
|
|
|
|
|
$node = $rs
|
|
$node = $rs
|
|
->select()
|
|
->select()
|
|
@@ -113,4 +118,114 @@ class Process extends Base
|
|
return app_show(0, "获取成功", $node);
|
|
return app_show(0, "获取成功", $node);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //获取流程列表
|
|
|
|
+ public function getList()
|
|
|
|
+ {
|
|
|
|
+ $param = $this->request->filter('trim')->only(['status' => '', 'process_name' => '', 'creater' => '', 'addtime_start' => '', 'addtime_end' => '', 'page' => 1, 'size' => 15], 'post');
|
|
|
|
+
|
|
|
|
+ $where = [['is_del', '=', ProcessModel::$is_del_normal]];
|
|
|
|
+ if ($param['status'] != '') $where[] = ['status', '=', $param['status']];
|
|
|
|
+ if ($param['process_name'] != '') $where[] = ['process_name', 'like', '%' . $param['process_name'] . '%'];
|
|
|
|
+ if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
|
|
|
|
+ if ($param['addtime_start'] != '' && $param['addtime_end'] != '') $where[] = ['addtime', 'between', [$param['addtime_start'], $param['addtime_end'] . ' 23:59:59']];
|
|
|
|
+
|
|
|
|
+ $count = Db::name('process')
|
|
|
|
+ ->where($where)
|
|
|
|
+ ->count('id');
|
|
|
|
+
|
|
|
|
+ $list = ProcessModel::field('id,process_name,process_type,status,creater,addtime')
|
|
|
|
+ ->where($where)
|
|
|
|
+ ->order('id', 'desc')
|
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
|
+ ->select()
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ return app_show(0, '获取成功', ['count' => $count, 'list' => $list]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //增加流程
|
|
|
|
+ public function add()
|
|
|
|
+ {
|
|
|
|
+ $param = $this->request->filter('trim')->only(['token', 'process_name', 'process_type', 'remark' => ''], 'post');
|
|
|
|
+
|
|
|
|
+ $val = Validate::rule([
|
|
|
|
+ 'token' => 'require',
|
|
|
|
+ 'process_name|流程名称' => 'require|max:255',
|
|
|
|
+ 'process_type|流程值' => 'require|max:255|checkProcessType:',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $val->extend('checkProcessType', function ($val) {
|
|
|
|
+ return ProcessModel::where(['process_type' => $val, 'is_del' => ProcessModel::$is_del_normal])->field('id')->findOrEmpty()->isEmpty() ? true : '该流程值已存在';
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (!$val->check($param)) return error_show(1005, $val->getError());
|
|
|
|
+
|
|
|
|
+ $user = GetUserInfo($param['token']);
|
|
|
|
+
|
|
|
|
+ $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
|
|
|
|
+ $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
|
|
|
|
+ $date = date('Y-m-d H:i:s');
|
|
|
|
+
|
|
|
|
+ return ProcessModel::create(array_merge($param, [
|
|
|
|
+ 'is_del' => ProcessModel::$is_del_normal,
|
|
|
|
+ 'status' => ProcessModel::$status_normal,
|
|
|
|
+ 'createrid' => $uid,
|
|
|
|
+ 'creater' => $uname,
|
|
|
|
+ 'addtime' => $date,
|
|
|
|
+ 'updaterid' => $uid,
|
|
|
|
+ 'updater' => $uname,
|
|
|
|
+ 'updatetime' => $date,
|
|
|
|
+ ]))->save() ? app_show(0, '新增流程成功') : error_show(1005, '新增流程失败');
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //读取
|
|
|
|
+ public function read(){
|
|
|
|
+ $id=$this->request->filter('trim')->post('id/d',0);
|
|
|
|
+
|
|
|
|
+ $res = ProcessModel::field('id,process_name,process_type')
|
|
|
|
+ ->where(['id'=>$id,'is_del'=>ProcessModel::$is_del_normal])
|
|
|
|
+ ->findOrEmpty()
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ return app_show(0,'获取详情成功',$res);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //修改流程
|
|
|
|
+ public function update()
|
|
|
|
+ {
|
|
|
|
+ $param = $this->request->filter('trim')->only(['token', 'id', 'process_name', 'process_type', 'status', 'is_del', 'remark'], 'post');
|
|
|
|
+
|
|
|
|
+ $val = Validate::rule([
|
|
|
|
+ 'token' => 'require',
|
|
|
|
+ 'id|ID' => 'require|number|gt:0',
|
|
|
|
+ 'process_name|流程名称' => 'max:255',
|
|
|
|
+ 'process_type|流程值' => 'max:255|checkProcessType:',
|
|
|
|
+ 'status|状态' => 'number|in:'.ProcessModel::$status_normal.','.ProcessModel::$status_disable,
|
|
|
|
+ 'is_del|是否删除' => 'number|eq:'.ProcessModel::$is_deleted,
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $val->extend('checkProcessType', function ($val, $rule, $data) {
|
|
|
|
+ return ProcessModel::where(['process_type' => $val, 'is_del' => ProcessModel::$is_del_normal])->where('id', '<>', $data['id'])->field('id')->findOrEmpty()->isEmpty() ? true : '该流程值已存在';
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (!$val->check($param)) return error_show(1005, $val->getError());
|
|
|
|
+
|
|
|
|
+ $user = GetUserInfo($param['token']);
|
|
|
|
+
|
|
|
|
+ $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
|
|
|
|
+ $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
|
|
|
|
+ $date = date('Y-m-d H:i:s');
|
|
|
|
+
|
|
|
|
+ return ProcessModel::where(['id' => $param['id'], 'is_del' => ProcessModel::$is_del_normal])->strict(false)->save(array_merge($param, [
|
|
|
|
+ 'updaterid' => $uid,
|
|
|
|
+ 'updater' => $uname,
|
|
|
|
+ 'updatetime' => $date,
|
|
|
|
+ ])) ? app_show(0, '修改流程成功') : error_show(1005, '修改流程失败');
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|