更新细节
This commit is contained in:
parent
d2e1d1b03e
commit
fd4c6d3ebb
@ -18,7 +18,7 @@ namespace app\adminapi\lists\contract;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\contract\ContractNegotiation;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 合同洽商列表
|
||||
@ -38,7 +38,7 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['contract_id', 'negotiation_name', 'negotiation_no'],
|
||||
'=' => ['cn.contract_id', 'cn.negotiation_name', 'cn.negotiation_no'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,11 +54,31 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ContractNegotiation::where($this->searchWhere)
|
||||
->field(['*'])
|
||||
return Db::name('ContractNegotiation')->alias('cn')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('cn.delete_time')
|
||||
->leftJoin('orgs o','o.id = cn.org_id')
|
||||
->leftJoin('dept d','d.id = cn.dept_id')
|
||||
->leftJoin('contract c','c.id = cn.contract_id')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')
|
||||
->field('cn.*, bbbd.project_id, c.contract_code, c.contract_name, p.name as project_name, p.project_code')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->order(['cn.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
//关联数据后续添加
|
||||
$item['supplier_name'] = '供应商名称';
|
||||
$item['approve_no'] = '付款单号';
|
||||
$item['approve_step'] = '流程步骤';
|
||||
$item['approve_settle_status'] = 1;
|
||||
if (!empty($item['pay_plan'])) {
|
||||
$planArray = json_decode($item['pay_plan'], true);
|
||||
if (is_array($planArray)) {
|
||||
$item['pay_plan'] = $planArray;
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -71,7 +91,14 @@ class ContractNegotiationLists extends BaseAdminDataLists implements ListsSearch
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ContractNegotiation::where($this->searchWhere)->count();
|
||||
return Db::name('ContractNegotiation')->alias('cn')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('cn.delete_time')
|
||||
->leftJoin('orgs o','o.id = cn.org_id')
|
||||
->leftJoin('dept d','d.id = cn.dept_id')
|
||||
->leftJoin('contract c','c.id = cn.contract_id')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')->count();
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,8 @@ class ContractNegotiationLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
ContractNegotiation::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'contract_id' => $params['contract_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'negotiation_name' => $params['negotiation_name'] ?? '',
|
||||
@ -81,6 +83,8 @@ class ContractNegotiationLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
ContractNegotiation::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'contract_id' => $params['contract_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'negotiation_name' => $params['negotiation_name'] ?? '',
|
||||
@ -133,6 +137,13 @@ class ContractNegotiationLogic extends BaseLogic
|
||||
{
|
||||
$contractNegotiation = ContractNegotiation::findOrEmpty($params['id']);
|
||||
$contractNegotiation->contract;
|
||||
$contractNegotiation->project= null;
|
||||
if (!empty($contractNegotiation->contract->document) && !empty($contractNegotiation->contract->document->project)) {
|
||||
$contractNegotiation->project = $contractNegotiation->contract->document->project;
|
||||
unset($contractNegotiation->contract->document);
|
||||
}
|
||||
$contractNegotiation->org;
|
||||
$contractNegotiation->dept;
|
||||
return $contractNegotiation->toArray();
|
||||
}
|
||||
}
|
@ -35,6 +35,16 @@ class ContractNegotiation extends BaseModel
|
||||
return $this->belongsTo(\app\common\model\contract\Contract::class, 'contract_id');
|
||||
}
|
||||
|
||||
public function org()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
|
||||
}
|
||||
|
||||
public function dept()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
|
||||
}
|
||||
|
||||
public function getWarrantyExpireDateAttr($value)
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user