Merge pull request '商机管理模块完善' (#2) from zhangwei into dev
Reviewed-on: #2
This commit is contained in:
commit
691994a41d
@ -16,6 +16,7 @@ namespace app\adminapi\lists\project;
|
|||||||
|
|
||||||
|
|
||||||
use app\adminapi\lists\BaseAdminDataLists;
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -38,7 +39,8 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['custom_id', 'project_type', 'project_code', 'project_content', 'project_estimation', 'project_address', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status'],
|
'=' => ['project_type', 'project_content', 'project_estimation', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status'],
|
||||||
|
'%like%' => ['project_code','project_address']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +56,21 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return Project::where($this->searchWhere)
|
$params = $this->request->param();
|
||||||
|
$condition = [];
|
||||||
|
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||||
|
$customIds = Custom::where('name','like','%'.$params['custom_id'].'%')->column('id');
|
||||||
|
$condition[] = ['custom_id','in',$customIds];
|
||||||
|
}
|
||||||
|
return Project::where($this->searchWhere)->where($condition)
|
||||||
->field(['id', 'custom_id', 'project_type', 'project_code', 'project_content', 'project_estimation', 'project_address', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status'])
|
->field(['id', 'custom_id', 'project_type', 'project_code', 'project_content', 'project_estimation', 'project_address', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()->each(function($item){
|
||||||
|
$custom = Custom::field('name')->where('id',$item['custom_id'])->findOrEmpty();
|
||||||
|
$item['custom_name'] = $custom->isEmpty() ? '' : $custom['name'];
|
||||||
|
return $item;
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
namespace app\adminapi\logic\project;
|
namespace app\adminapi\logic\project;
|
||||||
|
|
||||||
|
|
||||||
|
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 think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -42,6 +43,7 @@ class ProjectLogic extends BaseLogic
|
|||||||
try {
|
try {
|
||||||
Project::create([
|
Project::create([
|
||||||
'custom_id' => $params['custom_id'],
|
'custom_id' => $params['custom_id'],
|
||||||
|
'name' => $params['name'],
|
||||||
'project_type' => $params['project_type'],
|
'project_type' => $params['project_type'],
|
||||||
'project_code' => $params['project_code'],
|
'project_code' => $params['project_code'],
|
||||||
'project_content' => $params['project_content'],
|
'project_content' => $params['project_content'],
|
||||||
@ -94,6 +96,7 @@ class ProjectLogic extends BaseLogic
|
|||||||
try {
|
try {
|
||||||
Project::where('id', $params['id'])->update([
|
Project::where('id', $params['id'])->update([
|
||||||
'custom_id' => $params['custom_id'],
|
'custom_id' => $params['custom_id'],
|
||||||
|
'name' => $params['name'],
|
||||||
'project_type' => $params['project_type'],
|
'project_type' => $params['project_type'],
|
||||||
'project_code' => $params['project_code'],
|
'project_code' => $params['project_code'],
|
||||||
'project_content' => $params['project_content'],
|
'project_content' => $params['project_content'],
|
||||||
@ -155,6 +158,9 @@ class ProjectLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return Project::findOrEmpty($params['id'])->toArray();
|
$data = Project::findOrEmpty($params['id'])->toArray();
|
||||||
|
$custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty();
|
||||||
|
$data['custom_name'] = $custom->isEmpty() ? '' : $custom['name'];
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,6 +32,10 @@ class ProjectValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
'id' => 'require',
|
||||||
|
'custom_id' => 'require',
|
||||||
|
'project_code' => 'require',
|
||||||
|
'project_type' => 'require',
|
||||||
|
'name' => 'require',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ namespace app\common\model\project;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -30,5 +31,13 @@ class Project extends BaseModel
|
|||||||
protected $name = 'project';
|
protected $name = 'project';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public function getStatusAttr($value)
|
||||||
|
{
|
||||||
|
$project_status = DictData::field('name,value')->where('type_id',39)->select();
|
||||||
|
$status = [];
|
||||||
|
foreach ($project_status as $v) {
|
||||||
|
$status[$v['value']] = $v['name'];
|
||||||
|
}
|
||||||
|
return $status[$value];
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user