mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-06 07:21:24 +08:00
Added regex search in StaffManagement
This commit is contained in:
@@ -29,8 +29,8 @@ public class StaffController {
|
|||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex) {
|
||||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo));
|
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo, searchRegex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface StaffMapper extends BaseMapper<Staff> {
|
public interface StaffMapper extends BaseMapper<Staff> {
|
||||||
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId") Long departmentId, @Param("searchType") Integer searchType, @Param("searchInput") String searchInput, @Param("searchGender") Integer searchGender, @Param("searchBirthFrom") String searchBirthFrom, @Param("searchBirthTo") String searchBirthTo);
|
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId") Long departmentId, @Param("searchType") Integer searchType, @Param("searchInput") String searchInput, @Param("searchGender") Integer searchGender, @Param("searchBirthFrom") String searchBirthFrom, @Param("searchBirthTo") String searchBirthTo, @Param("searchRegex") Integer searchRegex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import com.cfive.pinnacle.entity.permission.User;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
public interface IStaffService extends IService<Staff> {
|
public interface IStaffService extends IService<Staff> {
|
||||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo);
|
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex);
|
||||||
|
|
||||||
boolean modifyStaff(User user);
|
boolean modifyStaff(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex) {
|
||||||
Long departmentId = WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId();
|
Long departmentId = WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId();
|
||||||
IPage<User> userIPage;
|
IPage<User> userIPage;
|
||||||
if (currentPage == null || pageSize == null) {
|
if (currentPage == null || pageSize == null) {
|
||||||
@@ -48,7 +48,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|||||||
userIPage = PageDTO.of(currentPage, pageSize);
|
userIPage = PageDTO.of(currentPage, pageSize);
|
||||||
}
|
}
|
||||||
searchInput = searchInput.trim();
|
searchInput = searchInput.trim();
|
||||||
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo);
|
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo, searchRegex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -33,32 +33,72 @@
|
|||||||
<if test="searchInput != null and searchInput != ''">
|
<if test="searchInput != null and searchInput != ''">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="searchType == 0">
|
<when test="searchType == 0">
|
||||||
and (
|
<if test="searchRegex == 1">
|
||||||
instr(t_user.username, #{searchInput}) > 0
|
and (
|
||||||
or instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
t_user.username regexp #{searchInput}
|
||||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
or concat(ts.first_name, ts.last_name) regexp #{searchInput}
|
||||||
or instr(ts.email, #{searchInput}) > 0
|
or concat(ts.last_name, ts.first_name) regexp #{searchInput}
|
||||||
or instr(ts.tel, #{searchInput}) > 0
|
or ts.email regexp #{searchInput}
|
||||||
or instr(ts.address, #{searchInput}) > 0
|
or ts.tel regexp #{searchInput}
|
||||||
)
|
or ts.address regexp #{searchInput}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and (
|
||||||
|
instr(t_user.username, #{searchInput}) > 0
|
||||||
|
or instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||||
|
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||||
|
or instr(ts.email, #{searchInput}) > 0
|
||||||
|
or instr(ts.tel, #{searchInput}) > 0
|
||||||
|
or instr(ts.address, #{searchInput}) > 0
|
||||||
|
)
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
<when test="searchType == 1">
|
<when test="searchType == 1">
|
||||||
and instr(t_user.username, #{searchInput}) > 0
|
<if test="searchRegex == 1">
|
||||||
|
and t_user.username regexp #{searchInput}
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and instr(t_user.username, #{searchInput}) > 0
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
<when test="searchType == 2">
|
<when test="searchType == 2">
|
||||||
and (
|
<if test="searchRegex == 1">
|
||||||
instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
and (
|
||||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
concat(ts.first_name, ts.last_name) regexp #{searchInput}
|
||||||
)
|
or concat(ts.last_name, ts.first_name) regexp #{searchInput}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and (
|
||||||
|
instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||||
|
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||||
|
)
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
<when test="searchType == 3">
|
<when test="searchType == 3">
|
||||||
and instr(ts.email, #{searchInput}) > 0
|
<if test="searchRegex == 1">
|
||||||
|
and ts.email regexp #{searchInput}
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and instr(ts.email, #{searchInput}) > 0
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
<when test="searchType == 4">
|
<when test="searchType == 4">
|
||||||
and instr(ts.tel, #{searchInput}) > 0
|
<if test="searchRegex == 1">
|
||||||
|
and ts.tel regexp #{searchInput}
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and instr(ts.tel, #{searchInput}) > 0
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
<when test="searchType == 5">
|
<when test="searchType == 5">
|
||||||
and instr(ts.address, #{searchInput}) > 0
|
<if test="searchRegex == 1">
|
||||||
|
and ts.address regexp #{searchInput}
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
|
and instr(ts.address, #{searchInput}) > 0
|
||||||
|
</if>
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ export default {
|
|||||||
inputInput: '',
|
inputInput: '',
|
||||||
searchRegex: 0,
|
searchRegex: 0,
|
||||||
checkedRegex: 0,
|
checkedRegex: 0,
|
||||||
currentPage: 1,
|
|
||||||
isRegexLegal: true,
|
isRegexLegal: true,
|
||||||
|
currentPage: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
totalCount: 0,
|
totalCount: 0,
|
||||||
departmentTable: [],
|
departmentTable: [],
|
||||||
|
|||||||
@@ -15,24 +15,37 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-input
|
<el-form-item :error="isRegexLegal ? '' : '非法正则表达式'">
|
||||||
v-model="inputInput"
|
<el-input
|
||||||
class="fill-with"
|
v-model="inputInput"
|
||||||
placeholder="请输入内容"
|
class="fill-with"
|
||||||
clearable
|
placeholder="请输入内容"
|
||||||
@keyup.enter="handleQuery"
|
clearable
|
||||||
>
|
@keyup.enter="handleQuery"
|
||||||
<template #prepend>
|
@change="handleInputChange"
|
||||||
<el-select v-model="selectedType" style="width: 100px">
|
>
|
||||||
<el-option label="综合搜索" :value="0" />
|
<template #prepend>
|
||||||
<el-option label="用户名" :value="1" />
|
<el-select v-model="selectedType" style="width: 100px">
|
||||||
<el-option label="姓名" :value="2" />
|
<el-option label="综合搜索" :value="0" />
|
||||||
<el-option label="邮箱" :value="3" />
|
<el-option label="用户名" :value="1" />
|
||||||
<el-option label="手机号码" :value="4" />
|
<el-option label="姓名" :value="2" />
|
||||||
<el-option label="联系地址" :value="5" />
|
<el-option label="邮箱" :value="3" />
|
||||||
</el-select>
|
<el-option label="手机号码" :value="4" />
|
||||||
</template>
|
<el-option label="联系地址" :value="5" />
|
||||||
</el-input>
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<template #suffix>
|
||||||
|
<el-tooltip content="正则表达式">
|
||||||
|
<el-checkbox
|
||||||
|
v-model="checkedRegex"
|
||||||
|
label=".*"
|
||||||
|
:true-label="1"
|
||||||
|
@change="handleInputChange"
|
||||||
|
/>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-form-item label="性别" class="fill-with">
|
<el-form-item label="性别" class="fill-with">
|
||||||
@@ -195,6 +208,9 @@ export default {
|
|||||||
selectedType: 0,
|
selectedType: 0,
|
||||||
searchInput: '',
|
searchInput: '',
|
||||||
inputInput: '',
|
inputInput: '',
|
||||||
|
searchRegex: 0,
|
||||||
|
checkedRegex: 0,
|
||||||
|
isRegexLegal: true,
|
||||||
searchGender: -1,
|
searchGender: -1,
|
||||||
selectedGender: -1,
|
selectedGender: -1,
|
||||||
searchBirth: [],
|
searchBirth: [],
|
||||||
@@ -234,6 +250,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadStaffTable() {
|
loadStaffTable() {
|
||||||
|
if (!this.isRegexLegal) {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>非法正则表达式</strong>,请重新输入'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
request
|
request
|
||||||
.get('/staff', {
|
.get('/staff', {
|
||||||
@@ -243,7 +266,8 @@ export default {
|
|||||||
searchInput: this.searchInput,
|
searchInput: this.searchInput,
|
||||||
searchGender: this.searchGender,
|
searchGender: this.searchGender,
|
||||||
searchBirthFrom: this.searchBirth ? this.searchBirth[0] ?? null : null,
|
searchBirthFrom: this.searchBirth ? this.searchBirth[0] ?? null : null,
|
||||||
searchBirthTo: this.searchBirth ? this.searchBirth[1] ?? null : null
|
searchBirthTo: this.searchBirth ? this.searchBirth[1] ?? null : null,
|
||||||
|
searchRegex: this.searchRegex ?? 0
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
@@ -357,17 +381,34 @@ export default {
|
|||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.searchType = _.cloneDeep(this.selectedType)
|
this.searchType = _.cloneDeep(this.selectedType)
|
||||||
this.searchInput = _.cloneDeep(this.inputInput)
|
this.searchInput = _.cloneDeep(this.inputInput)
|
||||||
|
this.searchRegex = _.cloneDeep(this.checkedRegex)
|
||||||
this.searchGender = _.cloneDeep(this.selectedGender)
|
this.searchGender = _.cloneDeep(this.selectedGender)
|
||||||
this.searchBirth = _.cloneDeep(this.selectedBirth)
|
this.searchBirth = _.cloneDeep(this.selectedBirth)
|
||||||
this.currentPage = 1
|
this.currentPage = 1
|
||||||
|
this.handleInputChange()
|
||||||
this.loadStaffTable()
|
this.loadStaffTable()
|
||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.selectedType = 0
|
this.selectedType = 0
|
||||||
this.inputInput = ''
|
this.inputInput = ''
|
||||||
|
this.checkedRegex = 0
|
||||||
this.selectedGender = -1
|
this.selectedGender = -1
|
||||||
this.selectedBirth = []
|
this.selectedBirth = []
|
||||||
this.handleQuery()
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleInputChange() {
|
||||||
|
if (this.checkedRegex) {
|
||||||
|
try {
|
||||||
|
RegExp(this.inputInput)
|
||||||
|
this.isRegexLegal = !(
|
||||||
|
this.inputInput.includes('{}') || this.inputInput.includes('[]')
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
this.isRegexLegal = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.isRegexLegal = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
Reference in New Issue
Block a user