12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\bug\model;
- use think\Exception;use think\model\concern\SoftDelete;class WorkSubscr extends Base
- {
- //设置字段信息
- use SoftDelete;
- protected $schema = [
- 'id' =>'int',//
- 'belong' =>'tinyint',//系统归属
- 'role_id' =>'int',//角色id
- 'action' =>'text',//选中的岗位功能
- 'role_action' =>'text',//选中的岗位功能
- 'apply_id' =>'int',//申请人id
- 'apply_name' =>'varchar',//申请人名称
- 'check_id' =>'int',//审核人
- 'check_name' =>'varchar',//审核人
- 'status' =>'tinyint',//状态
- 'is_check' =>'tinyint',//是否有待审核数据
- 'createTime' =>'datetime',//
- 'updateTime' =>'datetime',//
- 'delete_time' =>'datetime',//
- ];
- protected $updateTime='updateTime';
- protected $createTime='createTime';
- protected $deleteTime = 'delete_time';
- public static $statusCn=['无状态',"待审批","部分通过", "全部通过" ,"全部驳回","废弃"];
- public function RoleInfo(){
- return $this->belongsTo(WorkRole::class,"role_id","id")->bind(["role_name","work_id","work_name","companyNo",'companyName']);
- }
- public function subInfo(){
- return $this->hasMany(WorkSubinfo::class,'sub_id','id');
- }
-
- public function GetActionAttr($v){
- return json_decode($v,true);
- }
- public function SetActionAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public function GetRoleActionAttr($v){
- return json_decode($v,true);
- }
- public function SetRoleActionAttr($v){
- return json_encode($v,JSON_UNESCAPED_UNICODE);
- }
-
- public static function GetActionById($id){
- $info = self::findOrEmpty($id);
- if($info->is_check==1) throw new \Exception("功能权限申请存在数据未审核",1004);
- $list = WorkSubinfo::where(["sub_id"=>$id,"status"=>1])->column("action_id,type");
- $result = $info->role_action;
- $tempAdd=[];
- $tempRemove=[];
- if(!empty($list)){
- foreach ($list as $item){
- if($item['type']==1) $tempAdd[]=$item['action_id'];
- if($item['type']==2)$tempRemove[]=$item['action_id'];
- }
- }
- return array_diff(array_merge($result,$tempAdd),$tempRemove);
- }
- }
|