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

Reviewed-on: #110
This commit is contained in:
weiz 2024-01-03 17:43:04 +08:00
commit 01f8abac68
17 changed files with 177 additions and 117 deletions

View File

@ -55,7 +55,7 @@ class CustomerDemandController extends BaseAdminController
public function add()
{
$params = (new CustomerDemandValidate())->post()->goCheck('add');
$result = CustomerDemandLogic::add($params);
$result = CustomerDemandLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
@ -72,7 +72,7 @@ class CustomerDemandController extends BaseAdminController
public function edit()
{
$params = (new CustomerDemandValidate())->post()->goCheck('edit');
$result = CustomerDemandLogic::edit($params);
$result = CustomerDemandLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -52,7 +52,7 @@ class CustomerDemandSolutionController extends BaseAdminController
public function add()
{
$params = (new CustomerDemandSolutionValidate())->post()->goCheck('add');
$result = CustomerDemandSolutionLogic::add($params);
$result = CustomerDemandSolutionLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
@ -69,7 +69,7 @@ class CustomerDemandSolutionController extends BaseAdminController
public function edit()
{
$params = (new CustomerDemandSolutionValidate())->post()->goCheck('edit');
$result = CustomerDemandSolutionLogic::edit($params);
$result = CustomerDemandSolutionLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -52,7 +52,7 @@ class CompetitorController extends BaseAdminController
public function add()
{
$params = (new CompetitorValidate())->post()->goCheck('add');
$result = CompetitorLogic::add($params);
$result = CompetitorLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
@ -69,7 +69,7 @@ class CompetitorController extends BaseAdminController
public function edit()
{
$params = (new CompetitorValidate())->post()->goCheck('edit');
$result = CompetitorLogic::edit($params);
$result = CompetitorLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -52,7 +52,7 @@ class ProjectEstimateController extends BaseAdminController
public function add()
{
$params = (new ProjectEstimateValidate())->post()->goCheck('add');
$result = ProjectEstimateLogic::add($params);
$result = ProjectEstimateLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
@ -69,7 +69,7 @@ class ProjectEstimateController extends BaseAdminController
public function edit()
{
$params = (new ProjectEstimateValidate())->post()->goCheck('edit');
$result = ProjectEstimateLogic::edit($params);
$result = ProjectEstimateLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -41,6 +41,7 @@ class CustomerDemandSolutionLists extends BaseAdminDataLists implements ListsSea
public function setSearch(): array
{
return [
'=' => ['project_id','customer_demand_id'],
'%like%' => ['theme'],
];
}
@ -77,7 +78,6 @@ class CustomerDemandSolutionLists extends BaseAdminDataLists implements ListsSea
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$item['submission_time'] = date('Y-m-d H:i:s',$item['submission_time']);
$project = Project::field('name,custom_id')->where('id',$item['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$demand = CustomerDemand::field('theme')->where('id',$item['customer_demand_id'])->findOrEmpty();

View File

@ -18,8 +18,6 @@ namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\project\Competitor;
use app\common\lists\ListsSearchInterface;
use app\common\model\project\Project;
@ -43,6 +41,7 @@ class CompetitorLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['project_id','customer_demand_id'],
'%like%' => ['competitor_name','competitor_contacts','competitor_contacts_phone'],
];
}
@ -79,8 +78,6 @@ class CompetitorLists extends BaseAdminDataLists implements ListsSearchInterface
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty();
$project = Project::field('name,custom_id')->where('id',$item['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$demand = CustomerDemand::field('theme')->where('id',$item['customer_demand_id'])->findOrEmpty();

View File

@ -43,7 +43,7 @@ class ProjectEstimateLists extends BaseAdminDataLists implements ListsSearchInte
public function setSearch(): array
{
return [
'=' => ['estimate_source','invoice_type'],
'=' => ['project_id','customer_demand_id','estimate_source','invoice_type'],
'%like%' => ['create_user'],
];
}
@ -94,7 +94,6 @@ class ProjectEstimateLists extends BaseAdminDataLists implements ListsSearchInte
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$item['quotation_date'] = date('Y-m-d H:i:s',$item['quotation_date']);
$item['estimate_source_text'] = $item->estimate_source_text;
$item['invoice_type_text'] = $item->invoice_type_text;
$project = Project::field('name,custom_id')->where('id',$item['project_id'])->findOrEmpty();

View File

@ -15,6 +15,7 @@
namespace app\adminapi\logic\custom;
use app\common\model\auth\Admin;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\logic\BaseLogic;
@ -40,7 +41,7 @@ class CustomerDemandLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:18
*/
public static function add(array $params): bool
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -55,6 +56,8 @@ class CustomerDemandLogic extends BaseLogic
'recording_time' => strtotime($params['recording_time']),
'demand_content' => $params['demand_content'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'add_user' => $admin_id,
'update_user' => $admin_id,
]);
Db::commit();
return true;
@ -73,7 +76,7 @@ class CustomerDemandLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:18
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -88,6 +91,7 @@ class CustomerDemandLogic extends BaseLogic
'recording_time' => strtotime($params['recording_time']),
'demand_content' => $params['demand_content'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'update_user' => $admin_id,
'update_time' => time(),
]);
Db::commit();
@ -122,17 +126,20 @@ class CustomerDemandLogic extends BaseLogic
*/
public static function detail($params): array
{
$data = CustomerDemand::field('id,org_id,dept_id,project_id,theme,supplier,supplier_contacts,importance,recording_time,demand_content,annex')->findOrEmpty($params['id']);
$data = CustomerDemand::field('id,org_id,dept_id,project_id,theme,supplier,supplier_contacts,importance,recording_time,demand_content,annex,add_user,update_user,create_time,update_time')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['importance_text'] = $data->importance_text;
$data['add_user_name'] = $admin[$data['add_user']];
$data['update_user_name'] = $admin[$data['update_user']];
return $data->toArray();
}
}

View File

@ -15,6 +15,7 @@
namespace app\adminapi\logic\custom;
use app\common\model\auth\Admin;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\model\custom\CustomerDemandSolution;
@ -41,7 +42,7 @@ class CustomerDemandSolutionLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:32
*/
public static function add(array $params): bool
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -52,9 +53,11 @@ class CustomerDemandSolutionLogic extends BaseLogic
'customer_demand_id' => $params['customer_demand_id'],
'theme' => $params['theme'],
'submission_time' => strtotime($params['submission_time']),
'solution_content' => $params['solution_content'],
'customer_feedback' => $params['customer_feedback'],
'annex' => $params['annex']
'solution_content' => $params['solution_content'] ?? '',
'customer_feedback' => $params['customer_feedback'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'add_user' => $admin_id,
'update_user' => $admin_id,
]);
Db::commit();
return true;
@ -73,20 +76,22 @@ class CustomerDemandSolutionLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:32
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
CustomerDemandSolution::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'theme' => $params['theme'],
'submission_time' => strtotime($params['submission_time']),
'solution_content' => $params['solution_content'],
'customer_feedback' => $params['customer_feedback'],
'annex' => $params['annex']
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'theme' => $params['theme'],
'submission_time' => strtotime($params['submission_time']),
'solution_content' => $params['solution_content'] ?? '',
'customer_feedback' => $params['customer_feedback'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'update_user' => $admin_id,
'update_time' => time(),
]);
Db::commit();
return true;
@ -120,19 +125,21 @@ class CustomerDemandSolutionLogic extends BaseLogic
*/
public static function detail($params): array
{
$data = CustomerDemandSolution::field('id,org_id,dept_id,project_id,customer_demand_id,theme,submission_time,solution_content,customer_feedback,annex')->findOrEmpty($params['id'])->toArray();
$data['submission_time'] = date('Y-m-d H:i:s',$data['submission_time']);
$data = CustomerDemandSolution::field('id,org_id,dept_id,project_id,customer_demand_id,theme,submission_time,solution_content,customer_feedback,annex,add_user,update_user,create_time,update_time')->findOrEmpty($params['id'])->toArray();
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['customer_demand_name'] = $demand['theme'];
$data['add_user_name'] = $admin[$data['add_user']];
$data['update_user_name'] = $admin[$data['update_user']];
return $data;
}
}

View File

@ -15,6 +15,7 @@
namespace app\adminapi\logic\project;
use app\common\model\auth\Admin;
use app\common\model\custom\Custom;
use app\common\model\custom\CustomerDemand;
use app\common\model\dept\Dept;
@ -38,7 +39,7 @@ class CompetitorLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 22:01
*/
public static function add(array $params): bool
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -48,13 +49,15 @@ class CompetitorLogic extends BaseLogic
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'competitor_name' => $params['competitor_name'],
'competitor_contacts' => $params['competitor_contacts'],
'competitor_contacts_phone' => $params['competitor_contacts_phone'],
'competitive_power' => $params['competitive_power'],
'competitor_advantages' => $params['competitor_advantages'],
'competitor_disadvantages' => $params['competitor_disadvantages'],
'remark' => $params['remark'],
'annex' => $params['annex']
'competitor_contacts' => $params['competitor_contacts'] ?? '',
'competitor_contacts_phone' => $params['competitor_contacts_phone'] ?? '',
'competitive_power' => $params['competitive_power'] ?? '',
'competitor_advantages' => $params['competitor_advantages'] ?? '',
'competitor_disadvantages' => $params['competitor_disadvantages'] ?? '',
'remark' => $params['remark'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'add_user' => $admin_id,
'update_user' => $admin_id,
]);
Db::commit();
return true;
@ -73,25 +76,26 @@ class CompetitorLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 22:01
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
Competitor::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'competitor_name' => $params['competitor_name'],
'competitor_contacts' => $params['competitor_contacts'],
'competitor_contacts_phone' => $params['competitor_contacts_phone'],
'competitive_power' => $params['competitive_power'],
'competitor_advantages' => $params['competitor_advantages'],
'competitor_disadvantages' => $params['competitor_disadvantages'],
'remark' => $params['remark'],
'annex' => $params['annex']
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'competitor_name' => $params['competitor_name'],
'competitor_contacts' => $params['competitor_contacts'] ?? '',
'competitor_contacts_phone' => $params['competitor_contacts_phone'] ?? '',
'competitive_power' => $params['competitive_power'] ?? '',
'competitor_advantages' => $params['competitor_advantages'] ?? '',
'competitor_disadvantages' => $params['competitor_disadvantages'] ?? '',
'remark' => $params['remark'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'add_user' => $admin_id,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -124,19 +128,22 @@ class CompetitorLogic extends BaseLogic
*/
public static function detail($params): array
{
$field = 'id,org_id,dept_id,project_id,customer_demand_id,competitor_name,competitor_contacts,competitor_contacts_phone,competitive_power,competitor_advantages,competitor_disadvantages,remark,annex';
$field = 'id,org_id,dept_id,project_id,customer_demand_id,competitor_name,competitor_contacts,competitor_contacts_phone,competitive_power,competitor_advantages,competitor_disadvantages,remark,annex,add_user,update_user,create_time,update_time';
$data = Competitor::field($field)->findOrEmpty($params['id'])->toArray();
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name'];
$data['customer_demand_name'] = $demand['theme'];
$data['add_user_name'] = $admin[$data['add_user']];
$data['update_user_name'] = $admin[$data['update_user']];
return $data;
}
}

View File

@ -43,7 +43,7 @@ class ProjectEstimateLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:42
*/
public static function add(array $params): bool
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -54,13 +54,15 @@ class ProjectEstimateLogic extends BaseLogic
'customer_demand_id' => $params['customer_demand_id'],
'estimate_source' => $params['estimate_source'],
'contact_id' => $params['contact_id'],
'create_user' => $params['create_user'],
'create_user' => $params['create_user'] ?? '',
'quotation_date' => strtotime($params['quotation_date']),
'invoice_type' => $params['invoice_type'],
'technician' => $params['technician'],
'estimate_amount' => $params['estimate_amount'],
'ask' => $params['ask'],
'annex' => $params['annex']
'invoice_type' => $params['invoice_type'] ?? 0,
'technician' => $params['technician'] ?? 0,
'estimate_amount' => $params['estimate_amount'] ?? 0,
'ask' => $params['ask'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'add_user' => $admin_id,
'update_user' => $admin_id,
]);
Db::commit();
return true;
@ -79,24 +81,26 @@ class ProjectEstimateLogic extends BaseLogic
* @author likeadmin
* @date 2023/11/24 21:42
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
ProjectEstimate::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'estimate_source' => $params['estimate_source'],
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'customer_demand_id' => $params['customer_demand_id'],
'estimate_source' => $params['estimate_source'],
'contact_id' => $params['contact_id'],
'create_user' => $params['create_user'],
'quotation_date' => strtotime($params['quotation_date']),
'invoice_type' => $params['invoice_type'],
'technician' => $params['technician'],
'estimate_amount' => $params['estimate_amount'],
'ask' => $params['ask'],
'annex' => $params['annex']
'create_user' => $params['create_user'] ?? '',
'quotation_date' => strtotime($params['quotation_date']),
'invoice_type' => $params['invoice_type'] ?? 0,
'technician' => $params['technician'] ?? 0,
'estimate_amount' => $params['estimate_amount'] ?? 0,
'ask' => $params['ask'] ?? '',
'annex' => !empty($params['annex']) ? $params['annex'] : null,
'update_user' => $admin_id,
'update_time' => time(),
]);
Db::commit();
return true;
@ -130,9 +134,8 @@ class ProjectEstimateLogic extends BaseLogic
*/
public static function detail($params): array
{
$field = 'id,org_id,dept_id,project_id,customer_demand_id,contact_id,estimate_source,create_user,quotation_date,invoice_type,technician,estimate_amount,ask,annex';
$field = 'id,org_id,dept_id,project_id,customer_demand_id,contact_id,estimate_source,create_user,quotation_date,invoice_type,technician,estimate_amount,ask,annex,add_user,update_user,create_time,update_time';
$data = ProjectEstimate::field($field)->findOrEmpty($params['id']);
$data['quotation_date'] = date('Y-m-d H:i:s',$data['quotation_date']);
$data['estimate_source_text'] = $data->estimate_source_text;
$data['invoice_type_text'] = $data->invoice_type_text;
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
@ -142,6 +145,7 @@ class ProjectEstimateLogic extends BaseLogic
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
$contract = CustomContacts::field('name,phone')->where('id',$data['contact_id'])->findOrEmpty();
$technician = Admin::field('name')->where('id',$data['technician'])->findOrEmpty();
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
@ -151,6 +155,8 @@ class ProjectEstimateLogic extends BaseLogic
$data['contact_name'] = $contract['name'];
$data['contact_phone'] = $contract['phone'];
$data['technician_name'] = $technician['name'];
$data['add_user_name'] = $admin[$data['add_user']];
$data['update_user_name'] = $admin[$data['update_user']];
return $data->toArray();
}
}

