ProjectInsuranceManagement
This commit is contained in:
parent
1795d8ddfa
commit
5099e1378e
@ -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\project;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\project\ProjectInsuranceManagementLists;
|
||||
use app\adminapi\logic\project\ProjectInsuranceManagementLogic;
|
||||
use app\adminapi\validate\project\ProjectInsuranceManagementValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 保险管理控制器
|
||||
* Class ProjectInsuranceManagementController
|
||||
* @package app\adminapi\controller\project
|
||||
*/
|
||||
class ProjectInsuranceManagementController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取保险管理列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ProjectInsuranceManagementLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加保险管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ProjectInsuranceManagementValidate())->post()->goCheck('add');
|
||||
$result = ProjectInsuranceManagementLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectInsuranceManagementLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑保险管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ProjectInsuranceManagementValidate())->post()->goCheck('edit');
|
||||
$result = ProjectInsuranceManagementLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectInsuranceManagementLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除保险管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProjectInsuranceManagementValidate())->post()->goCheck('delete');
|
||||
ProjectInsuranceManagementLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取保险管理详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ProjectInsuranceManagementValidate())->goCheck('detail');
|
||||
$result = ProjectInsuranceManagementLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\project\ProjectPersonnelLists;
|
||||
use app\adminapi\logic\project\ProjectPersonnelLogic;
|
||||
use app\adminapi\validate\project\ProjectPersonnelValidate;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
|
||||
|
||||
@ -114,17 +115,20 @@ class ProjectPersonnelController extends BaseAdminController
|
||||
}
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$data = ProjectPersonnel::field('id,name,idcard,work_type,unit_price,daily_living_expenses')
|
||||
$data = ProjectPersonnel::field(['id', 'project_id', 'name', 'idcard', 'mobile', 'work_type', 'unit_price', 'daily_living_expenses', 'idcard_front', 'idcard_backend', 'bank_card', 'bank_no', 'deposit_bank', 'remark', 'opening_income'])
|
||||
->where('project_id',$params['project_id'])
|
||||
->page($pageNo, $pageSize)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function($item){
|
||||
$item['work_type_text'] = $item->work_type_text;
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$count = ProjectPersonnel::field('id,name,idcard,work_type,unit_price,daily_living_expenses')->where('project_id',$params['project_id'])->count();
|
||||
$count = ProjectPersonnel::field('id')->where('project_id',$params['project_id'])->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
|
@ -0,0 +1,87 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectInsuranceManagement;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
|
||||
|
||||
/**
|
||||
* 保险管理列表
|
||||
* Class ProjectInsuranceManagementLists
|
||||
* @package app\adminapi\listsproject
|
||||
*/
|
||||
class ProjectInsuranceManagementLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['type', 'insurance_no', 'insurance_company', 'invoice_no', 'handler'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取保险管理列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ProjectInsuranceManagement::where($this->searchWhere)
|
||||
->field(['id', 'project_id', 'project_person_id', 'insurance_date', 'due_date', 'type', 'insurance_no', 'insurance', 'insured_amount', 'insurance_company', 'insurance_detail', 'invoice_no', 'handler', 'annex'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$person = ProjectPersonnel::field('name,idcard')->where('id',$item['project_person_id'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['person_name'] = $person['name'];
|
||||
$item['person_idcard'] = $person['idcard'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取保险管理数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ProjectInsuranceManagement::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
137
app/adminapi/logic/project/ProjectInsuranceManagementLogic.php
Normal file
137
app/adminapi/logic/project/ProjectInsuranceManagementLogic.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectInsuranceManagement;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 保险管理逻辑
|
||||
* Class ProjectInsuranceManagementLogic
|
||||
* @package app\adminapi\logic\project
|
||||
*/
|
||||
class ProjectInsuranceManagementLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加保险管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectInsuranceManagement::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'project_person_id' => $params['project_person_id'],
|
||||
'insurance_date' => strtotime($params['insurance_date']),
|
||||
'due_date' => strtotime($params['due_date']),
|
||||
'type' => $params['type'],
|
||||
'insurance_no' => $params['insurance_no'],
|
||||
'insurance' => $params['insurance'],
|
||||
'insured_amount' => $params['insured_amount'],
|
||||
'insurance_company' => $params['insurance_company'],
|
||||
'insurance_detail' => $params['insurance_detail'],
|
||||
'invoice_no' => $params['invoice_no'],
|
||||
'handler' => $params['handler'],
|
||||
'annex' => !empty($params['annex']) ? $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 2023/12/25 15:58
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectInsuranceManagement::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'project_person_id' => $params['project_person_id'],
|
||||
'insurance_date' => strtotime($params['insurance_date']),
|
||||
'due_date' => strtotime($params['due_date']),
|
||||
'type' => $params['type'],
|
||||
'insurance_no' => $params['insurance_no'],
|
||||
'insurance' => $params['insurance'],
|
||||
'insured_amount' => $params['insured_amount'],
|
||||
'insurance_company' => $params['insurance_company'],
|
||||
'insurance_detail' => $params['insurance_detail'],
|
||||
'invoice_no' => $params['invoice_no'],
|
||||
'handler' => $params['handler'],
|
||||
'annex' => !empty($params['annex']) ? $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 2023/12/25 15:58
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ProjectInsuranceManagement::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取保险管理详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = ProjectInsuranceManagement::findOrEmpty($params['id'])->toArray();
|
||||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$person = ProjectPersonnel::field('name,idcard')->where('id',$data['project_person_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['person_name'] = $person['name'];
|
||||
$data['person_idcard'] = $person['idcard'];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -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\validate\project;
|
||||
|
||||
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 保险管理验证器
|
||||
* Class ProjectInsuranceManagementValidate
|
||||
* @package app\adminapi\validate\project
|
||||
*/
|
||||
class ProjectInsuranceManagementValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'project_id' => 'require|checkProject',
|
||||
'project_person_id' => 'require|checkProjectPerson',
|
||||
'insurance_date' => 'require|dateFormat:Y-m-d',
|
||||
'due_date' => 'require|dateFormat:Y-m-d',
|
||||
'annex' => 'checkFile',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'project_id.require' => '请选择项目',
|
||||
'project_person_id.require' => '请选择项目人员',
|
||||
'insurance_date.require' => '请选择投保日期',
|
||||
'insurance_date.dateFormat' => '投保日期格式错误',
|
||||
'due_date.require' => '请选择到期日期',
|
||||
'due_date.dateFormat' => '到期日期格式错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ProjectInsuranceManagementValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return ProjectInsuranceManagementValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ProjectInsuranceManagementValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ProjectInsuranceManagementValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/25 15:58
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$data = Project::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '项目不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProjectPerson($value,$rule,$data): bool|string
|
||||
{
|
||||
$person = ProjectPersonnel::where('id',$value)->findOrEmpty();
|
||||
if($person->isEmpty()){
|
||||
return '项目人员不存在';
|
||||
}
|
||||
if($person['project_id'] != $data['project_id']){
|
||||
return '项目人员无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkFile($value): bool|string
|
||||
{
|
||||
if($value != ''){
|
||||
$file = json_decode($value,true);
|
||||
if(empty($file)){
|
||||
return '附件必须是json数组';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
47
app/common/model/project/ProjectInsuranceManagement.php
Normal file
47
app/common/model/project/ProjectInsuranceManagement.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 保险管理模型
|
||||
* Class ProjectInsuranceManagement
|
||||
* @package app\common\model\project
|
||||
*/
|
||||
class ProjectInsuranceManagement extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'project_insurance_management';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return json_decode($value,true);
|
||||
}
|
||||
|
||||
public function getInsuranceDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getDueDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user