Process.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. //流程单
  7. class Process extends BaseController
  8. {
  9. public $post="";
  10. public function __construct(App $app)
  11. {
  12. parent::__construct($app);
  13. $this->post = $this->request->post();
  14. }
  15. /**
  16. * @return \think\response\Json|void
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function list(){
  22. $page =isset($this->post['page']) &&$this->post['page']!="" ? intval($this->post['page']) : 1;
  23. $size =isset($this->post['size']) &&$this->post['size']!="" ? intval($this->post['size']) : 10;
  24. $count = Db::name("process")->where('is_del',1)->count();
  25. $total = ceil($count/$size);
  26. $page = $page>$total ? $total:$page;
  27. $list = Db::name("process")->where('is_del', 1)->page($page, $size)->select();
  28. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  29. }
  30. /**
  31. * @return \think\response\Json|void
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. */
  36. public function info(){
  37. $id =isset($this->post['id']) &&$this->post['id']!="" ? intval($this->post['id']) : "";
  38. if($id==""){
  39. return error_show(1004,"参数id 不能为空");
  40. }
  41. $info = Db::name("process")->where(['id'=>$id,"is_del"=>0])->find();
  42. if(empty($info)){
  43. return error_show(1004,"流程信息未找到");
  44. }
  45. $list=Db::name("action_process")->where(["pid"=>$id,"is_del"=>0])->order("weight,id")->select();
  46. $info['item'] = empty($list) ? []:$list;
  47. return app_show(0,"获取成功",$info);
  48. }
  49. /**
  50. * @return \think\response\Json|void
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\DbException
  53. * @throws \think\db\exception\ModelNotFoundException
  54. */
  55. public function process(){
  56. $process_type = isset($this->post['type'])&&$this->post['type']!="" ? $this->post['type']:"";
  57. if($process_type==""){
  58. return error_show(1004,"参数type 不能为空");
  59. }
  60. $orderCode = isset($this->post['orderCode'])&&$this->post['orderCode']!="" ? $this->post['orderCode']:"";
  61. if($orderCode==""){
  62. return error_show(1004,"参数orderCode不能为空");
  63. }
  64. $list = Db::name("action_process")->where(['order_type'=>$process_type,"is_del"=>0,"status"=>1])->order("weight desc,id desc")
  65. ->select();
  66. $data=[];
  67. foreach ($list as $value){
  68. $node = Db::name("process_order")->where(["order_type"=>$value['order_type'],"action_process"=>$value['order_process'],"order_code"=>$orderCode])->find();
  69. $value['action_uid']= isset($node['action_uid']) ? $node['action_uid']:'';
  70. $value['action_name']= isset($node['action_name']) ? $node['action_name']:'';
  71. $data[]=$value;
  72. }
  73. return app_show(0,"获取成功",$data);
  74. }
  75. }