This commit is contained in:
weiz 2024-03-20 11:38:16 +08:00
parent c01031ccbf
commit 8b0c92100a
4 changed files with 5 additions and 60 deletions

View File

@ -64,12 +64,8 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface,L
*/
public function lists(): array
{
$params = $this->request->get(['project_name','business_director_name','custom_id']);
$params = $this->request->get();
$where = [];
if(isset($params['project_name']) && $params['project_name'] != ''){
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['business_director_name']) && $params['business_director_name'] != ''){
$business_director_ids = Admin::where('name','like','%'.$params['business_director_name'].'%')->column('id');
$where[] = ['business_director','in',$business_director_ids];
@ -124,12 +120,8 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface,L
*/
public function count(): int
{
$params = $this->request->get(['project_name','business_director_name','custom_id']);
$params = $this->request->get();
$where = [];
if(isset($params['project_name']) && $params['project_name'] != ''){
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
$where[] = ['project_id','in',$project_ids];
}
if(isset($params['business_director_name']) && $params['business_director_name'] != ''){
$business_director_ids = Admin::where('name','like','%'.$params['business_director_name'].'%')->column('id');
$where[] = ['business_director','in',$business_director_ids];

View File

@ -46,12 +46,9 @@ class ContractLogic extends BaseLogic
public static function add(array $params): bool
{
$buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty();
$returned_money = $params['returned_money'];//json_decode($params['returned_money'],true);
Db::startTrans();
try {
$contractRes = Contract::create([
"org_id" => $params['org_id'],
"dept_id" =>$params['dept_id'],
"project_id" => $buy_bidding_document['project_id'],
"buy_bidding_document_id" => $params['buy_bidding_document_id'],
"contract_name" =>$params['contract_name'],
@ -79,7 +76,7 @@ class ContractLogic extends BaseLogic
"remark" => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($returned_money as $item)
foreach ($params['returned_money'] as $item)
{
FinanceReturnedMoney::create([
'project_id' => $buy_bidding_document['project_id'],
@ -117,12 +114,9 @@ class ContractLogic extends BaseLogic
public static function edit(array $params): bool
{
$buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty();
$returned_money = $params['returned_money'];
Db::startTrans();
try {
Contract::where('id', $params['id'])->update([
"org_id" => $params['org_id'],
"dept_id" =>$params['dept_id'],
"project_id" => $buy_bidding_document['project_id'],
"buy_bidding_document_id" => $params['buy_bidding_document_id'],
"contract_name" =>$params['contract_name'],
@ -149,7 +143,7 @@ class ContractLogic extends BaseLogic
"remark" => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($returned_money as $item)
foreach ($params['returned_money'] as $item)
{
if(isset($item['id']) && $item['id'] != ''){
FinanceReturnedMoney::where('id',$item['id'])->update([

View File

@ -19,8 +19,6 @@ use app\common\model\auth\Admin;
use app\common\model\bid\BidBuyBiddingDocument;
use app\common\model\contract\Contract;
use app\common\model\custom\Custom;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\dict\DictData;
use app\common\model\finance\FinanceReturnedMoney;
use app\common\model\project\Project;
@ -41,8 +39,6 @@ class ContractValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require|checkData',
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'custom_id' => 'require|checkCustom',
'buy_bidding_document_id' => 'require|checkBuyBiddingDocument',
'contract_name' => 'require',
@ -70,8 +66,6 @@ class ContractValidate extends BaseValidate
*/
protected $message = [
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'custom_id.require' => '请选择客户',
'buy_bidding_document_id.require' => '请选择标书编号',
'contract_name.require' => '请填写合同名称',
@ -126,7 +120,7 @@ class ContractValidate extends BaseValidate
*/
public function sceneDelete()
{
return $this->only(['id']);
return $this->only(['id'])->remove('id','checkData');
}
@ -155,27 +149,6 @@ class ContractValidate extends BaseValidate
return true;
}
public function checkOrg($value): bool|string
{
$org = Orgs::where('id',$value)->findOrEmpty();
if($org->isEmpty()){
return '组织不存在';
}
return true;
}
public function checkDept($value,$rule,$data): bool|string
{
$dept = Dept::where('id',$value)->findOrEmpty();
if($dept->isEmpty()){
return '部门不存在';
}
if($dept['org_id'] != $data['org_id']){
return '部门无效';
}
return true;
}
public function checkCustom($value): bool|string
{
$custom = Custom::where('id',$value)->findOrEmpty();
@ -234,16 +207,6 @@ class ContractValidate extends BaseValidate
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
public function checkReturnedMoney($value): bool|string
{
$detail = $value;//json_decode($value,true);

View File

@ -58,8 +58,4 @@ class Contract extends BaseModel
return !empty($value) ? date('Y-m-d',$value) : '';
}
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
}