新增危大方案提交列表模块

This commit is contained in:
weiz 2024-03-04 14:53:57 +08:00
parent 7bb9aea11d
commit e46db2d7fd
5 changed files with 497 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\supervision_dangerous;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_dangerous\SupervisionDangerousEngineeringCaseLists;
use app\adminapi\logic\supervision_dangerous\SupervisionDangerousEngineeringCaseLogic;
use app\adminapi\validate\supervision_dangerous\SupervisionDangerousEngineeringCaseValidate;
/**
* 工程监理--危大方案提交列表控制器
* Class SupervisionDangerousEngineeringCaseController
* @package app\adminapi\controller\supervision_dangerous
*/
class SupervisionDangerousEngineeringCaseController extends BaseAdminController
{
/**
* @notes 获取工程监理--危大方案提交列表列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function lists()
{
return $this->dataLists(new SupervisionDangerousEngineeringCaseLists());
}
/**
* @notes 添加工程监理--危大方案提交列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function add()
{
$params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('add');
$result = SupervisionDangerousEngineeringCaseLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionDangerousEngineeringCaseLogic::getError());
}
/**
* @notes 编辑工程监理--危大方案提交列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function edit()
{
$params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('edit');
$result = SupervisionDangerousEngineeringCaseLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionDangerousEngineeringCaseLogic::getError());
}
/**
* @notes 删除工程监理--危大方案提交列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function delete()
{
$params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('delete');
SupervisionDangerousEngineeringCaseLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--危大方案提交列表详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function detail()
{
$params = (new SupervisionDangerousEngineeringCaseValidate())->goCheck('detail');
$result = SupervisionDangerousEngineeringCaseLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,86 @@
<?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\supervision_dangerous;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringCase;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\model\supervision_project\SupervisionProject;
/**
* 工程监理--危大方案提交列表列表
* Class SupervisionDangerousEngineeringCaseLists
* @package app\adminapi\listssupervision_dangerous
*/
class SupervisionDangerousEngineeringCaseLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function setSearch(): array
{
return [
'=' => ['dangerous_engineering_monitoring_id'],
'%like%' => ['case_name', 'assessor'],
];
}
/**
* @notes 获取工程监理--危大方案提交列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function lists(): array
{
return SupervisionDangerousEngineeringCase::where($this->searchWhere)
->field(['id', 'dangerous_engineering_monitoring_id', 'case_name', 'assessor'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty();
$project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty();
$data['dangerous_engineering_monitoring_title'] = $project['project_name'];
$data['project_name'] = $project['project_name'];
$data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text;
})
->toArray();
}
/**
* @notes 获取工程监理--危大方案提交列表数量
* @return int
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function count(): int
{
return SupervisionDangerousEngineeringCase::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,136 @@
<?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\logic\supervision_dangerous;
use app\common\model\auth\Admin;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringCase;
use app\common\logic\BaseLogic;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\model\supervision_project\SupervisionProject;
use think\facade\Db;
/**
* 工程监理--危大方案提交列表逻辑
* Class SupervisionDangerousEngineeringCaseLogic
* @package app\adminapi\logic\supervision_dangerous
*/
class SupervisionDangerousEngineeringCaseLogic extends BaseLogic
{
/**
* @notes 添加工程监理--危大方案提交列表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/04 14:00
*/
public static function add(array $params,$admin_id): bool
{
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->findOrEmpty();
if($dangerous_engineering_monitoring['status'] != 0){
self::setError('当前危大工程监控信息已提交方案');
return false;
}
Db::startTrans();
try {
SupervisionDangerousEngineeringCase::create([
'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'],
'case_name' => $params['case_name'],
'assessor' => $params['assessor'],
'review_content' => $params['review_content'],
'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $admin_id
]);
SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->update([
'status' => 1,
'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/03/04 14:00
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionDangerousEngineeringCase::where('id', $params['id'])->update([
'case_name' => $params['case_name'],
'assessor' => $params['assessor'],
'review_content' => $params['review_content'],
'remark' => $params['remark'],
'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/03/04 14:00
*/
public static function delete(array $params): bool
{
return SupervisionDangerousEngineeringCase::destroy($params['id']);
}
/**
* @notes 获取工程监理--危大方案提交列表详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/03/04 14:00
*/
public static function detail($params): array
{
$data = SupervisionDangerousEngineeringCase::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty();
$project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty();
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['dangerous_engineering_monitoring_title'] = $project['project_name'];
$data['project_name'] = $project['project_name'];
$data['type'] = $dangerous_engineering_monitoring->type_text;
$data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text;
$data['create_user_name'] = $create_user['name'];
return $data->toArray();
}
}

View File

@ -0,0 +1,131 @@
<?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\supervision_dangerous;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringCase;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\validate\BaseValidate;
/**
* 工程监理--危大方案提交列表验证器
* Class SupervisionDangerousEngineeringCaseValidate
* @package app\adminapi\validate\supervision_dangerous
*/
class SupervisionDangerousEngineeringCaseValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'dangerous_engineering_monitoring_id' => 'require|checkDangerousEngineeringMonitoring',
'case_name' => 'require',
'assessor' => 'require',
'review_content' => 'require',
'annex' => 'checkAnnex'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'dangerous_engineering_monitoring_id' => '危大工程监控id',
'case_name' => '方案名称',
'assessor' => '评审人员',
'review_content' => '评审内容',
'remark' => '备注',
'create_user' => '提交人',
];
/**
* @notes 添加场景
* @return SupervisionDangerousEngineeringCaseValidate
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionDangerousEngineeringCaseValidate
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionDangerousEngineeringCaseValidate
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionDangerousEngineeringCaseValidate
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionDangerousEngineeringCase::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkDangerousEngineeringMonitoring($value): bool|string
{
$data = SupervisionDangerousEngineeringMonitoring::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '危大工程监控信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}

View File

@ -0,0 +1,36 @@
<?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\supervision_dangerous;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工程监理--危大方案提交列表模型
* Class SupervisionDangerousEngineeringCase
* @package app\common\model\supervision_dangerous
*/
class SupervisionDangerousEngineeringCase extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_dangerous_engineering_case';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
}