This commit is contained in:
weiz 2024-04-05 16:08:26 +08:00
parent 427dfa55d2
commit 6ea7d4469b
11 changed files with 917 additions and 883 deletions

View File

@ -11,98 +11,97 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\controller\material;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\material\MaterialPurchaseRequestLists;
use app\adminapi\logic\material\MaterialPurchaseRequestLogic;
use app\adminapi\validate\material\MaterialPurchaseRequestValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 材料采购申请控制器
* Class MaterialPurchaseRequestController
* @package app\adminapi\controller\material
*/
class MaterialPurchaseRequestController extends BaseAdminController
{
/**
* @notes 获取材料采购申请列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/09 13:47
*/
public function lists()
{
return $this->dataLists(new MaterialPurchaseRequestLists());
}
/**
* @notes 添加材料采购申请
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/09 13:47
*/
public function add()
{
$params = (new MaterialPurchaseRequestValidate())->post()->goCheck('add');
$result = MaterialPurchaseRequestLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(MaterialPurchaseRequestLogic::getError());
}
public function edit()
namespace app\adminapi\controller\material;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\material\MaterialPurchaseRequestLists;
use app\adminapi\logic\material\MaterialPurchaseRequestLogic;
use app\adminapi\validate\material\MaterialPurchaseRequestValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 材料采购申请控制器
* Class MaterialPurchaseRequestController
* @package app\adminapi\controller\material
*/
class MaterialPurchaseRequestController extends BaseAdminController
{ {
$params = (new MaterialPurchaseRequestValidate())->post()->goCheck('edit');
$result = MaterialPurchaseRequestLogic::edit($params,$this->adminId);
if (true === $result) { /**
return $this->success('编辑成功', [], 1, 1); * @notes 获取材料采购申请列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/09 13:47
*/
public function lists()
{
return $this->dataLists(new MaterialPurchaseRequestLists());
} }
return $this->fail(MaterialPurchaseRequestLogic::getError());
}
/**
* @notes 添加材料采购申请
* @return \think\response\Json
/** * @author likeadmin
* @notes 获取材料采购申请详情 * @date 2024/01/09 13:47
* @return \think\response\Json */
* @author likeadmin public function add()
* @date 2024/01/09 13:47 {
*/ $params = (new MaterialPurchaseRequestValidate())->post()->goCheck('add');
public function detail() $result = MaterialPurchaseRequestLogic::add($params, $this->adminId);
{ if (true === $result) {
$params = (new MaterialPurchaseRequestValidate())->goCheck('detail'); return $this->success('添加成功', [], 1, 1);
$result = MaterialPurchaseRequestLogic::detail($params); }
return $this->data($result); return $this->fail(MaterialPurchaseRequestLogic::getError());
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type',5)->where('name','cgsq')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate',$flow_type['id'])->where('status',2)->select();
return $this->success('请求成功',$data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new MaterialPurchaseRequestValidate())->post()->goCheck('approve');
$result = MaterialPurchaseRequestLogic::approve($params,$this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
} }
return $this->fail(MaterialPurchaseRequestLogic::getError());
} public function edit()
{
$params = (new MaterialPurchaseRequestValidate())->post()->goCheck('edit');
} $result = MaterialPurchaseRequestLogic::edit($params, $this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(MaterialPurchaseRequestLogic::getError());
}
/**
* @notes 获取材料采购申请详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/09 13:47
*/
public function detail()
{
$params = (new MaterialPurchaseRequestValidate())->goCheck('detail');
$result = MaterialPurchaseRequestLogic::detail($params);
return $this->data($result);
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type', 5)->where('name', 'cgsq')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new MaterialPurchaseRequestValidate())->post()->goCheck('approve');
$result = MaterialPurchaseRequestLogic::approve($params, $this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(MaterialPurchaseRequestLogic::getError());
}
}

View File

@ -11,98 +11,101 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\controller\project; namespace app\adminapi\controller\project;
use app\adminapi\controller\BaseAdminController; use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\project\ProjectAttendanceRecordLists; use app\adminapi\lists\project\ProjectAttendanceRecordLists;
use app\adminapi\logic\project\ProjectAttendanceRecordLogic; use app\adminapi\logic\project\ProjectAttendanceRecordLogic;
use app\adminapi\validate\project\ProjectAttendanceRecordValidate; use app\adminapi\validate\project\ProjectAttendanceRecordValidate;
/** /**
* 考勤记录控制器 * 考勤记录控制器
* Class ProjectAttendanceRecordController * Class ProjectAttendanceRecordController
* @package app\adminapi\controller\project * @package app\adminapi\controller\project
*/ */
class ProjectAttendanceRecordController extends BaseAdminController class ProjectAttendanceRecordController extends BaseAdminController
{ {
/** /**
* @notes 获取考勤记录列表 * @notes 获取考勤记录列表
* @return \think\response\Json * @return \think\response\Json
* @author likeadmin * @author likeadmin
* @date 2023/12/26 09:44 * @date 2023/12/26 09:44
*/ */
public function lists() public function lists()
{ {
return $this->dataLists(new ProjectAttendanceRecordLists()); return $this->dataLists(new ProjectAttendanceRecordLists());
} }
/** /**
* @notes 添加考勤记录 * @notes 添加考勤记录
* @return \think\response\Json * @return \think\response\Json
* @author likeadmin * @author likeadmin
* @date 2023/12/26 09:44 * @date 2023/12/26 09:44
*/ */
public function add() public function add()
{ {
$params = (new ProjectAttendanceRecordValidate())->post()->goCheck('add'); $params = (new ProjectAttendanceRecordValidate())->post()->goCheck('add');
$result = ProjectAttendanceRecordLogic::add($params); $result = ProjectAttendanceRecordLogic::add($params);
if (true === $result) { if (true === $result) {
return $this->success('添加成功', [], 1, 1); return $this->success('添加成功', [], 1, 1);
} }
return $this->fail(ProjectAttendanceRecordLogic::getError()); return $this->fail(ProjectAttendanceRecordLogic::getError());
} }
/** /**
* @notes 编辑考勤记录 * @notes 编辑考勤记录
* @return \think\response\Json * @return \think\response\Json
* @author likeadmin * @author likeadmin
* @date 2023/12/26 09:44 * @date 2023/12/26 09:44
*/ */
public function edit() public function edit()
{ {
$params = (new ProjectAttendanceRecordValidate())->post()->goCheck('edit'); $params = (new ProjectAttendanceRecordValidate())->post()->goCheck('edit');
$result = ProjectAttendanceRecordLogic::edit($params); $result = ProjectAttendanceRecordLogic::edit($params);
if (true === $result) { if (true === $result) {
return $this->success('编辑成功', [], 1, 1); return $this->success('编辑成功', [], 1, 1);
} }
return $this->fail(ProjectAttendanceRecordLogic::getError()); return $this->fail(ProjectAttendanceRecordLogic::getError());
} }
/** /**
* @notes 删除考勤记录 * @notes 删除考勤记录
* @return \think\response\Json * @return \think\response\Json
* @author likeadmin * @author likeadmin
* @date 2023/12/26 09:44 * @date 2023/12/26 09:44
*/ */
public function delete() public function delete()
{ {
$params = (new ProjectAttendanceRecordValidate())->post()->goCheck('delete'); $params = (new ProjectAttendanceRecordValidate())->post()->goCheck('delete');
$res = ProjectAttendanceRecordLogic::delete($params); $result = ProjectAttendanceRecordLogic::delete($params);
return $res ? $this->success('删除成功', [], 1, 1) : $this->fail(ProjectAttendanceRecordLogic::getError()); if (true === $result) {
} return $this->success('删除成功', [], 1, 1);
}
return $this->fail(ProjectAttendanceRecordLogic::getError());
/** }
* @notes 获取考勤记录详情
* @return \think\response\Json
* @author likeadmin /**
* @date 2023/12/26 09:44 * @notes 获取考勤记录详情
*/ * @return \think\response\Json
public function detail() * @author likeadmin
{ * @date 2023/12/26 09:44
$params = (new ProjectAttendanceRecordValidate())->goCheck('detail'); */
$result = ProjectAttendanceRecordLogic::detail($params); public function detail()
return $this->data($result); {
} $params = (new ProjectAttendanceRecordValidate())->goCheck('detail');
$result = ProjectAttendanceRecordLogic::detail($params);
return $this->data($result);
} }
}

View File

@ -11,118 +11,121 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\controller\project;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\project\ProjectMaterialBudgetLists;
use app\adminapi\logic\project\ProjectMaterialBudgetLogic;
use app\adminapi\validate\project\ProjectMaterialBudgetValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 材料预算控制器
* Class ProjectMaterialBudgetController
* @package app\adminapi\controller\project
*/
class ProjectMaterialBudgetController extends BaseAdminController
{
/**
* @notes 获取材料预算列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function lists()
{
return $this->dataLists(new ProjectMaterialBudgetLists());
}
/**
* @notes 添加材料预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function add()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('add');
$result = ProjectMaterialBudgetLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 编辑材料预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function edit()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('edit');
$result = ProjectMaterialBudgetLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 删除材料预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function delete()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('delete');
ProjectMaterialBudgetLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取材料预算详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function detail()
{
$params = (new ProjectMaterialBudgetValidate())->goCheck('detail');
$result = ProjectMaterialBudgetLogic::detail($params);
return $this->data($result);
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type',4)->where('name','clys')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate',$flow_type['id'])->where('status',2)->select();
return $this->success('请求成功',$data->toArray());
}
//添加审批 namespace app\adminapi\controller\project;
public function approve(): \think\response\Json
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\project\ProjectMaterialBudgetLists;
use app\adminapi\logic\project\ProjectMaterialBudgetLogic;
use app\adminapi\validate\project\ProjectMaterialBudgetValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 材料预算控制器
* Class ProjectMaterialBudgetController
* @package app\adminapi\controller\project
*/
class ProjectMaterialBudgetController extends BaseAdminController
{ {
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('approve');
$result = ProjectMaterialBudgetLogic::approve($params,$this->adminId);
if (true === $result) { /**
return $this->success('提交审核信息成功', [], 1, 1); * @notes 获取材料预算列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function lists()
{
return $this->dataLists(new ProjectMaterialBudgetLists());
} }
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 添加材料预算
} * @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function add()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('add');
$result = ProjectMaterialBudgetLogic::add($params, $this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 编辑材料预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function edit()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('edit');
$result = ProjectMaterialBudgetLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 删除材料预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function delete()
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('delete');
$result = ProjectMaterialBudgetLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
/**
* @notes 获取材料预算详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/08 16:30
*/
public function detail()
{
$params = (new ProjectMaterialBudgetValidate())->goCheck('detail');
$result = ProjectMaterialBudgetLogic::detail($params);
return $this->data($result);
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type', 4)->where('name', 'clys')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('approve');
$result = ProjectMaterialBudgetLogic::approve($params, $this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(ProjectMaterialBudgetLogic::getError());
}
}

View File

@ -11,118 +11,121 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\controller\project;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\project\ProjectSubpackageBudgetLists;
use app\adminapi\logic\project\ProjectSubpackageBudgetLogic;
use app\adminapi\validate\project\ProjectSubpackageBudgetValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 分包预算控制器
* Class ProjectSubpackageBudgetController
* @package app\adminapi\controller\project
*/
class ProjectSubpackageBudgetController extends BaseAdminController
{
/**
* @notes 获取分包预算列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function lists()
{
return $this->dataLists(new ProjectSubpackageBudgetLists());
}
/**
* @notes 添加分包预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function add()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('add');
$result = ProjectSubpackageBudgetLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 编辑分包预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function edit()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('edit');
$result = ProjectSubpackageBudgetLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 删除分包预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function delete()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('delete');
ProjectSubpackageBudgetLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取分包预算详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function detail()
{
$params = (new ProjectSubpackageBudgetValidate())->goCheck('detail');
$result = ProjectSubpackageBudgetLogic::detail($params);
return $this->data($result);
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type',4)->where('name','fbys')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate',$flow_type['id'])->where('status',2)->select();
return $this->success('请求成功',$data->toArray());
}
//添加审批 namespace app\adminapi\controller\project;
public function approve(): \think\response\Json
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\project\ProjectSubpackageBudgetLists;
use app\adminapi\logic\project\ProjectSubpackageBudgetLogic;
use app\adminapi\validate\project\ProjectSubpackageBudgetValidate;
use app\common\model\oa\Flow;
use app\common\model\oa\FlowType;
/**
* 分包预算控制器
* Class ProjectSubpackageBudgetController
* @package app\adminapi\controller\project
*/
class ProjectSubpackageBudgetController extends BaseAdminController
{ {
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('approve');
$result = ProjectSubpackageBudgetLogic::approve($params,$this->adminId);
if (true === $result) { /**
return $this->success('提交审核信息成功', [], 1, 1); * @notes 获取分包预算列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function lists()
{
return $this->dataLists(new ProjectSubpackageBudgetLists());
} }
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 添加分包预算
} * @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function add()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('add');
$result = ProjectSubpackageBudgetLogic::add($params, $this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 编辑分包预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function edit()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('edit');
$result = ProjectSubpackageBudgetLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 删除分包预算
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function delete()
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('delete');
$result = ProjectSubpackageBudgetLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
/**
* @notes 获取分包预算详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/01/10 15:19
*/
public function detail()
{
$params = (new ProjectSubpackageBudgetValidate())->goCheck('detail');
$result = ProjectSubpackageBudgetLogic::detail($params);
return $this->data($result);
}
public function flows(): \think\response\Json
{
$flow_type = FlowType::where('type', 4)->where('name', 'fbys')->findOrEmpty();
$data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select();
return $this->success('请求成功', $data->toArray());
}
//添加审批
public function approve(): \think\response\Json
{
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('approve');
$result = ProjectSubpackageBudgetLogic::approve($params, $this->adminId);
if (true === $result) {
return $this->success('提交审核信息成功', [], 1, 1);
}
return $this->fail(ProjectSubpackageBudgetLogic::getError());
}
}

View File

@ -11,78 +11,81 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\lists\project; namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\project\Project; use app\common\lists\ListsSearchInterface;
use app\common\model\project\ProjectAttendanceDetail; use app\common\model\project\Project;
use app\common\lists\ListsSearchInterface; use app\common\model\project\ProjectAttendanceDetail;
use app\common\model\project\ProjectPersonnel; use app\common\model\project\ProjectAttendanceRecord;
use app\common\model\project\ProjectPersonnel;
/**
* 考勤明细列表 /**
* Class ProjectAttendanceDetailLists * 考勤明细列表
* @package app\adminapi\listsproject * Class ProjectAttendanceDetailLists
*/ * @package app\adminapi\listsproject
class ProjectAttendanceDetailLists extends BaseAdminDataLists implements ListsSearchInterface */
{ class ProjectAttendanceDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件 /**
* @return \string[][] * @notes 设置搜索条件
* @author likeadmin * @return \string[][]
* @date 2023/12/26 10:54 * @author likeadmin
*/ * @date 2023/12/26 10:54
public function setSearch(): array */
{ public function setSearch(): array
return [ {
'=' => ['project_id'] return [
]; '=' => ['project_id']
} ];
}
/**
* @notes 获取考勤明细列表 /**
* @return array * @notes 获取考勤明细列表
* @throws \think\db\exception\DataNotFoundException * @return array
* @throws \think\db\exception\DbException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\DbException
* @author likeadmin * @throws \think\db\exception\ModelNotFoundException
* @date 2023/12/26 10:54 * @author likeadmin
*/ * @date 2023/12/26 10:54
public function lists(): array */
{ public function lists(): array
return ProjectAttendanceDetail::where($this->searchWhere) {
->field(['id', 'attendance_code', 'project_id', 'person_id', 'attendance_date', 'work_start_time', 'work_end_time', 'work_record_num', 'daily_salary', 'daily_living', 'daily_subsidy', 'daily_other', 'daily_income', 'remark']) return ProjectAttendanceDetail::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength) ->field(['id', 'attendance_id', 'project_id', 'person_id', 'attendance_date', 'work_start_time', 'work_end_time', 'work_record_num', 'daily_salary', 'daily_living', 'daily_subsidy', 'daily_other', 'daily_income', 'remark'])
->order(['id' => 'desc']) ->limit($this->limitOffset, $this->limitLength)
->select()->each(function($item){ ->order(['id' => 'desc'])
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); ->select()->each(function ($item) {
$person = ProjectPersonnel::field('name,idcard,work_type')->where('id',$item['person_id'])->findOrEmpty(); $attendance = ProjectAttendanceRecord::field('attendance_code')->where('id', $item['attendance_id'])->findOrEmpty();
$item['project_name'] = $project['name']; $project = Project::field('name,project_code')->where('id', $item['project_id'])->findOrEmpty();
$item['project_code'] = $project['project_code']; $person = ProjectPersonnel::field('name,idcard,work_type')->where('id', $item['person_id'])->findOrEmpty();
$item['person_name'] = $person['name']; $item['attendance_code'] = $attendance['attendance_code'];
$item['person_idcard'] = $person['idcard']; $item['project_name'] = $project['name'];
$item['work_type_text'] = $person->work_type_text; $item['project_code'] = $project['project_code'];
return $item; $item['person_name'] = $person['name'];
}) $item['person_idcard'] = $person['idcard'];
->toArray(); $item['work_type_text'] = $person->work_type_text;
} return $item;
})
->toArray();
/** }
* @notes 获取考勤明细数量
* @return int
* @author likeadmin /**
* @date 2023/12/26 10:54 * @notes 获取考勤明细数量
*/ * @return int
public function count(): int * @author likeadmin
{ * @date 2023/12/26 10:54
return ProjectAttendanceDetail::where($this->searchWhere)->count(); */
} public function count(): int
{
} return ProjectAttendanceDetail::where($this->searchWhere)->count();
}
}

View File

@ -42,17 +42,15 @@
{ {
Db::startTrans(); Db::startTrans();
try { try {
$attendance_code = data_unique_code('项目考勤记录');
$ProjectAttendanceRecordRes = ProjectAttendanceRecord::create([ $ProjectAttendanceRecordRes = ProjectAttendanceRecord::create([
'project_id' => $params['project_id'], 'project_id' => $params['project_id'],
'attendance_code' => $attendance_code, 'attendance_code' => data_unique_code('项目考勤记录'),
'attendance_date' => strtotime($params['attendance_date']), 'attendance_date' => strtotime($params['attendance_date']),
'remark' => $params['remark'], 'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]); ]);
foreach ($params['attendance_detail'] as $v) { foreach ($params['attendance_detail'] as $v) {
ProjectAttendanceDetail::create([ ProjectAttendanceDetail::create([
'attendance_code' => $attendance_code,
'attendance_id' => $ProjectAttendanceRecordRes->id, 'attendance_id' => $ProjectAttendanceRecordRes->id,
'project_id' => $params['project_id'], 'project_id' => $params['project_id'],
'person_id' => $v['person_id'], 'person_id' => $v['person_id'],
@ -95,6 +93,41 @@
'remark' => $params['remark'], 'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]); ]);
foreach ($params['attendance_detail'] as $v) {
if (!empty($v['id'])) {
ProjectAttendanceDetail::where('id', $v['id'])->update([
'attendance_id' => $params['id'],
'project_id' => $params['project_id'],
'person_id' => $v['person_id'],
'attendance_date' => strtotime($params['attendance_date']),
'work_start_time' => strtotime($v['work_start_time']),
'work_end_time' => strtotime($v['work_end_time']),
'work_record_num' => $v['work_record_num'],
'daily_salary' => $v['daily_salary'],
'daily_living' => $v['daily_living'],
'daily_subsidy' => $v['daily_subsidy'],
'daily_other' => $v['daily_other'],
'daily_income' => $v['daily_income'],
'remark' => $v['work_num'] ?? '',
]);
} else {
ProjectAttendanceDetail::create([
'attendance_id' => $params['id'],
'project_id' => $params['project_id'],
'person_id' => $v['person_id'],
'attendance_date' => strtotime($params['attendance_date']),
'work_start_time' => strtotime($v['work_start_time']),
'work_end_time' => strtotime($v['work_end_time']),
'work_record_num' => $v['work_record_num'],
'daily_salary' => $v['daily_salary'],
'daily_living' => $v['daily_living'],
'daily_subsidy' => $v['daily_subsidy'],
'daily_other' => $v['daily_other'],
'daily_income' => $v['daily_income'],
'remark' => $v['work_num'] ?? '',
]);
}
}
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -114,18 +147,12 @@
*/ */
public static function delete(array $params): bool public static function delete(array $params): bool
{ {
Db::startTrans(); $detail = ProjectAttendanceDetail::where('attendance_id', 'in', $params['id'])->findOrEmpty();
try { if (!$detail->isEmpty()) {
$detailIds = ProjectAttendanceDetail::where('attendance_id', $params['id'])->column('id'); self::setError('此数据关联了考勤明细内容,需删除考勤明细内容');
ProjectAttendanceDetail::destroy($detailIds);
ProjectAttendanceRecord::destroy($params['id']);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false; return false;
} }
return ProjectAttendanceRecord::destroy($params['id']);
} }

View File

@ -11,107 +11,53 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\logic\project; namespace app\adminapi\logic\project;
use app\common\model\dept\Dept; use app\common\logic\BaseLogic;
use app\common\model\dept\Orgs; use app\common\model\dept\Dept;
use app\common\model\oa\FlowApprove; use app\common\model\dept\Orgs;
use app\common\model\project\Project; use app\common\model\oa\FlowApprove;
use app\common\model\project\ProjectMaterialBudget; use app\common\model\project\Project;
use app\common\logic\BaseLogic; use app\common\model\project\ProjectMaterialBudget;
use app\common\model\project\ProjectMaterialBudgetDetail; use app\common\model\project\ProjectMaterialBudgetDetail;
use think\facade\Db; use think\facade\Db;
/** /**
* 材料预算逻辑 * 材料预算逻辑
* Class ProjectMaterialBudgetLogic * Class ProjectMaterialBudgetLogic
* @package app\adminapi\logic\project * @package app\adminapi\logic\project
*/ */
class ProjectMaterialBudgetLogic extends BaseLogic class ProjectMaterialBudgetLogic extends BaseLogic
{ {
/** /**
* @notes 添加材料预算 * @notes 添加材料预算
* @param array $params * @param array $params
* @return bool * @return bool
* @author likeadmin * @author likeadmin
* @date 2024/01/08 16:30 * @date 2024/01/08 16:30
*/ */
public static function add(array $params,$admin_id): bool public static function add(array $params, $admin_id): bool
{ {
$detail = $params['material_budget_detail'];//json_decode($params['material_budget_detail'],true); $detail = $params['material_budget_detail'];//json_decode($params['material_budget_detail'],true);
Db::startTrans(); Db::startTrans();
try { try {
$project_material_budget = ProjectMaterialBudget::create([ $project_material_budget = ProjectMaterialBudget::create([
'org_id' => $params['org_id'], 'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'], 'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'material_budget_code' => data_unique_code('项目材料预算'),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($detail as $item)
{
ProjectMaterialBudgetDetail::create([
'project_id' => $params['project_id'], 'project_id' => $params['project_id'],
'material_budget_id' => $project_material_budget->id, 'material_budget_code' => data_unique_code('项目材料预算'),
'material_id' => $item['material_id'], 'remark' => $params['remark'] ?? '',
'budget_type' => 0, 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'price' => $item['price'], ]);
'num' => $item['num'], foreach ($detail as $item) {
'amount' => $item['price'] * $item['num'],
'remark' => $item['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/01/08 16:30
*/
public static function edit(array $params): bool
{
$detail = $params['material_budget_detail'];//json_decode($params['material_budget_detail'],true);
Db::startTrans();
try {
ProjectMaterialBudget::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'remark' => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($detail as $item)
{
if(isset($item['id']) && $item['id'] != ''){
ProjectMaterialBudgetDetail::where('id',$item['id'])->update([
'project_id' => $params['project_id'],
'material_budget_id' => $params['id'],
'material_id' => $item['material_id'],
'price' => $item['price'],
'num' => $item['num'],
'amount' => $item['price'] * $item['num'],
'remark' => $item['remark'] ?? '',
]);
}else{
ProjectMaterialBudgetDetail::create([ ProjectMaterialBudgetDetail::create([
'project_id' => $params['project_id'], 'project_id' => $params['project_id'],
'material_budget_id' => $params['id'], 'material_budget_id' => $project_material_budget->id,
'material_id' => $item['material_id'], 'material_id' => $item['material_id'],
'budget_type' => 0, 'budget_type' => 0,
'price' => $item['price'], 'price' => $item['price'],
@ -120,80 +66,138 @@ class ProjectMaterialBudgetLogic extends BaseLogic
'remark' => $item['remark'] ?? '', 'remark' => $item['remark'] ?? '',
]); ]);
} }
} Db::commit();
Db::commit(); return true;
return true; } catch (\Exception $e) {
} catch (\Exception $e) { Db::rollback();
Db::rollback(); self::setError($e->getMessage());
self::setError($e->getMessage()); return false;
return false;
}
}
/**
* @notes 删除材料预算
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/08 16:30
*/
public static function delete(array $params): bool
{
return ProjectMaterialBudget::destroy($params['id']);
}
/**
* @notes 获取材料预算详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/01/08 16:30
*/
public static function detail($params): array
{
$data = ProjectMaterialBudget::field('id,org_id,dept_id,project_id,material_budget_code,remark,annex,approve_id')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray();
}
public static function approve($params,$admin_id): bool{
$data = ProjectMaterialBudget::where('id',$params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
if(!empty($data['approve_id']) && $approve_data['check_status'] != 3){
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'材料预算',
$params['id'],
'app\common\model\project\ProjectMaterialBudget',
$params['path'],
$params['flow_id'],
$admin_id
);
if($res){
ProjectMaterialBudget::where('id',$params['id'])->update([
'approve_id' => $res,
]);
} }
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/01/08 16:30
*/
public static function edit(array $params): bool
{
$detail = $params['material_budget_detail'];//json_decode($params['material_budget_detail'],true);
Db::startTrans();
try {
ProjectMaterialBudget::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
foreach ($detail as $item) {
if (isset($item['id']) && $item['id'] != '') {
ProjectMaterialBudgetDetail::where('id', $item['id'])->update([
'project_id' => $params['project_id'],
'material_budget_id' => $params['id'],
'material_id' => $item['material_id'],
'price' => $item['price'],
'num' => $item['num'],
'amount' => $item['price'] * $item['num'],
'remark' => $item['remark'] ?? '',
]);
} else {
ProjectMaterialBudgetDetail::create([
'project_id' => $params['project_id'],
'material_budget_id' => $params['id'],
'material_id' => $item['material_id'],
'budget_type' => 0,
'price' => $item['price'],
'num' => $item['num'],
'amount' => $item['price'] * $item['num'],
'remark' => $item['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/01/08 16:30
*/
public static function delete(array $params): bool
{
$detail = ProjectMaterialBudgetDetail::where('material_budget_id', 'in', $params['id'])->findOrEmpty();
if (!$detail->isEmpty()) {
self::setError('此数据关联了预算明细内容,需删除预算明细内容');
return false;
}
return ProjectMaterialBudget::destroy($params['id']);
}
/**
* @notes 获取材料预算详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/01/08 16:30
*/
public static function detail($params): array
{
$data = ProjectMaterialBudget::field('id,org_id,dept_id,project_id,material_budget_code,remark,annex,approve_id')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id', $data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id', $data['project_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray();
}
public static function approve($params, $admin_id): bool
{
$data = ProjectMaterialBudget::where('id', $params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) {
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'材料预算',
$params['id'],
'app\common\model\project\ProjectMaterialBudget',
$params['path'],
$params['flow_id'],
$admin_id
);
if ($res) {
ProjectMaterialBudget::where('id', $params['id'])->update([
'approve_id' => $res,
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -11,196 +11,200 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\logic\project;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
use app\common\model\oa\FlowApprove;
use app\common\model\project\Project;
use app\common\model\project\ProjectSubpackageBudget;
use app\common\logic\BaseLogic;
use app\common\model\project\ProjectSubpackageBudgetDetail;
use think\facade\Db;
/**
* 分包预算逻辑
* Class ProjectSubpackageBudgetLogic
* @package app\adminapi\logic\project
*/
class ProjectSubpackageBudgetLogic extends BaseLogic
{
/**
* @notes 添加分包预算
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/10 15:19
*/
public static function add(array $params,$admin_id): bool
{
$detail = $params['subpackage_budget_detail'];//json_decode($params['subpackage_budget_detail'],true);
Db::startTrans();
try {
$res = ProjectSubpackageBudget::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'subpackage_budget_code' => data_unique_code('项目分包预算'),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($detail as $item)
{
ProjectSubpackageBudgetDetail::create([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $res->id,
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['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/01/10 15:19
*/
public static function edit(array $params): bool
{
$detail =$params['subpackage_budget_detail'];//json_decode($params['subpackage_budget_detail'],true);
Db::startTrans();
try {
ProjectSubpackageBudget::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'subpackage_budget_code' => data_unique_code('项目分包预算'),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex']? json_encode($params['annex']) : null,
]);
foreach ($detail as $item)
{
if(isset($item['id']) && $item['id'] != ''){
ProjectSubpackageBudgetDetail::where('id',$item['id'])->update([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $params['id'],
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['remark'] ?? '',
]);
}else{
ProjectSubpackageBudgetDetail::create([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $params['id'],
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['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/01/10 15:19
*/
public static function delete(array $params): bool
{
return ProjectSubpackageBudget::destroy($params['id']);
}
/**
* @notes 获取分包预算详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/01/10 15:19
*/
public static function detail($params): array
{
$data = ProjectSubpackageBudget::field('id,org_id,dept_id,project_id,subpackage_budget_code,remark,annex,approve_id')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray();
}
public static function approve($params,$admin_id): bool{ namespace app\adminapi\logic\project;
$data = ProjectSubpackageBudget::where('id',$params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty(); use app\common\logic\BaseLogic;
if(!empty($data['approve_id']) && $approve_data['check_status'] != 3){ use app\common\model\dept\Dept;
self::setError('当前内容存在审核信息,请勿重复提交'); use app\common\model\dept\Orgs;
return false; use app\common\model\oa\FlowApprove;
} use app\common\model\project\Project;
Db::startTrans(); use app\common\model\project\ProjectSubpackageBudget;
try { use app\common\model\project\ProjectSubpackageBudgetDetail;
$res = addApprove( use think\facade\Db;
'分包预算',
$params['id'],
'app\common\model\project\ProjectSubpackageBudget', /**
$params['path'], * 分包预算逻辑
$params['flow_id'], * Class ProjectSubpackageBudgetLogic
$admin_id * @package app\adminapi\logic\project
); */
if($res){ class ProjectSubpackageBudgetLogic extends BaseLogic
ProjectSubpackageBudget::where('id',$params['id'])->update([ {
'approve_id' => $res,
/**
* @notes 添加分包预算
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/01/10 15:19
*/
public static function add(array $params, $admin_id): bool
{
$detail = $params['subpackage_budget_detail'];//json_decode($params['subpackage_budget_detail'],true);
Db::startTrans();
try {
$res = ProjectSubpackageBudget::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'subpackage_budget_code' => data_unique_code('项目分包预算'),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]); ]);
foreach ($detail as $item) {
ProjectSubpackageBudgetDetail::create([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $res->id,
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['remark'] ?? '',
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
} }
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/01/10 15:19
*/
public static function edit(array $params): bool
{
$detail = $params['subpackage_budget_detail'];//json_decode($params['subpackage_budget_detail'],true);
Db::startTrans();
try {
ProjectSubpackageBudget::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'project_id' => $params['project_id'],
'subpackage_budget_code' => data_unique_code('项目分包预算'),
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
foreach ($detail as $item) {
if (isset($item['id']) && $item['id'] != '') {
ProjectSubpackageBudgetDetail::where('id', $item['id'])->update([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $params['id'],
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['remark'] ?? '',
]);
} else {
ProjectSubpackageBudgetDetail::create([
'project_id' => $params['project_id'],
'subpackage_budget_id' => $params['id'],
'work_type' => $item['work_type'],
'work_content' => $item['work_content'],
'project_features' => $item['project_features'] ?? '',
'unit' => $item['unit'],
'num' => $item['num'],
'price' => $item['price'],
'amount' => $item['num'] * $item['price'],
'remark' => $item['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/01/10 15:19
*/
public static function delete(array $params): bool
{
$detail = ProjectSubpackageBudgetDetail::where('subpackage_budget_id', 'in', $params['id'])->findOrEmpty();
if (!$detail->isEmpty()) {
self::setError('此数据关联了预算明细内容,需删除预算明细内容');
return false;
}
return ProjectSubpackageBudget::destroy($params['id']);
}
/**
* @notes 获取分包预算详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/01/10 15:19
*/
public static function detail($params): array
{
$data = ProjectSubpackageBudget::field('id,org_id,dept_id,project_id,subpackage_budget_code,remark,annex,approve_id')->findOrEmpty($params['id']);
$org = Orgs::field('name')->where('id', $data['org_id'])->findOrEmpty();
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id', $data['project_id'])->findOrEmpty();
$data['org_name'] = $org['name'];
$data['dept_name'] = $dept['name'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
$data['approve_check_status'] = $approve_data['check_status'];
return $data->toArray();
}
public static function approve($params, $admin_id): bool
{
$data = ProjectSubpackageBudget::where('id', $params['id'])->findOrEmpty();
$approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty();
if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) {
self::setError('当前内容存在审核信息,请勿重复提交');
return false;
}
Db::startTrans();
try {
$res = addApprove(
'分包预算',
$params['id'],
'app\common\model\project\ProjectSubpackageBudget',
$params['path'],
$params['flow_id'],
$admin_id
);
if ($res) {
ProjectSubpackageBudget::where('id', $params['id'])->update([
'approve_id' => $res,
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -203,6 +203,10 @@
if (!is_numeric($v['num']) || $v['num'] <= 0) { if (!is_numeric($v['num']) || $v['num'] <= 0) {
return '工作量必须是大于0的数字'; return '工作量必须是大于0的数字';
} }
$subcontracting_budget_detail = ProjectSubpackageBudgetDetail::where('id', $v['subpackage_budget_detail_id'])->findOrEmpty();
if ($v['num'] > $subcontracting_budget_detail['num']) {
return '工作量不能超过预算工作量';
}
} }
if (empty($v['price'])) { if (empty($v['price'])) {
return '含税单价不能为空'; return '含税单价不能为空';

View File

@ -37,8 +37,8 @@
'project_id' => 'require|checkProject', 'project_id' => 'require|checkProject',
'person_id' => 'require|checkPerson', 'person_id' => 'require|checkPerson',
'attendance_date' => 'require|dateFormat:Y-m-d', 'attendance_date' => 'require|dateFormat:Y-m-d',
'work_start_time' => 'checkWorkStartTime', 'work_start_time' => 'dateFormat:H:i:s',
'work_end_time' => 'checkWorkEndTime', 'work_end_time' => 'dateFormat:H:i:s',
'work_record_num' => 'require|float|gt:0', 'work_record_num' => 'require|float|gt:0',
'daily_salary' => 'require|float|gt:0', 'daily_salary' => 'require|float|gt:0',
'daily_living' => 'require|float|gt:0', 'daily_living' => 'require|float|gt:0',
@ -136,27 +136,4 @@
return true; return true;
} }
public function checkWorkStartTime($value): bool|string
{
if ($value != '') {
if (date('Y-m-d H:i', strtotime($value)) != $value) {
return '上班时间格式错误';
}
}
return true;
}
public function checkWorkEndTime($value, $rule, $data): bool|string
{
if ($value != '') {
if (date('Y-m-d H:i', strtotime($value)) != $value) {
return '下班时间格式错误';
}
if (strtotime($value) - strtotime($data['work_start_time']) <= 0) {
return '下班时间不能小于上班时间';
}
}
return true;
}
} }

View File

@ -16,6 +16,7 @@
use app\common\model\project\Project; use app\common\model\project\Project;
use app\common\model\project\ProjectAttendanceDetail;
use app\common\model\project\ProjectPersonnel; use app\common\model\project\ProjectPersonnel;
use app\common\validate\BaseValidate; use app\common\validate\BaseValidate;
@ -112,6 +113,12 @@
return '考勤记录清单数据格式错误'; return '考勤记录清单数据格式错误';
} }
foreach ($attendance_detail as $v) { foreach ($attendance_detail as $v) {
if (isset($v['id']) && $v['id'] != '') {
$data_detail = ProjectAttendanceDetail::where('id', $v['id'])->findOrEmpty();
if ($data_detail->isEmpty()) {
return '考勤记录明细信息不存在';
}
}
if (empty($v['person_id'])) { if (empty($v['person_id'])) {
return '请选择项目人员'; return '请选择项目人员';
} else { } else {