This commit is contained in:
weiz 2024-04-12 13:49:31 +08:00
parent e37557fe71
commit 8f134fe78c
10 changed files with 499 additions and 472 deletions

View File

@ -126,7 +126,7 @@
//获取审批流程列表 //获取审批流程列表
public function flows(): \think\response\Json public function flows(): \think\response\Json
{ {
$flow_type = FlowType::where('type', 1)->where('name', 'TBPS')->findOrEmpty(); $flow_type = FlowType::where('type', 1)->where('name', 'tbps')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select(); $data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray()); return $this->success('请求成功', $data->toArray());
} }

View File

@ -22,7 +22,6 @@
use app\common\model\marketing\MarketingBidEvaluation; use app\common\model\marketing\MarketingBidEvaluation;
use app\common\model\marketing\MarketingBusinessOpportunity; use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom; use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
/** /**
@ -43,7 +42,7 @@
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['business_opportunity_id', 'bid_type', 'bid_nature'], '=' => ['business_opportunity_id', 'bid_type', 'bid_nature', 'approve_check_status'],
'%like%' => ['bid_code'], '%like%' => ['bid_code'],
]; ];
} }
@ -60,7 +59,13 @@
*/ */
public function lists(): array public function lists(): array
{ {
return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) $params = $this->request->get();
$where = [];
if (isset($params['construct_company']) && $params['construct_company'] != '') {
$business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id');
$where[] = ['business_opportunity_id', 'in', $business_opportunity_ids];
}
return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where)
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($data) { ->select()->each(function ($data) {
@ -81,6 +86,7 @@
$data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? ''; $data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? '';
$data['bid_type_text'] = $data->bid_type_text; $data['bid_type_text'] = $data->bid_type_text;
$data['bid_nature_text'] = $data->bid_nature_text; $data['bid_nature_text'] = $data->bid_nature_text;
$data['approve_check_status_text'] = $data->approve_check_status_text;
if (empty($data['reg_date'])) { if (empty($data['reg_date'])) {
$data['reg_status'] = 0; $data['reg_status'] = 0;
$data['reg_status_text'] = '未报名'; $data['reg_status_text'] = '未报名';
@ -93,20 +99,6 @@
$data['reg_status_text'] = '报名不通过'; $data['reg_status_text'] = '报名不通过';
} }
} }
if (!empty($data['approve_id'])) {
$approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBidEvaluation')->findOrEmpty();
$data['approve_status'] = $approve['check_status'];
$data['approve_status_text'] = match ($approve['check_status']) {
0 => '待审核',
1 => '审核中',
2 => '审核通过',
3 => '审核不通过',
4 => '撤销审核',
};
} else {
$data['approve_status'] = 0;
$data['approve_status_text'] = '待审核';
}
}) })
->toArray(); ->toArray();
} }
@ -120,7 +112,13 @@
*/ */
public function count(): int public function count(): int
{ {
return MarketingBidEvaluation::where($this->searchWhere)->count(); $params = $this->request->get();
$where = [];
if (isset($params['construct_company']) && $params['construct_company'] != '') {
$business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id');
$where[] = ['business_opportunity_id', 'in', $business_opportunity_ids];
}
return MarketingBidEvaluation::where($this->searchWhere)->where($where)->count();
} }
} }

View File

@ -43,7 +43,7 @@
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['bid_evaluation_id', 'general_manager', 'bid_head'], '=' => ['bid_evaluation_id', 'general_manager', 'bid_head', 'bid_status'],
]; ];
} }
@ -59,7 +59,18 @@
*/ */
public function lists(): array public function lists(): array
{ {
return MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) $params = $this->request->get();
$where = [];
if (isset($params['business_opportunity_id']) && $params['business_opportunity_id'] != '') {
$bid_evaluation_ids0 = MarketingBidEvaluation::where('business_opportunity_id', $params['business_opportunity_id'])->column('id');
$where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids0];
}
if (isset($params['construct_company']) && $params['construct_company'] != '') {
$business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id');
$bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', 'in', $business_opportunity_ids)->column('id');
$where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids];
}
return MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where)
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($data) { ->select()->each(function ($data) {
@ -105,7 +116,18 @@
*/ */
public function count(): int public function count(): int
{ {
return MarketingBidInfo::where($this->searchWhere)->count(); $params = $this->request->get();
$where = [];
if (isset($params['business_opportunity_id']) && $params['business_opportunity_id'] != '') {
$bid_evaluation_ids0 = MarketingBidEvaluation::where('business_opportunity_id', $params['business_opportunity_id'])->column('id');
$where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids0];
}
if (isset($params['construct_company']) && $params['construct_company'] != '') {
$business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id');
$bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', 'in', $business_opportunity_ids)->column('id');
$where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids];
}
return MarketingBidInfo::where($this->searchWhere)->where($where)->count();
} }
} }

