修复person_id 添加项目部门分布api
This commit is contained in:
parent
f72cd218ea
commit
69619f7eb8
@ -129,29 +129,57 @@ class CostConsultationReportController extends BaseAdminController
|
||||
$project_name = $params['project_name'] ?? '';
|
||||
$depar_id = $params['depar_id'] ?? 0;
|
||||
$query = (new CostProject)->with(['cost_project_contract']);
|
||||
$field='id,project_num,project_name,depar,principal,contract_id';
|
||||
$field = 'id,project_num,project_name,depar,principal,contract_id';
|
||||
if ($project_name) {
|
||||
$query->where('project_name', 'like', '%' . $project_name . '%');
|
||||
}
|
||||
if ($depar_id) {
|
||||
$query->where('depar',$depar_id);
|
||||
$query->where('depar', $depar_id);
|
||||
}
|
||||
|
||||
$count = $query->count();
|
||||
$lists = $query->field($field)->page($page_no, $page_size)->select()->each(function ($item) {
|
||||
$item['start_date'] = date('Y-m-d', $item['start_date']);
|
||||
$item['end_date'] = date('Y-m-d', $item['end_date']);
|
||||
if($item['depar']>0){
|
||||
$item['depar'] =Dept::where('id', $item['depar'])->value('name');
|
||||
if ($item['depar'] > 0) {
|
||||
$item['depar'] = Dept::where('id', $item['depar'])->value('name');
|
||||
}
|
||||
if($item['principal']>0){
|
||||
$item['principal'] =Dept::where('id', $item['principal'])->value('name');
|
||||
if ($item['principal'] > 0) {
|
||||
$item['principal'] = Dept::where('id', $item['principal'])->value('name');
|
||||
}
|
||||
$item['has_invoice_amount']=0;
|
||||
$item['amount_Collected']=0;
|
||||
$item['has_invoice_amount'] = 0;
|
||||
$item['amount_Collected'] = 0;
|
||||
return $item;
|
||||
});
|
||||
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目部门分布
|
||||
|
||||
*/
|
||||
public function distribution_project_departments()
|
||||
{
|
||||
$page_no = $this->request->param('page_no', 1);
|
||||
$page_size = $this->request->param('page_size', 15);
|
||||
$project_name = $params['project_name'] ?? '';
|
||||
$depar_id = $params['depar_id'] ?? 0;
|
||||
$query = (new CostProject);
|
||||
$field = 'id,project_num,project_name,depar,principal';
|
||||
|
||||
|
||||
$count = $query->count();
|
||||
$lists = $query->field($field)->page($page_no, $page_size)->select()->each(function ($item) {
|
||||
$item['start_date'] = date('Y-m-d', $item['start_date']);
|
||||
$item['end_date'] = date('Y-m-d', $item['end_date']);
|
||||
if ($item['depar'] > 0) {
|
||||
$item['depar'] = Dept::where('id', $item['depar'])->value('name');
|
||||
}
|
||||
if ($item['principal'] > 0) {
|
||||
$item['principal'] = Dept::where('id', $item['principal'])->value('name');
|
||||
}
|
||||
return $item;
|
||||
});
|
||||
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\cost_project\CostProject;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
|
||||
/**
|
||||
* 造价项目台账列表
|
||||
@ -67,6 +67,12 @@ class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
->with(['contract'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function($item){
|
||||
if($item['person']){
|
||||
$arr=explode(',',$item['person']);
|
||||
Admin::whereIn('id',$arr)->column('name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
return CostProject::where($this->searchWhere)
|
||||
@ -74,6 +80,12 @@ class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
->with(['contract'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function($item){
|
||||
if($item['person']){
|
||||
$arr=explode(',',$item['person']);
|
||||
Admin::whereIn('id',$arr)->column('name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class CostProjectLogic extends BaseLogic
|
||||
'org_id' => $params['org_id'],
|
||||
'depar' => $params['depar'],
|
||||
'principal' => $params['principal'],
|
||||
'person' => $params['person'],
|
||||
'person' => $params['person_id'],
|
||||
'invest' => $params['invest'],
|
||||
'budget' => $params['budget'],
|
||||
'cost' => $params['cost'],
|
||||
@ -107,7 +107,7 @@ class CostProjectLogic extends BaseLogic
|
||||
'org_id' => $params['org_id'],
|
||||
'depar' => $params['depar'],
|
||||
'principal' => $params['principal'],
|
||||
'person' => $params['person'],
|
||||
'person' => $params['person_id'],
|
||||
'invest' => $params['invest'],
|
||||
'budget' => $params['budget'],
|
||||
'cost' => $params['cost'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user