130 lines
4.8 KiB
PHP
130 lines
4.8 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\lists\contract;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\model\contract\SubcontractingContract;
|
||
use app\common\model\contract\SubcontractingContractDetail;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectSubpackageBudgetDetail;
|
||
use app\common\model\supplier\Supplier;
|
||
|
||
|
||
/**
|
||
* 分包合同-分包明细列表
|
||
* Class SubcontractingContractDetailLists
|
||
* @package app\adminapi\listscontract
|
||
*/
|
||
class SubcontractingContractDetailLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/28 22:08
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id','subpackage_budget_detail_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取分包合同-分包明细列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/28 22:08
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return SubcontractingContractDetail::where($this->searchWhere)
|
||
->field('id,contract_id,subpackage_budget_detail_id,num,price,tax_rate,amount_excluding_tax,amount_including_tax,remark')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$contract = SubcontractingContract::field('contract_no,project_id,supplier_id,contract_type')->where('id',$data['contract_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();
|
||
$subpackage_budget_detail = ProjectSubpackageBudgetDetail::field('work_type,work_content,project_features,unit')->where('id',$data['subpackage_budget_detail_id'])->findOrEmpty();
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['supplier_code'] = $supplier['supplier_code'];
|
||
$data['supplier_name'] = $supplier['supplier_name'];
|
||
$data['contract_no'] = $contract['contract_no'];
|
||
$data['contract_type'] = $contract->contract_type_text;
|
||
$data['work_type'] = $subpackage_budget_detail['work_type'];
|
||
$data['work_content'] = $subpackage_budget_detail['work_content'];
|
||
$data['project_features'] = $subpackage_budget_detail['project_features'];
|
||
$data['unit'] = $subpackage_budget_detail['unit'];
|
||
$data['tax_rate_text'] = $data->tax_rate_text;
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取分包合同-分包明细数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/28 22:08
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return SubcontractingContractDetail::where($this->searchWhere)->count();
|
||
}
|
||
|
||
public function setFileName(): string
|
||
{
|
||
return '分包明细列表';
|
||
}
|
||
|
||
/**
|
||
* @notes 导出字段
|
||
* @return string[]
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setExcelFields(): array
|
||
{
|
||
return [
|
||
"id" => "id",
|
||
"project_name" => "项目名称",
|
||
"project_code" => "项目编码",
|
||
"contract_no" => "合同编号",
|
||
"contract_type" => "合同类型",
|
||
"supplier_name" => "供应商名称",
|
||
"work_type" => "工作类型",
|
||
"work_content" => "工作内容",
|
||
"project_features" => "项目特征",
|
||
"unit" => "单位",
|
||
"tax_rate_text" => "税率(%)",
|
||
"num" => "工作量",
|
||
"amount_excluding_tax" => "不含税金额",
|
||
"amount_including_tax" => "含税金额",
|
||
];
|
||
}
|
||
|
||
} |