新增合同洽谈

This commit is contained in:
yaooo 2023-12-12 11:04:30 +08:00
parent 353a605a04
commit c65186bab0
4 changed files with 48 additions and 33 deletions

View File

@ -38,7 +38,7 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
public function setSearch(): array
{
return [
'=' => ['contract_id', 'negotiation_name'],
'=' => ['contract_id', 'negotiation_name', 'negotiation_no'],
];
}

View File

@ -41,22 +41,22 @@ class ContractNegotiationLogic extends BaseLogic
Db::startTrans();
try {
ContractNegotiation::create([
'contract_id' => $params['contract_id'],
'approve_id' => $params['approve_id'],
'negotiation_name' => $params['negotiation_name'],
'negotiation_no' => $params['negotiation_no'],
'negotiation_amount' => $params['negotiation_amount'],
'negotiation_type' => $params['negotiation_type'],
'labor_costs' => $params['labor_costs'],
'material_costs' => $params['material_costs'],
'warranty_amount' => $params['warranty_amount'],
'contract_id' => $params['contract_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'negotiation_name' => $params['negotiation_name'] ?? '',
'negotiation_no' => $params['negotiation_no'] ?? '',
'negotiation_amount' => $params['negotiation_amount'] ?? 0,
'negotiation_type' => $params['negotiation_type'] ?? 0,
'labor_costs' => $params['labor_costs'] ?? 0,
'material_costs' => $params['material_costs'] ?? 0,
'warranty_amount' => $params['warranty_amount'] ?? 0,
'Warranty_expire_date' => strtotime($params['Warranty_expire_date']),
'profit' => $params['profit'],
'profit_rate' => $params['profit_rate'],
'negotiation_content' => $params['negotiation_content'],
'negotiation_detail' => $params['negotiation_detail'],
'negotiation_quotation' => $params['negotiation_quotation'],
'negotiation_basis' => $params['negotiation_basis']
'profit' => $params['profit'] ?? 0,
'profit_rate' => $params['profit_rate'] ?? '',
'negotiation_content' => $params['negotiation_content'] ?? 0,
'negotiation_detail' => $params['negotiation_detail'] ?? 0,
'negotiation_quotation' => $params['negotiation_quotation'] ?? 0,
'negotiation_basis' => $params['negotiation_basis'] ?? 0,
]);
Db::commit();
@ -81,22 +81,22 @@ class ContractNegotiationLogic extends BaseLogic
Db::startTrans();
try {
ContractNegotiation::where('id', $params['id'])->update([
'contract_id' => $params['contract_id'],
'approve_id' => $params['approve_id'],
'negotiation_name' => $params['negotiation_name'],
'negotiation_no' => $params['negotiation_no'],
'negotiation_amount' => $params['negotiation_amount'],
'negotiation_type' => $params['negotiation_type'],
'labor_costs' => $params['labor_costs'],
'material_costs' => $params['material_costs'],
'warranty_amount' => $params['warranty_amount'],
'contract_id' => $params['contract_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'negotiation_name' => $params['negotiation_name'] ?? '',
'negotiation_no' => $params['negotiation_no'] ?? '',
'negotiation_amount' => $params['negotiation_amount'] ?? 0,
'negotiation_type' => $params['negotiation_type'] ?? 0,
'labor_costs' => $params['labor_costs'] ?? 0,
'material_costs' => $params['material_costs'] ?? 0,
'warranty_amount' => $params['warranty_amount'] ?? 0,
'Warranty_expire_date' => strtotime($params['Warranty_expire_date']),
'profit' => $params['profit'],
'profit_rate' => $params['profit_rate'],
'negotiation_content' => $params['negotiation_content'],
'negotiation_detail' => $params['negotiation_detail'],
'negotiation_quotation' => $params['negotiation_quotation'],
'negotiation_basis' => $params['negotiation_basis']
'profit' => $params['profit'] ?? 0,
'profit_rate' => $params['profit_rate'] ?? '',
'negotiation_content' => $params['negotiation_content'] ?? 0,
'negotiation_detail' => $params['negotiation_detail'] ?? 0,
'negotiation_quotation' => $params['negotiation_quotation'] ?? 0,
'negotiation_basis' => $params['negotiation_basis'] ?? 0
]);
Db::commit();
@ -131,6 +131,8 @@ class ContractNegotiationLogic extends BaseLogic
*/
public static function detail($params): array
{
return ContractNegotiation::findOrEmpty($params['id'])->toArray();
$contractNegotiation = ContractNegotiation::findOrEmpty($params['id']);
$contractNegotiation->contract = $contractNegotiation->contract;
return $contractNegotiation->toArray();
}
}

View File

@ -32,6 +32,10 @@ class ContractNegotiationValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'contract_id' => 'require',
'approve_id' => 'require',
'negotiation_name' => 'require',
'negotiation_no' => 'require',
];
@ -64,7 +68,7 @@ class ContractNegotiationValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['id']);
return $this->only(['id', 'contract_id', 'approve_id', 'negotiation_name', 'negotiation_no']);
}

View File

@ -30,5 +30,14 @@ class ContractNegotiation extends BaseModel
protected $name = 'contract_negotiation';
protected $deleteTime = 'delete_time';
public function contract()
{
return $this->belongsTo(\app\common\model\contract\Contract::class, 'contract_id');
}
public function getWarrantyExpireDateAttr($value)
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
}