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

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-select @change="changeDept" v-model="queryParams.deptId" placeholder="请选择学院" filterable
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-select>
</el-form-item>
@@ -88,6 +88,24 @@
</el-collapse-item>
</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-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>
@@ -119,7 +137,7 @@
</template>
<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 { fullLoading, groupBy, getChineseKey, getImg, isEmpty } from "@/api/helpFunc";
@@ -139,8 +157,7 @@ export default {
dicts: ['dorm_in_status'],
data() {
return {
searInputS: ['1', '2'],
// 遮罩层
// 加载层
loading: true,
// 选中数组
ids: [],
@@ -162,75 +179,67 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
campusId: null,
parkId: null,
buildingId: null,
floorId: null,
dormitoryId: null,
bedId: null,
deptId: null,
majorId: null,
classId: null,
gradeId: null,
stuNo: null,
isDormitoryHead: null,
status: null,
checkinTime: null,
inStatus: null
stuName: null,
teacherName: null,
idCard: null,
submitTime: null,
roleType: null
},
// 表单参数
form: {},
// 表单校验
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: {
campusId: null,
parkId: null,
buildingId: null,
floorId: null,
dormitoryId: null,
},
deptList: [],//学院列表
majorList: [],//专业列表
classList: [],//班级列表
gradeList: [],//年级列表
searInputS: ['1', '2'],
campus_list: [],
park_list: [],
building_list: [],
floor_list: [],
room_list: [],
exportV: false,
campus_list: [],
fast_park_list: [],
fast_building_list: [],
fast_floor_list: [],
fast_class_list: [],
fast_major_list: [],
fast_room_list: [],
uploadV: false,
deptList: [],
majorList: [],
classList: [],
gradeList: [],
userRoleInfo: null,
showRoleSwitch: false,
// 导入参数
upload: {
// 是否显示弹出层(导入)
open: false,
// 弹出层标题(导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
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
};
},
created() {
this.listDept();
async created() {
await this.getUserRoles();
await this.listDept();
this.listGrade();
this.getList();
this.listAllCampus();
@@ -247,8 +256,8 @@ export default {
},
async changeFloor(val) {
this.queryParams.dormitoryId = null;
this.room_list = [];
if (!isEmpty(val)) {
let res = await listAllRoomByFloor(this.queryParams.floorId);
if (res.code == 200) {
@@ -259,9 +268,10 @@ export default {
async changeBuilding(val) {
this.queryParams.floorId = null;
this.queryParams.dormitoryId = null;
this.floor_list = [];
this.room_list = [];
this.queryParams.dormitoryId = null;
if (!isEmpty(val)) {
let res = await listFloorByBuilding(this.queryParams.buildingId);
if (res.code == 200) {
@@ -273,7 +283,6 @@ export default {
this.queryParams.buildingId = null;
this.queryParams.floorId = null;
this.queryParams.dormitoryId = null;
this.building_list = [];
this.floor_list = [];
this.room_list = [];
@@ -291,7 +300,6 @@ export default {
this.queryParams.buildingId = null;
this.queryParams.floorId = null;
this.queryParams.dormitoryId = null;
this.park_list = [];
this.building_list = [];
this.floor_list = [];
@@ -304,44 +312,42 @@ export default {
}
}
},
async listGrade() {
let res = await listGrade();
this.gradeList = [...res.rows];
},
async changeMajor() {
if (!isEmpty(this.queryParams.majorId)) {
let sdata = {
majorId: this.queryParams.majorId
async changeMajor(val) {
this.queryParams.classId = null;
this.classList = [];
if (!isEmpty(val)) {
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() {
if (!isEmpty(this.queryParams.deptId)) {
let sdata = {
collegeId: this.queryParams.deptId,
pageNum: 1,
pageSize: 100
async changeDept(val) {
this.queryParams.majorId = null;
this.queryParams.classId = null;
this.majorList = [];
this.classList = [];
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() {
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) {
this.form.dormitoryId = null;
this.fast_room_list = [];
this.fastForm.dormitoryId = null;
this.room_list = [];
if (!isEmpty(val)) {
let res = await listAllRoomByFloor(this.fastForm.floorId);
if (res.code == 200) {
this.fast_room_list = [...res.data];
this.room_list = [...res.data];
}
}
},
async changeFastBuilding(val) {
this.fastForm.floorId = null;
this.fast_floor_list = [];
this.fast_room_list = [];
this.form.dormitoryId = null;
this.fastForm.dormitoryId = null;
this.floor_list = [];
this.room_list = [];
if (!isEmpty(val)) {
let res = await listFloorByBuilding(this.fastForm.buildingId);
if (res.code == 200) {
this.fast_floor_list = [...res.data];
this.floor_list = [...res.data];
}
}
},
async changeFastPark(val) {
this.fastForm.buildingId = null;
this.fastForm.floorId = null;
this.form.dormitoryId = null;
this.fast_building_list = [];
this.fast_floor_list = [];
this.fast_room_list = [];
this.fastForm.dormitoryId = null;
this.building_list = [];
this.floor_list = [];
this.room_list = [];
if (!isEmpty(val)) {
let res = await listBuildingByPark(this.fastForm.parkId);
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.buildingId = null;
this.fastForm.floorId = null;
this.form.dormitoryId = null;
this.fast_park_list = [];
this.fast_building_list = [];
this.fast_floor_list = [];
this.fast_room_list = [];
this.fastForm.dormitoryId = null;
this.park_list = [];
this.building_list = [];
this.floor_list = [];
this.room_list = [];
if (!isEmpty(val)) {
let res = await listParkByCampus(this.fastForm.campusId);
if (res.code == 200) {
this.fast_park_list = [...res.data];
this.park_list = [...res.data];
}
}
},
@@ -441,13 +444,13 @@ export default {
reset() {
this.form = {
id: null,
stuId: null,
dormitoryId: null,
bedId: null,
stuNo: null,
isDormitoryHead: null,
status: null,
checkinTime: null,
inStatus: null
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
@@ -462,7 +465,27 @@ export default {
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>
@@ -473,3 +496,4 @@ export default {
}
}
</style>