作者 赵彬吉

update

... ... @@ -8,6 +8,8 @@ use App\Http\Logic\Aside\Task\TaskLogic;
use App\Http\Logic\Aside\Task\TaskOwnerLogic;
use App\Http\Requests\Aside\Task\TaskFollowRequest;
use App\Http\Requests\Aside\Task\TaskRequest;
use App\Models\Manage\Manage;
use App\Models\Project\Project;
use App\Models\Task\Task;
use App\Models\Task\TaskOwner;
use Illuminate\Http\Request;
... ... @@ -27,15 +29,24 @@ class TaskController extends BaseController
public function list(TaskLogic $logic)
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['content', 'like', "%{$this->param['search']}%"];
if(!empty($this->param['search']) && !empty($this->param['search_type'])){
if($this->param['search_type'] == 'project'){
$map[] = ['project_id', 'in', Project::where('title', 'like', "%{$this->param['search']}%")->pluck('id')->toarray()];
}else{
$map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];
}
if(!empty($this->param['created_manage_id'])){
$map[] = ['created_manage_id', $this->param['created_manage_id']];
}
if(!empty($this->param['owner_manage_id'])){
if(!empty($this->param['dep_id'])){
$manage_ids = Manage::where('dept_id', $this->param['dep_id'])->pluck('id')->toArray();
$map[] = ['id', 'in', TaskOwner::whereIn('manage_id',$manage_ids)->pluck('task_id')->toArray()];
}
if(!empty($this->param['created_manage_id']) && !empty($this->param['type'])){
if($this->param['type'] == 1){
$map[] = ['created_manage_id', $this->param['created_manage_id']];
}else{
$map[] = ['id', 'in', TaskOwner::where('manage_id', $this->param['owner_manage_id'])->pluck('task_id')->toArray()];
}
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'project_id', 'workload', 'priority', 'content', 'attachment', 'status', 'end_at', 'created_manage_id']);
... ...