ActionProcess.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\admin\controller;
  3. //流程节点
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. class ActionProcess extends Base
  7. {
  8. //获取流程节点列表
  9. public function getList()
  10. {
  11. $param = $this->request->filter('trim')->only(['order_type', 'page' => 1, 'size' => 15], 'post');
  12. $val = Validate::rule([
  13. 'order_type|所属流程编码' => 'require',
  14. 'page|页码' => 'require|number|gt:0',
  15. 'size|每页显示的页码' => 'require|number|gt:0',
  16. ]);
  17. if (!$val->check($param)) return error_show(1005, $val->getError());
  18. $where = [];
  19. if ($param['order_type'] != '') $where[] = ['order_type', '=', $param['order_type']];
  20. $count = Db::name('action_process')
  21. ->where($where)
  22. ->count('id');
  23. $list = Db::name('action_process')
  24. ->field('id,status_name,order_process,status,action_type,operation_type,next_action_ids,creater,addtime')
  25. ->where($where)
  26. ->order('id', 'desc')
  27. ->page($param['page'], $param['size'])
  28. ->select()
  29. ->toArray();
  30. $all_next_ids = implode(',', array_column($list, 'next_action_ids'));
  31. //处理下一个节点的名称
  32. $child = Db::name('action_process')
  33. ->whereIn('id', $all_next_ids)
  34. ->column('status_name', 'id');
  35. foreach ($list as &$item) {
  36. if ($item['next_action_ids']) {
  37. $next_action_ids = explode(',', $item['next_action_ids']);
  38. foreach ($next_action_ids as $next_action_id) {
  39. if (isset($child[$next_action_id])) $item['next_actions'][] = $child[$next_action_id];
  40. }
  41. } else $item['next_actions'] = [];
  42. }
  43. return app_show(0, '获取成功', ['count' => $count, 'list' => $list]);
  44. }
  45. //新增流程节点
  46. public function add(){
  47. $param = $this->request->filter('trim')->only(['','','',''],'post');
  48. $val=Validate::rule();
  49. if(!$val->check([])) return error_show(1005,$val->getError());
  50. $user = GetUserInfo($param['token']);
  51. $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
  52. $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
  53. $date = date('Y-m-d H:i:s');
  54. }
  55. }