View File

@ -21,7 +21,6 @@
use app\common\model\dept\Dept; use app\common\model\dept\Dept;
use app\common\model\marketing\MarketingBusinessOpportunity; use app\common\model\marketing\MarketingBusinessOpportunity;
use app\common\model\marketing\MarketingCustom; use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
/** /**
@ -42,7 +41,7 @@
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status'], '=' => ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status', 'approve_check_status'],
'%like%' => ['project_name', 'project_code'], '%like%' => ['project_name', 'project_code'],
]; ];
} }
@ -73,23 +72,10 @@
$data['fund_sources_text'] = $data->fund_sources_text; $data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text; $data['const_area_text'] = $data->const_area_text;
$data['status_text'] = $data->status_text; $data['status_text'] = $data->status_text;
$data['approve_check_status_text'] = $data->approve_check_status_text;
$data['dept_name'] = $dept?->name; $data['dept_name'] = $dept?->name;
$data['head_name'] = $admin[$data['head']] ?? ''; $data['head_name'] = $admin[$data['head']] ?? '';
$data['leader_name'] = $admin[$data['leader']] ?? ''; $data['leader_name'] = $admin[$data['leader']] ?? '';
if (!empty($data['approve_id'])) {
$approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBusinessOpportunity')->findOrEmpty();
$data['approve_status'] = $approve['check_status'];
$data['approve_status_text'] = match ($approve['check_status']) {
0 => '待审核',
1 => '审核中',
2 => '审核通过',
3 => '审核不通过',
4 => '撤销审核',
};
} else {
$data['approve_status'] = 0;
$data['approve_status_text'] = '待审核';
}
}) })
->toArray(); ->toArray();
} }

View File

@ -12,25 +12,25 @@
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\logic\bid; namespace app\adminapi\logic\bid;
use app\common\model\bid\BidBiddingDecision; use app\common\logic\BaseLogic;
use app\common\model\bid\BidBuyBiddingDocument; use app\common\model\bid\BidBiddingDecision;
use app\common\model\custom\Custom; use app\common\model\bid\BidBuyBiddingDocument;
use app\common\logic\BaseLogic; use app\common\model\custom\Custom;
use app\common\model\oa\FlowApprove; use app\common\model\oa\FlowApprove;
use app\common\model\project\Project; use app\common\model\project\Project;
use think\facade\Db; use think\facade\Db;
/** /**
* 投标决策逻辑 * 投标决策逻辑
* Class BidBiddingDecisionLogic * Class BidBiddingDecisionLogic
* @package app\adminapi\logic\bid * @package app\adminapi\logic\bid
*/ */
class BidBiddingDecisionLogic extends BaseLogic class BidBiddingDecisionLogic extends BaseLogic
{ {
/** /**
@ -62,7 +62,7 @@ class BidBiddingDecisionLogic extends BaseLogic
'project_desc' => $params['project_desc'] ?? '', 'project_desc' => $params['project_desc'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]); ]);
Project::where('id',$params['project_id'])->update([ Project::where('id', $params['project_id'])->update([
'status' => 2, 'status' => 2,
'update_time' => time(), 'update_time' => time(),
]); ]);
@ -124,8 +124,8 @@ class BidBiddingDecisionLogic extends BaseLogic
*/ */
public static function delete(array $params): bool public static function delete(array $params): bool
{ {
$data = BidBuyBiddingDocument::where('bid_decision_id','in',$params['id'])->findOrEmpty(); $data = BidBuyBiddingDocument::where('bid_decision_id', 'in', $params['id'])->findOrEmpty();
if(!$data->isEmpty()){ if (!$data->isEmpty()) {
self::setError('此数据关联了购买标书信息,需删除购买标书信息'); self::setError('此数据关联了购买标书信息,需删除购买标书信息');
return false; return false;
} }
@ -143,8 +143,8 @@ class BidBiddingDecisionLogic extends BaseLogic
public static function detail($params): array public static function detail($params): array
{ {
$data = BidBiddingDecision::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); $data = BidBiddingDecision::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$project = Project::field('id,custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $project = Project::field('id,custom_id,name,project_code')->where('id', $data['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id', $project['custom_id'])->findOrEmpty();
$data['project_name'] = $project['name']; $data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code']; $data['project_code'] = $project['project_code'];
$data['custom_name'] = $custom['name']; $data['custom_name'] = $custom['name'];
@ -153,15 +153,14 @@ class BidBiddingDecisionLogic extends BaseLogic
$data['is_margin_text'] = $data->is_margin_text; $data['is_margin_text'] = $data->is_margin_text;
$data['is_internal_resources_text'] = $data->is_internal_resources_text; $data['is_internal_resources_text'] = $data->is_internal_resources_text;
$data['project_assurance_text'] = $data->project_assurance_text; $data['project_assurance_text'] = $data->project_assurance_text;
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray(); return $data->toArray();
} }
public static function approve($params,$admin_id): bool{ public static function approve($params, $admin_id): bool
$data = BidBiddingDecision::where('id',$params['id'])->findOrEmpty(); {
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty(); $data = BidBiddingDecision::where('id', $params['id'])->findOrEmpty();
if(!empty($data['approve_id']) && $approve_data['check_status'] != 3){ $approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) {
self::setError('当前内容存在审核信息,请勿重复提交'); self::setError('当前内容存在审核信息,请勿重复提交');
return false; return false;
} }
@ -175,8 +174,8 @@ class BidBiddingDecisionLogic extends BaseLogic
$params['flow_id'], $params['flow_id'],
$admin_id $admin_id
); );
if($res){ if ($res) {
BidBiddingDecision::where('id',$params['id'])->update([ BidBiddingDecision::where('id', $params['id'])->update([
'approve_id' => $res, 'approve_id' => $res,
]); ]);
} }
@ -188,4 +187,4 @@ class BidBiddingDecisionLogic extends BaseLogic
return false; return false;
} }
} }
} }

