新增待立项造价项目模块

This commit is contained in:
weiz 2024-02-20 17:13:27 +08:00
parent c733310ca5
commit 855d5d8312
5 changed files with 702 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?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\controller\cost_project;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\cost_project\CostApprovedProjectLists;
use app\adminapi\logic\cost_project\CostApprovedProjectLogic;
use app\adminapi\validate\cost_project\CostApprovedProjectValidate;
/**
* 待立项造价项目控制器
* Class CostApprovedProjectController
* @package app\adminapi\controller\cost_project
*/
class CostApprovedProjectController extends BaseAdminController
{
/**
* @notes 获取待立项造价项目列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function lists()
{
return $this->dataLists(new CostApprovedProjectLists());
}
/**
* @notes 添加待立项造价项目
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function add()
{
$params = (new CostApprovedProjectValidate())->post()->goCheck('add');
$result = CostApprovedProjectLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(CostApprovedProjectLogic::getError());
}
/**
* @notes 编辑待立项造价项目
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function edit()
{
$params = (new CostApprovedProjectValidate())->post()->goCheck('edit');
$result = CostApprovedProjectLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(CostApprovedProjectLogic::getError());
}
/**
* @notes 删除待立项造价项目
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function delete()
{
$params = (new CostApprovedProjectValidate())->post()->goCheck('delete');
CostApprovedProjectLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取待立项造价项目详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function detail()
{
$params = (new CostApprovedProjectValidate())->goCheck('detail');
$result = CostApprovedProjectLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,83 @@
<?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\cost_project;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\cost_project\CostApprovedProject;
use app\common\lists\ListsSearchInterface;
/**
* 待立项造价项目列表
* Class CostApprovedProjectLists
* @package app\adminapi\listscost_project
*/
class CostApprovedProjectLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function setSearch(): array
{
return [
'=' => ['business_nature', 'industry_nature', 'fund_sources', 'const_area'],
'%like%' => ['contract_name', 'contract_num', 'part_a', 'part_b'],
];
}
/**
* @notes 获取待立项造价项目列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function lists(): array
{
return CostApprovedProject::where($this->searchWhere)
->field(['id', 'contract_name', 'contract_num', 'part_a', 'part_b', 'business_nature', 'industry_nature', 'fund_sources', 'const_area', 'project_money', 'start_date', 'end_date', 'dept', 'regulators', 'project_director'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$data['business_nature_text'] = $data->business_nature_text;
$data['industry_nature_text'] = $data->industry_nature_text;
$data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text;
})
->toArray();
}
/**
* @notes 获取待立项造价项目数量
* @return int
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function count(): int
{
return CostApprovedProject::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,174 @@
<?php
namespace app\adminapi\logic\cost_project;
use app\common\model\cost_project\CostApprovedProject;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 待立项造价项目逻辑
* Class CostApprovedProjectLogic
* @package app\adminapi\logic\cost_project
*/
class CostApprovedProjectLogic extends BaseLogic
{
/**
* @notes 添加待立项造价项目
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/20 14:16
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
CostApprovedProject::create([
'contract_name' => $params['contract_name'],
'contract_num' => date('Ymd',time()).'-'.mt_rand(100000, 999999),
'part_a' => $params['part_a'],
'part_a_contract' => $params['part_a_contract'] ?? '',
'part_a_address' => $params['part_a_address'] ?? '',
'part_b' => $params['part_b'],
'part_b_signatory' => $params['part_b_signatory'] ?? '',
'business_nature' => $params['business_nature'] ?? 0,
'industry_nature' => $params['industry_nature'] ?? 0,
'fund_sources' => $params['fund_sources'] ?? 0,
'const_area' => $params['const_area'] ?? 0,
'project_money' => $params['project_money'] ?? 0,
'project_scale' => $params['project_scale'] ?? '',
'money' => $params['money'],
'rate' => $params['rate'] ?? 0,
'contract_service' => $params['contract_service'] ?? '',
'start_date' => !empty($params['start_date']) ? strtotime($params['start_date']) : 0,
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
'performance' => $params['performance'] ?? 0,
'due_time' => !empty($params['due_time']) ? strtotime($params['due_time']) : 0,
'payment' => $params['payment'] ?? '',
'content' => $params['content'] ?? '',
'founder' => $params['founder'] ?? '',
'create_date' => !empty($params['create_date']) ? strtotime($params['create_date']) : 0,
'dept' => $params['dept'],
'signing_person' => $params['signing_person'] ?? '',
'regulators' => $params['regulators'],
'project_director' => $params['project_director'] ?? '',
'way' => $params['way'] ?? 0,
'seal_name' => $params['seal_name'] ?? 0,
'limit' => $params['limit'] ?? 0,
'limit_num' => $params['limit_num'] ?? 0,
'file_type' => $params['file_type'] ?? 0,
'seal_num' => $params['seal_num'] ?? 0,
'sealer' => $params['sealer'] ?? '',
'plance_seal' => $params['plance_seal'] ?? 0,
'send_date' => !empty($params['send_date']) ? strtotime($params['send_date']) : 0,
'number' => $params['number'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑待立项造价项目
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/20 14:16
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
CostApprovedProject::where('id', $params['id'])->update([
'contract_name' => $params['contract_name'],
'part_a' => $params['part_a'],
'part_a_contract' => $params['part_a_contract'] ?? '',
'part_a_address' => $params['part_a_address'] ?? '',
'part_b' => $params['part_b'],
'part_b_signatory' => $params['part_b_signatory'] ?? '',
'business_nature' => $params['business_nature'] ?? 0,
'industry_nature' => $params['industry_nature'] ?? 0,
'fund_sources' => $params['fund_sources'] ?? 0,
'const_area' => $params['const_area'] ?? 0,
'project_money' => $params['project_money'] ?? 0,
'project_scale' => $params['project_scale'] ?? '',
'money' => $params['money'],
'rate' => $params['rate'] ?? 0,
'contract_service' => $params['contract_service'] ?? '',
'start_date' => !empty($params['start_date']) ? strtotime($params['start_date']) : 0,
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
'performance' => $params['performance'] ?? 0,
'due_time' => !empty($params['due_time']) ? strtotime($params['due_time']) : 0,
'payment' => $params['payment'] ?? '',
'content' => $params['content'] ?? '',
'founder' => $params['founder'] ?? '',
'create_date' => !empty($params['create_date']) ? strtotime($params['create_date']) : 0,
'dept' => $params['dept'],
'signing_person' => $params['signing_person'] ?? '',
'regulators' => $params['regulators'],
'project_director' => $params['project_director'] ?? '',
'way' => $params['way'] ?? 0,
'seal_name' => $params['seal_name'] ?? 0,
'limit' => $params['limit'] ?? 0,
'limit_num' => $params['limit_num'] ?? 0,
'file_type' => $params['file_type'] ?? 0,
'seal_num' => $params['seal_num'] ?? 0,
'sealer' => $params['sealer'] ?? '',
'plance_seal' => $params['plance_seal'] ?? 0,
'send_date' => !empty($params['send_date']) ? strtotime($params['send_date']) : 0,
'number' => $params['number'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除待立项造价项目
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/20 14:16
*/
public static function delete(array $params): bool
{
return CostApprovedProject::destroy($params['id']);
}
/**
* @notes 获取待立项造价项目详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/20 14:16
*/
public static function detail($params): array
{
$data = CostApprovedProject::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$data['business_nature_text'] = $data->business_nature_text;
$data['industry_nature_text'] = $data->industry_nature_text;
$data['fund_sources_text'] = $data->fund_sources_text;
$data['const_area_text'] = $data->const_area_text;
$data['way_text'] = $data->way_text;
$data['seal_name_text'] = $data->seal_name_text;
$data['file_type_text'] = $data->file_type_text;
$data['plance_seal_text'] = $data->plance_seal_text;
return $data->toArray();
}
}

View File

@ -0,0 +1,227 @@
<?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\validate\cost_project;
use app\common\model\cost_project\CostApprovedProject;
use app\common\model\dict\DictData;
use app\common\validate\BaseValidate;
/**
* 待立项造价项目验证器
* Class CostApprovedProjectValidate
* @package app\adminapi\validate\cost_project
*/
class CostApprovedProjectValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'contract_name' => 'require',
'part_a' => 'require',
'part_b' => 'require',
'business_nature' => 'checkBusinessNature',
'industry_nature' => 'checkIndustryNature',
'fund_sources' => 'checkFundSources',
'const_area' => 'checkConstArea',
'project_money' => 'float|egt:0',
'money' => 'require|float|gt:0',
'rate' => 'float|egt:0',
'start_date' => 'dateFormat:Y-m-d',
'end_date' => 'dateFormat:Y-m-d',
'performance' => 'float|egt:0',
'due_time' => 'dateFormat:Y-m-d',
'create_date' => 'dateFormat:Y-m-d',
'dept' => 'require',
'regulators' => 'require',
'way' => 'checkWay',
'seal_name' => 'checkSealName',
'limit' => 'integer|in:0,1',
'limit_num' => 'integer',
'file_type' => 'checkFileType',
'seal_num' => 'integer',
'plance_seal' => 'integer|in:0,1',
'send_date' => 'dateFormat:Y-m-d',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'contract_name' => '合同名称',
'part_a' => '甲方签约单位',
'part_b' => '乙方签约单位',
'business_nature' => '业务性质',
'industry_nature' => '行业性质',
'fund_sources' => '资金来源',
'const_area' => '建设区域',
'project_money' => '工程总投资(元)',
'money' => '签订金额(元)',
'rate' => '合同签订费率(%)',
'start_date' => '合同计划开始日期',
'end_date' => '合同计划结束日期',
'performance' => '履约金(元)',
'due_time' => '履约金到期时间',
'create_date' => '录入日期',
'dept' => '签订部门',
'regulators' => '监管部门',
'way' => '实施方式',
'seal_name' => '盖章名称',
'limit' => '是否限制',
'limit_num' => '限制次数',
'file_type' => '文件类型',
'seal_num' => '盖章份数',
'plance_seal' => '骑缝盖章',
'send_date' => '发出日期',
];
/**
* @notes 添加场景
* @return CostApprovedProjectValidate
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return CostApprovedProjectValidate
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return CostApprovedProjectValidate
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return CostApprovedProjectValidate
* @author likeadmin
* @date 2024/02/20 14:16
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = CostApprovedProject::field('id')->where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkBusinessNature($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_business_nature')->column('value');
if(!in_array($value,$dict)){
return '业务性质数据值无效';
}
return true;
}
public function checkIndustryNature($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_industry_nature')->column('value');
if(!in_array($value,$dict)){
return '行业性质数据值无效';
}
return true;
}
public function checkFundSources($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_fund_sources')->column('value');
if(!in_array($value,$dict)){
return '资金来源数据值无效';
}
return true;
}
public function checkConstArea($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_const_area')->column('value');
if(!in_array($value,$dict)){
return '建设区域数据值无效';
}
return true;
}
public function checkWay($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_way')->column('value');
if(!in_array($value,$dict)){
return '实施方式数据值无效';
}
return true;
}
public function checkSealName($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_seal_name')->column('value');
if(!in_array($value,$dict)){
return '盖章名称数据值无效';
}
return true;
}
public function checkFileType($value): bool|string
{
$dict = DictData::where('type_value','cost_consultation_file_type')->column('value');
if(!in_array($value,$dict)){
return '文件类型数据值无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
}

View File

@ -0,0 +1,110 @@
<?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\common\model\cost_project;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 待立项造价项目模型
* Class CostApprovedProject
* @package app\common\model\cost_project
*/
class CostApprovedProject extends BaseModel
{
use SoftDelete;
protected $name = 'cost_approved_project';
protected $deleteTime = 'delete_time';
public function getBusinessNatureTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_business_nature')->column('name','value');
return !empty($data['business_nature']) ? $dict[$data['business_nature']] : '';
}
public function getIndustryNatureTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_industry_nature')->column('name','value');
return !empty($data['industry_nature']) ? $dict[$data['industry_nature']] : '';
}
public function getFundSourcesTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_fund_sources')->column('name','value');
return !empty($data['fund_sources']) ? $dict[$data['fund_sources']] : '';
}
public function getConstAreaTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_const_area')->column('name','value');
return !empty($data['const_area']) ? $dict[$data['const_area']] : '';
}
public function getWayTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_way')->column('name','value');
return !empty($data['way']) ? $dict[$data['way']] : '';
}
public function getFileTypeTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_file_type')->column('name','value');
return !empty($data['file_type']) ? $dict[$data['file_type']] : '';
}
public function getSealNameTextAttr($value,$data){
$dict = DictData::where('type_value','cost_consultation_seal_name')->column('name','value');
return !empty($data['seal_name']) ? $dict[$data['seal_name']] : '';
}
public function getLimitTextAttr($value,$data): string
{
$arr = [0=>'否',1=>'是'];
return $arr[$data['limit']];
}
public function getPlanceSealTextAttr($value,$data): string
{
$arr = [0=>'否',1=>'是'];
return $arr[$data['plance_seal']];
}
public function getStartDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getEndDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getDueTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getCreateDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getSendDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
}