mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added search in StaffManagement
This commit is contained in:
@@ -5,7 +5,6 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
import com.cfive.pinnacle.service.IStaffService;
|
||||
import com.cfive.pinnacle.utils.WebUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -32,8 +31,8 @@ public class StaffController {
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize) {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId()));
|
||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
|
||||
@@ -17,5 +17,5 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
@Mapper
|
||||
public interface StaffMapper extends BaseMapper<Staff> {
|
||||
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId")Long departmentId);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.cfive.pinnacle.entity.permission.User;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IStaffService extends IService<Staff> {
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId);
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo);
|
||||
|
||||
boolean modifyStaff(User user);
|
||||
}
|
||||
|
||||
@@ -39,14 +39,16 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId) {
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
||||
Long departmentId = WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId();
|
||||
IPage<User> userIPage;
|
||||
if (currentPage == null || pageSize == null) {
|
||||
userIPage = PageDTO.of(0, -1);
|
||||
} else {
|
||||
userIPage = PageDTO.of(currentPage, pageSize);
|
||||
}
|
||||
return staffMapper.getAllStaff(userIPage, departmentId);
|
||||
searchInput = searchInput.trim();
|
||||
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,44 @@
|
||||
<if test="departmentId != null">
|
||||
and t_user.department_id = #{departmentId}
|
||||
</if>
|
||||
|
||||
<if test="searchInput != null and searchInput != ''">
|
||||
<choose>
|
||||
<when test="searchType == 0">
|
||||
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
|
||||
)
|
||||
</when>
|
||||
<when test="searchType == 1">
|
||||
and instr(t_user.username, #{searchInput}) > 0
|
||||
</when>
|
||||
<when test="searchType == 2">
|
||||
and (
|
||||
instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||
)
|
||||
</when>
|
||||
<when test="searchType == 3">
|
||||
and instr(ts.email, #{searchInput}) > 0
|
||||
</when>
|
||||
<when test="searchType == 4">
|
||||
and instr(ts.tel, #{searchInput}) > 0
|
||||
</when>
|
||||
<when test="searchType == 5">
|
||||
and instr(ts.address, #{searchInput}) > 0
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="searchGender != null and searchGender != -1">
|
||||
and ts.gender = #{searchGender}
|
||||
</if>
|
||||
<if test="searchBirthFrom != null and searchBirthFrom != '' and searchBirthTo != null and searchBirthTo != ''">
|
||||
and ts.birth between #{searchBirthFrom} and #{searchBirthTo}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<resultMap id="staffMap" type="user">
|
||||
|
||||
@@ -1,11 +1,64 @@
|
||||
<template>
|
||||
<el-button bg style="background-color: white" :loading="tableLoading" @click="loadStaffTable">
|
||||
<el-row gutter="20">
|
||||
<el-col :span="-1">
|
||||
<el-button
|
||||
bg
|
||||
style="background-color: white"
|
||||
:loading="tableLoading"
|
||||
@click="loadStaffTable"
|
||||
>
|
||||
<template #icon>
|
||||
<el-icon>
|
||||
<icon-pinnacle-refresh />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input
|
||||
v-model="inputInput"
|
||||
class="fill-with"
|
||||
placeholder="请输入内容"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
>
|
||||
<template #prepend>
|
||||
<el-select v-model="selectedType" style="width: 100px">
|
||||
<el-option label="综合搜索" :value="0" />
|
||||
<el-option label="用户名" :value="1" />
|
||||
<el-option label="姓名" :value="2" />
|
||||
<el-option label="邮箱" :value="3" />
|
||||
<el-option label="手机号码" :value="4" />
|
||||
<el-option label="联系地址" :value="5" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-form-item label="性别" class="fill-with">
|
||||
<el-select v-model="selectedGender" class="fill-with">
|
||||
<el-option label="全部" :value="-1" />
|
||||
<el-option label="未知" :value="0" />
|
||||
<el-option label="男" :value="1" />
|
||||
<el-option label="女" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="生日">
|
||||
<el-date-picker
|
||||
type="daterange"
|
||||
v-model="selectedBirth"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="fill-with"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="handleClear">清空</el-button>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
:data="staffTable"
|
||||
@@ -101,6 +154,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import _ from 'lodash'
|
||||
import request from '@/services'
|
||||
import { DATABASE_SELECT_OK, DATABASE_UPDATE_OK } from '@/constants/Common.constants'
|
||||
import { ElMessage } from 'element-plus'
|
||||
@@ -112,6 +166,14 @@ export default {
|
||||
dialogVisible: false,
|
||||
tableLoading: true,
|
||||
dialogLoading: true,
|
||||
searchType: 0,
|
||||
selectedType: 0,
|
||||
searchInput: '',
|
||||
inputInput: '',
|
||||
searchGender: -1,
|
||||
selectedGender: -1,
|
||||
searchBirth: [],
|
||||
selectedBirth: [],
|
||||
currentPage: 1,
|
||||
pageSize: 50,
|
||||
totalCount: 0,
|
||||
@@ -147,7 +209,15 @@ export default {
|
||||
loadStaffTable() {
|
||||
this.tableLoading = true
|
||||
request
|
||||
.get('/staff', { currentPage: this.currentPage, pageSize: this.pageSize })
|
||||
.get('/staff', {
|
||||
currentPage: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
searchType: this.searchType,
|
||||
searchInput: this.searchInput,
|
||||
searchGender: this.searchGender,
|
||||
searchBirthFrom: this.searchBirth ? this.searchBirth[0] : null,
|
||||
searchBirthTo: this.searchBirth ? this.searchBirth[1] : null
|
||||
})
|
||||
.then((res) => {
|
||||
const response = res.data
|
||||
if (response.code === DATABASE_SELECT_OK) {
|
||||
@@ -236,6 +306,20 @@ export default {
|
||||
handleCurrentChange(currentPage) {
|
||||
this.currentPage = currentPage
|
||||
this.loadStaffTable()
|
||||
},
|
||||
handleQuery() {
|
||||
this.searchType = _.cloneDeep(this.selectedType)
|
||||
this.searchInput = _.cloneDeep(this.inputInput)
|
||||
this.searchGender = _.cloneDeep(this.selectedGender)
|
||||
this.searchBirth = _.cloneDeep(this.selectedBirth)
|
||||
this.loadStaffTable()
|
||||
},
|
||||
handleClear() {
|
||||
this.selectedType = 0
|
||||
this.inputInput = ''
|
||||
this.selectedGender = -1
|
||||
this.selectedBirth = []
|
||||
this.handleQuery()
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
Reference in New Issue
Block a user