This commit is contained in:
weiz 2024-03-19 15:14:41 +08:00
parent ef2995cfe1
commit a8fe4ddc15

View File

@ -16,6 +16,7 @@ namespace app\adminapi\lists;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\task\TaskAllocation;
use app\common\model\TaskDetail; use app\common\model\TaskDetail;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
@ -54,11 +55,20 @@ class TaskDetailLists extends BaseAdminDataLists implements ListsSearchInterface
*/ */
public function lists(): array public function lists(): array
{ {
return TaskDetail::where($this->searchWhere) $params = $this->request->get();
$where = [];
if(!empty($params['task_allocation_num'])){
$task_allocation_ids = TaskAllocation::where('num','like','%'.$params['task_allocation_num'].'%')->column('id');
$where[] = ['task_allocation_id','in',$task_allocation_ids];
}
return TaskDetail::where($this->searchWhere)->where($where)
->with(['taskTypeInfo', 'taskAllocation']) ->with(['taskTypeInfo', 'taskAllocation'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select() ->select()->each(function($data){
$task_allocation = TaskAllocation::field('num')->where('id',$data['task_allocation_id'])->findOrEmpty();
$data['task_allocation_num'] = $task_allocation['num'];
})
->toArray(); ->toArray();
} }
@ -71,7 +81,13 @@ class TaskDetailLists extends BaseAdminDataLists implements ListsSearchInterface
*/ */
public function count(): int public function count(): int
{ {
return TaskDetail::where($this->searchWhere)->count(); $params = $this->request->get();
$where = [];
if(!empty($params['task_allocation_num'])){
$task_allocation_ids = TaskAllocation::where('num','like','%'.$params['task_allocation_num'].'%')->column('id');
$where[] = ['task_allocation_id','in',$task_allocation_ids];
}
return TaskDetail::where($this->searchWhere)->where($where)->count();
} }
} }