uodate
This commit is contained in:
parent
427dfa55d2
commit
6ea7d4469b
@ -72,7 +72,6 @@ class MaterialPurchaseRequestController extends BaseAdminController
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取材料采购申请详情
|
||||
* @return \think\response\Json
|
||||
|
@ -86,8 +86,11 @@ class ProjectAttendanceRecordController extends BaseAdminController
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProjectAttendanceRecordValidate())->post()->goCheck('delete');
|
||||
$res = ProjectAttendanceRecordLogic::delete($params);
|
||||
return $res ? $this->success('删除成功', [], 1, 1) : $this->fail(ProjectAttendanceRecordLogic::getError());
|
||||
$result = ProjectAttendanceRecordLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectAttendanceRecordLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,9 +88,12 @@ class ProjectMaterialBudgetController extends BaseAdminController
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProjectMaterialBudgetValidate())->post()->goCheck('delete');
|
||||
ProjectMaterialBudgetLogic::delete($params);
|
||||
$result = ProjectMaterialBudgetLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectMaterialBudgetLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -88,9 +88,12 @@ class ProjectSubpackageBudgetController extends BaseAdminController
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProjectSubpackageBudgetValidate())->post()->goCheck('delete');
|
||||
ProjectSubpackageBudgetLogic::delete($params);
|
||||
$result = ProjectSubpackageBudgetLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectSubpackageBudgetLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -16,9 +16,10 @@ namespace app\adminapi\lists\project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectAttendanceDetail;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\project\ProjectAttendanceRecord;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
|
||||
|
||||
@ -57,12 +58,14 @@ class ProjectAttendanceDetailLists extends BaseAdminDataLists implements ListsSe
|
||||
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'])
|
||||
->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'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$attendance = ProjectAttendanceRecord::field('attendance_code')->where('id', $item['attendance_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code')->where('id', $item['project_id'])->findOrEmpty();
|
||||
$person = ProjectPersonnel::field('name,idcard,work_type')->where('id', $item['person_id'])->findOrEmpty();
|
||||
$item['attendance_code'] = $attendance['attendance_code'];
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['person_name'] = $person['name'];
|
||||
|
@ -42,17 +42,15 @@
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$attendance_code = data_unique_code('项目考勤记录');
|
||||
$ProjectAttendanceRecordRes = ProjectAttendanceRecord::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'attendance_code' => $attendance_code,
|
||||
'attendance_code' => data_unique_code('项目考勤记录'),
|
||||
'attendance_date' => strtotime($params['attendance_date']),
|
||||
'remark' => $params['remark'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
foreach ($params['attendance_detail'] as $v) {
|
||||
ProjectAttendanceDetail::create([
|
||||
'attendance_code' => $attendance_code,
|
||||
'attendance_id' => $ProjectAttendanceRecordRes->id,
|
||||
'project_id' => $params['project_id'],
|
||||
'person_id' => $v['person_id'],
|
||||
@ -95,6 +93,41 @@
|
||||
'remark' => $params['remark'],
|
||||
'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();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -114,18 +147,12 @@
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$detailIds = ProjectAttendanceDetail::where('attendance_id', $params['id'])->column('id');
|
||||
ProjectAttendanceDetail::destroy($detailIds);
|
||||
ProjectAttendanceRecord::destroy($params['id']);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
$detail = ProjectAttendanceDetail::where('attendance_id', 'in', $params['id'])->findOrEmpty();
|
||||
if (!$detail->isEmpty()) {
|
||||
self::setError('此数据关联了考勤明细内容,需删除考勤明细内容');
|
||||
return false;
|
||||
}
|
||||
return ProjectAttendanceRecord::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,12 +15,12 @@
|
||||
namespace app\adminapi\logic\project;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
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\ProjectMaterialBudget;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\project\ProjectMaterialBudgetDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -54,8 +54,7 @@ class ProjectMaterialBudgetLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
foreach ($detail as $item)
|
||||
{
|
||||
foreach ($detail as $item) {
|
||||
ProjectMaterialBudgetDetail::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'material_budget_id' => $project_material_budget->id,
|
||||
@ -96,8 +95,7 @@ class ProjectMaterialBudgetLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
foreach ($detail as $item)
|
||||
{
|
||||
foreach ($detail as $item) {
|
||||
if (isset($item['id']) && $item['id'] != '') {
|
||||
ProjectMaterialBudgetDetail::where('id', $item['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
@ -140,6 +138,11 @@ class ProjectMaterialBudgetLogic extends BaseLogic
|
||||
*/
|
||||
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']);
|
||||
}
|
||||
|
||||
@ -166,7 +169,8 @@ class ProjectMaterialBudgetLogic extends BaseLogic
|
||||
return $data->toArray();
|
||||
}
|
||||
|
||||
public static function approve($params,$admin_id): bool{
|
||||
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) {
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
namespace app\adminapi\logic\project;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
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;
|
||||
|
||||
@ -53,8 +53,7 @@ class ProjectSubpackageBudgetLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
foreach ($detail as $item)
|
||||
{
|
||||
foreach ($detail as $item) {
|
||||
ProjectSubpackageBudgetDetail::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'subpackage_budget_id' => $res->id,
|
||||
@ -98,8 +97,7 @@ class ProjectSubpackageBudgetLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
]);
|
||||
foreach ($detail as $item)
|
||||
{
|
||||
foreach ($detail as $item) {
|
||||
if (isset($item['id']) && $item['id'] != '') {
|
||||
ProjectSubpackageBudgetDetail::where('id', $item['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
@ -147,6 +145,11 @@ class ProjectSubpackageBudgetLogic extends BaseLogic
|
||||
*/
|
||||
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']);
|
||||
}
|
||||
|
||||
@ -173,7 +176,8 @@ class ProjectSubpackageBudgetLogic extends BaseLogic
|
||||
return $data->toArray();
|
||||
}
|
||||
|
||||
public static function approve($params,$admin_id): bool{
|
||||
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) {
|
||||
|
@ -203,6 +203,10 @@
|
||||
if (!is_numeric($v['num']) || $v['num'] <= 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'])) {
|
||||
return '含税单价不能为空';
|
||||
|
@ -37,8 +37,8 @@
|
||||
'project_id' => 'require|checkProject',
|
||||
'person_id' => 'require|checkPerson',
|
||||
'attendance_date' => 'require|dateFormat:Y-m-d',
|
||||
'work_start_time' => 'checkWorkStartTime',
|
||||
'work_end_time' => 'checkWorkEndTime',
|
||||
'work_start_time' => 'dateFormat:H:i:s',
|
||||
'work_end_time' => 'dateFormat:H:i:s',
|
||||
'work_record_num' => 'require|float|gt:0',
|
||||
'daily_salary' => 'require|float|gt:0',
|
||||
'daily_living' => 'require|float|gt:0',
|
||||
@ -136,27 +136,4 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectAttendanceDetail;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
@ -112,6 +113,12 @@
|
||||
return '考勤记录清单数据格式错误';
|
||||
}
|
||||
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'])) {
|
||||
return '请选择项目人员';
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user