update
This commit is contained in:
parent
277fffdf62
commit
3000e57cfd
@ -54,7 +54,7 @@ class ContractNegotiationController extends BaseAdminController
|
|||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$params = (new ContractNegotiationValidate())->post()->goCheck('add');
|
$params = (new ContractNegotiationValidate())->post()->goCheck('add');
|
||||||
$result = ContractNegotiationLogic::add($params,$this->adminId);
|
$result = ContractNegotiationLogic::add($params);
|
||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
return $this->success('添加成功', [], 1, 1);
|
return $this->success('添加成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,16 @@ class ProcurementContractController extends BaseAdminController
|
|||||||
return $this->fail(ProcurementContractLogic::getError());
|
return $this->fail(ProcurementContractLogic::getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new ProcurementContractValidate())->post()->goCheck('delete');
|
||||||
|
$result = ProcurementContractLogic::delete($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(ProcurementContractLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取采购合同详情
|
* @notes 获取采购合同详情
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
@ -108,5 +118,10 @@ class ProcurementContractController extends BaseAdminController
|
|||||||
return $this->fail(ProcurementContractLogic::getError());
|
return $this->fail(ProcurementContractLogic::getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas()
|
||||||
|
{
|
||||||
|
return $this->data(ProcurementContractLogic::datas());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -42,6 +42,23 @@ class ProcurementContractDetailController extends BaseAdminController
|
|||||||
return $this->dataLists(new ProcurementContractDetailLists());
|
return $this->dataLists(new ProcurementContractDetailLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new ProcurementContractDetailValidate())->post()->goCheck('edit');
|
||||||
|
$result = ProcurementContractDetailLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(ProcurementContractDetailLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new ProcurementContractDetailValidate())->post()->goCheck('delete');
|
||||||
|
ProcurementContractDetailLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取采购明细详情
|
* @notes 获取采购明细详情
|
||||||
|
@ -104,5 +104,10 @@ class SupplierController extends BaseAdminController
|
|||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas()
|
||||||
|
{
|
||||||
|
return $this->data(SupplierLogic::datas());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -48,7 +48,7 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface,L
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['project_id','contract_type', 'contract_code'],
|
'=' => ['project_id','contract_type', 'contract_code'],
|
||||||
'%like%' => ['contract_code']
|
'%like%' => ['contract_code','contract_name']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['contract_id', 'project_id', 'negotiation_type'],
|
'=' => ['contract_id', 'project_id', 'negotiation_type'],
|
||||||
'%like%' => ['negotiation_name','negotiation_no']
|
'%like%' => ['negotiation_no']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,16 +60,12 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$params = $this->request->get(['custom_id','project_name']);
|
$params = $this->request->get();
|
||||||
$where = [];
|
$where = [];
|
||||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||||||
$where[] = ['project_id','in',$project_ids];
|
$where[] = ['project_id','in',$project_ids];
|
||||||
}
|
}
|
||||||
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];
|
|
||||||
}
|
|
||||||
return ContractNegotiation::field('id,project_id,contract_id,negotiation_name,negotiation_no,negotiation_amount,negotiation_type,profit,profit_rate')
|
return ContractNegotiation::field('id,project_id,contract_id,negotiation_name,negotiation_no,negotiation_amount,negotiation_type,profit,profit_rate')
|
||||||
->where($this->searchWhere)->where($where)
|
->where($this->searchWhere)->where($where)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
@ -102,16 +98,12 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
$params = $this->request->get(['custom_id','project_name']);
|
$params = $this->request->get();
|
||||||
$where = [];
|
$where = [];
|
||||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||||
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
$project_ids = Project::where('custom_id',$params['custom_id'])->column('id');
|
||||||
$where[] = ['project_id','in',$project_ids];
|
$where[] = ['project_id','in',$project_ids];
|
||||||
}
|
}
|
||||||
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];
|
|
||||||
}
|
|
||||||
return ContractNegotiation::field('id')->where($this->searchWhere)->where($where)->count();
|
return ContractNegotiation::field('id')->where($this->searchWhere)->where($where)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class ProcurementContractDetailLists extends BaseAdminDataLists implements Lists
|
|||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($data){
|
->select()->each(function($data){
|
||||||
$contract = ProcurementContract::field('contract_no,project_id,supplier_id,contract_type')->where('id',$data['contract_id'])->findOrEmpty();
|
$contract = ProcurementContract::field('contract_no,contract_name,project_id,supplier_id,contract_type')->where('id',$data['contract_id'])->findOrEmpty();
|
||||||
$project = Project::field('name,project_code')->where('id',$contract['project_id'])->findOrEmpty();
|
$project = Project::field('name,project_code')->where('id',$contract['project_id'])->findOrEmpty();
|
||||||
$supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty();
|
$supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty();
|
||||||
$material_purchase_request_detail = MaterialPurchaseRequestDetail::field('material_purchase_request_id,project_material_budget_detail_id')->where('id',$data['material_purchase_request_detail_id'])->findOrEmpty();
|
$material_purchase_request_detail = MaterialPurchaseRequestDetail::field('material_purchase_request_id,project_material_budget_detail_id')->where('id',$data['material_purchase_request_detail_id'])->findOrEmpty();
|
||||||
@ -81,6 +81,7 @@ class ProcurementContractDetailLists extends BaseAdminDataLists implements Lists
|
|||||||
$data['supplier_code'] = $supplier['supplier_code'];
|
$data['supplier_code'] = $supplier['supplier_code'];
|
||||||
$data['supplier_name'] = $supplier['supplier_name'];
|
$data['supplier_name'] = $supplier['supplier_name'];
|
||||||
$data['contract_no'] = $contract['contract_no'];
|
$data['contract_no'] = $contract['contract_no'];
|
||||||
|
$data['contract_name'] = $contract['contract_name'];
|
||||||
$data['contract_type_text'] = $contract->contract_type_text;
|
$data['contract_type_text'] = $contract->contract_type_text;
|
||||||
$data['tax_rate_text'] = $data->tax_rate_text;
|
$data['tax_rate_text'] = $data->tax_rate_text;
|
||||||
$data['material_purchase_request_code'] = $material_purchase_request['material_purchase_request_code'];
|
$data['material_purchase_request_code'] = $material_purchase_request['material_purchase_request_code'];
|
||||||
|
@ -20,8 +20,6 @@ use app\common\model\contract\Contract;
|
|||||||
use app\common\model\contract\ContractNegotiation;
|
use app\common\model\contract\ContractNegotiation;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\model\custom\Custom;
|
use app\common\model\custom\Custom;
|
||||||
use app\common\model\dept\Dept;
|
|
||||||
use app\common\model\dept\Orgs;
|
|
||||||
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;
|
||||||
@ -43,16 +41,14 @@ class ContractNegotiationLogic extends BaseLogic
|
|||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2023/12/04 21:26
|
* @date 2023/12/04 21:26
|
||||||
*/
|
*/
|
||||||
public static function add(array $params,$admin_id): bool
|
public static function add(array $params): bool
|
||||||
{
|
{
|
||||||
$contract = Contract::field('project_id')->where('id',$params['contract_id'])->findOrEmpty();
|
$contract = Contract::field('project_id')->where('id',$params['contract_id'])->findOrEmpty();
|
||||||
$profit = $params['negotiation_amount'] - (($params['labor_costs']?:0) + ($params['material_costs']?:0));
|
$profit = $params['negotiation_amount'] - (($params['labor_costs']?:0) + ($params['material_costs']?:0));
|
||||||
$profit_rate = $profit / $params['negotiation_amount'];
|
$profit_rate = $profit / $params['negotiation_amount'];
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$res = ContractNegotiation::create([
|
ContractNegotiation::create([
|
||||||
'org_id' => $params['org_id'],
|
|
||||||
'dept_id' => $params['dept_id'],
|
|
||||||
'project_id' => $contract['project_id'],
|
'project_id' => $contract['project_id'],
|
||||||
'contract_id' => $params['contract_id'],
|
'contract_id' => $params['contract_id'],
|
||||||
'negotiation_name' => $params['negotiation_name'],
|
'negotiation_name' => $params['negotiation_name'],
|
||||||
@ -67,8 +63,8 @@ class ContractNegotiationLogic extends BaseLogic
|
|||||||
'profit_rate' => $profit_rate,
|
'profit_rate' => $profit_rate,
|
||||||
'negotiation_content' => $params['negotiation_content'] ?? '',
|
'negotiation_content' => $params['negotiation_content'] ?? '',
|
||||||
'negotiation_detail' => $params['negotiation_detail'] ?? '',
|
'negotiation_detail' => $params['negotiation_detail'] ?? '',
|
||||||
'negotiation_quotation' => !empty($params['negotiation_quotation']) ? $params['negotiation_quotation'] : null,
|
'negotiation_quotation' => $params['negotiation_quotation'] ? json_encode($params['negotiation_quotation']) : null,
|
||||||
'negotiation_basis' => !empty($params['negotiation_basis']) ? $params['negotiation_basis'] : null,
|
'negotiation_basis' => $params['negotiation_basis'] ? json_encode($params['negotiation_basis']) : null,
|
||||||
]);
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -95,12 +91,9 @@ class ContractNegotiationLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
ContractNegotiation::where('id', $params['id'])->update([
|
ContractNegotiation::where('id', $params['id'])->update([
|
||||||
'org_id' => $params['org_id'],
|
|
||||||
'dept_id' => $params['dept_id'],
|
|
||||||
'project_id' => $contract['project_id'],
|
'project_id' => $contract['project_id'],
|
||||||
'contract_id' => $params['contract_id'],
|
'contract_id' => $params['contract_id'],
|
||||||
'negotiation_name' => $params['negotiation_name'],
|
'negotiation_name' => $params['negotiation_name'],
|
||||||
'negotiation_no' => data_unique_code('QS'),
|
|
||||||
'negotiation_amount' => $params['negotiation_amount'],
|
'negotiation_amount' => $params['negotiation_amount'],
|
||||||
'negotiation_type' => $params['negotiation_type'],
|
'negotiation_type' => $params['negotiation_type'],
|
||||||
'labor_costs' => $params['labor_costs'] ?? 0,
|
'labor_costs' => $params['labor_costs'] ?? 0,
|
||||||
@ -111,8 +104,8 @@ class ContractNegotiationLogic extends BaseLogic
|
|||||||
'profit_rate' => $profit_rate,
|
'profit_rate' => $profit_rate,
|
||||||
'negotiation_content' => $params['negotiation_content'] ?? '',
|
'negotiation_content' => $params['negotiation_content'] ?? '',
|
||||||
'negotiation_detail' => $params['negotiation_detail'] ?? '',
|
'negotiation_detail' => $params['negotiation_detail'] ?? '',
|
||||||
'negotiation_quotation' => !empty($params['negotiation_quotation']) ? $params['negotiation_quotation'] : null,
|
'negotiation_quotation' => $params['negotiation_quotation'] ? json_encode($params['negotiation_quotation']) : null,
|
||||||
'negotiation_basis' => !empty($params['negotiation_basis']) ? $params['negotiation_basis'] : null,
|
'negotiation_basis' => $params['negotiation_basis'] ? json_encode($params['negotiation_basis']) : null,
|
||||||
]);
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -147,14 +140,10 @@ class ContractNegotiationLogic extends BaseLogic
|
|||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$data = ContractNegotiation::findOrEmpty($params['id']);
|
$data = ContractNegotiation::findOrEmpty($params['id']);
|
||||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
|
||||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
|
||||||
$contract = Contract::field('contract_name,contract_code,contract_type,contract_pricing_method,contract_date,business_director')->where('id',$data['contract_id'])->findOrEmpty();
|
$contract = Contract::field('contract_name,contract_code,contract_type,contract_pricing_method,contract_date,business_director')->where('id',$data['contract_id'])->findOrEmpty();
|
||||||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
$project = Project::field('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();
|
||||||
$business_director = Admin::field('name')->where('id',$contract['business_director'])->findOrEmpty();
|
$business_director = Admin::field('name')->where('id',$contract['business_director'])->findOrEmpty();
|
||||||
$data['org_name'] = $org['name'];
|
|
||||||
$data['dept_name'] = $dept['name'];
|
|
||||||
$data['contract_name'] = $contract['contract_name'];
|
$data['contract_name'] = $contract['contract_name'];
|
||||||
$data['contract_code'] = $contract['contract_code'];
|
$data['contract_code'] = $contract['contract_code'];
|
||||||
$data['contract_type'] = $contract->contract_type_text;
|
$data['contract_type'] = $contract->contract_type_text;
|
||||||
|
@ -46,15 +46,11 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function add(array $params): bool
|
public static function add(array $params): bool
|
||||||
{
|
{
|
||||||
//采购合同明细
|
|
||||||
$procurement_contract_detail =$params['procurement_contract_detail'];// json_decode($params['procurement_contract_detail'],true);
|
|
||||||
//付款计划
|
|
||||||
$payment_plan =$params['payment_plan'];// json_decode($params['payment_plan'],true);
|
|
||||||
//税率字典值
|
//税率字典值
|
||||||
$tax_rate_dict = DictData::where('type_value','tax_rate')->column('name','value');
|
$tax_rate_dict = DictData::where('type_value','tax_rate')->column('name','value');
|
||||||
//合同金额\不含税金额
|
//合同金额\不含税金额
|
||||||
$contract_amount = 0;
|
$contract_amount = 0;
|
||||||
foreach($procurement_contract_detail as $v){
|
foreach($params['procurement_contract_detail'] as $v){
|
||||||
$contract_amount += $v['price']*$v['num'];
|
$contract_amount += $v['price']*$v['num'];
|
||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
@ -77,7 +73,7 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
'remark' => $params['remark'] ?? '',
|
'remark' => $params['remark'] ?? '',
|
||||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||||
]);
|
]);
|
||||||
foreach ($procurement_contract_detail as $v)
|
foreach ($params['procurement_contract_detail'] as $v)
|
||||||
{
|
{
|
||||||
ProcurementContractDetail::create([
|
ProcurementContractDetail::create([
|
||||||
'contract_id' => $procurementContract->id,
|
'contract_id' => $procurementContract->id,
|
||||||
@ -91,7 +87,7 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
'amount_including_tax' => $v['num'] * $v['price'],
|
'amount_including_tax' => $v['num'] * $v['price'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
foreach ($payment_plan as $v)
|
foreach ($params['payment_plan'] as $v)
|
||||||
{
|
{
|
||||||
FinancePaymentPlan::create([
|
FinancePaymentPlan::create([
|
||||||
'supplier_id' => $params['supplier_id'],
|
'supplier_id' => $params['supplier_id'],
|
||||||
@ -124,15 +120,11 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function edit(array $params): bool
|
public static function edit(array $params): bool
|
||||||
{
|
{
|
||||||
//采购合同明细
|
|
||||||
$procurement_contract_detail = $params['procurement_contract_detail'];//json_decode($params['procurement_contract_detail'],true);
|
|
||||||
//付款计划
|
|
||||||
$payment_plan = $params['payment_plan'];//json_decode($params['payment_plan'],true);
|
|
||||||
//税率字典值
|
//税率字典值
|
||||||
$tax_rate_dict = DictData::where('type_value','tax_rate')->column('name','value');
|
$tax_rate_dict = DictData::where('type_value','tax_rate')->column('name','value');
|
||||||
//合同金额\不含税金额
|
//合同金额\不含税金额
|
||||||
$contract_amount = 0;
|
$contract_amount = 0;
|
||||||
foreach($procurement_contract_detail as $v){
|
foreach($params['procurement_contract_detail'] as $v){
|
||||||
$contract_amount += $v['price']*$v['num'];
|
$contract_amount += $v['price']*$v['num'];
|
||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
@ -154,7 +146,7 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
'remark' => $params['remark'] ?? '',
|
'remark' => $params['remark'] ?? '',
|
||||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||||
]);
|
]);
|
||||||
foreach ($procurement_contract_detail as $v)
|
foreach ($params['procurement_contract_detail'] as $v)
|
||||||
{
|
{
|
||||||
if(isset($v['id']) && $v != ''){
|
if(isset($v['id']) && $v != ''){
|
||||||
ProcurementContractDetail::where('id',$v['id'])->update([
|
ProcurementContractDetail::where('id',$v['id'])->update([
|
||||||
@ -182,7 +174,7 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($payment_plan as $v)
|
foreach ($params['payment_plan'] as $v)
|
||||||
{
|
{
|
||||||
if(isset($v['id']) && $v != ''){
|
if(isset($v['id']) && $v != ''){
|
||||||
FinancePaymentPlan::where('id',$v['id'])->update([
|
FinancePaymentPlan::where('id',$v['id'])->update([
|
||||||
@ -219,6 +211,16 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
$detail = ProcurementContractDetail::where('contract_id','in',$params['id'])->findOrEmpty();
|
||||||
|
if(!$detail->isEmpty()){
|
||||||
|
self::setError('此数据关联了采购明细信息,需删除采购明细信息');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ProcurementContract::destroy($params['id']);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 获取采购合同详情
|
* @notes 获取采购合同详情
|
||||||
* @param $params
|
* @param $params
|
||||||
@ -229,12 +231,8 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
$data = ProcurementContract::findOrEmpty($params['id']);
|
$data = ProcurementContract::findOrEmpty($params['id']);
|
||||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
|
||||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
|
||||||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||||
$supplier = Supplier::field('supplier_name,supplier_code')->where('id',$data['supplier_id'])->findOrEmpty();
|
$supplier = Supplier::field('supplier_name,supplier_code')->where('id',$data['supplier_id'])->findOrEmpty();
|
||||||
$data['org_name'] = $org['name'];
|
|
||||||
$data['dept_name'] = $dept['name'];
|
|
||||||
$data['project_name'] = $project['name'];
|
$data['project_name'] = $project['name'];
|
||||||
$data['project_code'] = $project['project_code'];
|
$data['project_code'] = $project['project_code'];
|
||||||
$data['supplier_name'] = $supplier['supplier_name'];
|
$data['supplier_name'] = $supplier['supplier_name'];
|
||||||
@ -279,4 +277,11 @@ class ProcurementContractLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function datas()
|
||||||
|
{
|
||||||
|
return ProcurementContract::field(['id','contract_name'])->order(['id' => 'desc'])->select()->each(function($data){
|
||||||
|
$data['projectinfo'] = 'ID:' . $data['id'] . ' / 名称:' . $data['contract_name'];
|
||||||
|
})->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
@ -170,4 +170,11 @@ class SupplierLogic extends BaseLogic
|
|||||||
$data['contacts_sex_text'] = $data->contacts_sex_text;
|
$data['contacts_sex_text'] = $data->contacts_sex_text;
|
||||||
return $data->toArray();
|
return $data->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function datas()
|
||||||
|
{
|
||||||
|
return Supplier::field(['id','supplier_name'])->order(['id' => 'desc'])->select()->each(function($data){
|
||||||
|
$data['projectinfo'] = 'ID:' . $data['id'] . ' / 名称:' . $data['supplier_name'];
|
||||||
|
})->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,8 +17,6 @@ namespace app\adminapi\validate\contract;
|
|||||||
|
|
||||||
use app\common\model\contract\Contract;
|
use app\common\model\contract\Contract;
|
||||||
use app\common\model\contract\ContractNegotiation;
|
use app\common\model\contract\ContractNegotiation;
|
||||||
use app\common\model\dept\Dept;
|
|
||||||
use app\common\model\dept\Orgs;
|
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\validate\BaseValidate;
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
@ -37,8 +35,6 @@ class ContractNegotiationValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require|checkData',
|
'id' => 'require|checkData',
|
||||||
'org_id' => 'require|checkOrg',
|
|
||||||
'dept_id' => 'require|checkDept',
|
|
||||||
'contract_id' => 'require|checkContract',
|
'contract_id' => 'require|checkContract',
|
||||||
'negotiation_name' => 'require',
|
'negotiation_name' => 'require',
|
||||||
'negotiation_amount' => 'require|float|gt:0',
|
'negotiation_amount' => 'require|float|gt:0',
|
||||||
@ -55,8 +51,6 @@ class ContractNegotiationValidate extends BaseValidate
|
|||||||
|
|
||||||
protected $message = [
|
protected $message = [
|
||||||
'id.require' => '缺少必要参数',
|
'id.require' => '缺少必要参数',
|
||||||
'org_id.require' => '请选择组织',
|
|
||||||
'dept_id.require' => '请选择部门',
|
|
||||||
'contract_id.require' => '请选择项目合同',
|
'contract_id.require' => '请选择项目合同',
|
||||||
'negotiation_name.require' => '请填写洽商单名称',
|
'negotiation_name.require' => '请填写洽商单名称',
|
||||||
'negotiation_amount.require' => '请填写洽商金额',
|
'negotiation_amount.require' => '请填写洽商金额',
|
||||||
@ -105,7 +99,7 @@ class ContractNegotiationValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneDelete()
|
public function sceneDelete()
|
||||||
{
|
{
|
||||||
return $this->only(['id']);
|
return $this->only(['id'])->remove('id','checkData');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,27 +128,6 @@ class ContractNegotiationValidate extends BaseValidate
|
|||||||
return true;
|
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 checkContract($value): bool|string
|
public function checkContract($value): bool|string
|
||||||
{
|
{
|
||||||
$contract = Contract::where('id',$value)->findOrEmpty();
|
$contract = Contract::where('id',$value)->findOrEmpty();
|
||||||
@ -173,15 +146,4 @@ class ContractNegotiationValidate extends BaseValidate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkAnnex($value): bool|string
|
|
||||||
{
|
|
||||||
if(!empty($value) && $value != ''){
|
|
||||||
$annex =$value;// json_decode($value,true);
|
|
||||||
if(empty($annex) || !is_array($annex)){
|
|
||||||
return '附件数据格式错误';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -17,8 +17,6 @@ namespace app\adminapi\validate\contract;
|
|||||||
|
|
||||||
use app\common\model\contract\ProcurementContract;
|
use app\common\model\contract\ProcurementContract;
|
||||||
use app\common\model\contract\ProcurementContractDetail;
|
use app\common\model\contract\ProcurementContractDetail;
|
||||||
use app\common\model\dept\Dept;
|
|
||||||
use app\common\model\dept\Orgs;
|
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\finance\FinancePaymentPlan;
|
use app\common\model\finance\FinancePaymentPlan;
|
||||||
use app\common\model\material\MaterialPurchaseRequestDetail;
|
use app\common\model\material\MaterialPurchaseRequestDetail;
|
||||||
@ -41,8 +39,6 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require|checkData',
|
'id' => 'require|checkData',
|
||||||
'org_id' => 'require|checkOrg',
|
|
||||||
'dept_id' => 'require|checkDept',
|
|
||||||
'supplier_id' => 'require|checkSupplier',
|
'supplier_id' => 'require|checkSupplier',
|
||||||
'project_id' => 'require|checkProject',
|
'project_id' => 'require|checkProject',
|
||||||
'contract_name' => 'require',
|
'contract_name' => 'require',
|
||||||
@ -65,8 +61,6 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $message = [
|
protected $message = [
|
||||||
'id.require' => '缺少必要参数',
|
'id.require' => '缺少必要参数',
|
||||||
'org_id.require' => '请选择组织',
|
|
||||||
'dept_id.require' => '请选择部门',
|
|
||||||
'supplier_id.require' => '请选择供应商',
|
'supplier_id.require' => '请选择供应商',
|
||||||
'project_id.require' => '请选择项目',
|
'project_id.require' => '请选择项目',
|
||||||
'contract_name.require' => '请填写合同名称',
|
'contract_name.require' => '请填写合同名称',
|
||||||
@ -115,7 +109,7 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneDelete()
|
public function sceneDelete()
|
||||||
{
|
{
|
||||||
return $this->only(['id']);
|
return $this->only(['id'])->remove('id','checkData');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,27 +138,6 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
return true;
|
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 checkSupplier($value): bool|string
|
public function checkSupplier($value): bool|string
|
||||||
{
|
{
|
||||||
$supplier = Supplier::where('id',$value)->findOrEmpty();
|
$supplier = Supplier::where('id',$value)->findOrEmpty();
|
||||||
@ -210,16 +183,6 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkAnnex($value): bool|string
|
|
||||||
{
|
|
||||||
if(!empty($value) && $value != ''){
|
|
||||||
if(!is_array($value)){
|
|
||||||
return '附件格式错误';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkProcurementContractDetail($value): bool|string
|
public function checkProcurementContractDetail($value): bool|string
|
||||||
{
|
{
|
||||||
$detail = $value;//json_decode($value,true);
|
$detail = $value;//json_decode($value,true);
|
||||||
|
@ -36,10 +36,6 @@ class ProcurementContract extends BaseModel
|
|||||||
return empty($value) ? '' : date('Y-m-d', $value);
|
return empty($value) ? '' : date('Y-m-d', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAnnexAttr($value){
|
|
||||||
return !empty($value) ? json_decode($value) : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContractTypeTextAttr($value,$data){
|
public function getContractTypeTextAttr($value,$data){
|
||||||
$dict = DictData::where('type_value','procurement_contract_type')->column('name','value');
|
$dict = DictData::where('type_value','procurement_contract_type')->column('name','value');
|
||||||
return !empty($data['contract_type']) ? $dict[$data['contract_type']] : '';
|
return !empty($data['contract_type']) ? $dict[$data['contract_type']] : '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user