修复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'] ?? '';
|
$project_name = $params['project_name'] ?? '';
|
||||||
$depar_id = $params['depar_id'] ?? 0;
|
$depar_id = $params['depar_id'] ?? 0;
|
||||||
$query = (new CostProject)->with(['cost_project_contract']);
|
$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) {
|
if ($project_name) {
|
||||||
$query->where('project_name', 'like', '%' . $project_name . '%');
|
$query->where('project_name', 'like', '%' . $project_name . '%');
|
||||||
}
|
}
|
||||||
if ($depar_id) {
|
if ($depar_id) {
|
||||||
$query->where('depar',$depar_id);
|
$query->where('depar', $depar_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$lists = $query->field($field)->page($page_no, $page_size)->select()->each(function ($item) {
|
$lists = $query->field($field)->page($page_no, $page_size)->select()->each(function ($item) {
|
||||||
$item['start_date'] = date('Y-m-d', $item['start_date']);
|
$item['start_date'] = date('Y-m-d', $item['start_date']);
|
||||||
$item['end_date'] = date('Y-m-d', $item['end_date']);
|
$item['end_date'] = date('Y-m-d', $item['end_date']);
|
||||||
if($item['depar']>0){
|
if ($item['depar'] > 0) {
|
||||||
$item['depar'] =Dept::where('id', $item['depar'])->value('name');
|
$item['depar'] = Dept::where('id', $item['depar'])->value('name');
|
||||||
}
|
}
|
||||||
if($item['principal']>0){
|
if ($item['principal'] > 0) {
|
||||||
$item['principal'] =Dept::where('id', $item['principal'])->value('name');
|
$item['principal'] = Dept::where('id', $item['principal'])->value('name');
|
||||||
}
|
}
|
||||||
$item['has_invoice_amount']=0;
|
$item['has_invoice_amount'] = 0;
|
||||||
$item['amount_Collected']=0;
|
$item['amount_Collected'] = 0;
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
|
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\lists\ListsExcelInterface;
|
||||||
use app\common\model\cost_project\CostProject;
|
use app\common\model\cost_project\CostProject;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 造价项目台账列表
|
* 造价项目台账列表
|
||||||
@ -67,6 +67,12 @@ class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterfac
|
|||||||
->with(['contract'])
|
->with(['contract'])
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
->each(function($item){
|
||||||
|
if($item['person']){
|
||||||
|
$arr=explode(',',$item['person']);
|
||||||
|
Admin::whereIn('id',$arr)->column('name');
|
||||||
|
}
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
return CostProject::where($this->searchWhere)
|
return CostProject::where($this->searchWhere)
|
||||||
@ -74,6 +80,12 @@ class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterfac
|
|||||||
->with(['contract'])
|
->with(['contract'])
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
->each(function($item){
|
||||||
|
if($item['person']){
|
||||||
|
$arr=explode(',',$item['person']);
|
||||||
|
Admin::whereIn('id',$arr)->column('name');
|
||||||
|
}
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ class CostProjectLogic extends BaseLogic
|
|||||||
'org_id' => $params['org_id'],
|
'org_id' => $params['org_id'],
|
||||||
'depar' => $params['depar'],
|
'depar' => $params['depar'],
|
||||||
'principal' => $params['principal'],
|
'principal' => $params['principal'],
|
||||||
'person' => $params['person'],
|
'person' => $params['person_id'],
|
||||||
'invest' => $params['invest'],
|
'invest' => $params['invest'],
|
||||||
'budget' => $params['budget'],
|
'budget' => $params['budget'],
|
||||||
'cost' => $params['cost'],
|
'cost' => $params['cost'],
|
||||||
@ -107,7 +107,7 @@ class CostProjectLogic extends BaseLogic
|
|||||||
'org_id' => $params['org_id'],
|
'org_id' => $params['org_id'],
|
||||||
'depar' => $params['depar'],
|
'depar' => $params['depar'],
|
||||||
'principal' => $params['principal'],
|
'principal' => $params['principal'],
|
||||||
'person' => $params['person'],
|
'person' => $params['person_id'],
|
||||||
'invest' => $params['invest'],
|
'invest' => $params['invest'],
|
||||||
'budget' => $params['budget'],
|
'budget' => $params['budget'],
|
||||||
'cost' => $params['cost'],
|
'cost' => $params['cost'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user