From 17ceb6575a27212767bf199f1cb28f0493be9863 Mon Sep 17 00:00:00 2001 From: ggb <1223416496@qq.com> Date: Thu, 8 Jun 2023 21:46:46 +0800 Subject: [PATCH] Modify employee gender options --- .../pinnacle/controller/DepartmentController.java | 8 ++++++++ ui/src/pages/info/DepartmentManagement.vue | 13 +++++++++++++ ui/src/pages/info/StaffManagement.vue | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/DepartmentController.java b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/DepartmentController.java index 35a5bee..54a76fc 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/DepartmentController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/DepartmentController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.cfive.pinnacle.entity.Department; import com.cfive.pinnacle.entity.common.ResponseCode; import com.cfive.pinnacle.entity.common.ResponseResult; +import com.cfive.pinnacle.exception.DataValidationFailedException; import com.cfive.pinnacle.service.IDepartmentService; import com.cfive.pinnacle.utils.WebUtil; import io.swagger.v3.oas.annotations.tags.Tag; @@ -13,6 +14,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.regex.Pattern; /** *

@@ -63,6 +65,9 @@ public class DepartmentController { @PostMapping @PreAuthorize("hasAuthority('department:admin:add')") public ResponseResult addDepartment(@RequestBody Department department) { + if (Pattern.matches("[0-9-()()]{7,18}", department.getTel())) { + throw new DataValidationFailedException(); + } if (departmentService.save(department)) { return ResponseResult.databaseSaveSuccess(null); } else { @@ -73,6 +78,9 @@ public class DepartmentController { @PutMapping @PreAuthorize("hasAuthority('department:admin:modify')") public ResponseResult modifyDepartment(@RequestBody Department department) { + if (Pattern.matches("[0-9-()()]{7,18}", department.getTel())) { + throw new DataValidationFailedException(); + } if (departmentService.updateById(department)) { return ResponseResult.databaseUpdateSuccess(null); } else { diff --git a/ui/src/pages/info/DepartmentManagement.vue b/ui/src/pages/info/DepartmentManagement.vue index 3ef0095..045ef96 100644 --- a/ui/src/pages/info/DepartmentManagement.vue +++ b/ui/src/pages/info/DepartmentManagement.vue @@ -145,6 +145,13 @@ import { ElMessage, ElMessageBox } from 'element-plus' export default { name: 'DepartmentManagement', data() { + const checkTel = (rule, value, callback) => { + if (value && !/[0-9-()()]{7,18}/.test(value)) { + return callback(new Error('非法电话号码')) + } else { + return callback() + } + } return { dialogTitle: '', dialogVisible: false, @@ -168,6 +175,12 @@ export default { required: true, message: '名称为必填项' } + ], + inputTel: [ + { + validator: checkTel, + message: '非法电话号码' + } ] }, departmentForm: { diff --git a/ui/src/pages/info/StaffManagement.vue b/ui/src/pages/info/StaffManagement.vue index fd22d8b..970f3f3 100644 --- a/ui/src/pages/info/StaffManagement.vue +++ b/ui/src/pages/info/StaffManagement.vue @@ -51,7 +51,7 @@ - + @@ -156,7 +156,7 @@ - + @@ -315,7 +315,7 @@ export default { } switch (row.staff.gender) { case 0: - return '未知' + return '保密' case 1: return '男' case 2: