From 7336a2f6e957edd7a693b57e6fd2b3c3c7428c3b Mon Sep 17 00:00:00 2001 From: zeyan <258785420@qq.com> Date: Mon, 30 Jun 2025 19:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E5=90=8C=E7=AD=BE?= =?UTF-8?q?=E8=AE=A2=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/apiController/Contract.php | 188 ++++ .../controller/apiController/Personnel.php | 47 + niucloud/app/api/route/route.php | 9 + .../schedule/PerformanceCalculation.php | 3 +- .../api/apiService/ContractService.php | 358 +++++++ .../PersonCourseScheduleService.php | 80 +- .../api/apiService/PersonnelService.php | 160 ++++ uniapp/pages.json | 37 + .../pages/common/contract/contract_detail.vue | 766 +++++++++++++++ .../pages/common/contract/contract_sign.vue | 806 ++++++++++++++++ uniapp/pages/common/contract/my_contract.vue | 481 ++++++++++ .../pages/common/personnel/add_personnel.vue | 901 ++++++++++++++++++ 12 files changed, 3809 insertions(+), 27 deletions(-) create mode 100644 niucloud/app/api/controller/apiController/Contract.php create mode 100644 niucloud/app/service/api/apiService/ContractService.php create mode 100644 uniapp/pages/common/contract/contract_detail.vue create mode 100644 uniapp/pages/common/contract/contract_sign.vue create mode 100644 uniapp/pages/common/contract/my_contract.vue create mode 100644 uniapp/pages/common/personnel/add_personnel.vue diff --git a/niucloud/app/api/controller/apiController/Contract.php b/niucloud/app/api/controller/apiController/Contract.php new file mode 100644 index 00000000..5538a8de --- /dev/null +++ b/niucloud/app/api/controller/apiController/Contract.php @@ -0,0 +1,188 @@ +param('page', 1); + $limit = $request->param('limit', 10); + + $where = [ + 'personnel_id' => $this->member_id, + 'page' => $page, + 'limit' => $limit + ]; + + try { + $service = new ContractService(); + $res = $service->getMyContracts($where); + + if (!$res['code']) { + return fail($res['msg']); + } + + return success($res['data']); + } catch (\Exception $e) { + return fail('获取合同列表失败:' . $e->getMessage()); + } + } + + /** + * 获取合同详情 + * @param Request $request + * @return mixed + */ + public function detail(Request $request) + { + $contract_id = $request->param('id', 0); + + if (empty($contract_id)) { + return fail('合同ID不能为空'); + } + + $where = [ + 'contract_id' => $contract_id, + 'personnel_id' => $this->member_id + ]; + + try { + $service = new ContractService(); + $res = $service->getContractDetail($where); + + if (!$res['code']) { + return fail($res['msg']); + } + + return success($res['data']); + } catch (\Exception $e) { + return fail('获取合同详情失败:' . $e->getMessage()); + } + } + + /** + * 签订合同 + * @param Request $request + * @return mixed + */ + public function sign(Request $request) + { + $contract_id = $request->param('contract_id', 0); + $sign_file = $request->param('sign_file', ''); + + if (empty($contract_id)) { + return fail('合同ID不能为空'); + } + + if (empty($sign_file)) { + return fail('签名文件不能为空'); + } + + $data = [ + 'contract_id' => $contract_id, + 'personnel_id' => $this->member_id, + 'sign_file' => $sign_file + ]; + + try { + $service = new ContractService(); + $res = $service->signContract($data); + + if (!$res['code']) { + return fail($res['msg']); + } + + return success($res['data']); + } catch (\Exception $e) { + return fail('签订合同失败:' . $e->getMessage()); + } + } + + /** + * 获取合同签订状态 + * @param Request $request + * @return mixed + */ + public function signStatus(Request $request) + { + $contract_id = $request->param('contract_id', 0); + + if (empty($contract_id)) { + return fail('合同ID不能为空'); + } + + $where = [ + 'contract_id' => $contract_id, + 'personnel_id' => $this->member_id + ]; + + try { + $service = new ContractService(); + $res = $service->getSignStatus($where); + + if (!$res['code']) { + return fail($res['msg']); + } + + return success($res['data']); + } catch (\Exception $e) { + return fail('获取签订状态失败:' . $e->getMessage()); + } + } + + /** + * 下载合同文件 + * @param Request $request + * @return mixed + */ + public function download(Request $request) + { + $contract_id = $request->param('contract_id', 0); + + if (empty($contract_id)) { + return fail('合同ID不能为空'); + } + + $where = [ + 'contract_id' => $contract_id, + 'personnel_id' => $this->member_id + ]; + + try { + $service = new ContractService(); + $res = $service->downloadContract($where); + + if (!$res['code']) { + return fail($res['msg']); + } + + return success($res['data']); + } catch (\Exception $e) { + return fail('下载合同失败:' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/niucloud/app/api/controller/apiController/Personnel.php b/niucloud/app/api/controller/apiController/Personnel.php index 1bc57aa2..91727648 100644 --- a/niucloud/app/api/controller/apiController/Personnel.php +++ b/niucloud/app/api/controller/apiController/Personnel.php @@ -141,4 +141,51 @@ class Personnel extends BaseApiService } + /** + * 添加新员工信息 + * @param Request $request + * @return mixed + */ + public function add(Request $request) + { + $params = $request->all(); + + // 验证必填字段 + if (empty($params['name'])) { + return fail('员工姓名不能为空'); + } + + if (!isset($params['gender']) || $params['gender'] === '') { + return fail('请选择性别'); + } + + if (empty($params['phone'])) { + return fail('手机号码不能为空'); + } + + if (empty($params['account_type'])) { + return fail('请选择职位类型'); + } + + // 验证手机号格式 + if (!preg_match('/^1[3-9]\d{9}$/', $params['phone'])) { + return fail('请输入正确的手机号码'); + } + + // 验证邮箱格式(如果提供了邮箱) + if (!empty($params['email']) && !filter_var($params['email'], FILTER_VALIDATE_EMAIL)) { + return fail('请输入正确的邮箱地址'); + } + + try { + $res = (new PersonnelService())->addPersonnel($params); + if (!$res['code']) { + return fail($res['msg']); + } + return success($res['data']); + } catch (\Exception $e) { + return fail('添加员工信息失败:' . $e->getMessage()); + } + } + } diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 991c3fd5..6f821589 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -224,6 +224,8 @@ Route::group(function () { //员工端-获取全部人员列表 Route::get('personnel/getPersonnelAll', 'apiController.Personnel/getPersonnelAll'); + //员工端-添加新员工信息 + Route::post('personnel/add', 'apiController.Personnel/add'); //员工端统计(销售)-获取销售首页数据统计 Route::get('statistics/marketHome', 'apiController.Statistics/marketHome'); @@ -355,6 +357,13 @@ Route::group(function () { Route::post('personnel/reimbursement_add', 'apiController.Personnel/reimbursement_add'); Route::get('personnel/reimbursement_info', 'apiController.Personnel/reimbursement_info'); + //合同管理 + Route::get('contract/myContracts', 'apiController.Contract/myContracts'); + Route::get('contract/detail', 'apiController.Contract/detail'); + Route::post('contract/sign', 'apiController.Contract/sign'); + Route::get('contract/signStatus', 'apiController.Contract/signStatus'); + Route::get('contract/download', 'apiController.Contract/download'); + })->middleware(ApiChannel::class) ->middleware(ApiPersonnelCheckToken::class, true) diff --git a/niucloud/app/job/transfer/schedule/PerformanceCalculation.php b/niucloud/app/job/transfer/schedule/PerformanceCalculation.php index 0a37f859..c08f6438 100644 --- a/niucloud/app/job/transfer/schedule/PerformanceCalculation.php +++ b/niucloud/app/job/transfer/schedule/PerformanceCalculation.php @@ -37,14 +37,13 @@ class PerformanceCalculation extends BaseJob * 绩效服务类实例 * @var PerformanceService */ - protected $performanceService; + protected $performanceService = null; /** * 构造函数 */ public function __construct() { - parent::__construct(); $this->performanceService = new PerformanceService(); } diff --git a/niucloud/app/service/api/apiService/ContractService.php b/niucloud/app/service/api/apiService/ContractService.php new file mode 100644 index 00000000..e9098c3b --- /dev/null +++ b/niucloud/app/service/api/apiService/ContractService.php @@ -0,0 +1,358 @@ + 0, + 'msg' => '获取合同列表失败', + 'data' => [] + ]; + + try { + $page = $where['page'] ?? 1; + $limit = $where['limit'] ?? 10; + $personnel_id = $where['personnel_id'] ?? 0; + + if (empty($personnel_id)) { + $res['msg'] = '员工ID不能为空'; + return $res; + } + + // 查询合同签订记录,关联合同表 + $contractSignModel = new ContractSign(); + $list = $contractSignModel->alias('cs') + ->join('school_contract c', 'cs.contract_id = c.id') + ->where('cs.personnel_id', $personnel_id) + ->where('cs.deleted_at', 0) + ->where('c.deleted_at', 0) + ->field([ + 'cs.id', + 'cs.contract_id', + 'cs.personnel_id', + 'cs.sign_file', + 'cs.status', + 'cs.created_at', + 'cs.sign_time', + 'c.contract_name', + 'c.contract_template', + 'c.contract_status', + 'c.contract_type', + 'c.remarks' + ]) + ->order('cs.created_at', 'desc') + ->paginate([ + 'list_rows' => $limit, + 'page' => $page + ]) + ->toArray(); + + $res = [ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $list + ]; + + } catch (\Exception $e) { + $res['msg'] = '获取合同列表异常:' . $e->getMessage(); + } + + return $res; + } + + /** + * 获取合同详情 + * @param array $where + * @return array + */ + public function getContractDetail(array $where) + { + $res = [ + 'code' => 0, + 'msg' => '获取合同详情失败', + 'data' => [] + ]; + + try { + $contract_id = $where['contract_id'] ?? 0; + $personnel_id = $where['personnel_id'] ?? 0; + + if (empty($contract_id) || empty($personnel_id)) { + $res['msg'] = '参数错误'; + return $res; + } + + // 查询合同签订记录,关联合同表 + $contractSign = ContractSign::alias('cs') + ->join('school_contract c', 'cs.contract_id = c.id') + ->where('cs.contract_id', $contract_id) + ->where('cs.personnel_id', $personnel_id) + ->where('cs.deleted_at', 0) + ->where('c.deleted_at', 0) + ->field([ + 'cs.id', + 'cs.contract_id', + 'cs.personnel_id', + 'cs.sign_file', + 'cs.status', + 'cs.created_at', + 'cs.sign_time', + 'cs.updated_at', + 'c.contract_name', + 'c.contract_template', + 'c.contract_status', + 'c.contract_type', + 'c.remarks' + ]) + ->find(); + + if (empty($contractSign)) { + $res['msg'] = '合同不存在或无权限访问'; + return $res; + } + + $contractData = $contractSign->toArray(); + + $res = [ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $contractData + ]; + + } catch (\Exception $e) { + $res['msg'] = '获取合同详情异常:' . $e->getMessage(); + } + + return $res; + } + + /** + * 签订合同 + * @param array $data + * @return array + */ + public function signContract(array $data) + { + $res = [ + 'code' => 0, + 'msg' => '签订合同失败', + 'data' => [] + ]; + + try { + $contract_id = $data['contract_id'] ?? 0; + $personnel_id = $data['personnel_id'] ?? 0; + $sign_file = $data['sign_file'] ?? ''; + + if (empty($contract_id) || empty($personnel_id) || empty($sign_file)) { + $res['msg'] = '参数错误'; + return $res; + } + + // 开启事务 + Db::startTrans(); + + // 查询合同签订记录 + $contractSign = ContractSign::where('contract_id', $contract_id) + ->where('personnel_id', $personnel_id) + ->where('deleted_at', 0) + ->find(); + + if (empty($contractSign)) { + Db::rollback(); + $res['msg'] = '合同签订记录不存在'; + return $res; + } + + // 检查合同状态 + if ($contractSign['status'] != 1) { + Db::rollback(); + $res['msg'] = '合同状态不允许签订'; + return $res; + } + + // 检查是否已经签订 + if (!empty($contractSign['sign_file'])) { + Db::rollback(); + $res['msg'] = '合同已经签订,无需重复签订'; + return $res; + } + + // 更新签订信息 + $updateData = [ + 'sign_file' => $sign_file, + 'sign_time' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s') + ]; + + $updateResult = ContractSign::where('id', $contractSign['id'])->update($updateData); + + if (!$updateResult) { + Db::rollback(); + $res['msg'] = '更新签订信息失败'; + return $res; + } + + // 提交事务 + Db::commit(); + + $res = [ + 'code' => 1, + 'msg' => '签订成功', + 'data' => [ + 'contract_id' => $contract_id, + 'sign_time' => $updateData['sign_time'] + ] + ]; + + } catch (\Exception $e) { + Db::rollback(); + $res['msg'] = '签订合同异常:' . $e->getMessage(); + } + + return $res; + } + + /** + * 获取合同签订状态 + * @param array $where + * @return array + */ + public function getSignStatus(array $where) + { + $res = [ + 'code' => 0, + 'msg' => '获取签订状态失败', + 'data' => [] + ]; + + try { + $contract_id = $where['contract_id'] ?? 0; + $personnel_id = $where['personnel_id'] ?? 0; + + if (empty($contract_id) || empty($personnel_id)) { + $res['msg'] = '参数错误'; + return $res; + } + + $contractSign = ContractSign::where('contract_id', $contract_id) + ->where('personnel_id', $personnel_id) + ->where('deleted_at', 0) + ->field('id,sign_file,status,sign_time') + ->find(); + + if (empty($contractSign)) { + $res['msg'] = '合同签订记录不存在'; + return $res; + } + + $signData = $contractSign->toArray(); + + // 判断签订状态 + $signData['is_signed'] = !empty($signData['sign_file']); + $signData['can_sign'] = $signData['status'] == 1 && empty($signData['sign_file']); + + $res = [ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $signData + ]; + + } catch (\Exception $e) { + $res['msg'] = '获取签订状态异常:' . $e->getMessage(); + } + + return $res; + } + + /** + * 下载合同文件 + * @param array $where + * @return array + */ + public function downloadContract(array $where) + { + $res = [ + 'code' => 0, + 'msg' => '下载合同失败', + 'data' => [] + ]; + + try { + $contract_id = $where['contract_id'] ?? 0; + $personnel_id = $where['personnel_id'] ?? 0; + + if (empty($contract_id) || empty($personnel_id)) { + $res['msg'] = '参数错误'; + return $res; + } + + // 查询合同信息 + $contractSign = ContractSign::alias('cs') + ->join('school_contract c', 'cs.contract_id = c.id') + ->where('cs.contract_id', $contract_id) + ->where('cs.personnel_id', $personnel_id) + ->where('cs.deleted_at', 0) + ->where('c.deleted_at', 0) + ->field([ + 'cs.sign_file', + 'c.contract_template', + 'c.contract_name' + ]) + ->find(); + + if (empty($contractSign)) { + $res['msg'] = '合同不存在或无权限访问'; + return $res; + } + + $contractData = $contractSign->toArray(); + + // 返回下载信息 + $downloadData = [ + 'contract_name' => $contractData['contract_name'], + 'sign_file' => $contractData['sign_file'], + 'contract_template' => $contractData['contract_template'], + 'download_url' => !empty($contractData['sign_file']) ? $contractData['sign_file'] : $contractData['contract_template'] + ]; + + $res = [ + 'code' => 1, + 'msg' => '获取下载信息成功', + 'data' => $downloadData + ]; + + } catch (\Exception $e) { + $res['msg'] = '获取下载信息异常:' . $e->getMessage(); + } + + return $res; + } +} \ No newline at end of file diff --git a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php index f89a9724..c50797c8 100644 --- a/niucloud/app/service/api/apiService/PersonCourseScheduleService.php +++ b/niucloud/app/service/api/apiService/PersonCourseScheduleService.php @@ -366,17 +366,11 @@ class PersonCourseScheduleService extends BaseApiService 'data' => [] ]; - // 通过客户资源ID查找对应的学员 - $student = Student::where('user_id', $where['resource_id'])->find(); - if (!$student) { - return $res; - } - - // 查询学员的课程信息 - $studentCourses = StudentCourses::where('student_id', $student['id']) + // 直接通过resource_id查询学员课程表 + $studentCourses = StudentCourses::where('resource_id', $where['resource_id']) ->with([ 'course' => function($query) { - $query->field('id,course_name,status'); + $query->field('id,course_name'); }, 'student' => function($query) { $query->field('id,name'); @@ -386,16 +380,22 @@ class PersonCourseScheduleService extends BaseApiService ->toArray(); if (empty($studentCourses)) { + $res['msg'] = '该客户暂无课程信息'; return $res; } $courseData = []; foreach ($studentCourses as $course) { - // 计算已上课时和请假次数 - $usedCount = StudentCourseUsage::where('student_course_id', $course['id']) - ->where('usage_type', 'consume') - ->count(); + // 计算总课时数(正式课时 + 赠送课时) + $totalHours = ($course['total_hours'] ?? 0) + ($course['gift_hours'] ?? 0); + + // 计算已使用课时数(已使用正式课时 + 已使用赠送课时) + $usedHours = ($course['use_total_hours'] ?? 0) + ($course['use_gift_hours'] ?? 0); + + // 计算剩余课时数 + $remainingHours = $totalHours - $usedHours; + // 计算请假次数(通过课程安排表统计该资源下的请假记录) $leaveCount = PersonCourseSchedule::where('resources_id', $where['resource_id']) ->where('status', 2) // 2表示请假 ->count(); @@ -412,29 +412,59 @@ class PersonCourseScheduleService extends BaseApiService $education = Personnel::where('id', $course['education_id'])->field('id,name')->find(); } if (!empty($course['assistant_ids'])) { - $assistantIds = explode(',', $course['assistant_ids']); - $assistants = Personnel::whereIn('id', $assistantIds)->field('id,name')->select()->toArray(); + $assistantIds = array_filter(explode(',', $course['assistant_ids'])); + if (!empty($assistantIds)) { + $assistants = Personnel::whereIn('id', $assistantIds)->field('id,name')->select()->toArray(); + } } - // 计算课程状态 + // 根据数据库状态字段和日期计算课程状态 $status = 'active'; // 默认进行中 - if (!empty($course['end_date'])) { + $dbStatus = $course['status'] ?? 1; + + switch ($dbStatus) { + case 1: + $status = 'active'; // 有效 + break; + case 2: + $status = 'expired'; // 过期 + break; + case 3: + $status = 'waiting'; // 等待期 + break; + case 4: + $status = 'delayed'; // 延期 + break; + } + + // 如果课程已到期但状态还是有效,更新为过期 + if ($status === 'active' && !empty($course['end_date'])) { if (strtotime($course['end_date']) < time()) { - $status = 'expired'; // 已过期 + $status = 'expired'; } } - if ($usedCount >= $course['total_hours']) { - $status = 'completed'; // 已完成 + + // 如果课时已用完,标记为已完成 + if ($remainingHours <= 0) { + $status = 'completed'; } $courseData[] = [ 'id' => $course['id'], 'course_name' => $course['course']['course_name'] ?? '未知课程', - 'total_count' => $course['total_hours'] ?? 0, - 'used_count' => $usedCount, - 'leave_count' => $leaveCount, - 'expiry_date' => $course['end_date'] ?? '', - 'status' => $status, + 'total_count' => $totalHours, // 总课时(正式+赠送) + 'used_count' => $usedHours, // 已使用课时 + 'remaining_count' => $remainingHours, // 剩余课时 + 'formal_hours' => $course['total_hours'] ?? 0, // 正式课时 + 'gift_hours' => $course['gift_hours'] ?? 0, // 赠送课时 + 'used_formal_hours' => $course['use_total_hours'] ?? 0, // 已使用正式课时 + 'used_gift_hours' => $course['use_gift_hours'] ?? 0, // 已使用赠送课时 + 'leave_count' => $leaveCount, // 请假次数 + 'start_date' => $course['start_date'] ?? '', // 开始日期 + 'expiry_date' => $course['end_date'] ?? '', // 结束日期 + 'status' => $status, // 课程状态 + 'db_status' => $dbStatus, // 数据库原始状态 + 'single_session_count' => $course['single_session_count'] ?? 1, // 单次消课数量 'main_coach_id' => $course['main_coach_id'] ?? null, 'main_coach_name' => $mainCoach['name'] ?? '未分配', 'education_id' => $course['education_id'] ?? null, diff --git a/niucloud/app/service/api/apiService/PersonnelService.php b/niucloud/app/service/api/apiService/PersonnelService.php index 5f5652a3..281c3fbe 100644 --- a/niucloud/app/service/api/apiService/PersonnelService.php +++ b/niucloud/app/service/api/apiService/PersonnelService.php @@ -413,4 +413,164 @@ class PersonnelService extends BaseApiService } + /** + * 添加新员工信息 + * @param array $data + * @return array + */ + public function addPersonnel(array $data) + { + $res = [ + 'code' => 0, + 'msg' => '添加失败', + 'data' => [] + ]; + + try { + // 开启事务 + $this->model->startTrans(); + + // 检查手机号是否已存在 + $existingPersonnel = $this->model->where('phone', $data['phone'])->find(); + if ($existingPersonnel) { + $res['msg'] = '该手机号已存在,请更换'; + return $res; + } + + // 准备基本员工信息数据 + $personnelData = [ + 'name' => $data['name'], + 'head_img' => $data['head_img'] ?? '', + 'gender' => intval($data['gender']), + 'birthday' => $data['birthday'] ?? null, + 'phone' => $data['phone'], + 'email' => $data['email'] ?? '', + 'wx' => $data['wx'] ?? '', + 'address' => $data['current_address'] ?? '', + 'native_place' => $data['native_place'] ?? '', + 'education' => $data['education'] ?? '', + 'profile' => $data['remark'] ?? '', + 'emergency_contact_phone' => $data['emergency_phone'] ?? '', + 'employee_number' => $this->generateEmployeeNumber(), + 'status' => 1, + 'is_sys_user' => 0, + 'account_type' => $data['account_type'], + 'create_time' => date('Y-m-d H:i:s'), + 'update_time' => date('Y-m-d H:i:s'), + 'join_time' => $data['join_time'] ?? date('Y-m-d H:i:s'), + 'delete_time' => 0 + ]; + + // 插入员工基本信息 + $personnelId = $this->model->insertGetId($personnelData); + + if (!$personnelId) { + $this->model->rollback(); + $res['msg'] = '添加员工基本信息失败'; + return $res; + } + + // 如果有详细信息,插入到personnel_info表 + if ($this->hasDetailInfo($data)) { + $detailData = [ + 'person_id' => $personnelId, + 'name' => $data['name'], + 'ethnicity' => $data['ethnicity'] ?? '', + 'birthday' => $data['birthday'] ?? '', + 'age' => $data['age'] ?? null, + 'politics' => $data['politics'] ?? '', + 'university' => $data['university'] ?? '', + 'education' => $data['education'] ?? '', + 'major' => $data['major'] ?? '', + 'graduation_date' => $data['graduation_date'] ?? '', + 'native_place' => $data['native_place'] ?? '', + 'household_place' => $data['household_place'] ?? '', + 'household_type' => $data['household_type'] ?? '', + 'household_address' => $data['household_address'] ?? '', + 'current_address' => $data['current_address'] ?? '', + 'emergency_contact' => $data['emergency_contact'] ?? '', + 'emergency_phone' => $data['emergency_phone'] ?? '', + 'marital_status' => $data['marital_status'] ?? '', + 'bank_card' => $data['bank_card'] ?? '', + 'bank_name' => $data['bank_name'] ?? '', + 'remark' => $data['remark'] ?? '', + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s') + ]; + + $insertResult = \think\facade\Db::name('school_personnel_info')->insert($detailData); + if (!$insertResult) { + $this->model->rollback(); + $res['msg'] = '添加员工详细信息失败'; + return $res; + } + } + + // 提交事务 + $this->model->commit(); + + $res = [ + 'code' => 1, + 'msg' => '添加员工信息成功', + 'data' => [ + 'personnel_id' => $personnelId, + 'employee_number' => $personnelData['employee_number'] + ] + ]; + + } catch (\Exception $e) { + $this->model->rollback(); + $res['msg'] = '添加员工信息异常:' . $e->getMessage(); + } + + return $res; + } + + /** + * 检查是否有详细信息需要保存 + * @param array $data + * @return bool + */ + private function hasDetailInfo(array $data): bool + { + $detailFields = [ + 'ethnicity', 'age', 'politics', 'university', 'education', 'major', + 'graduation_date', 'household_place', 'household_type', 'household_address', + 'emergency_contact', 'emergency_phone', 'marital_status', 'bank_card', 'bank_name' + ]; + + foreach ($detailFields as $field) { + if (!empty($data[$field])) { + return true; + } + } + + return false; + } + + /** + * 生成员工编号 + * @return string + */ + private function generateEmployeeNumber(): string + { + $prefix = 'EMP'; + $date = date('Ymd'); + + // 查询今天已生成的最大编号 + $maxNumber = $this->model + ->where('employee_number', 'like', $prefix . $date . '%') + ->max('employee_number'); + + if ($maxNumber) { + // 提取序号并加1 + $sequence = intval(substr($maxNumber, -4)) + 1; + } else { + // 今天第一个员工 + $sequence = 1; + } + + return $prefix . $date . str_pad($sequence, 4, '0', STR_PAD_LEFT); + } + } diff --git a/uniapp/pages.json b/uniapp/pages.json index 113e3932..00e75b6f 100644 --- a/uniapp/pages.json +++ b/uniapp/pages.json @@ -228,6 +228,43 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/common/personnel/add_personnel", + "style": { + "navigationBarTitleText": "新员工信息填写", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#fff", + "navigationBarTextStyle": "black" + } + }, + { + "path": "pages/common/contract/my_contract", + "style": { + "navigationBarTitleText": "我的合同", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#fff", + "navigationBarTextStyle": "black", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/common/contract/contract_detail", + "style": { + "navigationBarTitleText": "合同详情", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#fff", + "navigationBarTextStyle": "black" + } + }, + { + "path": "pages/common/contract/contract_sign", + "style": { + "navigationBarTitleText": "合同签订", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#fff", + "navigationBarTextStyle": "black" + } + }, { "path": "pages/coach/home/index", diff --git a/uniapp/pages/common/contract/contract_detail.vue b/uniapp/pages/common/contract/contract_detail.vue new file mode 100644 index 00000000..888b51d4 --- /dev/null +++ b/uniapp/pages/common/contract/contract_detail.vue @@ -0,0 +1,766 @@ + + + + + \ No newline at end of file diff --git a/uniapp/pages/common/contract/contract_sign.vue b/uniapp/pages/common/contract/contract_sign.vue new file mode 100644 index 00000000..895db518 --- /dev/null +++ b/uniapp/pages/common/contract/contract_sign.vue @@ -0,0 +1,806 @@ + + + + + \ No newline at end of file diff --git a/uniapp/pages/common/contract/my_contract.vue b/uniapp/pages/common/contract/my_contract.vue new file mode 100644 index 00000000..1d747ae9 --- /dev/null +++ b/uniapp/pages/common/contract/my_contract.vue @@ -0,0 +1,481 @@ + + + + + \ No newline at end of file diff --git a/uniapp/pages/common/personnel/add_personnel.vue b/uniapp/pages/common/personnel/add_personnel.vue new file mode 100644 index 00000000..88bafa8a --- /dev/null +++ b/uniapp/pages/common/personnel/add_personnel.vue @@ -0,0 +1,901 @@ + + + + + \ No newline at end of file