提交代码

This commit is contained in:
zlwu committed 2025-08-17 14:32:13 +08:00
1 parent 09389af455
commit 7d7e5280c9
4 files changed
+760 -11

No files matched your search

+8
View File
@@ -127,6 +127,14 @@
"navigationBarBackgroundColor": "#0051d9",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/xgss/sswj/grsswj",
"style": {
"navigationBarTitleText": "宿舍违纪",
"navigationBarBackgroundColor": "#0051d9",
"navigationBarTextStyle": "white"
}
}
],
"globalStyle": {
+33 -11
View File
@@ -168,6 +168,20 @@
/>
</template>
</ServiceItem>
<ServiceItem
v-if="hasPermi(['student:dormviolation:list'])"
title="宿舍违纪"
@click="gotoDormViolation"
>
<template #icon>
<image
src="/static/0012.png"
mode="aspectFit"
style="width: 24px; height: 24px"
/>
</template>
</ServiceItem>
</GridLayout>
</Card>
@@ -375,7 +389,7 @@
</template>
<GridLayout :columns="3" gap="16px">
<ServiceItem
v-if="hasPermi(['system:user:list'])"
v-if="hasPermi(['system:mobileuser:list'])"
title="用户管理"
@click="handleServiceClick"
>
@@ -572,12 +586,12 @@ export default {
console.log(
this.userInfo.avatar && this.userInfo.avatar.trim() !== ''
? this.userInfo.avatar
: '/static/logo-2.png',
: '/static/111.png',
);
// 确保当avatar为空字符串、null或undefined时都显示默认图片
return this.userInfo.avatar && this.userInfo.avatar.trim() !== ''
? this.userInfo.avatar
: '/static/logo-2.png';
: '/static/111.png';
},
// 检查各模块是否有权限
@@ -590,7 +604,8 @@ export default {
this.hasPermi(['student:club:list']) ||
this.hasPermi(['student:counsel:list']) ||
this.hasPermi(['student:info:edit']) ||
this.hasPermi(['student:internship:list'])
this.hasPermi(['student:internship:list']) ||
this.hasPermi(['student:dorm:violation:list'])
);
},
@@ -631,7 +646,7 @@ export default {
hasSystemServices() {
return (
this.hasPermi(['system:user:list']) ||
this.hasPermi(['system:mobileuser:list']) ||
this.hasPermi(['system:role:list']) ||
this.hasPermi(['system:menu:list']) ||
this.hasPermi(['system:dept:list']) ||
@@ -677,12 +692,12 @@ export default {
// 点击用户头像
handleUserClick() {
const info = userManager.getUserInfoString();
uni.showModal({
title: '个人信息',
content: info,
showCancel: false,
});
// const info = userManager.getUserInfoString();
// uni.showModal({
// title: '个人信息',
// content: info,
// showCancel: false,
// });
},
// 退出登录
@@ -798,6 +813,13 @@ export default {
});
},
// 跳转到宿舍违纪页面
gotoDormViolation() {
uni.navigateTo({
url: '/pages/xgss/sswj/grsswj',
});
},
// 图片加载成功处理
handleImageLoad(event) {
console.log('✅ 轮播图片加载成功:', event.detail);
+719
View File
@@ -0,0 +1,719 @@
<template>
<view class="dorm-violation-container">
<!-- 顶部导航 -->
<u-navbar title="宿舍违纪查询" :border-bottom="false" bg-color="#3c9cff" title-color="#fff">
<view slot="left" @click="goBack">
<u-icon name="arrow-left" color="#fff" size="22"></u-icon>
</view>
</u-navbar>
<!-- 搜索区域 -->
<view class="search-container">
<view class="filter-section">
<view class="filter-item">
<text class="filter-label">违纪时间:</text>
<view class="date-display" @click="showDatePicker = true">
<text class="date-text">{{ formatDate(queryParams.violationTime) }}</text>
<u-icon name="calendar" size="16" color="#3c9cff"></u-icon>
</view>
<u-datetime-picker
v-model="queryParams.violationTime"
mode="date"
:show="showDatePicker"
@confirm="onDateConfirm"
@cancel="showDatePicker = false"
style="position: absolute; left: -9999px"
></u-datetime-picker>
</view>
</view>
<view class="search-actions">
<u-button type="primary" size="small" class="search-btn" @click="handleQuery">
搜索
</u-button>
<u-button type="info" size="small" class="reset-btn" @click="resetQuery">
重置
</u-button>
</view>
</view>
<!-- 加载状态 -->
<u-loading-page :loading="loading" loading-text="加载中..."></u-loading-page>
<!-- 列表内容 -->
<view v-if="!loading" class="content-wrapper">
<!-- 空状态 -->
<view v-if="dormViolationList.length === 0" class="empty-container">
<u-empty text="暂无违纪记录" mode="data"></u-empty>
</view>
<!-- 违纪记录列表 -->
<view v-else class="violation-list">
<view
v-for="(item, index) in dormViolationList"
:key="item.id || index"
class="violation-card"
>
<!-- 卡片头部 -->
<view class="card-header">
<view class="student-info">
<text class="student-name">{{ item.studentName || '-' }}</text>
<text class="student-no">{{ item.studentNo || '-' }}</text>
</view>
<view class="violation-time">
<text class="time-text">{{ formatTime(item.violationTime) }}</text>
</view>
</view>
<!-- 卡片内容 -->
<view class="card-content">
<view class="info-row">
<view class="info-item">
<text class="label">学院:</text>
<text class="value">{{ item.collegeName || '-' }}</text>
</view>
<view class="info-item">
<text class="label">专业:</text>
<text class="value">{{ item.majorName || '-' }}</text>
</view>
</view>
<view class="info-row">
<view class="info-item">
<text class="label">班级:</text>
<text class="value">{{ item.className || '-' }}</text>
</view>
<view class="info-item">
<text class="label">校区:</text>
<text class="value">{{ item.campusName || '-' }}</text>
</view>
</view>
<view class="info-row">
<view class="info-item">
<text class="label">宿舍楼:</text>
<text class="value">{{ item.buildingName || '-' }}</text>
</view>
<view class="info-item">
<text class="label">房间:</text>
<text class="value">{{ item.roomName || '-' }}</text>
</view>
</view>
<view class="info-row">
<view class="info-item">
<text class="label">床位:</text>
<text class="value">{{ item.bedName || '-' }}</text>
</view>
</view>
<view class="violation-info">
<view class="violation-type">
<text class="label">违纪类型:</text>
<u-tag
:text="getDictLabel(dormViolationTypeDict, item.violationType)"
:type="
getDictTagType(
dormViolationTypeDict,
item.violationType,
violationTypeFallbackMap,
)
"
size="mini"
></u-tag>
</view>
<view class="violation-level">
<text class="label">违纪等级:</text>
<u-tag
:text="
getDictLabel(dormViolationLevelDict, item.violationLevel)
"
:type="
getDictTagType(
dormViolationLevelDict,
item.violationLevel,
violationLevelFallbackMap,
)
"
size="mini"
></u-tag>
</view>
</view>
<view class="violation-description" v-if="item.violationDescription">
<text class="label">违纪描述:</text>
<text class="value">{{ item.violationDescription }}</text>
</view>
<view class="remark" v-if="item.remark">
<text class="label">备注:</text>
<text class="value">{{ item.remark }}</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="card-actions">
<view class="action-btn view-btn" @click="handleView(item)">
<u-icon name="eye" size="16" color="#3c9cff"></u-icon>
<text class="btn-text">查看详细</text>
</view>
</view>
</view>
</view>
<!-- 加载更多 -->
<view v-if="hasMore" class="load-more">
<u-loadmore
:status="loadMoreStatus"
@loadmore="loadMore"
:loading-text="loadingText"
:loadmore-text="loadMoreText"
:nomore-text="noMoreText"
></u-loadmore>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/common/request.js';
import { getDict, getDictLabel, getDictTagType } from '@/common/dict.js';
import { userManager } from '@/utils/user.js';
export default {
name: 'DormViolation',
data() {
return {
loading: false,
dormViolationList: [],
total: 0,
hasMore: true,
loadMoreStatus: 'loadmore',
loadingText: '努力加载中...',
loadMoreText: '点击或上拉加载更多',
noMoreText: '没有更多了',
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
violationTime: '', // 违纪发生时间
},
// 字典数据
dormViolationTypeDict: [],
dormViolationLevelDict: [],
// 字典标签类型降级映射
violationTypeFallbackMap: {
WS001001: 'warning', // 垃圾乱扔
WS001002: 'warning', // 床铺不整
WS001003: 'warning', // 物品摆放混乱
JL001001: 'info', // 晚归违纪
JL001002: 'info', // 噪音扰民
JL001003: 'error', // 夜不归宿
AQ001001: 'error', // 违规用电
AQ001002: 'error', // 吸烟违纪
AQ001003: 'error', // 明火使用
WP001001: 'primary', // 损坏公物
WP001002: 'primary', // 私改设施
WP001003: 'error', // 盗用他人物品
},
violationLevelFallbackMap: {
1: 'success', // 轻微
2: 'warning', // 一般
3: 'error', // 严重
4: 'error', // 特别严重
},
// 日期选择器
showDatePicker: false,
};
},
async created() {
await this.initData();
},
methods: {
// 返回上一页
goBack() {
uni.navigateBack();
},
// 初始化数据
async initData() {
await Promise.all([this.loadDictData(), this.getList()]);
},
// 加载字典数据
async loadDictData() {
try {
const [typeDict, levelDict] = await Promise.all([
getDict('dorm_violation_type'),
getDict('dorm_violation_level'),
]);
this.dormViolationTypeDict = typeDict;
this.dormViolationLevelDict = levelDict;
console.log('字典数据加载完成:', {
type: this.dormViolationTypeDict.length,
level: this.dormViolationLevelDict.length,
});
} catch (error) {
console.error('加载字典数据失败:', error);
}
},
// 获取字典标签
getDictLabel(dictData, value) {
return getDictLabel(dictData, value);
},
// 获取字典标签类型
getDictTagType(dictData, value, fallbackMap) {
return getDictTagType(dictData, value, fallbackMap);
},
// 获取违纪记录列表
async getList(isLoadMore = false) {
if (this.loading) return;
this.loading = true;
this.loadMoreStatus = 'loading';
try {
// 获取当前登录用户信息
const currentUser = userManager.getCurrentUser();
if (!currentUser || !currentUser.userId) {
uni.showToast({
title: '请先登录',
icon: 'none',
});
return;
}
const res = await request({
url: '/dormViolation/dormViolation/list',
method: 'GET',
params: {
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
violationTime: this.queryParams.violationTime || undefined,
studentId: currentUser.userId, // 传入当前登录用户的ID
},
});
if (res && res.code === 200) {
const { rows, total } = res;
if (isLoadMore) {
this.dormViolationList = [...this.dormViolationList, ...rows];
} else {
this.dormViolationList = rows;
}
this.total = total;
this.hasMore = this.dormViolationList.length < total;
console.log('获取违纪记录成功:', {
current: this.dormViolationList.length,
total: total,
hasMore: this.hasMore,
});
} else {
if (!isLoadMore) {
this.dormViolationList = [];
this.total = 0;
}
uni.showToast({
title: res?.msg || '获取数据失败',
icon: 'none',
});
}
} catch (error) {
console.error('获取违纪记录失败:', error);
if (!isLoadMore) {
this.dormViolationList = [];
this.total = 0;
}
uni.showToast({
title: '获取数据失败',
icon: 'none',
});
} finally {
this.loading = false;
this.loadMoreStatus = this.hasMore ? 'loadmore' : 'nomore';
}
},
// 搜索操作
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
// 重置搜索
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
violationTime: '',
};
this.getList();
},
// 加载更多
loadMore() {
if (this.hasMore && !this.loading) {
this.queryParams.pageNum++;
this.getList(true);
}
},
// 日期确认
onDateConfirm(e) {
this.queryParams.violationTime = this.formatDateForAPI(e.value);
this.showDatePicker = false;
},
// 格式化日期显示
formatDate(dateStr) {
if (!dateStr) return '请选择日期';
try {
const date = new Date(dateStr);
if (isNaN(date.getTime())) return '请选择日期';
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
} catch (error) {
console.error('日期格式化失败:', error);
return '请选择日期';
}
},
// 格式化日期用于API
formatDateForAPI(dateStr) {
if (!dateStr) return '';
try {
const date = new Date(dateStr);
if (isNaN(date.getTime())) return '';
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
} catch (error) {
console.error('日期格式化失败:', error);
return '';
}
},
// 格式化时间显示
formatTime(timeStr) {
if (!timeStr) return '-';
try {
const date = new Date(timeStr);
if (isNaN(date.getTime())) return timeStr;
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
} catch (error) {
console.error('时间格式化失败:', error);
return timeStr;
}
},
// 查看详细
handleView(item) {
console.log('查看违纪记录详细:', item);
// 跳转到详情页面(后续开发)
uni.showToast({
title: '详情页面开发中',
icon: 'none',
duration: 2000,
});
},
},
};
</script>
<style lang="scss" scoped>
.dorm-violation-container {
background-color: #f5f6fa;
min-height: 100vh;
}
.search-container {
padding: 20rpx;
background-color: #fff;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}
.filter-section {
margin-bottom: 20rpx;
}
.filter-item {
display: flex;
align-items: center;
margin-bottom: 16rpx;
width: 100%;
}
.filter-label {
font-size: 28rpx;
color: #606266;
width: 140rpx;
margin-right: 20rpx;
flex-shrink: 0;
}
.date-display {
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
padding: 0rpx 20rpx;
background-color: #f8f9fa;
border: 1px solid #e4e7ed;
border-radius: 8rpx;
min-height: 60rpx;
margin-right: 20rpx;
}
.date-text {
font-size: 28rpx;
color: #303133;
flex: 1;
margin-right: 16rpx;
}
.search-actions {
display: flex;
justify-content: center;
margin-top: 20rpx;
gap: 20rpx;
padding: 0 20rpx;
}
.content-wrapper {
padding: 20rpx;
}
.empty-container {
padding: 100rpx 20rpx;
}
.violation-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.violation-card {
background-color: #fff;
border-radius: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
overflow: hidden;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx;
border-bottom: 1px solid #f0f0f0;
background-color: #f8f9fa;
}
.student-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.student-name {
font-size: 32rpx;
font-weight: bold;
color: #303133;
}
.student-no {
font-size: 24rpx;
color: #909399;
}
.violation-time {
text-align: right;
}
.time-text {
font-size: 24rpx;
color: #606266;
}
.card-content {
padding: 24rpx;
}
.info-row {
display: flex;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
}
.info-item {
display: flex;
align-items: center;
flex: 1;
margin-right: 20rpx;
&:last-child {
margin-right: 0;
}
}
.label {
font-size: 26rpx;
color: #606266;
min-width: 80rpx;
margin-right: 12rpx;
}
.value {
font-size: 26rpx;
color: #303133;
flex: 1;
word-break: break-all;
}
.violation-info {
display: flex;
align-items: center;
margin: 20rpx 0;
gap: 40rpx;
}
.violation-type,
.violation-level {
display: flex;
align-items: center;
gap: 12rpx;
}
.violation-description,
.remark {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 1px solid #f0f0f0;
}
.violation-description .label,
.remark .label {
font-size: 26rpx;
color: #606266;
margin-bottom: 8rpx;
display: block;
}
.violation-description .value,
.remark .value {
font-size: 26rpx;
color: #303133;
line-height: 1.5;
word-break: break-all;
}
.card-actions {
display: flex;
justify-content: flex-end;
padding: 20rpx;
border-top: 1px solid #f0f0f0;
}
.action-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 16rpx 20rpx;
border-radius: 12rpx;
background-color: #f8f9fa;
min-width: 120rpx;
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
opacity: 0.8;
}
}
.view-btn {
background-color: rgba(60, 156, 255, 0);
}
.btn-text {
font-size: 24rpx;
margin-top: 8rpx;
color: #3c9cff;
font-weight: 500;
}
.load-more {
padding: 20rpx 0;
}
// uview组件样式调整
::v-deep .u-tag {
margin: 0;
}
::v-deep .u-button {
flex: 1;
// max-width: 200rpx;
border-radius: 8rpx;
}
// 搜索按钮样式
::v-deep .search-btn {
background: linear-gradient(135deg, #007aff, #0051d9) !important;
border: none !important;
box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3) !important;
transition: all 0.3s ease !important;
&:active {
transform: scale(0.95) !important;
box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4) !important;
}
}
// 重置按钮样式
::v-deep .reset-btn {
background-color: #f4f4f5 !important;
border: 1px solid #dcdfe6 !important;
color: #606266 !important;
transition: all 0.3s ease !important;
&:active {
transform: scale(0.95) !important;
background-color: #e9e9eb !important;
}
}
</style>
Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB