新增监理日记列表模块
This commit is contained in:
parent
221de465ef
commit
7e8f5d440e
@ -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_work;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\supervision_work\SupervisionDiaryLists;
|
||||
use app\adminapi\logic\supervision_work\SupervisionDiaryLogic;
|
||||
use app\adminapi\validate\supervision_work\SupervisionDiaryValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理日记控制器
|
||||
* Class SupervisionDiaryController
|
||||
* @package app\adminapi\controller\supervision_work
|
||||
*/
|
||||
class SupervisionDiaryController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理日记列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionDiaryLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理日记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionDiaryValidate())->post()->goCheck('add');
|
||||
$result = SupervisionDiaryLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionDiaryLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--监理日记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionDiaryValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionDiaryLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionDiaryLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--监理日记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionDiaryValidate())->post()->goCheck('delete');
|
||||
SupervisionDiaryLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理日记详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionDiaryValidate())->goCheck('detail');
|
||||
$result = SupervisionDiaryLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?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_work;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_work\SupervisionDiary;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理日记列表
|
||||
* Class SupervisionDiaryLists
|
||||
* @package app\adminapi\listssupervision_work
|
||||
*/
|
||||
class SupervisionDiaryLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id'],
|
||||
'%like%' => ['user', 'director'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理日记列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionDiary::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理日记数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionDiary::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
131
app/adminapi/logic/supervision_work/SupervisionDiaryLogic.php
Normal file
131
app/adminapi/logic/supervision_work/SupervisionDiaryLogic.php
Normal 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\logic\supervision_work;
|
||||
|
||||
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_work\SupervisionDiary;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理日记逻辑
|
||||
* Class SupervisionDiaryLogic
|
||||
* @package app\adminapi\logic\supervision_work
|
||||
*/
|
||||
class SupervisionDiaryLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理日记
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionDiary::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
|
||||
'week' => $params['week'],
|
||||
'air_temperature' => $params['air_temperature'],
|
||||
'climate' => $params['climate'],
|
||||
'user' => $params['user'],
|
||||
'director' => $params['director'],
|
||||
'engineering_dynamics' => $params['engineering_dynamics'],
|
||||
'supervision_work' => $params['supervision_work'],
|
||||
'construction_situation' => $params['construction_situation'],
|
||||
'other_matters' => $params['other_matters'],
|
||||
'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/03/01 13:53
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionDiary::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
|
||||
'week' => $params['week'],
|
||||
'air_temperature' => $params['air_temperature'],
|
||||
'climate' => $params['climate'],
|
||||
'user' => $params['user'],
|
||||
'director' => $params['director'],
|
||||
'engineering_dynamics' => $params['engineering_dynamics'],
|
||||
'supervision_work' => $params['supervision_work'],
|
||||
'construction_situation' => $params['construction_situation'],
|
||||
'other_matters' => $params['other_matters'],
|
||||
'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/01 13:53
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionDiary::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理日记详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionDiary::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -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\validate\supervision_work;
|
||||
|
||||
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_work\SupervisionDiary;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理日记验证器
|
||||
* Class SupervisionDiaryValidate
|
||||
* @package app\adminapi\validate\supervision_work
|
||||
*/
|
||||
class SupervisionDiaryValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'project_id' => 'require|checkProject',
|
||||
'date' => 'require|dateFormat:Y-m-d',
|
||||
'user' => 'require',
|
||||
'director' => 'require',
|
||||
'annex' => 'checkAnnex',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'date' => '日期',
|
||||
'week' => '星期',
|
||||
'air_temperature' => '气温',
|
||||
'climate' => '气候',
|
||||
'user' => '监理人员',
|
||||
'director' => '监理总监',
|
||||
'engineering_dynamics' => '工程动态',
|
||||
'supervision_work' => '监理工作',
|
||||
'construction_situation' => '安全文明施工情况',
|
||||
'other_matters' => '其他事项',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionDiaryValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionDiaryValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionDiaryValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionDiaryValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 13:53
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionDiary::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$data = SupervisionProject::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;
|
||||
}
|
||||
|
||||
}
|
41
app/common/model/supervision_work/SupervisionDiary.php
Normal file
41
app/common/model/supervision_work/SupervisionDiary.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?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_work;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理日记模型
|
||||
* Class SupervisionDiary
|
||||
* @package app\common\model\supervision_work
|
||||
*/
|
||||
class SupervisionDiary extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = 'supervision_diary';
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getDateAttr($value)
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user