|
@@ -2,12 +2,12 @@
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
-//流程节点
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
|
use app\admin\model\ActionProcess as APModel;
|
|
|
use app\admin\model\Process as PModel;
|
|
|
|
|
|
+//流程节点
|
|
|
class ActionProcess extends Base
|
|
|
{
|
|
|
|
|
@@ -18,7 +18,7 @@ class ActionProcess extends Base
|
|
|
$param = $this->request->filter('trim')->only(['order_type', 'page' => 1, 'size' => 15], 'post');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
- 'order_type|所属流程编码' => 'require',
|
|
|
+ 'order_type|流程编码' => 'require',
|
|
|
'page|页码' => 'require|number|gt:0',
|
|
|
'size|每页显示的页码' => 'require|number|gt:0',
|
|
|
]);
|
|
@@ -32,8 +32,7 @@ class ActionProcess extends Base
|
|
|
->where($where)
|
|
|
->count('id');
|
|
|
|
|
|
- $list = Db::name('action_process')
|
|
|
- ->field('id,status_name,order_process,status,action_type,operation_type,next_action_ids,creater,addtime')
|
|
|
+ $list = APModel::field('id,status_name,order_process,status,action_type,operation_type,next_action_ids,creater,addtime,remark')
|
|
|
->where($where)
|
|
|
->order('id', 'desc')
|
|
|
->page($param['page'], $param['size'])
|
|
@@ -60,7 +59,7 @@ class ActionProcess extends Base
|
|
|
|
|
|
}
|
|
|
|
|
|
- //新增流程节点
|
|
|
+ //新增
|
|
|
public function add()
|
|
|
{
|
|
|
|
|
@@ -74,7 +73,7 @@ class ActionProcess extends Base
|
|
|
'operation_type|操作类型' => 'require|number|in:' . APModel::$operation_type_approval . ',' . APModel::$operation_type_system,
|
|
|
'status_name|节点名称' => 'require|max:255',
|
|
|
'order_process|节点值' => 'require|number|egt:0|checkOrderProcess:',
|
|
|
- 'next_action_ids|下一节点' => 'requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
|
|
|
+ 'next_action_ids|下一节点' => 'array|requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
|
|
|
]);
|
|
|
|
|
|
$val->extend('checkProcess', function ($val, $rule, $data) {
|
|
@@ -112,7 +111,6 @@ class ActionProcess extends Base
|
|
|
'updatetime' => $date,
|
|
|
]))->save() ? app_show(0, '新增流程节点成功') : error_show(1005, '新增流程节点失败');
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//读取
|
|
@@ -123,6 +121,9 @@ class ActionProcess extends Base
|
|
|
|
|
|
$res = APModel::field(true)
|
|
|
->where(['id' => $id, 'is_del' => APModel::$is_del_normal])
|
|
|
+ ->withAttr('next_action_ids', function ($val) {
|
|
|
+ return explode(',', $val);
|
|
|
+ })
|
|
|
->findOrEmpty()
|
|
|
->toArray();
|
|
|
|
|
@@ -133,7 +134,7 @@ class ActionProcess extends Base
|
|
|
public function update()
|
|
|
{
|
|
|
|
|
|
- $param = $this->request->filter('trim')->only(['token', 'id', 'order_type', 'order_name', 'action_type', 'operation_type', 'status_name', 'order_process', 'next_action_ids' => '', 'remark' => ''], 'post');
|
|
|
+ $param = $this->request->filter('trim')->only(['token', 'id', 'order_type', 'order_name', 'action_type', 'operation_type', 'status_name', 'order_process', 'next_action_ids' => '', 'remark' => '', 'status' => '', 'is_del' => ''], 'post');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
'token' => 'require',
|
|
@@ -144,17 +145,19 @@ class ActionProcess extends Base
|
|
|
'operation_type|操作类型' => 'number|in:' . APModel::$operation_type_approval . ',' . APModel::$operation_type_system,
|
|
|
'status_name|节点名称' => 'max:255',
|
|
|
'order_process|节点值' => 'number|egt:0|checkOrderProcess:',
|
|
|
- 'next_action_ids|下一节点' => 'requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
|
|
|
- 'is_del' => 'eq:' . APModel::$is_deleted,
|
|
|
- 'status' => 'in:' . APModel::$status_disable . ',' . APModel::$status_normal,
|
|
|
+ 'next_action_ids|下一节点' => 'array|requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
|
|
|
+ 'is_del|是否删除' => 'eq:' . APModel::$is_deleted,
|
|
|
+ 'status|状态' => 'in:' . APModel::$status_disable . ',' . APModel::$status_normal,
|
|
|
]);
|
|
|
|
|
|
$val->extend('checkProcess', function ($val, $rule, $data) {
|
|
|
- return PModel::where(['process_name' => $val, 'process_type' => $data['order_type'], 'is_del' => PModel::$is_del_normal])->field('id')->findOrEmpty()->isEmpty() ? '流程编码和流程名称不存在' : true;
|
|
|
+ if (isset($val) && isset($data['order_type'])) return PModel::where(['process_name' => $val, 'process_type' => $data['order_type'], 'is_del' => PModel::$is_del_normal])->field('id')->findOrEmpty()->isEmpty() ? '流程编码和流程名称不存在' : true;
|
|
|
+ else return true;
|
|
|
});
|
|
|
|
|
|
$val->extend('checkOrderProcess', function ($val, $rule, $data) {
|
|
|
- return APModel::where(['order_type' => $data['order_type'], 'order_process' => $val, 'is_del' => APModel::$is_del_normal])->where('id', '<>', $data['id'])->field('id')->findOrEmpty()->isEmpty() ? true : '同一个流程编码下该节点值已存在';
|
|
|
+ if (isset($val) && isset($data['order_type'])) return APModel::where(['order_type' => $data['order_type'], 'order_process' => $val, 'is_del' => APModel::$is_del_normal])->where('id', '<>', $data['id'])->field('id')->findOrEmpty()->isEmpty() ? true : '同一个流程编码下该节点值已存在';
|
|
|
+ else return true;
|
|
|
});
|
|
|
|
|
|
if (!$val->check($param)) return error_show(1005, $val->getError());
|
|
@@ -165,7 +168,26 @@ class ActionProcess extends Base
|
|
|
$uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
|
|
- return APModel::where(['id' => $param['id'], 'is_del' => APModel::$is_del_normal])->strict(false)->save(array_merge($param, ['updaterid' => $uid, 'updater' => $uname, 'updatetime' => $date])) ? app_show(0, '新增流程节点成功') : error_show(1005, '新增流程节点失败');
|
|
|
+ return APModel::where(['id' => $param['id'], 'is_del' => APModel::$is_del_normal])->strict(false)->save(array_merge($param, ['updaterid' => $uid, 'updater' => $uname, 'updatetime' => $date])) ? app_show(0, '修改流程节点成功') : error_show(1005, '修改流程节点失败');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有流程的所有节点
|
|
|
+ public function getAll()
|
|
|
+ {
|
|
|
+
|
|
|
+ $data = PModel::where(['is_del' => PModel::$is_del_normal, 'status' => PModel::$status_normal])
|
|
|
+ ->column('id,process_name,process_type', 'process_type');
|
|
|
+
|
|
|
+ $action = APModel::where(['is_del' => APModel::$is_del_normal, 'status' => APModel::$status_normal])
|
|
|
+ ->field('id,order_type,order_process,status_name')
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ foreach ($action as $item) {
|
|
|
+ $data[$item->order_type]['child'][] = $item->toArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', array_column($data,null,null));
|
|
|
|
|
|
}
|
|
|
|