Merge pull request 'update' (#28) from zhangwei into dev

Reviewed-on: #28
This commit is contained in:
weiz 2023-12-13 17:32:46 +08:00
commit 38cee067eb
2 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,7 @@ use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\custom\Custom; use app\common\model\custom\Custom;
use app\common\model\project\Project; use app\common\model\project\Project;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\project\ProjectTypeSet;
/** /**
@ -63,12 +64,14 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface
$condition[] = ['custom_id','in',$customIds]; $condition[] = ['custom_id','in',$customIds];
} }
return Project::where($this->searchWhere)->where($condition) return Project::where($this->searchWhere)->where($condition)
->field(['id','custom_id','project_code','name','status','project_address','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources','person']) ->field(['id','custom_id','project_code','name','status','contacts','telephone','project_address','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources','person'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function($item){ ->select()->each(function($item){
$projectType = ProjectTypeSet::where('id',$item['project_type'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$item['custom_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$item['custom_id'])->findOrEmpty();
$item['custom_name'] = $custom->isEmpty() ? '' : $custom['name']; $item['custom_name'] = $custom->isEmpty() ? '' : $custom['name'];
$item['project_type_name'] = $projectType->isEmpty() ? '' : $projectType['name'];
return $item; return $item;
}) })
->toArray(); ->toArray();

View File

@ -18,6 +18,7 @@ namespace app\adminapi\logic\project;
use app\common\model\custom\Custom; use app\common\model\custom\Custom;
use app\common\model\project\Project; use app\common\model\project\Project;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\project\ProjectTypeSet;
use think\facade\Db; use think\facade\Db;
@ -157,8 +158,10 @@ class ProjectLogic extends BaseLogic
public static function detail($params): array public static function detail($params): array
{ {
$data = Project::findOrEmpty($params['id'])->toArray(); $data = Project::findOrEmpty($params['id'])->toArray();
$projectType = ProjectTypeSet::where('id',$data['project_type'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty();
$data['custom_name'] = $custom->isEmpty() ? '' : $custom['name']; $data['custom_name'] = $custom->isEmpty() ? '' : $custom['name'];
$data['project_type_name'] = $projectType->isEmpty() ? '' : $projectType['name'];
return $data; return $data;
} }
} }