$allData = $this->reportMainpageRepo->findWhere(['delete_status'=>1]);
//循环获取的数据记录,根据当前的记录状态,和用户的角色,确定最终的操作按钮
foreach ($allData as $k => $v) {
$allData[$k]['buttons'] = $this->getButtons($organizeRoleIds,$v['role_organize_status'],$v['user_id'],$v['id'],$userNowId);
}
//
//
// return $allData;
return DataTables::of($allData)
->addColumn('action', getThemeTemplate('back.report.mainpage.datatable'))
->make();
//获取当前报告的状态和用户操作人public function getButtons($organizeRoleIds,$reportStatus,$user_id,$id,$userNowId){ //报告10 用户的是 2,7 if(in_array($reportStatus,$organizeRoleIds)){ // 存在 判断当前用户是否是数据录入员 if(in_array(2,$organizeRoleIds)) { //$user_id 为报告里的Id $userId是当前用户的id if($user_id == $userNowId&&$reportStatus == 2) { $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/edit" data-id="' . $id . '">删除</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ]; } else{ //当前报告编号如果为已完成的话数据录入员则可以进行新建版本 if($reportStatus == 6) { $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/new" data-id="' . $id . '">新建版本</a></span>'], ]; } else{ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ]; } } } else{ //没有数据录入员的权限 if($user_id == $userNowId){ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/edit" data-id="' . $id . '">删除</a></span>'], ]; } else{ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ]; } } } else{ //报告编号不存在用户的权限里 if(in_array(2,$organizeRoleIds)) { //$user_id 为报告里的Id $userId是当前用户的id if($user_id == $userNowId&&$reportStatus == 2) { $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/edit" data-id="' . $id . '">删除</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ]; } else{ //当前报告编号如果为已完成的话数据录入员则可以进行新建版本 if($reportStatus == 6) { $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/new" data-id="' . $id . '">新建版本</a></span>'], ]; } else{ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/copy" data-id="' . $id . '">复制</a></span>'], ]; } } } else{ //没有数据录入员的权限 if($user_id == $userNowId){ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/edit" data-id="' . $id . '">删除</a></span>'], ]; } else{ $operations = [ ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/show" data-id="' . $id . '">详情</a></span>'], ['<span class="label label-success"><a href="http://127.0.0.1/medsci_pv/public/admin/report/mainpage/id=' . $id . '/export" data-id="' . $id . '">导出</a></span>'], ]; } } } return $operations;}