This commit is contained in:
weiz 2024-02-19 15:22:01 +08:00
parent 156d5b79e5
commit 8fcd8586fb
3 changed files with 78 additions and 4 deletions

View File

@ -20,6 +20,8 @@ use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\bid\BidBuyBiddingDocumentLists;
use app\adminapi\logic\bid\BidBuyBiddingDocumentLogic;
use app\adminapi\validate\bid\BidBuyBiddingDocumentValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
@ -73,5 +75,24 @@ class BidBuyBiddingDocumentController extends BaseAdminController
return $this->data($result);
}
//获取审批流程列表
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type',1)->where('name','gmbs')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate',$flow_type['id'])->where('status',2)->select();
return $this->success('请求成功',$data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new BidBuyBiddingDocumentValidate())->post()->goCheck('approve');
$result = BidBuyBiddingDocumentLogic::approve($params,$this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(BidBuyBiddingDocumentLogic::getError());
}
}

View File

@ -20,6 +20,7 @@ use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidBuyBiddingDocument;
use app\common\model\custom\Custom;
use app\common\logic\BaseLogic;
use app\common\model\oa\FlowApprove;
use app\common\model\project\Project;
use think\facade\Db;
@ -117,7 +118,7 @@ class BidBuyBiddingDocumentLogic extends BaseLogic
*/
public static function detail($params): array
{
$data = BidBuyBiddingDocument::field('id,project_id,bid_decision_id,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date')->findOrEmpty($params['id']);
$data = BidBuyBiddingDocument::field('id,project_id,bid_decision_id,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date,approve_id')->findOrEmpty($params['id']);
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$bid_decision = BidBiddingDecision::field('code,bidding_project_fund_source,bidding_time,bid_type,is_margin,margin_amount,bid_opening_date,margin_amount_return_date,bid_project_overview,project_desc,annex')->where('id',$data['bid_decision_id'])->findOrEmpty();
@ -137,6 +138,39 @@ class BidBuyBiddingDocumentLogic extends BaseLogic
$data['project_desc'] = $bid_decision['project_desc'];
$data['annex'] = $bid_decision['annex'];
$data['buyer'] = $admin['name'];
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray();
}
public static function approve($params,$admin_id): bool{
$data = BidBuyBiddingDocument::where('id',$params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
if(!empty($data['approve_id']) && $approve_data['check_status'] != 3){
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'购买标书',
$params['id'],
'app\common\model\bid\BidBuyBiddingDocument',
$params['path'],
$params['flow_id'],
$admin_id
);
if($res){
BidBuyBiddingDocument::where('id',$params['id'])->update([
'approve_id' => $res,
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -17,6 +17,7 @@ namespace app\adminapi\validate\bid;
use app\common\model\auth\Admin;
use app\common\model\bid\BidBiddingDecision;
use app\common\model\bid\BidBuyBiddingDocument;
use app\common\model\project\Project;
use app\common\validate\BaseValidate;
@ -34,7 +35,7 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
* @var string[]
*/
protected $rule = [
'id' => 'require',
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'bid_decision_id' => 'require|checkBidDecision',
'bid_document_no' => 'require',
@ -44,6 +45,8 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
'amount' => 'float|egt:0',
'project_fund_source' => 'checkProjectFundSource',
'buy_date' => 'dateFormat:Y-m-d',
'flow_id' => 'require|checkFlow',
'path' => 'require',
];
protected $message = [
@ -67,7 +70,7 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
*/
public function sceneAdd()
{
return $this->remove('id', true);
return $this->remove('id', true)->remove('flow_id',true)->remove('path',true);
}
@ -78,7 +81,9 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
* @date 2023/11/27 18:22
*/
public function sceneEdit()
{}
{
return $this->remove('flow_id',true)->remove('path',true);
}
/**
@ -104,6 +109,20 @@ class BidBuyBiddingDocumentValidate extends BaseValidate
return $this->only(['id']);
}
public function sceneApprove()
{
return $this->only(['id','flow_id','path']);
}
public function checkData($value): bool|string
{
$data = BidBuyBiddingDocument::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$project = Project::where('id',$value)->findOrEmpty();