View File

@ -184,6 +184,7 @@
$data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? ''; $data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? '';
$data['bid_type_text'] = $data->bid_type_text; $data['bid_type_text'] = $data->bid_type_text;
$data['bid_nature_text'] = $data->bid_nature_text; $data['bid_nature_text'] = $data->bid_nature_text;
$data['approve_check_status_text'] = $data->approve_check_status_text;
return $data->toArray(); return $data->toArray();
} }

View File

@ -157,6 +157,7 @@
$data['fund_sources_text'] = $data->fund_sources_text; $data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text; $data['const_area_text'] = $data->const_area_text;
$data['status_text'] = $data->status_text; $data['status_text'] = $data->status_text;
$data['approve_check_status_text'] = $data->approve_check_status_text;
$data['dept_name'] = $dept?->name; $data['dept_name'] = $dept?->name;
$data['head_name'] = $admin[$data['head']] ?? ''; $data['head_name'] = $admin[$data['head']] ?? '';
$data['leader_name'] = $admin[$data['leader']] ?? ''; $data['leader_name'] = $admin[$data['leader']] ?? '';
@ -174,7 +175,7 @@
{ {
$data = MarketingBusinessOpportunity::where('id', $params['id'])->findOrEmpty(); $data = MarketingBusinessOpportunity::where('id', $params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty(); $approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) { if ((!empty($data['approve_id']) && $approve_data['check_status'] != 3) || (!empty($data['approve_id']) && $approve_data['check_status'] != 4)) {
self::setError('当前内容存在审核信息,请勿重复提交'); self::setError('当前内容存在审核信息,请勿重复提交');
return false; return false;
} }

View File

@ -1,22 +1,23 @@
<?php <?php
namespace app\adminapi\logic\oa;
use app\common\model\auth\Admin; namespace app\adminapi\logic\oa;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowApprove; use app\common\logic\BaseLogic;
use app\common\logic\BaseLogic; use app\common\model\auth\Admin;
use app\common\model\oa\FlowRecord; use app\common\model\oa\Flow;
use app\common\model\oa\FlowStep; use app\common\model\oa\FlowApprove;
use think\facade\Db; use app\common\model\oa\FlowRecord;
use app\common\model\oa\FlowStep;
use think\facade\Db;
/** /**
* 日常审批逻辑 * 日常审批逻辑
* Class FlowApproveLogic * Class FlowApproveLogic
* @package app\adminapi\logic\oa * @package app\adminapi\logic\oa
*/ */
class FlowApproveLogic extends BaseLogic class FlowApproveLogic extends BaseLogic
{ {
/** /**
* @notes 获取日常审批详情 * @notes 获取日常审批详情
* @param $params * @param $params
@ -27,34 +28,34 @@ class FlowApproveLogic extends BaseLogic
public static function detail($params): array public static function detail($params): array
{ {
$data = FlowApprove::field('id,title,flow_id,content_id,create_user,check_status')->findOrEmpty($params['id']); $data = FlowApprove::field('id,title,flow_id,content_id,create_user,check_status')->findOrEmpty($params['id']);
if($data->isEmpty()) return []; if ($data->isEmpty()) return [];
//获取创建人信息 //获取创建人信息
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); $create_user = Admin::field('name')->where('id', $data['create_user'])->findOrEmpty();
//获取审批流程信息 //获取审批流程信息
$flow = Flow::field('name,copy_uids')->where('id',$data['flow_id'])-> findOrEmpty(); $flow = Flow::field('name,copy_uids')->where('id', $data['flow_id'])->findOrEmpty();
//获取抄送人信息 //获取抄送人信息
$copy = Admin::where('id','in',$flow['copy_uids'])->column('name'); $copy = Admin::where('id', 'in', $flow['copy_uids'])->column('name');
//当前审核人 //当前审核人
$current_check_user = ''; $current_check_user = '';
$current_check_user_ids = ''; $current_check_user_ids = '';
//获取审核步骤 //获取审核步骤
$step = FlowStep::field('flow_step,flow_user,is_active')->where('approve_id',$data['id'])->order('sort asc')->select()->each(function($item)use($create_user,&$current_check_user,&$current_check_user_ids){ $step = FlowStep::field('flow_step,flow_user,is_active')->where('approve_id', $data['id'])->order('sort asc')->select()->each(function ($item) use ($create_user, &$current_check_user, &$current_check_user_ids) {
$item['flow_step_text'] = $item->flow_step_text; $item['flow_step_text'] = $item->flow_step_text;
if($item['flow_step'] == 0){ if ($item['flow_step'] == 0) {
$item['flow_step_text'] = $create_user['name'].'创建'; $item['flow_step_text'] = $create_user['name'] . '创建';
$item['flow_user_name'] = ''; $item['flow_user_name'] = '';
}else{ } else {
$item['flow_step_text'] = $item->flow_step_text; $item['flow_step_text'] = $item->flow_step_text;
$flow_user = Admin::where('id','in',$item['flow_user'])->column('name'); $flow_user = Admin::where('id', 'in', $item['flow_user'])->column('name');
$item['flow_user_name'] = implode(',',$flow_user); $item['flow_user_name'] = implode(',', $flow_user);
} }
if($item['is_active'] == 1){ if ($item['is_active'] == 1) {
$current_check_user = $item['flow_user_name']; $current_check_user = $item['flow_user_name'];
$current_check_user_ids = explode(',',$item['flow_user']); $current_check_user_ids = explode(',', $item['flow_user']);
} }
})->toArray(); })->toArray();
//获取审批记录 //获取审批记录
$record = FlowRecord::field('title,content,check_time,status')->where('approve_id',$data['id'])->select()->each(function($item){ $record = FlowRecord::field('title,content,check_time,status')->where('approve_id', $data['id'])->select()->each(function ($item) {
$item['status_text'] = $item->status_text; $item['status_text'] = $item->status_text;
})->toArray(); })->toArray();
$data['flow_name'] = $flow['name']; $data['flow_name'] = $flow['name'];
@ -62,7 +63,7 @@ class FlowApproveLogic extends BaseLogic
$data['current_check_user'] = $current_check_user; $data['current_check_user'] = $current_check_user;
$data['current_check_user_ids'] = $current_check_user_ids; $data['current_check_user_ids'] = $current_check_user_ids;
$data['create_user_name'] = $create_user['name']; $data['create_user_name'] = $create_user['name'];
$data['copy_user'] = implode(',',$copy); $data['copy_user'] = implode(',', $copy);
$data['step'] = $step; $data['step'] = $step;
$data['record'] = $record; $data['record'] = $record;
unset($data['flow_id']); unset($data['flow_id']);
@ -70,26 +71,26 @@ class FlowApproveLogic extends BaseLogic
} }
//撤销申请 //撤销申请
public static function revoke(array $params,$admin_id): bool public static function revoke(array $params, $admin_id): bool
{ {
$approve_data = FlowApprove::where('id',$params['id'])->findOrEmpty(); $approve_data = FlowApprove::where('id', $params['id'])->findOrEmpty();
if($approve_data->isEmpty()){ if ($approve_data->isEmpty()) {
self::setError('审批信息不存在'); self::setError('审批信息不存在');
return false; return false;
} }
if($approve_data['check_status'] != 0){ if ($approve_data['check_status'] != 0) {
self::setError('审批信息状态不是待审核状态,不可撤回'); self::setError('审批信息状态不是待审核状态,不可撤回');
return false; return false;
} }
if($approve_data['create_user'] != $admin_id){ if ($approve_data['create_user'] != $admin_id) {
self::setError('当前登录用户不是该审批信息的创建用户'); self::setError('当前登录用户不是该审批信息的创建用户');
return false; return false;
} }
$createUser = Admin::field('name')->where('id',$approve_data['create_user'])->findOrEmpty(); $createUser = Admin::field('name')->where('id', $approve_data['create_user'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
$revoke_time = time(); $revoke_time = time();
FlowApprove::where('id',$params['id'])->update([ FlowApprove::where('id', $params['id'])->update([
'check_status' => 4, 'check_status' => 4,
'update_time' => $revoke_time, 'update_time' => $revoke_time,
]); ]);
@ -100,12 +101,12 @@ class FlowApproveLogic extends BaseLogic
'check_user_id' => 0, 'check_user_id' => 0,
'check_time' => $revoke_time, 'check_time' => $revoke_time,
'status' => 3, 'status' => 3,
'title' => $createUser['name'].'撤销了此申请', 'title' => $createUser['name'] . '撤销了此申请',
'content' => $params['revoke_reason'], 'content' => $params['revoke_reason'],
'is_invalid' => 0 'is_invalid' => 0
]); ]);
$approve_data['content_model']::where('id',$approve_data['content_id'])->update([ $approve_data['content_model']::where('id', $approve_data['content_id'])->update([
'approve_id' => 0 'approve_check_status' => 4,
]); ]);
Db::commit(); Db::commit();
return true; return true;
@ -117,131 +118,137 @@ class FlowApproveLogic extends BaseLogic
} }
//审核申请 //审核申请
public static function check($params,$admin_id): bool{ public static function check($params, $admin_id): bool
{
$str = $params['check_status'] == 1 ? '通过' : '拒绝'; $str = $params['check_status'] == 1 ? '通过' : '拒绝';
$check_user = Admin::field('name')->where('id',$admin_id)->findOrEmpty(); $check_user = Admin::field('name')->where('id', $admin_id)->findOrEmpty();
$approve_data = FlowApprove::where('id',$params['id'])->findOrEmpty(); $approve_data = FlowApprove::where('id', $params['id'])->findOrEmpty();
if($approve_data->isEmpty()){ $approve_status = 0;
if ($approve_data->isEmpty()) {
self::setError('当前审批信息不存在'); self::setError('当前审批信息不存在');
return false; return false;
} }
if($approve_data['check_status'] == 2 || $approve_data['check_status'] == 3){ if ($approve_data['check_status'] == 2 || $approve_data['check_status'] == 3) {
self::setError('当前审批信息已审核'); self::setError('当前审批信息已审核');
return false; return false;
} }
if($approve_data['check_status'] == 4){ if ($approve_data['check_status'] == 4) {
self::setError('当前审批信息已撤销'); self::setError('当前审批信息已撤销');
return false; return false;
} }
//获取当前审批信息的审批步骤 //获取当前审批信息的审批步骤
$current_step = FlowStep::where('approve_id',$params['id'])->where('is_active',1)->findOrEmpty(); $current_step = FlowStep::where('approve_id', $params['id'])->where('is_active', 1)->findOrEmpty();
//获取下一步步骤 //获取下一步步骤
$next_step = FlowStep::where('approve_id',$params['id'])->where('sort',$current_step['sort']+1)->findOrEmpty(); $next_step = FlowStep::where('approve_id', $params['id'])->where('sort', $current_step['sort'] + 1)->findOrEmpty();
$current_check_user = explode(',',$current_step['flow_user']); $current_check_user = explode(',', $current_step['flow_user']);
//获取当前审批信息的步骤总数 if (!in_array($admin_id, $current_check_user)) {
$step_count = FlowStep::where('approve_id',$params['id'])->count();
if(!in_array($admin_id,$current_check_user)){
self::setError('当前登录用户不是此审批信息的审核人'); self::setError('当前登录用户不是此审批信息的审核人');
return false; return false;
} }
//判断当前用户是否审核过该条记录 //判断当前用户是否审核过该条记录
$check_record = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('check_user_id',$admin_id)->where('is_invalid',0)->findOrEmpty(); $check_record = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('check_user_id', $admin_id)->where('is_invalid', 0)->findOrEmpty();
if(!$check_record->isEmpty()){ if (!$check_record->isEmpty()) {
self::setError('你已经审核过该条信息,无需重复审核'); self::setError('你已经审核过该条信息,无需重复审核');
return false; return false;
} }
//审批时间 //审批时间
$check_time = time(); $check_time = time();
//获取审批流程信息 //获取审批流程信息
$flow_data = Flow::where('id',$approve_data['flow_id'])->findOrEmpty(); $flow_data = Flow::where('id', $approve_data['flow_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
if($flow_data['check_type'] == 1){ if ($flow_data['check_type'] == 1) {
//判断当前审批步骤类型 //判断当前审批步骤类型
switch($current_step['flow_step']){ switch ($current_step['flow_step']) {
case 1://当前部门负责人审批 case 1://当前部门负责人审批
if($next_step->isEmpty()){ if ($next_step->isEmpty()) {
FlowApprove::where('id',$params['id'])->update([ FlowApprove::where('id', $params['id'])->update([
'check_status' => $params['check_status'] == 1 ? 2 : 3, 'check_status' => $params['check_status'] == 1 ? 2 : 3,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
}else{ $approve_status = $params['check_status'] == 1 ? 2 : 3;
FlowApprove::where('id',$params['id'])->update([ } else {
FlowApprove::where('id', $params['id'])->update([
'check_status' => $params['check_status'] == 1 ? 1 : 3, 'check_status' => $params['check_status'] == 1 ? 1 : 3,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
//设置下一步 //设置下一步
if($params['check_status'] == 1){ if ($params['check_status'] == 1) {
FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]);
FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]);
} }
$approve_status = $params['check_status'] == 1 ? 1 : 3;
} }
break; break;
case 2: //指定人或签 case 2: //指定人或签
//判断当前审核状态 //判断当前审核状态
if($params['check_status'] == 1){ if ($params['check_status'] == 1) {
$approve_check_status = $next_step->isEmpty() ? 2 : 1; $approve_check_status = $next_step->isEmpty() ? 2 : 1;
if(!$next_step->isEmpty()){ if (!$next_step->isEmpty()) {
FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]);
FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]);
} }
}else{ } else {
//获取当前记录的审核记录数 //获取当前记录的审核记录数
$check_record_count = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('is_invalid',0)->where('status','<>',0)->count(); $check_record_count = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('is_invalid', 0)->where('status', '<>', 0)->count();
//判断当前记录除当前用户外,是否都审批了 //判断当前记录除当前用户外,是否都审批了
if(count($current_check_user)-1 == $check_record_count){ if (count($current_check_user) - 1 == $check_record_count) {
$approve_check_status = 3; $approve_check_status = 3;
if(!$next_step->isEmpty()){ if (!$next_step->isEmpty()) {
FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]);
FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]);
} }
}else{ } else {
$approve_check_status = 1; $approve_check_status = 1;
} }
} }
FlowApprove::where('id',$params['id'])->update([ FlowApprove::where('id', $params['id'])->update([
'check_status' => $approve_check_status, 'check_status' => $approve_check_status,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
$approve_status = $approve_check_status;
break; break;
case 3: //指定人会签 case 3: //指定人会签
if($params['check_status'] == 2){ if ($params['check_status'] == 2) {
$approve_check_status = 3; $approve_check_status = 3;
}else{ } else {
//获取当前记录的审核记录数 //获取当前记录的审核记录数
$check_record_count = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('is_invalid',0)->where('status','<>',0)->count(); $check_record_count = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('is_invalid', 0)->where('status', '<>', 0)->count();
//判断当前记录除当前用户外,是否都审批了, //判断当前记录除当前用户外,是否都审批了,
if(count($current_check_user)-1 == $check_record_count){ if (count($current_check_user) - 1 == $check_record_count) {
$approve_check_status = 2; $approve_check_status = 2;
if(!$next_step->isEmpty()){ if (!$next_step->isEmpty()) {
FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]);
FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]);
} }
}else{ } else {
$approve_check_status = 1; $approve_check_status = 1;
} }
} }
FlowApprove::where('id',$params['id'])->update([ FlowApprove::where('id', $params['id'])->update([
'check_status' => $approve_check_status, 'check_status' => $approve_check_status,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
$approve_status = $approve_check_status;
break; break;
} }
}else{ } else {
if($next_step->isEmpty()){ if ($next_step->isEmpty()) {
FlowApprove::where('id',$params['id'])->update([ FlowApprove::where('id', $params['id'])->update([
'check_status' => $params['check_status'] == 1 ? 2 : 3, 'check_status' => $params['check_status'] == 1 ? 2 : 3,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
}else{ $approve_status = $params['check_status'] == 1 ? 2 : 3;
FlowApprove::where('id',$params['id'])->update([ } else {
FlowApprove::where('id', $params['id'])->update([
'check_status' => $params['check_status'] == 1 ? 1 : 3, 'check_status' => $params['check_status'] == 1 ? 1 : 3,
'update_time' => $check_time, 'update_time' => $check_time,
]); ]);
$approve_status = $params['check_status'] == 1 ? 1 : 3;
//设置下一步 //设置下一步
if($params['check_status'] == 1){ if ($params['check_status'] == 1) {
FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]);
FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]);
} }
} }
} }
@ -252,10 +259,11 @@ class FlowApproveLogic extends BaseLogic
'check_user_id' => $admin_id, 'check_user_id' => $admin_id,
'check_time' => $check_time, 'check_time' => $check_time,
'status' => $params['check_status'], 'status' => $params['check_status'],
'title' => $check_user['name'].$str.'了此申请', 'title' => $check_user['name'] . $str . '了此申请',
'content' => $params['check_reason'], 'content' => $params['check_reason'],
'is_invalid' => 0 'is_invalid' => 0
]); ]);
$approve_data['content_model']::where('id', $approve_data['content_id'])->update(['approve_check_status' => $approve_status]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -264,4 +272,4 @@ class FlowApproveLogic extends BaseLogic
return false; return false;
} }
} }
} }

View File

@ -44,6 +44,12 @@
return !empty($data['bid_nature']) ? $dict[$data['bid_nature']] : ''; return !empty($data['bid_nature']) ? $dict[$data['bid_nature']] : '';
} }
public function getApproveCheckStatusTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'check_status')->column('name', 'value');
return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : '';
}
public function getEndDateAttr($value): string public function getEndDateAttr($value): string
{ {
return !empty($value) ? date('Y-m-d', $value) : ''; return !empty($value) ? date('Y-m-d', $value) : '';

View File

@ -62,6 +62,12 @@
return !empty($data['const_area']) ? $dict[$data['const_area']] : ''; return !empty($data['const_area']) ? $dict[$data['const_area']] : '';
} }
public function getApproveCheckStatusTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'check_status')->column('name', 'value');
return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : '';
}
public function getStatusTextAttr($value, $data): string public function getStatusTextAttr($value, $data): string
{ {
$arr = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标']; $arr = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标'];