新增分包管理

This commit is contained in:
yaooo 2023-12-13 10:44:27 +08:00
parent 2ce0ff589b
commit 25cefd1633
6 changed files with 119 additions and 9 deletions

View File

@ -58,8 +58,15 @@ class SubcontractingContractLists extends BaseAdminDataLists implements ListsSea
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
->select()->each(function($item, $key){
if (!empty($item['pay_plan'])) {
$otherContactsArray = json_decode($item['pay_plan'], true);
if (is_array($otherContactsArray)) {
$item['pay_plan'] = $otherContactsArray;
}
}
return $item;
})->toArray();
}

View File

@ -39,7 +39,7 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['status','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources'],
'=' => ['custom_id', 'status','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources'],
'%like%' => ['project_code','name','project_address','person']
];
}

View File

@ -16,6 +16,7 @@ namespace app\adminapi\logic\contract;
use app\common\model\contract\SubcontractingContract;
use app\common\model\contract\SubcontractingContractDetail;
use app\common\logic\BaseLogic;
use think\facade\Db;
@ -40,14 +41,14 @@ class SubcontractingContractLogic extends BaseLogic
{
Db::startTrans();
try {
SubcontractingContract::create([
$subcontractingContract = SubcontractingContract::create([
'project_id' => $params['project_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'contract_no' => $params['contract_no'] ?? '',
'contract_name' => $params['contract_name'] ?? '',
'supplier_id' => $params['supplier_id'] ?? 0,
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtitime($params['signing_date']),
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,
'account_period' => $params['account_period'] ?? 0,
'amount' => $params['amount'] ?? 0,
@ -56,10 +57,23 @@ class SubcontractingContractLogic extends BaseLogic
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'retention_money_rate' => $params['retention_money_rate'] ?? '',
'retention_money' => $params['retention_money'] ?? 0,
'pay_plan' => empty($params['pay_plan']) ? [] : json_encode($params['pay_plan']),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
]);
SubcontractingContractDetail::where('subcontracting_contract_id', $subcontractingContract->id)->update(['delete_time' =>time()]);
foreach ($params['work'] ?? [] as $item)
{
SubcontractingContractDetail::create([
'subcontracting_contract_id' => $subcontractingContract->id,
'subcontracting_budget_id' => $item['subcontracting_budget_id'] ?? 0,
'workload' => $item['workload'] ?? '',
'unit_price_including_tax' => $item['unit_price_including_tax'] ?? 0,
'amount_excluding_tax' => $item['amount_excluding_tax'] ?? 0,
'amount_including_tax' => $item['amount_including_tax'] ?? 0,
'remark' => $item['remark'] ?? '',
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
@ -88,7 +102,7 @@ class SubcontractingContractLogic extends BaseLogic
'contract_name' => $params['contract_name'] ?? '',
'supplier_id' => $params['supplier_id'] ?? 0,
'contract_type' => $params['contract_type'] ?? 0,
'signing_date' => strtitime($params['signing_date']),
'signing_date' => strtotime($params['signing_date']),
'pay_type' => $params['pay_type'] ?? 0,
'account_period' => $params['account_period'] ?? 0,
'amount' => $params['amount'] ?? 0,
@ -97,10 +111,23 @@ class SubcontractingContractLogic extends BaseLogic
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
'retention_money_rate' => $params['retention_money_rate'] ?? '',
'retention_money' => $params['retention_money'] ?? 0,
'pay_plan' => empty($params['pay_plan']) ? [] : json_encode($params['pay_plan']),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
]);
SubcontractingContractDetail::where('subcontracting_contract_id', $params['id'])->update(['delete_time' =>time()]);
foreach ($params['work'] ?? [] as $item)
{
SubcontractingContractDetail::create([
'subcontracting_contract_id' => $params['id'],
'subcontracting_budget_id' => $item['subcontracting_budget_id'] ?? 0,
'workload' => $item['workload'] ?? '',
'unit_price_including_tax' => $item['unit_price_including_tax'] ?? 0,
'amount_excluding_tax' => $item['amount_excluding_tax'] ?? 0,
'amount_including_tax' => $item['amount_including_tax'] ?? 0,
'remark' => $item['remark'] ?? '',
]);
}
Db::commit();
return true;
} catch (\Exception $e) {

View File

@ -36,6 +36,8 @@ class SubcontractingContractValidate extends BaseValidate
'approve_id' => 'require',
'supplier_id' => 'require',
'contract_name' => 'require',
'work' => 'require|array|checkWork',
'pay_plan' => 'require|array|checkPlan',
];
@ -68,7 +70,7 @@ class SubcontractingContractValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['id', 'project_id', 'approve_id', 'supplier_id', 'contract_name']);
return $this->only(['id', 'project_id', 'approve_id', 'supplier_id', 'contract_name', 'pay_plan']);
}
@ -95,4 +97,40 @@ class SubcontractingContractValidate extends BaseValidate
return $this->only(['id']);
}
public function checkWork($value, $rule, $data)
{
$firstData = $value[0] ?? [];
if (empty($firstData['subcontracting_budget_id'])) {
return '分包预算id不能为空';
}
if (empty($firstData['workload'])) {
return '工作量不能为空!';
}
if (empty($firstData['unit_price_including_tax'])) {
return '含税单价不能为空!';
}
if (empty($firstData['amount_excluding_tax'])) {
return '不含税金额不能为空!';
}
if (empty($firstData['amount_including_tax'])) {
return '含税金额不能为空!';
}
return true;
}
public function checkPlan($value, $rule, $data)
{
$firstData = $value[0] ?? [];
if (empty($firstData['period'])) {
return '付款期次不能为空!';
}
if (empty($firstData['pay_date'])) {
return '付款日期不能为空!';
}
if (empty($firstData['pay_amount'])) {
return '付款金额不能为空!';
}
return true;
}
}

View File

@ -39,5 +39,10 @@ class SubcontractingContract extends BaseModel
{
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
}
public function work()
{
return $this->hasMany(\app\common\model\contract\SubcontractingContractDetail::class, 'subcontracting_contract_id', 'id');
}
}

View File

@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\contract;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* SubcontractingContract模型
* Class SubcontractingContract
* @package app\common\model\contract
*/
class SubcontractingContractDetail extends BaseModel
{
use SoftDelete;
protected $name = 'subcontracting_contract_detail';
protected $deleteTime = 'delete_time';
}