update
This commit is contained in:
parent
907c48c206
commit
abccccb9da
108
app/adminapi/controller/cost_project/CostProjectController.php
Normal file
108
app/adminapi/controller/cost_project/CostProjectController.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\cost_project;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\cost_project\CostProjectLists;
|
||||
use app\adminapi\logic\cost_project\CostProjectLogic;
|
||||
use app\adminapi\validate\cost_project\CostProjectValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 造价项目台账控制器
|
||||
* Class CostProjectController
|
||||
* @package app\adminapi\controller\cost_project
|
||||
*/
|
||||
class CostProjectController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取造价项目台账列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CostProjectLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加造价项目台账
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new CostProjectValidate())->post()->goCheck('add');
|
||||
$result = CostProjectLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CostProjectLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑造价项目台账
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new CostProjectValidate())->post()->goCheck('edit');
|
||||
$result = CostProjectLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(CostProjectLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除造价项目台账
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CostProjectValidate())->post()->goCheck('delete');
|
||||
CostProjectLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取造价项目台账详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new CostProjectValidate())->goCheck('detail');
|
||||
$result = CostProjectLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
78
app/adminapi/lists/cost_project/CostProjectLists.php
Normal file
78
app/adminapi/lists/cost_project/CostProjectLists.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?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\cost_project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\cost_project\CostProject;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 造价项目台账列表
|
||||
* Class CostProjectLists
|
||||
* @package app\adminapi\listscost_project
|
||||
*/
|
||||
class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['types', 'industry'],
|
||||
'%like%' => ['project_num', 'project_name'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取造价项目台账列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return CostProject::where($this->searchWhere)
|
||||
->field(['id', 'project_num', 'project_name', 'contract_id', 'types', 'industry', 'province', 'city', 'address', 'starting', 'endtime', 'jhgq', 'depar', 'principal', 'person', 'invest', 'budget', 'cost', 'approval', 'aunit', 'Acontact', 'acontactnum', 'date', 'generalize', 'note', 'remark', 'annex'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取造价项目台账数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return CostProject::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
156
app/adminapi/logic/cost_project/CostProjectLogic.php
Normal file
156
app/adminapi/logic/cost_project/CostProjectLogic.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?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\cost_project;
|
||||
|
||||
|
||||
use app\common\model\cost_project\CostProject;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 造价项目台账逻辑
|
||||
* Class CostProjectLogic
|
||||
* @package app\adminapi\logic\cost_project
|
||||
*/
|
||||
class CostProjectLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加造价项目台账
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CostProject::create([
|
||||
'project_num' => $params['project_num'],
|
||||
'project_name' => $params['project_name'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'types' => $params['types'],
|
||||
'industry' => $params['industry'],
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'address' => $params['address'],
|
||||
'starting' => $params['starting'],
|
||||
'endtime' => $params['endtime'],
|
||||
'jhgq' => $params['jhgq'],
|
||||
'depar' => $params['depar'],
|
||||
'principal' => $params['principal'],
|
||||
'person' => $params['person'],
|
||||
'invest' => $params['invest'],
|
||||
'budget' => $params['budget'],
|
||||
'cost' => $params['cost'],
|
||||
'approval' => $params['approval'],
|
||||
'aunit' => $params['aunit'],
|
||||
'Acontact' => $params['Acontact'],
|
||||
'acontactnum' => $params['acontactnum'],
|
||||
'date' => $params['date'],
|
||||
'generalize' => $params['generalize'],
|
||||
'note' => $params['note'],
|
||||
'remark' => $params['remark'],
|
||||
'annex' => $params['annex']
|
||||
]);
|
||||
|
||||
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/21 09:23
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CostProject::where('id', $params['id'])->update([
|
||||
'project_num' => $params['project_num'],
|
||||
'project_name' => $params['project_name'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'types' => $params['types'],
|
||||
'industry' => $params['industry'],
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'address' => $params['address'],
|
||||
'starting' => $params['starting'],
|
||||
'endtime' => $params['endtime'],
|
||||
'jhgq' => $params['jhgq'],
|
||||
'depar' => $params['depar'],
|
||||
'principal' => $params['principal'],
|
||||
'person' => $params['person'],
|
||||
'invest' => $params['invest'],
|
||||
'budget' => $params['budget'],
|
||||
'cost' => $params['cost'],
|
||||
'approval' => $params['approval'],
|
||||
'aunit' => $params['aunit'],
|
||||
'Acontact' => $params['Acontact'],
|
||||
'acontactnum' => $params['acontactnum'],
|
||||
'date' => $params['date'],
|
||||
'generalize' => $params['generalize'],
|
||||
'note' => $params['note'],
|
||||
'remark' => $params['remark'],
|
||||
'annex' => $params['annex']
|
||||
]);
|
||||
|
||||
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/21 09:23
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CostProject::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取造价项目台账详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return CostProject::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
113
app/adminapi/validate/cost_project/CostProjectValidate.php
Normal file
113
app/adminapi/validate/cost_project/CostProjectValidate.php
Normal file
@ -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\validate\cost_project;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 造价项目台账验证器
|
||||
* Class CostProjectValidate
|
||||
* @package app\adminapi\validate\cost_project
|
||||
*/
|
||||
class CostProjectValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'project_name' => 'require',
|
||||
'contract_id' => 'require|checkContract',
|
||||
'types' => 'checkTypes',
|
||||
'industry' => 'checkIndustry',
|
||||
'starting' => 'require|dateFormat:Y-m-d',
|
||||
'endtime' => 'require|dateFormat:Y-m-d',
|
||||
'jhgq' => 'require',
|
||||
'principal' => 'require',
|
||||
'invest' => 'require',
|
||||
'aunit' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_num' => '项目编号',
|
||||
'project_name' => '项目名称',
|
||||
'contract_id' => '关联合同',
|
||||
'starting' => '计划开始日期',
|
||||
'endtime' => '计划结束日期',
|
||||
'jhgq' => '计划工期(天)',
|
||||
'principal' => '项目负责人',
|
||||
'invest' => '项目总投资(万元)',
|
||||
'aunit' => '委托单位',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CostProjectValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['project_num','project_name','contract_id','starting','endtime','jhgq','principal','invest','aunit']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CostProjectValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','project_num','project_name','contract_id','starting','endtime','jhgq','principal','invest','aunit']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CostProjectValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CostProjectValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/02/21 09:23
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
34
app/common/model/cost_project/CostProject.php
Normal file
34
app/common/model/cost_project/CostProject.php
Normal file
@ -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\cost_project;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 造价项目台账模型
|
||||
* Class CostProject
|
||||
* @package app\common\model\cost_project
|
||||
*/
|
||||
class CostProject extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'cost_project';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user