前端页面宿舍管理学生打卡模块,对学务和辅导员角色查看学生打卡记录做了数据筛选

This commit is contained in:
MDSMO
2025-08-20 09:07:47 +08:00
parent f91d2034b5
commit d0dc60a342
2 changed files with 136 additions and 105 deletions

View File

@@ -47,6 +47,13 @@ export function listView(params) {
}) })
} }
export function checkRoles() {
return request({
url: '/dormitory/daily/checkRoles',
method: 'get'
})
}
// 查询学生宿舍打卡列表 // 查询学生宿舍打卡列表

View File

@@ -40,7 +40,7 @@
<el-form-item label="学院" prop="deptId"> <el-form-item label="学院" prop="deptId">
<el-select @change="changeDept" v-model="queryParams.deptId" placeholder="请选择学院" filterable <el-select @change="changeDept" v-model="queryParams.deptId" placeholder="请选择学院" filterable
clearable> clearable>
<el-option v-for="(v, i) in deptList" :key="i" :label="v.label" :value="v.value"> <el-option v-for="(v, i) in deptList" :key="i" :label="v.label" :value="v.value" :disabled="v.disabled">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -88,6 +88,24 @@
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
<!-- 角色切换按钮 -->
<el-form-item label="查看权限" v-if="showRoleSwitch">
<el-button-group>
<el-button
:type="queryParams.roleType === 'dept' ? 'primary' : 'default'"
size="mini"
@click="switchRole('dept')">
学院数据
</el-button>
<el-button
:type="queryParams.roleType === 'teacher' ? 'primary' : 'default'"
size="mini"
@click="switchRole('teacher')">
个人班级
</el-button>
</el-button-group>
</el-form-item>
<el-form-item label=" "> <el-form-item label=" ">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -119,7 +137,7 @@
</template> </template>
<script> <script>
import { listView as getList, sendMail } from "@/api/dormitory/daily"; import { listView as getList, sendMail, checkRoles } from "@/api/dormitory/daily";
import { cleanNotStu } from "@/api/dormitory/basedata/dormitory"; import { cleanNotStu } from "@/api/dormitory/basedata/dormitory";
import { fullLoading, groupBy, getChineseKey, getImg, isEmpty } from "@/api/helpFunc"; import { fullLoading, groupBy, getChineseKey, getImg, isEmpty } from "@/api/helpFunc";
@@ -139,8 +157,7 @@ export default {
dicts: ['dorm_in_status'], dicts: ['dorm_in_status'],
data() { data() {
return { return {
searInputS: ['1', '2'], // 加载层
// 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
ids: [], ids: [],
@@ -162,75 +179,67 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
campusId: null,
parkId: null,
buildingId: null,
floorId: null,
dormitoryId: null, dormitoryId: null,
bedId: null, deptId: null,
majorId: null,
classId: null,
gradeId: null,
stuNo: null, stuNo: null,
isDormitoryHead: null, stuName: null,
status: null, teacherName: null,
checkinTime: null, idCard: null,
inStatus: null submitTime: null,
roleType: null
}, },
// 表单参数 // 表单参数
form: {}, form: {},
// 表单校验 // 表单校验
rules: { rules: {
dormitoryId: [
{ required: true, message: "宿舍ID不能为空", trigger: "blur" }
],
bedId: [
{ required: true, message: "床位ID不能为空", trigger: "blur" }
],
stuNo: [
{ required: true, message: "学生学号不能为空", trigger: "blur" }
],
status: [
{ required: true, message: "状态(0未缴费不能为空", trigger: "change" }
],
checkinTime: [
{ required: true, message: "入住时间不能为空", trigger: "blur" }
],
}, },
fastForm: { fastForm: {
campusId: null, campusId: null,
parkId: null, parkId: null,
buildingId: null, buildingId: null,
floorId: null, floorId: null,
dormitoryId: null,
}, },
searInputS: ['1', '2'],
campus_list: [],
deptList: [],//学院列表
majorList: [],//专业列表
classList: [],//班级列表
gradeList: [],//年级列表
park_list: [], park_list: [],
building_list: [], building_list: [],
floor_list: [], floor_list: [],
room_list: [], room_list: [],
deptList: [],
majorList: [],
exportV: false, classList: [],
campus_list: [], gradeList: [],
fast_park_list: [], userRoleInfo: null,
fast_building_list: [], showRoleSwitch: false,
fast_floor_list: [], // 导入参数
fast_class_list: [],
fast_major_list: [],
fast_room_list: [],
uploadV: false,
upload: { upload: {
// 是否显示弹出层(导入)
open: false,
// 弹出层标题(导入)
title: "",
// 是否禁用上传
isUploading: false, isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0, updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: 'Bearer ' + getTokenKeySessionStorage() }, headers: { Authorization: 'Bearer ' + getTokenKeySessionStorage() },
url: process.env.VUE_APP_BASE_API + '/dormitory/srs-dormitory-student/importData', // 上传的地址
url: process.env.VUE_APP_BASE_API + '/dormitory/srs-dormitory-student/importData'
}, },
allLoading: false allLoading: false
}; };
}, },
created() { async created() {
this.listDept(); await this.getUserRoles();
await this.listDept();
this.listGrade(); this.listGrade();
this.getList(); this.getList();
this.listAllCampus(); this.listAllCampus();
@@ -247,8 +256,8 @@ export default {
}, },
async changeFloor(val) { async changeFloor(val) {
this.queryParams.dormitoryId = null; this.queryParams.dormitoryId = null;
this.room_list = []; this.room_list = [];
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listAllRoomByFloor(this.queryParams.floorId); let res = await listAllRoomByFloor(this.queryParams.floorId);
if (res.code == 200) { if (res.code == 200) {
@@ -259,9 +268,10 @@ export default {
async changeBuilding(val) { async changeBuilding(val) {
this.queryParams.floorId = null; this.queryParams.floorId = null;
this.queryParams.dormitoryId = null;
this.floor_list = []; this.floor_list = [];
this.room_list = []; this.room_list = [];
this.queryParams.dormitoryId = null;
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listFloorByBuilding(this.queryParams.buildingId); let res = await listFloorByBuilding(this.queryParams.buildingId);
if (res.code == 200) { if (res.code == 200) {
@@ -273,7 +283,6 @@ export default {
this.queryParams.buildingId = null; this.queryParams.buildingId = null;
this.queryParams.floorId = null; this.queryParams.floorId = null;
this.queryParams.dormitoryId = null; this.queryParams.dormitoryId = null;
this.building_list = []; this.building_list = [];
this.floor_list = []; this.floor_list = [];
this.room_list = []; this.room_list = [];
@@ -291,7 +300,6 @@ export default {
this.queryParams.buildingId = null; this.queryParams.buildingId = null;
this.queryParams.floorId = null; this.queryParams.floorId = null;
this.queryParams.dormitoryId = null; this.queryParams.dormitoryId = null;
this.park_list = []; this.park_list = [];
this.building_list = []; this.building_list = [];
this.floor_list = []; this.floor_list = [];
@@ -304,44 +312,42 @@ export default {
} }
} }
}, },
async listGrade() { async listGrade() {
let res = await listGrade(); let res = await listGrade();
this.gradeList = [...res.rows]; this.gradeList = [...res.rows];
}, },
async changeMajor(val) {
async changeMajor() { this.queryParams.classId = null;
if (!isEmpty(this.queryParams.majorId)) { this.classList = [];
let sdata = { if (!isEmpty(val)) {
majorId: this.queryParams.majorId let res = await listClass({ majorId: this.queryParams.majorId });
if (res.code == 200) {
this.classList = [...res.data];
} }
let res = await listClass(sdata);
this.classList = [...res.data];
} else {
this.queryParams.classId = null;
this.classList = [];
} }
}, },
async changeDept() { async changeDept(val) {
if (!isEmpty(this.queryParams.deptId)) { this.queryParams.majorId = null;
let sdata = { this.queryParams.classId = null;
collegeId: this.queryParams.deptId, this.majorList = [];
pageNum: 1, this.classList = [];
pageSize: 100 if (!isEmpty(val)) {
let res = await listMajors({ collegeId: this.queryParams.deptId, pageNum: 1, pageSize: 100 });
if (res.code == 200) {
this.majorList = [...res.rows];
} }
let res = await listMajors(sdata);
this.majorList = [...res.rows];
} else {
this.queryParams.majorId = null;
this.majorList = [];
} }
}, },
async listDept() { async listDept() {
let res = await getDeptName(); let res = await getDeptName();
this.deptList = [...res.data]; let allDepts = [...res.data];
// 如果是学务干事或辅导员,只显示其所属的学院
if (this.userRoleInfo && (this.userRoleInfo.isXuewu || this.userRoleInfo.isFudaoyuan) && this.userRoleInfo.userDeptName) {
this.deptList = allDepts.filter(dept => dept.label === this.userRoleInfo.userDeptName);
} else {
this.deptList = allDepts;
}
}, },
@@ -353,42 +359,40 @@ export default {
}, },
async changeFastFloor(val) { async changeFastFloor(val) {
this.form.dormitoryId = null; this.fastForm.dormitoryId = null;
this.room_list = [];
this.fast_room_list = [];
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listAllRoomByFloor(this.fastForm.floorId); let res = await listAllRoomByFloor(this.fastForm.floorId);
if (res.code == 200) { if (res.code == 200) {
this.fast_room_list = [...res.data]; this.room_list = [...res.data];
} }
} }
}, },
async changeFastBuilding(val) { async changeFastBuilding(val) {
this.fastForm.floorId = null; this.fastForm.floorId = null;
this.fast_floor_list = []; this.fastForm.dormitoryId = null;
this.fast_room_list = []; this.floor_list = [];
this.form.dormitoryId = null; this.room_list = [];
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listFloorByBuilding(this.fastForm.buildingId); let res = await listFloorByBuilding(this.fastForm.buildingId);
if (res.code == 200) { if (res.code == 200) {
this.fast_floor_list = [...res.data]; this.floor_list = [...res.data];
} }
} }
}, },
async changeFastPark(val) { async changeFastPark(val) {
this.fastForm.buildingId = null; this.fastForm.buildingId = null;
this.fastForm.floorId = null; this.fastForm.floorId = null;
this.form.dormitoryId = null; this.fastForm.dormitoryId = null;
this.building_list = [];
this.fast_building_list = []; this.floor_list = [];
this.fast_floor_list = []; this.room_list = [];
this.fast_room_list = [];
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listBuildingByPark(this.fastForm.parkId); let res = await listBuildingByPark(this.fastForm.parkId);
if (res.code == 200) { if (res.code == 200) {
this.fast_building_list = [...res.data]; this.building_list = [...res.data];
} }
} }
}, },
@@ -397,17 +401,16 @@ export default {
this.fastForm.parkId = null; this.fastForm.parkId = null;
this.fastForm.buildingId = null; this.fastForm.buildingId = null;
this.fastForm.floorId = null; this.fastForm.floorId = null;
this.form.dormitoryId = null; this.fastForm.dormitoryId = null;
this.park_list = [];
this.fast_park_list = []; this.building_list = [];
this.fast_building_list = []; this.floor_list = [];
this.fast_floor_list = []; this.room_list = [];
this.fast_room_list = [];
if (!isEmpty(val)) { if (!isEmpty(val)) {
let res = await listParkByCampus(this.fastForm.campusId); let res = await listParkByCampus(this.fastForm.campusId);
if (res.code == 200) { if (res.code == 200) {
this.fast_park_list = [...res.data]; this.park_list = [...res.data];
} }
} }
}, },
@@ -441,13 +444,13 @@ export default {
reset() { reset() {
this.form = { this.form = {
id: null, id: null,
stuId: null,
dormitoryId: null, dormitoryId: null,
bedId: null, createBy: null,
stuNo: null, createTime: null,
isDormitoryHead: null, updateBy: null,
status: null, updateTime: null,
checkinTime: null, remark: null
inStatus: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@@ -462,7 +465,27 @@ export default {
this.handleQuery(); this.handleQuery();
}, },
/** 获取用户角色信息 */
async getUserRoles() {
try {
let res = await checkRoles();
if (res.code === 200 && res.data) {
this.userRoleInfo = res.data;
if (res.data.hasMultipleRoles) {
this.showRoleSwitch = true;
this.queryParams.roleType = res.data.defaultRole || 'dept';
}
}
} catch (error) {
console.error('获取用户角色信息失败:', error);
}
},
/** 切换角色 */
switchRole(roleType) {
this.queryParams.roleType = roleType;
this.handleQuery();
},
} }
}; };
</script> </script>
@@ -472,4 +495,5 @@ export default {
margin-bottom: 5px; margin-bottom: 5px;
} }
} }
</style> </style>