WorkAction.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\bug\model;
  3. use think\model\concern\SoftDelete;
  4. class WorkAction extends Base
  5. {
  6. //设置字段信息
  7. use SoftDelete;
  8. protected $schema = [
  9. 'id' =>'int',//
  10. 'action_name' =>'varchar',//功能名称
  11. 'menu_id' =>'int',//归属菜单页面id
  12. 'belong' =>'tinyint',//系统归属1采销2结算3数据统计
  13. 'belong_action' =>'text',//功能集合
  14. 'belong_process' =>'text',//功能集合
  15. 'apply_id' =>'int',//申请人id
  16. 'apply_name' =>'varchar',//申请人名称
  17. 'createTime' =>'datetime',//
  18. 'updateTime' =>'datetime',//
  19. 'delete_time' =>'datetime',//
  20. ];
  21. protected $updateTime='updateTime';
  22. protected $createTime='createTime';
  23. protected $deleteTime = 'delete_time';
  24. public function GetBelongActionAttr($v){
  25. return json_decode($v,true);
  26. }
  27. public function SetBelongActionAttr($v){
  28. return json_encode($v,JSON_UNESCAPED_UNICODE);
  29. }
  30. public function GetBelongProcessAttr($v){
  31. return json_decode($v,true);
  32. }
  33. public function SetBelongProcessAttr($v){
  34. return json_encode($v,JSON_UNESCAPED_UNICODE);
  35. }
  36. public function GetTreeActionByIdArr($idArr,$belong=0){
  37. $list = $this->whereIn("id",$idArr)->field("id,action_name,menu_id,belong_action,belong_process")->select();
  38. $temp=[];
  39. foreach ($list as $item){
  40. $meun = $this->GetMenuList($item->menu_id,$belong);
  41. $item->belong_action_info = $this->GetActionList($item->belong_action,$belong);
  42. $item->belong_process_info = $this->GetProcessList($item->belong_process,$belong);
  43. $temp[]=array_merge($item->toArray(),$meun);
  44. }
  45. return $temp;
  46. }
  47. public function GetMenuList($menuid,$belong){
  48. $menu=[];
  49. switch ($belong){
  50. case 1:
  51. $menu=\app\admin\model\AdminMenu::GetMenu($menuid);
  52. break;
  53. case 2:
  54. $menu=\app\cxinv\model\AdminMenu::GetMenu($menuid);
  55. break;
  56. case 3:
  57. $menu=\app\cxinv\model\AdminMenu::GetMenu($menuid);
  58. break;
  59. }
  60. return$menu;
  61. }
  62. public function GetActionList($action,$belong){
  63. $act=[];
  64. switch ($belong){
  65. case 1:
  66. $act=\app\admin\model\AdminMenu::GetAction($action);
  67. break;
  68. case 2:
  69. $act=\app\cxinv\model\AdminMenu::GetAction($action);
  70. break;
  71. case 3:
  72. $act=\app\cxinv\model\AdminMenu::GetAction($action);
  73. break;
  74. }
  75. return$act;
  76. }
  77. public function GetProcessList($action,$belong){
  78. $act=[];
  79. switch ($belong){
  80. case 1:
  81. $act=\app\admin\model\ActionProcess::GetProcess($action);
  82. break;
  83. case 2:
  84. $act=\app\admin\model\ActionProcess::GetProcess($action);
  85. break;
  86. case 3:
  87. $act=\app\admin\model\ActionProcess::GetProcess($action);
  88. break;
  89. }
  90. return$act;
  91. }
  92. public function GetInfoById($id,$belong=0){
  93. $list = $this->where('id',$id)->field('id,action_name,menu_id,belong_action')->findOrEmpty();
  94. $temp=[];
  95. foreach ($list as $item){
  96. $meun = $this->GetMenuList($item->menu_id,$belong);
  97. $item->belong_action_info = $this->GetActionList($item->belong_action,$belong);
  98. $temp[]=array_merge($item->toArray(),$meun);
  99. }
  100. return $temp;
  101. }
  102. }