新增材料设备信息内容

This commit is contained in:
weiz 2024-02-27 16:46:44 +08:00
parent 4e70eb134c
commit e1d9cfbfcf
5 changed files with 488 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_work;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_work\SupervisionMaterialEquipmentInfoLists;
use app\adminapi\logic\supervision_work\SupervisionMaterialEquipmentInfoLogic;
use app\adminapi\validate\supervision_work\SupervisionMaterialEquipmentInfoValidate;
/**
* 工程监理--材料设备信息控制器
* Class SupervisionMaterialEquipmentInfoController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionMaterialEquipmentInfoController extends BaseAdminController
{
/**
* @notes 获取工程监理--材料设备信息列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function lists()
{
return $this->dataLists(new SupervisionMaterialEquipmentInfoLists());
}
/**
* @notes 添加工程监理--材料设备信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function add()
{
$params = (new SupervisionMaterialEquipmentInfoValidate())->post()->goCheck('add');
$result = SupervisionMaterialEquipmentInfoLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionMaterialEquipmentInfoLogic::getError());
}
/**
* @notes 编辑工程监理--材料设备信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function edit()
{
$params = (new SupervisionMaterialEquipmentInfoValidate())->post()->goCheck('edit');
$result = SupervisionMaterialEquipmentInfoLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionMaterialEquipmentInfoLogic::getError());
}
/**
* @notes 删除工程监理--材料设备信息
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function delete()
{
$params = (new SupervisionMaterialEquipmentInfoValidate())->post()->goCheck('delete');
SupervisionMaterialEquipmentInfoLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--材料设备信息详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function detail()
{
$params = (new SupervisionMaterialEquipmentInfoValidate())->goCheck('detail');
$result = SupervisionMaterialEquipmentInfoLogic::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\supervision_work;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMaterialEquipmentInfo;
use app\common\lists\ListsSearchInterface;
/**
* 工程监理--材料设备信息列表
* Class SupervisionMaterialEquipmentInfoLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionMaterialEquipmentInfoLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function setSearch(): array
{
return [
'=' => ['project_id', 'contract_brand', 'type'],
'%like%' => ['name', 'brand', 'model'],
];
}
/**
* @notes 获取工程监理--材料设备信息列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function lists(): array
{
return SupervisionMaterialEquipmentInfo::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'];
$data['contract_brand_text'] = $data->contract_brand_text;
$data['type_text'] = $data->type_text;
})
->toArray();
}
/**
* @notes 获取工程监理--材料设备信息数量
* @return int
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function count(): int
{
return SupervisionMaterialEquipmentInfo::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,127 @@
<?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\SupervisionMaterialEquipmentInfo;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 工程监理--材料设备信息逻辑
* Class SupervisionMaterialEquipmentInfoLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionMaterialEquipmentInfoLogic extends BaseLogic
{
/**
* @notes 添加工程监理--材料设备信息
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/27 16:28
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SupervisionMaterialEquipmentInfo::create([
'project_id' => $params['project_id'],
'name' => $params['name'],
'brand' => $params['brand'],
'model' => $params['model'],
'unit' => $params['unit'],
'number' => $params['number'],
'contract_brand' => $params['contract_brand'],
'type' => $params['type'],
'remark' => $params['remark']
]);
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/27 16:28
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionMaterialEquipmentInfo::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'name' => $params['name'],
'brand' => $params['brand'],
'model' => $params['model'],
'unit' => $params['unit'],
'number' => $params['number'],
'contract_brand' => $params['contract_brand'],
'type' => $params['type'],
'remark' => $params['remark'],
'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/27 16:28
*/
public static function delete(array $params): bool
{
return SupervisionMaterialEquipmentInfo::destroy($params['id']);
}
/**
* @notes 获取工程监理--材料设备信息详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/27 16:28
*/
public static function detail($params): array
{
$data = SupervisionMaterialEquipmentInfo::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'];
$data['contract_brand_text'] = $data->contract_brand_text;
$data['type_text'] = $data->type_text;
return $data->toArray();
}
}

View File

@ -0,0 +1,126 @@
<?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\SupervisionMaterialEquipmentInfo;
use app\common\validate\BaseValidate;
/**
* 工程监理--材料设备信息验证器
* Class SupervisionMaterialEquipmentInfoValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionMaterialEquipmentInfoValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'name' => 'require',
'number' => 'integer',
'contract_brand' => 'require|in:0,1',
'type' => 'require|in:0,1',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'name' => '材料/设备名称',
'brand' => '材料/设备品牌',
'model' => '型号',
'unit' => '计数单位',
'number' => '计划数量',
'contract_brand' => '合同约定品牌 0-否 1-是',
'type' => '类型 0-材料 1-设备',
'remark' => '备注',
];
/**
* @notes 添加场景
* @return SupervisionMaterialEquipmentInfoValidate
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionMaterialEquipmentInfoValidate
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionMaterialEquipmentInfoValidate
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionMaterialEquipmentInfoValidate
* @author likeadmin
* @date 2024/02/27 16:28
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionMaterialEquipmentInfo::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;
}
}

View File

@ -0,0 +1,44 @@
<?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;
use think\model\concern\SoftDelete;
/**
* 工程监理--材料设备信息模型
* Class SupervisionMaterialEquipmentInfo
* @package app\common\model\supervision_work
*/
class SupervisionMaterialEquipmentInfo extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_material_equipment_info';
protected $deleteTime = 'delete_time';
public function getContractBrandTextAttr($value,$data): string
{
$arr = [0=>'否',1=>'是'];
return $arr[$data['contract_brand']];
}
public function getTypeTextAttr($value,$data): string
{
$arr = [0=>'材料',1=>'设备'];
return $arr[$data['type']];
}
}