View File

@ -41,7 +41,8 @@ class CustomerDemandSolutionValidate extends BaseValidate
'project_id' => 'require|checkProject',
'customer_demand_id' => 'require|checkCustomerDemand',
'theme' => 'require',
'submission_time' => 'date'
'submission_time' => 'require|dateFormat:Y-m-d',
'annex' => 'checkAnnex',
];
protected $message = [
@ -51,18 +52,10 @@ class CustomerDemandSolutionValidate extends BaseValidate
'project_id.require' => '请选择项目',
'customer_demand_id.require' => '请选择客户需求',
'theme.require' => '请填写需求主题',
'submission_time.date' => '提交时间数据格式错误',
'submission_time.require' => '请选择提交时间',
'submission_time.dateFormat' => '提交时间数据格式错误',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
@ -150,5 +143,16 @@ class CustomerDemandSolutionValidate extends BaseValidate
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
}

View File

@ -41,7 +41,8 @@ class CompetitorValidate extends BaseValidate
'project_id' => 'require|checkProject',
'customer_demand_id' => 'require|checkCustomerDemand',
'competitor_name' => 'require',
'competitor_contacts_phone' =>'mobile'
'competitor_contacts_phone' =>'mobile',
'annex' => 'checkAnnex',
];
protected $message = [
@ -53,14 +54,6 @@ class CompetitorValidate extends BaseValidate
'competitor_name.require' => '请填写竞争对手名称',
'competitor_contacts_phone.mobile' => '联系电话格式错误'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
@ -149,5 +142,16 @@ class CompetitorValidate extends BaseValidate
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}
}

