114 lines
3.6 KiB
PHP
114 lines
3.6 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\project;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectJobType;
|
||
use app\common\model\project\ProjectLaborBudget;
|
||
use app\common\model\project\ProjectLaborBudgetDetail;
|
||
use app\common\lists\ListsSearchInterface;
|
||
|
||
|
||
/**
|
||
* 人工预算明细列表
|
||
* Class ProjectLaborBudgetDetailLists
|
||
* @package app\adminapi\listsproject
|
||
*/
|
||
class ProjectLaborBudgetDetailLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/01/16 09:26
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['project_id', 'labor_budget_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取人工预算明细列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/01/16 09:26
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return ProjectLaborBudgetDetail::where($this->searchWhere)
|
||
->field('id,project_id,labor_budget_id,job_type_id,desc,unit,num,price,amount,remark')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$labor_budget = ProjectLaborBudget::field('labor_budget_code')->where('id',$data['labor_budget_id'])->findOrEmpty();
|
||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$job_type = ProjectJobType::field('type_name')->where('id',$data['job_type_id'])->findOrEmpty();
|
||
$data['labor_budget_code'] = $labor_budget['labor_budget_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['job_type_name'] = $job_type['type_name'];
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取人工预算明细数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/01/16 09:26
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return ProjectLaborBudgetDetail::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",
|
||
"job_type_name" => "工种名称",
|
||
"desc" => "人工说明",
|
||
"unit" => "单位",
|
||
"num" => "数量",
|
||
"price" => "单价",
|
||
"amount" => "金额",
|
||
"remark" => "备注",
|
||
];
|
||
}
|
||
} |