更新合同关联

This commit is contained in:
yaooo 2023-12-15 17:30:00 +08:00
parent bd44af9af5
commit b8a929560b
4 changed files with 32 additions and 9 deletions

View File

@ -42,6 +42,15 @@ class ProcurementContractLists extends BaseAdminDataLists implements ListsSearch
];
}
public function querySearch(): array
{
$queryWhere = [];
if (!empty($this->params['contract_cate'])) {
$queryWhere['contract_cate'] = $this->params['contract_cate'];
}
$queryWhere['contract_cate'] = 1;
return $queryWhere;
}
/**
* @notes 获取采购合同列表
@ -54,7 +63,7 @@ class ProcurementContractLists extends BaseAdminDataLists implements ListsSearch
*/
public function lists(): array
{
return ProcurementContract::where($this->searchWhere)
return ProcurementContract::where($this->searchWhere)->where($this->querySearch())
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -71,7 +80,7 @@ class ProcurementContractLists extends BaseAdminDataLists implements ListsSearch
*/
public function count(): int
{
return ProcurementContract::where($this->searchWhere)->count();
return ProcurementContract::where($this->searchWhere)->where($this->querySearch())->count();
}
}

View File

@ -17,6 +17,7 @@ namespace app\adminapi\lists\contract;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\contract\SubcontractingContract;
use app\common\model\contract\ProcurementContract;
use app\common\lists\ListsSearchInterface;
@ -42,6 +43,15 @@ class SubcontractingContractLists extends BaseAdminDataLists implements ListsSea
];
}
public function querySearch(): array
{
$queryWhere = [];
if (!empty($this->params['contract_cate'])) {
$queryWhere['contract_cate'] = $this->params['contract_cate'];
}
$queryWhere['contract_cate'] = 2;
return $queryWhere;
}
/**
* @notes 获取列表
@ -54,7 +64,7 @@ class SubcontractingContractLists extends BaseAdminDataLists implements ListsSea
*/
public function lists(): array
{
return SubcontractingContract::where($this->searchWhere)
return ProcurementContract::where($this->searchWhere)->where($this->querySearch())
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
@ -78,7 +88,7 @@ class SubcontractingContractLists extends BaseAdminDataLists implements ListsSea
*/
public function count(): int
{
return SubcontractingContract::where($this->searchWhere)->count();
return ProcurementContract::where($this->searchWhere)->where($this->querySearch())->count();
}
}

View File

@ -46,8 +46,8 @@ class ProcurementContractLogic extends BaseLogic
'supplier_id' => $params['supplier_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'project_id' => $params['project_id'] ?? 0,
'contract_cate' => 1,
'contract_no' => $params['contract_no'] ?? '',
'supplier_contract_no' => $params['supplier_contract_no'] ?? '',
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,
@ -101,6 +101,7 @@ class ProcurementContractLogic extends BaseLogic
'project_id' => $params['project_id'] ?? 0,
'contract_no' => $params['contract_no'] ?? '',
'supplier_contract_no' => $params['supplier_contract_no'] ?? '',
'contract_cate' => 1,
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,

View File

@ -16,6 +16,7 @@ namespace app\adminapi\logic\contract;
use app\common\model\contract\SubcontractingContract;
use app\common\model\contract\ProcurementContract;
use app\common\model\contract\SubcontractingContractDetail;
use app\common\model\custom\Custom;
use app\common\logic\BaseLogic;
@ -42,9 +43,10 @@ class SubcontractingContractLogic extends BaseLogic
{
Db::startTrans();
try {
$subcontractingContract = SubcontractingContract::create([
$subcontractingContract = ProcurementContract::create([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'contract_cate' => 2,
'contract_no' => $params['contract_no'] ?? '',
'contract_name' => $params['contract_name'] ?? '',
'supplier_id' => $params['supplier_id'] ?? 0,
@ -96,9 +98,10 @@ class SubcontractingContractLogic extends BaseLogic
{
Db::startTrans();
try {
SubcontractingContract::where('id', $params['id'])->update([
ProcurementContract::where('id', $params['id'])->update([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'contract_cate' => 2,
'contract_no' => $params['contract_no'] ?? '',
'contract_name' => $params['contract_name'] ?? '',
'supplier_id' => $params['supplier_id'] ?? 0,
@ -148,7 +151,7 @@ class SubcontractingContractLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
return SubcontractingContract::destroy($params['id']);
return ProcurementContract::destroy($params['id']);
}
@ -161,7 +164,7 @@ class SubcontractingContractLogic extends BaseLogic
*/
public static function detail($params): array
{
$subcontractingContract = SubcontractingContract::findOrEmpty($params['id']);
$subcontractingContract = ProcurementContract::findOrEmpty($params['id']);
$subcontractingContract->custom = null;
if (!empty($subcontractingContract->project->custom_id)) {
$subcontractingContract->custom = Custom::findOrEmpty($subcontractingContract->project->custom_id);