1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 15:01:23 +08:00

Modify employee gender options

This commit is contained in:
ggb
2023-06-08 21:46:46 +08:00
parent 02511ae67a
commit 17ceb6575a
3 changed files with 24 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cfive.pinnacle.entity.Department; import com.cfive.pinnacle.entity.Department;
import com.cfive.pinnacle.entity.common.ResponseCode; import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult; import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.exception.DataValidationFailedException;
import com.cfive.pinnacle.service.IDepartmentService; import com.cfive.pinnacle.service.IDepartmentService;
import com.cfive.pinnacle.utils.WebUtil; import com.cfive.pinnacle.utils.WebUtil;
import io.swagger.v3.oas.annotations.tags.Tag; 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 org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
/** /**
* <p> * <p>
@@ -63,6 +65,9 @@ public class DepartmentController {
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('department:admin:add')") @PreAuthorize("hasAuthority('department:admin:add')")
public ResponseResult<?> addDepartment(@RequestBody Department department) { public ResponseResult<?> addDepartment(@RequestBody Department department) {
if (Pattern.matches("[0-9-()]{7,18}", department.getTel())) {
throw new DataValidationFailedException();
}
if (departmentService.save(department)) { if (departmentService.save(department)) {
return ResponseResult.databaseSaveSuccess(null); return ResponseResult.databaseSaveSuccess(null);
} else { } else {
@@ -73,6 +78,9 @@ public class DepartmentController {
@PutMapping @PutMapping
@PreAuthorize("hasAuthority('department:admin:modify')") @PreAuthorize("hasAuthority('department:admin:modify')")
public ResponseResult<?> modifyDepartment(@RequestBody Department department) { public ResponseResult<?> modifyDepartment(@RequestBody Department department) {
if (Pattern.matches("[0-9-()]{7,18}", department.getTel())) {
throw new DataValidationFailedException();
}
if (departmentService.updateById(department)) { if (departmentService.updateById(department)) {
return ResponseResult.databaseUpdateSuccess(null); return ResponseResult.databaseUpdateSuccess(null);
} else { } else {

View File

@@ -145,6 +145,13 @@ import { ElMessage, ElMessageBox } from 'element-plus'
export default { export default {
name: 'DepartmentManagement', name: 'DepartmentManagement',
data() { data() {
const checkTel = (rule, value, callback) => {
if (value && !/[0-9-()]{7,18}/.test(value)) {
return callback(new Error('非法电话号码'))
} else {
return callback()
}
}
return { return {
dialogTitle: '', dialogTitle: '',
dialogVisible: false, dialogVisible: false,
@@ -168,6 +175,12 @@ export default {
required: true, required: true,
message: '名称为必填项' message: '名称为必填项'
} }
],
inputTel: [
{
validator: checkTel,
message: '非法电话号码'
}
] ]
}, },
departmentForm: { departmentForm: {

View File

@@ -51,7 +51,7 @@
<el-form-item label="性别" class="fill-with"> <el-form-item label="性别" class="fill-with">
<el-select v-model="selectedGender" class="fill-with"> <el-select v-model="selectedGender" class="fill-with">
<el-option label="全部" :value="-1" /> <el-option label="全部" :value="-1" />
<el-option label="未知" :value="0" /> <el-option label="保密" :value="0" />
<el-option label="男" :value="1" /> <el-option label="男" :value="1" />
<el-option label="女" :value="2" /> <el-option label="女" :value="2" />
</el-select> </el-select>
@@ -156,7 +156,7 @@
</el-form-item> </el-form-item>
<el-form-item label="性别" prop="selectedGender"> <el-form-item label="性别" prop="selectedGender">
<el-select v-model="userForm.selectedGender"> <el-select v-model="userForm.selectedGender">
<el-option label="未知" :value="0" /> <el-option label="保密" :value="0" />
<el-option label="男" :value="1" /> <el-option label="男" :value="1" />
<el-option label="女" :value="2" /> <el-option label="女" :value="2" />
</el-select> </el-select>
@@ -315,7 +315,7 @@ export default {
} }
switch (row.staff.gender) { switch (row.staff.gender) {
case 0: case 0:
return '未知' return '保密'
case 1: case 1:
return '男' return '男'
case 2: case 2: