新增工作联系单模块
This commit is contained in:
parent
60c3233999
commit
221de465ef
app
adminapi
controller/supervision_work
lists/supervision_work
logic/supervision_work
validate/supervision_work
common/model/supervision_work
@ -0,0 +1,111 @@
|
||||
<?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\SupervisionWorkContactLists;
|
||||
use app\adminapi\logic\supervision_work\SupervisionWorkContactLogic;
|
||||
use app\adminapi\validate\supervision_work\SupervisionWorkContactValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单控制器
|
||||
* Class SupervisionWorkContactController
|
||||
* @package app\adminapi\controller\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionWorkContactLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理工作联系单
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionWorkContactValidate())->post()->goCheck('add');
|
||||
$result = SupervisionWorkContactLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionWorkContactLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--监理工作联系单
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionWorkContactValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionWorkContactLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionWorkContactLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--监理工作联系单
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionWorkContactValidate())->post()->goCheck('delete');
|
||||
$result = SupervisionWorkContactLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionWorkContactLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionWorkContactValidate())->goCheck('detail');
|
||||
$result = SupervisionWorkContactLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
108
app/adminapi/controller/supervision_work/SupervisionWorkContactProblemController.php
Normal file
108
app/adminapi/controller/supervision_work/SupervisionWorkContactProblemController.php
Normal 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\SupervisionWorkContactProblemLists;
|
||||
use app\adminapi\logic\supervision_work\SupervisionWorkContactProblemLogic;
|
||||
use app\adminapi\validate\supervision_work\SupervisionWorkContactProblemValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单问题控制器
|
||||
* Class SupervisionWorkContactProblemController
|
||||
* @package app\adminapi\controller\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactProblemController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单问题列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionWorkContactProblemLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理工作联系单问题
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionWorkContactProblemValidate())->post()->goCheck('add');
|
||||
$result = SupervisionWorkContactProblemLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionWorkContactProblemLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--监理工作联系单问题
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionWorkContactProblemValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionWorkContactProblemLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionWorkContactProblemLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--监理工作联系单问题
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionWorkContactProblemValidate())->post()->goCheck('delete');
|
||||
SupervisionWorkContactProblemLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单问题详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionWorkContactProblemValidate())->goCheck('detail');
|
||||
$result = SupervisionWorkContactProblemLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?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\SupervisionWorkContact;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单列表
|
||||
* Class SupervisionWorkContactLists
|
||||
* @package app\adminapi\listssupervision_work
|
||||
*/
|
||||
class SupervisionWorkContactLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id'],
|
||||
'%like%' => ['code', 'initiator', 'theme', 'copy_user'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionWorkContact::where($this->searchWhere)
|
||||
->field(['id', 'project_id', 'code', 'initiator', 'initiation_date', 'theme', 'copy_user'])
|
||||
->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 11:01
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionWorkContact::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?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_work\SupervisionWorkContact;
|
||||
use app\common\model\supervision_work\SupervisionWorkContactProblem;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单问题列表
|
||||
* Class SupervisionWorkContactProblemLists
|
||||
* @package app\adminapi\listssupervision_work
|
||||
*/
|
||||
class SupervisionWorkContactProblemLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['work_contact_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单问题列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionWorkContactProblem::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$work_contact = SupervisionWorkContact::field('code')->where('id',$data['work_contact_id'])->findOrEmpty();
|
||||
$data['code'] = $work_contact['code'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单问题数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionWorkContactProblem::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
<?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\SupervisionWorkContact;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\supervision_work\SupervisionWorkContactProblem;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单逻辑
|
||||
* Class SupervisionWorkContactLogic
|
||||
* @package app\adminapi\logic\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理工作联系单
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = SupervisionWorkContact::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'code' => data_unique_code('GZLXD'),
|
||||
'initiator' => $params['initiator'],
|
||||
'initiation_date' => !empty($params['initiation_date']) ? strtotime($params['initiation_date']) : 0,
|
||||
'theme' => $params['theme'],
|
||||
'copy_user' => $params['copy_user'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
if(!empty($params['problem'])){
|
||||
foreach($params['problem'] as $v){
|
||||
SupervisionWorkContactProblem::create([
|
||||
'work_contact_id' => $res->id,
|
||||
'problem_name' => $v['problem_name'],
|
||||
'problem_description' => $v['problem_description'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
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 11:01
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionWorkContact::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'initiator' => $params['initiator'],
|
||||
'initiation_date' => !empty($params['initiation_date']) ? strtotime($params['initiation_date']) : 0,
|
||||
'theme' => $params['theme'],
|
||||
'copy_user' => $params['copy_user'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'update_time' => time()
|
||||
]);
|
||||
if(!empty($params['problem'])){
|
||||
foreach($params['problem'] as $v){
|
||||
if(!empty($v['id'])){
|
||||
SupervisionWorkContactProblem::where('id',$v['id'])->update([
|
||||
'work_contact_id' => $params['id'],
|
||||
'problem_name' => $v['problem_name'],
|
||||
'problem_description' => $v['problem_description'],
|
||||
]);
|
||||
}else{
|
||||
SupervisionWorkContactProblem::create([
|
||||
'work_contact_id' => $params['id'],
|
||||
'problem_name' => $v['problem_name'],
|
||||
'problem_description' => $v['problem_description'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 11:01
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$problem = SupervisionWorkContactProblem::where('work_contact_id',$params['id'])->findOrEmpty();
|
||||
if(!$problem->isEmpty()){
|
||||
self::setError('该数据下存在通知问题数据,请先删除通知问题数据');
|
||||
return false;
|
||||
}
|
||||
return SupervisionWorkContact::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionWorkContact::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,113 @@
|
||||
<?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_work\SupervisionWorkContact;
|
||||
use app\common\model\supervision_work\SupervisionWorkContactProblem;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单问题逻辑
|
||||
* Class SupervisionWorkContactProblemLogic
|
||||
* @package app\adminapi\logic\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactProblemLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--监理工作联系单问题
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionWorkContactProblem::create([
|
||||
'work_contact_id' => $params['work_contact_id'],
|
||||
'problem_name' => $params['problem_name'],
|
||||
'problem_description' => $params['problem_description'],
|
||||
]);
|
||||
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 11:01
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionWorkContactProblem::where('id', $params['id'])->update([
|
||||
'work_contact_id' => $params['work_contact_id'],
|
||||
'problem_name' => $params['problem_name'],
|
||||
'problem_description' => $params['problem_description'],
|
||||
'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 11:01
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionWorkContactProblem::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--监理工作联系单问题详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionWorkContactProblem::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$work_contact = SupervisionWorkContact::field('code')->where('id',$data['work_contact_id'])->findOrEmpty();
|
||||
$data['code'] = $work_contact['code'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -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\supervision_work;
|
||||
|
||||
|
||||
use app\common\model\supervision_work\SupervisionWorkContact;
|
||||
use app\common\model\supervision_work\SupervisionWorkContactProblem;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单问题验证器
|
||||
* Class SupervisionWorkContactProblemValidate
|
||||
* @package app\adminapi\validate\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactProblemValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'work_contact_id' => 'require|checkWorkContact',
|
||||
'problem_name' => 'require',
|
||||
'problem_description' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'work_contact_id' => '监理工作联系单id',
|
||||
'problem_name' => '问题名称',
|
||||
'problem_description' => '问题说明',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionWorkContactProblemValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['work_contact_id','problem_name','problem_description']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionWorkContactProblemValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','work_contact_id','problem_name','problem_description']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionWorkContactProblemValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionWorkContactProblemValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionWorkContactProblem::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkWorkContact($value): bool|string
|
||||
{
|
||||
$data = SupervisionWorkContact::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '工作联系单信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
<?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\SupervisionWorkContact;
|
||||
use app\common\model\supervision_work\SupervisionWorkContactProblem;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--监理工作联系单验证器
|
||||
* Class SupervisionWorkContactValidate
|
||||
* @package app\adminapi\validate\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'project_id' => 'require|checkProject',
|
||||
'initiator' => 'require',
|
||||
'initiation_date' => 'require|dateFormat:Y-m-d',
|
||||
'theme' => 'require',
|
||||
'annex' => 'checkAnnex',
|
||||
'problem' => 'checkProblem'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'code' => '联系编号',
|
||||
'initiator' => '发起人',
|
||||
'initiation_date' => '发起日期',
|
||||
'theme' => '主题',
|
||||
'copy_user' => '抄送人员',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionWorkContactValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionWorkContactValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionWorkContactValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionWorkContactValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/01 11:01
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionWorkContact::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;
|
||||
}
|
||||
|
||||
public function checkProblem($value): bool|string
|
||||
{
|
||||
if(!isset($value) || $value == '') return true;
|
||||
if(!is_array($value)) return '工作联系单问题数据格式错误';
|
||||
foreach($value as $k=>$v){
|
||||
if(!empty($v['id'])){
|
||||
$data = SupervisionWorkContactProblem::where('id',$v['id'])->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '工作联系单问题列表第'.($k+1).'行数据不存在';
|
||||
}
|
||||
}
|
||||
if(empty($v['problem_name'])) return '工作联系单问题列表第'.($k+1).'行问题名称为空';
|
||||
if(empty($v['problem_description'])) return '工作联系单问题列表第'.($k+1).'行问题说明为空';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
42
app/common/model/supervision_work/SupervisionWorkContact.php
Normal file
42
app/common/model/supervision_work/SupervisionWorkContact.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 SupervisionWorkContact
|
||||
* @package app\common\model\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContact extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_work_contact';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getInitiationDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?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 SupervisionWorkContactProblem
|
||||
* @package app\common\model\supervision_work
|
||||
*/
|
||||
class SupervisionWorkContactProblem extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_work_contact_problem';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user