123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace app\bug\model;
- use think\model\concern\SoftDelete;
- class WorkAction extends Base
- {
- //设置字段信息
- use SoftDelete;
- protected $schema = [
- 'id' =>'int',//
- 'action_name' =>'varchar',//功能名称
- 'menu_id' =>'int',//归属菜单页面id
- 'belong' =>'tinyint',//系统归属1采销2结算3数据统计
- 'belong_action' =>'text',//功能集合
- 'belong_process' =>'text',//功能集合
- 'apply_id' =>'int',//申请人id
- 'apply_name' =>'varchar',//申请人名称
- 'createTime' =>'datetime',//
- 'updateTime' =>'datetime',//
- 'delete_time' =>'datetime',//
- ];
- protected $updateTime='updateTime';
- protected $createTime='createTime';
- protected $deleteTime = 'delete_time';
-
- public function GetBelongActionAttr($v){
- return json_decode($v,true);
- }
-
- public function SetBelongActionAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public function GetBelongProcessAttr($v){
- return json_decode($v,true);
- }
-
- public function SetBelongProcessAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public function GetTreeActionByIdArr($idArr,$belong=0){
- $list = $this->whereIn("id",$idArr)->field("id,action_name,menu_id,belong_action,belong_process")->select();
- $temp=[];
- foreach ($list as $item){
- $meun = $this->GetMenuList($item->menu_id,$belong);
- $item->belong_action_info = $this->GetActionList($item->belong_action,$belong);
- $item->belong_process_info = $this->GetProcessList($item->belong_process,$belong);
- $temp[]=array_merge($item->toArray(),$meun);
- }
- return $temp;
- }
-
- public function GetMenuList($menuid,$belong){
- $menu=[];
- switch ($belong){
- case 1:
- $menu=\app\admin\model\AdminMenu::GetMenu($menuid);
- break;
- case 2:
- $menu=\app\cxinv\model\AdminMenu::GetMenu($menuid);
- break;
- case 3:
- $menu=\app\cxinv\model\AdminMenu::GetMenu($menuid);
- break;
- }
- return$menu;
- }
-
- public function GetActionList($action,$belong){
- $act=[];
- switch ($belong){
- case 1:
- $act=\app\admin\model\AdminMenu::GetAction($action);
- break;
- case 2:
- $act=\app\cxinv\model\AdminMenu::GetAction($action);
- break;
- case 3:
- $act=\app\cxinv\model\AdminMenu::GetAction($action);
- break;
- }
- return$act;
- }
-
- public function GetProcessList($action,$belong){
- $act=[];
- switch ($belong){
- case 1:
- $act=\app\admin\model\ActionProcess::GetProcess($action);
- break;
- case 2:
- $act=\app\admin\model\ActionProcess::GetProcess($action);
- break;
- case 3:
- $act=\app\admin\model\ActionProcess::GetProcess($action);
- break;
- }
- return$act;
- }
- public function GetInfoById($id,$belong=0){
- $list = $this->where('id',$id)->field('id,action_name,menu_id,belong_action')->findOrEmpty();
- $temp=[];
- foreach ($list as $item){
- $meun = $this->GetMenuList($item->menu_id,$belong);
- $item->belong_action_info = $this->GetActionList($item->belong_action,$belong);
- $temp[]=array_merge($item->toArray(),$meun);
- }
- return $temp;
- }
- }
|