View File

@ -45,10 +45,12 @@ class ProjectEstimateValidate extends BaseValidate
'project_id' => 'require|checkProject',
'customer_demand_id' => 'require|checkCustomerDemand',
'estimate_source' => 'require|checkEstimateSource',
'contact_id' => 'checkContact',
'quotation_date' => 'date',
'contact_id' => 'require|checkContact',
'quotation_date' => 'require|dateFormat:Y-m-d',
'invoice_type' => 'checkInvoiceType',
'technician' => 'checkTechnician',
'estimate_amount' => 'float|egt:0',
'annex' => 'checkAnnex',
];
protected $message = [
@ -57,20 +59,15 @@ class ProjectEstimateValidate extends BaseValidate
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'customer_demand_id.require' => '请选择客户需求',
'contact_id.require' => '请选择联系人',
'estimate_source.require' => '请选择概算来源',
'quotation_date.date' => '报价日期格式错误'
'quotation_date.require' => '请选择报价日期',
'quotation_date.dateFormat' => '报价日期格式错误',
'estimate_amount.float' => '概算金额值必须是数字',
'estimate_amount.egt' => '概算金额值必须大于等于0',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return ProjectEstimateValidate
@ -193,7 +190,18 @@ class ProjectEstimateValidate extends BaseValidate
{
$admin = Admin::where('id',$value)->findOrEmpty();
if($admin->isEmpty()){
return '人员不存在';
return '技术人员不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
$annex = json_decode($value,true);
if(empty($annex) || !is_array($annex)){
return '附件格式错误';
}
}
return true;
}

View File

@ -29,6 +29,14 @@ class CustomerDemandSolution extends BaseModel
use SoftDelete;
protected $name = 'customer_demand_solution';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{
return empty($value) ? null : json_decode($value,true);
}
public function getSubmissionTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -29,6 +29,9 @@ class Competitor extends BaseModel
use SoftDelete;
protected $name = 'competitor';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{
return empty($value) ? null : json_decode($value,true);
}
}

View File

@ -41,4 +41,14 @@ class ProjectEstimate extends BaseModel
$dictData = DictData::where('type_value','invoice_type')->column('name','value');
return $dictData[$data['invoice_type']];
}
public function getAnnexAttr($value)
{
return empty($value) ? null : json_decode($value,true);
}
public function getQuotationDateAttr($value): string
{
return empty($value) ? '' : date('Y-m-d', $value);
}
}