QualityCheckNature

This commit is contained in:
weiz 2023-12-20 16:23:20 +08:00
parent fedba7efe0
commit d6cbfb53a3
21 changed files with 504 additions and 24 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\quality;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\quality\QualityCheckNatureLists;
use app\adminapi\logic\quality\QualityCheckNatureLogic;
use app\adminapi\validate\quality\QualityCheckNatureValidate;
/**
* 检查性质控制器
* Class QualityCheckNatureController
* @package app\adminapi\controller\quality
*/
class QualityCheckNatureController extends BaseAdminController
{
/**
* @notes 获取检查性质列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function lists()
{
return $this->dataLists(new QualityCheckNatureLists());
}
/**
* @notes 添加检查性质
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function add()
{
$params = (new QualityCheckNatureValidate())->post()->goCheck('add');
$result = QualityCheckNatureLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(QualityCheckNatureLogic::getError());
}
/**
* @notes 编辑检查性质
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function edit()
{
$params = (new QualityCheckNatureValidate())->post()->goCheck('edit');
$result = QualityCheckNatureLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(QualityCheckNatureLogic::getError());
}
/**
* @notes 删除检查性质
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function delete()
{
$params = (new QualityCheckNatureValidate())->post()->goCheck('delete');
QualityCheckNatureLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取检查性质详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function detail()
{
$params = (new QualityCheckNatureValidate())->goCheck('detail');
$result = QualityCheckNatureLogic::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\quality;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\quality\QualityCheckNature;
use app\common\lists\ListsSearchInterface;
/**
* 检查性质列表
* Class QualityCheckNatureLists
* @package app\adminapi\listsquality
*/
class QualityCheckNatureLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function setSearch(): array
{
return [
'%like%' => ['name', 'user'],
];
}
/**
* @notes 获取检查性质列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function lists(): array
{
return QualityCheckNature::where($this->searchWhere)
->field(['id', 'org_id', 'dept_id', 'name', 'user', 'illustrate', 'date'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty();
$item['org_name'] = $org['name'];
$item['dept_name'] = $dept['name'];
return $item;
})
->toArray();
}
/**
* @notes 获取检查性质数量
* @return int
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function count(): int
{
return QualityCheckNature::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,129 @@
<?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\quality;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\quality\QualityCheckNature;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 检查性质逻辑
* Class QualityCheckNatureLogic
* @package app\adminapi\logic\quality
*/
class QualityCheckNatureLogic extends BaseLogic
{
/**
* @notes 添加检查性质
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/20 15:56
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
QualityCheckNature::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'name' => $params['name'],
'user' => $params['user'],
'illustrate' => $params['illustrate'],
'date' => strtotime($params['date']),
'add_user' => $admin_id,
'update_user' => $admin_id,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑检查性质
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/20 15:56
*/
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
QualityCheckNature::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'name' => $params['name'],
'user' => $params['user'],
'illustrate' => $params['illustrate'],
'date' => strtotime($params['date']),
'update_user' => $admin_id,
'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 2023/12/20 15:56
*/
public static function delete(array $params): bool
{
return QualityCheckNature::destroy($params['id']);
}
/**
* @notes 获取检查性质详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/20 15:56
*/
public static function detail($params): array
{
$data = QualityCheckNature::findOrEmpty($params['id'])->toArray();
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['add_user_name'] = $admin[$data['add_user']];
$data['update_user_name'] = $admin[$data['update_user']];
return $data;
}
}

View File

@ -0,0 +1,120 @@
<?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\quality;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\validate\BaseValidate;
/**
* 检查性质验证器
* Class QualityCheckNatureValidate
* @package app\adminapi\validate\quality
*/
class QualityCheckNatureValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'name' => 'require',
'user' => 'require',
'date' => 'dateFormat:Y-m-d',
];
protected $message = [
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'name.require' => '请填写检查性质名称',
'user.require' => '请填写创建人',
'date.dateFormat' => '创建日期格式错误'
];
/**
* @notes 添加场景
* @return QualityCheckNatureValidate
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return QualityCheckNatureValidate
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return QualityCheckNatureValidate
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return QualityCheckNatureValidate
* @author likeadmin
* @date 2023/12/20 15:56
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkOrg($value): bool|string
{
$data = Orgs::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '组织不存在';
}
return true;
}
public function checkDept($value,$rule,$data): bool|string
{
$dept = Dept::where('id',$value)->findOrEmpty();
if($dept->isEmpty()){
return '部门不存在';
}
if($dept['org_id'] != $data['org_id']){
return '部门不属于当前选择的组织';
}
return true;
}
}

View File

@ -38,7 +38,7 @@ class SafetyAccidentValidate extends BaseValidate
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'happen_time' => 'date',
'happen_time' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -47,7 +47,7 @@ class SafetyAccidentValidate extends BaseValidate
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'happen_time.date' => '发生时间格式错误',
'happen_time.dateFormat' => '发生时间格式错误',
];

View File

@ -38,7 +38,7 @@ class SafetyCheckValidate extends BaseValidate
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'check_date' => 'date',
'check_date' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -47,7 +47,7 @@ class SafetyCheckValidate extends BaseValidate
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'check_date.date' => '检查日期格式错误',
'check_date.dateFormat' => '检查日期格式错误',
];
/**

View File

@ -39,7 +39,7 @@ class SafetyEmergencyPlanValidate extends BaseValidate
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'name' => 'require',
'happen_date' => 'date',
'happen_date' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -49,7 +49,7 @@ class SafetyEmergencyPlanValidate extends BaseValidate
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'name.require' => '请填写名称',
'happen_date.date' => '发生日期格式错误',
'happen_date.dateFormat' => '发生日期格式错误',
];

View File

@ -39,7 +39,7 @@ class SafetyEvaluateValidate extends BaseValidate
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'name' => 'require',
'happen_date' => 'date',
'happen_date' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -49,7 +49,7 @@ class SafetyEvaluateValidate extends BaseValidate
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'name.require' => '请填写名称',
'happen_date.date' => '发生日期格式错误',
'happen_date.dateFormat' => '发生日期格式错误',
];

View File

@ -38,7 +38,7 @@ class SafetyEventValidate extends BaseValidate
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'happen_time' => 'date',
'happen_time' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -47,7 +47,7 @@ class SafetyEventValidate extends BaseValidate
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'happen_time.date' => '发生时间格式错误',
'happen_time.dateFormat' => '发生时间格式错误',
];

View File

@ -38,7 +38,7 @@ class SafetyModifyValidate extends BaseValidate
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'check_date' => 'date',
'check_date' => 'dateFormat:Y-m-d',
];
protected $message = [
@ -46,7 +46,7 @@ class SafetyModifyValidate extends BaseValidate
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'check_date.date' => '检查日期格式错误',
'check_date.dateFormat' => '检查日期格式错误',
];

View File

@ -39,7 +39,7 @@ class SafetyRehearsalValidate extends BaseValidate
'dept_id' => 'require|checkDept',
'project_id' => 'require|checkProject',
'name' => 'require',
'happen_date' => 'date',
'happen_date' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -49,7 +49,7 @@ class SafetyRehearsalValidate extends BaseValidate
'dept_id.require' => '请选择部门',
'project_id.require' => '请选择项目',
'name.require' => '请填写名称',
'happen_date.date' => '发生日期格式错误',
'happen_date.dateFormat' => '发生日期格式错误',
];

View File

@ -37,7 +37,7 @@ class SafetySuperviseValidate extends BaseValidate
'id' => 'require',
'org_id' => 'require|checkOrg',
'dept_id' => 'require|checkDept',
'happen_time' => 'date',
'happen_time' => 'dateFormat:Y-m-d',
'file' => 'checkFile'
];
@ -45,7 +45,7 @@ class SafetySuperviseValidate extends BaseValidate
'id.require' => '缺少必要参数',
'org_id.require' => '请选择组织',
'dept_id.require' => '请选择部门',
'happen_time.date' => '发生时间格式错误',
'happen_time.dateFormat' => '发生时间格式错误',
];

View File

@ -0,0 +1,37 @@
<?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\quality;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 检查性质模型
* Class QualityCheckNature
* @package app\common\model\quality
*/
class QualityCheckNature extends BaseModel
{
use SoftDelete;
protected $name = 'quality_check_nature';
protected $deleteTime = 'delete_time';
public function getDateAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyAccident extends BaseModel
public function getHappenTimeAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyCheck extends BaseModel
public function getCheckDateAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyEmergencyPlan extends BaseModel
public function getHappenDateAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyEvaluate extends BaseModel
public function getHappenDateAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyEvent extends BaseModel
public function getHappenTimeAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -32,6 +32,6 @@ class SafetyModify extends BaseModel
public function getCheckDateAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetyRehearsal extends BaseModel
public function getHappenDateAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}

View File

@ -37,6 +37,6 @@ class SafetySupervise extends BaseModel
public function getHappenTimeAttr($value): string
{
return date('Y-m-d',$value);
return !empty($value) ? date('Y-m-d',$value) : '';
}
}