|
@@ -5,7 +5,8 @@ namespace app\admin\controller;
|
|
|
//流程节点
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
|
-use app\admin\model\ActionProcess as ActionProcessModel;
|
|
|
+use app\admin\model\ActionProcess as APModel;
|
|
|
+use app\admin\model\Process as PModel;
|
|
|
|
|
|
class ActionProcess extends Base
|
|
|
{
|
|
@@ -67,14 +68,31 @@ class ActionProcess extends Base
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
'token' => 'require',
|
|
|
- 'order_type|所属流程编码' => 'require|max:255',
|
|
|
- 'order_name|所属流程名称' => 'require|max:255',
|
|
|
- 'action_type|节点类型' => 'require|number|between:1,4',
|
|
|
- 'operation_type|操作类型' => 'require|number|in:1,2',
|
|
|
+ 'order_type|流程编码' => 'require|max:255',
|
|
|
+ 'order_name|流程名称' => 'require|max:255|checkProcess:',
|
|
|
+ 'action_type|节点类型' => 'require|number|between:' . APModel::$action_type_start . ',' . APModel::$action_type_end,
|
|
|
+ 'operation_type|操作类型' => 'require|number|in:' . APModel::$operation_type_approval . ',' . APModel::$operation_type_system,
|
|
|
'status_name|节点名称' => 'require|max:255',
|
|
|
- 'order_process|节点值' => 'require|number|gt:0',
|
|
|
+ 'order_process|节点值' => 'require|number|egt:0|checkOrderProcess:',
|
|
|
+ 'next_action_ids|下一节点' => 'requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
|
|
|
]);
|
|
|
|
|
|
+ $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;
|
|
|
+ });
|
|
|
+
|
|
|
+ $val->extend('checkOrderProcess', function ($val, $rule, $data) {
|
|
|
+ return APModel::where([
|
|
|
+ 'order_type' => $data['order_type'],
|
|
|
+ 'order_process' => $val,
|
|
|
+ 'is_del' => APModel::$is_del_normal
|
|
|
+ ])->field('id')->findOrEmpty()->isEmpty() ? true : '同一个流程编码下该节点值已存在';
|
|
|
+ });
|
|
|
+
|
|
|
if (!$val->check($param)) return error_show(1005, $val->getError());
|
|
|
|
|
|
$user = GetUserInfo($param['token']);
|
|
@@ -83,20 +101,73 @@ class ActionProcess extends Base
|
|
|
$uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
|
|
- return ActionProcessModel::create(array_merge($param, [
|
|
|
- 'status' => ActionProcessModel::$status_normal,
|
|
|
- 'is_del' => ActionProcessModel::$is_del_normal,
|
|
|
+ return APModel::create(array_merge($param, [
|
|
|
+ 'status' => APModel::$status_normal,
|
|
|
+ 'is_del' => APModel::$is_del_normal,
|
|
|
'createrid' => $uid,
|
|
|
'creater' => $uname,
|
|
|
'addtime' => $date,
|
|
|
'updaterid' => $uid,
|
|
|
'updater' => $uname,
|
|
|
'updatetime' => $date,
|
|
|
- 'remark' => $param['remark']
|
|
|
]))->save() ? app_show(0, '新增流程节点成功') : error_show(1005, '新增流程节点失败');
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //读取
|
|
|
+ public function read()
|
|
|
+ {
|
|
|
+
|
|
|
+ $id = $this->request->filter('trim')->post('id/d', 0);
|
|
|
+
|
|
|
+ $res = APModel::field(true)
|
|
|
+ ->where(['id' => $id, 'is_del' => APModel::$is_del_normal])
|
|
|
+ ->findOrEmpty()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', $res);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改
|
|
|
+ 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');
|
|
|
+
|
|
|
+ $val = Validate::rule([
|
|
|
+ 'token' => 'require',
|
|
|
+ 'id|ID' => 'require|number|gt:0',
|
|
|
+ 'order_type|流程编码' => 'max:255',
|
|
|
+ 'order_name|流程名称' => 'max:255|checkProcess:',
|
|
|
+ 'action_type|节点类型' => 'number|between:' . APModel::$action_type_start . ',' . APModel::$action_type_end,
|
|
|
+ '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,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $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;
|
|
|
+ });
|
|
|
+
|
|
|
+ $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 (!$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 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, '新增流程节点失败');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|