wuzhen 更新假期住宿申请

This commit is contained in:
“wuzhen” committed 2026-08-20 15:17:40 +08:00
1 parent 1d67506451
commit 3518ea697e
35 files changed
+2173 -98

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
import { request } from '@/common/request.js';
/** 学生提交留宿申请 */
export const applyHolidayStay = (data) => {
return request({
url: '/holidayStay/holidayStay/apply',
method: 'POST',
data
});
};
/** 当前学生申请列表 */
export const listMyHolidayStay = (query) => {
return request({
url: '/holidayStay/holidayStay/myList',
method: 'GET',
params: query
});
};
/** 班主任本班申请列表 */
export const listTeacherHolidayStay = (query) => {
return request({
url: '/holidayStay/holidayStay/teacherList',
method: 'GET',
params: query
});
};
/** 审批通过 */
export const approveHolidayStay = (data) => {
return request({
url: '/holidayStay/holidayStay/approve',
method: 'POST',
data
});
};
/** 驳回 */
export const rejectHolidayStay = (data) => {
return request({
url: '/holidayStay/holidayStay/reject',
method: 'POST',
data
});
};
/** 撤销已通过申请 */
export const revokeHolidayStay = (data) => {
return request({
url: '/holidayStay/holidayStay/revoke',
method: 'POST',
data
});
};
/** 详情 */
export const getHolidayStay = (id) => {
return request({
url: '/holidayStay/holidayStay/' + id,
method: 'GET'
});
};
/** 获取学生当前在住宿舍信息 */
export const getCurrentDormInfo = (studentId) => {
return request({
url: '/dormBedStudent/dormBedStudent/currentDormInfo/' + studentId,
method: 'GET'
});
};
/** 当前登录学生信息 */
export const getCurrentStudentInfo = () => {
return request({
url: '/studentMsg/studentMsg/currentUserInfo',
method: 'GET'
});
};
+24
View File
@@ -207,6 +207,30 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/xgss/jqzs/myList",
"style": {
"navigationBarTitleText": "我的留宿申请",
"navigationBarBackgroundColor": "#0051d9",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/xgss/jqzs/apply",
"style": {
"navigationBarTitleText": "申请假期留宿",
"navigationBarBackgroundColor": "#0051d9",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/xgss/jqzs/teacherList",
"style": {
"navigationBarTitleText": "留宿审批",
"navigationBarBackgroundColor": "#0051d9",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/xgss/ssdm/ssdm",
"style": {
+34
View File
@@ -111,6 +111,26 @@
</template>
</ServiceItem>
<ServiceItem
v-if="hasPermi(['holidayStay:holidayStay:apply'])"
title="假期留宿申请"
@click="gotoHolidayStayApply"
>
<template #icon>
<u-icon name="home" size="24" color="#3c9cff" />
</template>
</ServiceItem>
<ServiceItem
v-if="hasPermi(['holidayStay:holidayStay:list1'])"
title="假期留宿审批"
@click="gotoHolidayStayAudit"
>
<template #icon>
<u-icon name="checkmark-circle" size="24" color="#3c9cff" />
</template>
</ServiceItem>
<!-- <ServiceItem
v-if="hasPermi(['student:psychology:list'])"
title="心理健康"
@@ -1183,6 +1203,20 @@ export default {
});
},
// 跳转到假期留宿申请(学生)
gotoHolidayStayApply() {
uni.navigateTo({
url: '/pages/xgss/jqzs/myList',
});
},
// 跳转到假期留宿审批(班主任)
gotoHolidayStayAudit() {
uni.navigateTo({
url: '/pages/xgss/jqzs/teacherList',
});
},
// 跳转到实习管理页面
gotoInternshipManage() {
uni.navigateTo({
+370
View File
@@ -0,0 +1,370 @@
<template>
<view class="page-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="form-wrap">
<view class="dorm-card">
<view class="dorm-title">当前宿舍(自动带出)</view>
<view v-if="dormLoading" class="dorm-text">加载中...</view>
<view v-else-if="dormText" class="dorm-text">{{ dormText }}</view>
<view v-else class="dorm-text dorm-warn">未查询到在住床位,请先完成宿舍床位分配后再申请</view>
</view>
<u-form :model="form" ref="formRef" label-width="90">
<u-form-item label="假期类型" prop="holidayType" required>
<view @click="openHolidayPicker" style="width: 100%">
<u-input
v-model="holidayTypeLabel"
placeholder="请选择假期类型"
readonly
border="none"
suffix-icon="arrow-down"
suffix-icon-style="color: #c8c9cc;"
style="pointer-events: none"
/>
</view>
</u-form-item>
<u-form-item label="开始时间" prop="applyStartDate" required>
<view @click="openDate('start')" style="width: 100%">
<u-input
v-model="form.applyStartDate"
placeholder="请选择开始时间"
readonly
border="none"
suffix-icon="arrow-down"
suffix-icon-style="color: #c8c9cc;"
style="pointer-events: none"
/>
</view>
</u-form-item>
<u-form-item label="结束时间" prop="applyEndDate" required>
<view @click="openDate('end')" style="width: 100%">
<u-input
v-model="form.applyEndDate"
placeholder="请选择结束时间"
readonly
border="none"
suffix-icon="arrow-down"
suffix-icon-style="color: #c8c9cc;"
style="pointer-events: none"
/>
</view>
</u-form-item>
<u-form-item label="原因类型" prop="stayReasonType">
<view @click="openReasonPicker" style="width: 100%">
<u-input
v-model="stayReasonTypeLabel"
placeholder="请选择原因类型"
readonly
border="none"
suffix-icon="arrow-down"
suffix-icon-style="color: #c8c9cc;"
style="pointer-events: none"
/>
</view>
</u-form-item>
<u-form-item label="留宿原因" prop="stayReason" required>
<u-textarea
v-model="form.stayReason"
placeholder="请填写留宿原因"
maxlength="500"
count
></u-textarea>
</u-form-item>
<u-form-item label="联系电话" prop="studentPhone">
<u-input v-model="form.studentPhone" placeholder="可自动带出,可修改" />
</u-form-item>
<u-form-item label="紧急联系人" prop="emergencyContact">
<u-input v-model="form.emergencyContact" placeholder="请输入紧急联系人" />
</u-form-item>
<u-form-item label="紧急电话" prop="emergencyPhone">
<u-input v-model="form.emergencyPhone" placeholder="请输入紧急联系电话" />
</u-form-item>
<u-form-item label="家长同意" prop="parentConsent">
<u-radio-group v-model="form.parentConsent" class="radio-group">
<u-radio label="1" name="1" class="radio-item">是</u-radio>
<u-radio label="0" name="0" class="radio-item">否</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item label="备注" prop="remark">
<u-textarea v-model="form.remark" placeholder="选填" maxlength="200"></u-textarea>
</u-form-item>
</u-form>
<u-button type="primary" :loading="submitting" text="提交申请" @click="submit"></u-button>
<view class="tip">提交后由班主任一级审批;宿舍信息将按当前入住床位自动带出。</view>
</view>
<u-picker
:show="showHolidayPicker"
:columns="holidayColumns"
keyName="label"
@confirm="onHolidayConfirm"
@cancel="showHolidayPicker = false"
@close="showHolidayPicker = false"
></u-picker>
<u-picker
:show="showReasonPicker"
:columns="reasonColumns"
keyName="label"
@confirm="onReasonConfirm"
@cancel="showReasonPicker = false"
@close="showReasonPicker = false"
></u-picker>
<u-datetime-picker
:show="showDatePicker"
v-model="dateValue"
mode="datetime"
@confirm="onDateConfirm"
@cancel="showDatePicker = false"
@close="showDatePicker = false"
></u-datetime-picker>
</view>
</template>
<script>
import { applyHolidayStay } from '@/api/holidayStay.js';
import { getDict } from '@/api/system/dict/data.js';
import { request } from '@/common/request.js';
export default {
data() {
return {
submitting: false,
showHolidayPicker: false,
showReasonPicker: false,
showDatePicker: false,
dateField: 'start',
dateValue: Number(new Date()),
holidayTypeDict: [],
stayReasonTypeDict: [],
holidayTypeLabel: '',
stayReasonTypeLabel: '',
dormLoading: false,
dormText: '',
hasDorm: false,
studentId: null,
form: {
holidayType: '',
applyStartDate: '',
applyEndDate: '',
stayReasonType: 'other',
stayReason: '',
studentPhone: '',
emergencyContact: '',
emergencyPhone: '',
parentConsent: '1',
remark: ''
}
};
},
computed: {
holidayColumns() {
return [this.holidayTypeDict || []];
},
reasonColumns() {
return [this.stayReasonTypeDict || []];
}
},
async onLoad() {
try {
this.holidayTypeDict = (await getDict('xg_holiday_type')) || [];
this.stayReasonTypeDict = (await getDict('xg_stay_reason_type')) || [];
const reason = this.stayReasonTypeDict.find((d) => String(d.value) === 'other');
if (reason) {
this.stayReasonTypeLabel = reason.label;
this.form.stayReasonType = reason.value;
}
const stuRes = await request({
url: '/studentMsg/studentMsg/currentUserInfo',
method: 'GET'
});
const stu = stuRes.data || stuRes;
if (stu && stu.phone) {
this.form.studentPhone = stu.phone;
}
if (stu && stu.id) {
this.studentId = stu.id;
await this.loadDormInfo(stu.id);
}
} catch (e) {
// ignore
}
},
methods: {
goBack() {
uni.navigateBack();
},
async loadDormInfo(studentId) {
this.dormLoading = true;
this.hasDorm = false;
this.dormText = '';
try {
const res = await request({
url: `/dormBedStudent/dormBedStudent/currentDormInfo/${studentId}`,
method: 'GET'
});
const dorm = res.data || res;
if (dorm && (dorm.roomId || dorm.bedId || dorm.buildingName || dorm.roomName)) {
const parts = [
dorm.campusName,
dorm.buildingName,
dorm.roomName || dorm.roomNo,
dorm.bedName || dorm.bedNo
].filter(Boolean);
this.dormText = parts.join(' / ');
this.hasDorm = !!(dorm.roomId && dorm.bedId);
}
} catch (e) {
this.dormText = '';
this.hasDorm = false;
} finally {
this.dormLoading = false;
}
},
openHolidayPicker() {
if (!this.holidayTypeDict.length) {
uni.showToast({ title: '假期类型加载中,请稍后', icon: 'none' });
return;
}
this.showHolidayPicker = true;
},
openReasonPicker() {
if (!this.stayReasonTypeDict.length) {
uni.showToast({ title: '原因类型加载中,请稍后', icon: 'none' });
return;
}
this.showReasonPicker = true;
},
openDate(field) {
this.dateField = field;
const current = field === 'start' ? this.form.applyStartDate : this.form.applyEndDate;
this.dateValue = current ? new Date(current.replace(/-/g, '/')).getTime() : Number(new Date());
this.showDatePicker = true;
},
onHolidayConfirm(e) {
const item = (e.value && e.value[0]) || null;
if (item) {
this.form.holidayType = item.value;
this.holidayTypeLabel = item.label;
}
this.showHolidayPicker = false;
},
onReasonConfirm(e) {
const item = (e.value && e.value[0]) || null;
if (item) {
this.form.stayReasonType = item.value;
this.stayReasonTypeLabel = item.label;
}
this.showReasonPicker = false;
},
onDateConfirm(e) {
const ts = e && e.value !== undefined ? e.value : e;
const d = new Date(Number(ts));
if (Number.isNaN(d.getTime())) {
this.showDatePicker = false;
return;
}
const pad = (n) => (n < 10 ? '0' + n : '' + n);
const str =
d.getFullYear() +
'-' +
pad(d.getMonth() + 1) +
'-' +
pad(d.getDate()) +
' ' +
pad(d.getHours()) +
':' +
pad(d.getMinutes()) +
':' +
pad(d.getSeconds());
if (this.dateField === 'start') {
this.form.applyStartDate = str;
} else {
this.form.applyEndDate = str;
}
this.showDatePicker = false;
},
async submit() {
if (!this.hasDorm) {
return uni.showToast({ title: '未分配宿舍床位,无法申请', icon: 'none' });
}
if (!this.form.holidayType) {
return uni.showToast({ title: '请选择假期类型', icon: 'none' });
}
if (!this.form.applyStartDate || !this.form.applyEndDate) {
return uni.showToast({ title: '请选择留宿时间', icon: 'none' });
}
if (!this.form.stayReason || !this.form.stayReason.trim()) {
return uni.showToast({ title: '请填写留宿原因', icon: 'none' });
}
this.submitting = true;
try {
await applyHolidayStay({ ...this.form });
uni.showToast({ title: '提交成功', icon: 'success' });
setTimeout(() => {
uni.navigateBack();
}, 500);
} catch (e) {
uni.showToast({ title: (e && e.msg) || '提交失败', icon: 'none' });
} finally {
this.submitting = false;
}
}
}
};
</script>
<style scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
}
.form-wrap {
margin: 24rpx;
padding: 24rpx;
background: #fff;
border-radius: 16rpx;
}
.tip {
margin-top: 24rpx;
font-size: 24rpx;
color: #909399;
line-height: 1.5;
}
.dorm-card {
margin-bottom: 24rpx;
padding: 20rpx;
background: #f7f8fa;
border-radius: 12rpx;
}
.dorm-title {
font-size: 26rpx;
color: #909399;
margin-bottom: 8rpx;
}
.dorm-text {
font-size: 28rpx;
color: #303133;
}
.dorm-warn {
color: #e6a23c;
}
.radio-group {
display: flex;
align-items: center;
}
.radio-item {
margin-right: 32rpx;
}
</style>
+201
View File
@@ -0,0 +1,201 @@
<template>
<view class="page-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="filter-bar">
<u-tabs
:list="statusTabs"
:current="tabIndex"
@change="onTabChange"
line-color="#3c9cff"
></u-tabs>
</view>
<u-loading-page :loading="loading && list.length === 0" loading-text="加载中..."></u-loading-page>
<view v-if="!loading || list.length > 0" class="content">
<u-empty v-if="list.length === 0" text="暂无申请记录" mode="data"></u-empty>
<view v-else class="card-list">
<view v-for="(item, index) in list" :key="item.id || index" class="card">
<view class="card-header">
<text class="title">{{ holidayTypeLabel(item.holidayType) }}</text>
<u-tag
:text="applyStatusLabel(item.applyStatus)"
:type="applyStatusType(item.applyStatus)"
size="mini"
></u-tag>
</view>
<view class="row"><text class="label">宿舍:</text><text>{{ item.buildingName }}{{ item.roomName }} {{ item.bedName }}</text></view>
<view class="row"><text class="label">时间:</text><text>{{ formatDate(item.applyStartDate) }} ~ {{ formatDate(item.applyEndDate) }}</text></view>
<view class="row"><text class="label">原因:</text><text>{{ item.stayReason || '-' }}</text></view>
<view class="row" v-if="item.auditOpinion"><text class="label">意见:</text><text>{{ item.auditOpinion }}</text></view>
<view class="row" v-if="item.revokeReason"><text class="label">撤销:</text><text>{{ item.revokeReason }}</text></view>
</view>
</view>
<view class="load-more" v-if="list.length > 0">
<u-loadmore :status="loadStatus" />
</view>
</view>
<view class="fab">
<u-button type="primary" shape="circle" text="申请留宿" @click="gotoApply"></u-button>
</view>
</view>
</template>
<script>
import { listMyHolidayStay } from '@/api/holidayStay.js';
import { getDict } from '@/api/system/dict/data.js';
export default {
data() {
return {
loading: false,
list: [],
total: 0,
pageNum: 1,
pageSize: 10,
loadStatus: 'loadmore',
tabIndex: 0,
applyStatus: '',
statusTabs: [
{ name: '全部', value: '' },
{ name: '待审', value: '1' },
{ name: '已通过', value: '2' },
{ name: '已驳回', value: '3' },
{ name: '已撤销', value: '4' }
],
holidayTypeDict: [],
applyStatusDict: []
};
},
onShow() {
this.refresh();
},
onReachBottom() {
this.loadMore();
},
async onLoad() {
try {
this.holidayTypeDict = (await getDict('xg_holiday_type')) || [];
this.applyStatusDict = (await getDict('xg_holiday_stay_apply_status')) || [];
} catch (e) {
// ignore
}
},
methods: {
goBack() {
uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/index/index' }) });
},
gotoApply() {
uni.navigateTo({ url: '/pages/xgss/jqzs/apply' });
},
onTabChange(item) {
const idx = typeof item === 'number' ? item : item.index;
this.tabIndex = idx;
this.applyStatus = this.statusTabs[idx].value;
this.refresh();
},
async refresh() {
this.pageNum = 1;
this.list = [];
await this.fetchList();
},
async loadMore() {
if (this.loadStatus !== 'loadmore') return;
this.pageNum += 1;
await this.fetchList(true);
},
async fetchList(append = false) {
this.loading = true;
this.loadStatus = 'loading';
try {
const res = await listMyHolidayStay({
pageNum: this.pageNum,
pageSize: this.pageSize,
applyStatus: this.applyStatus || undefined
});
const rows = res.rows || [];
this.total = res.total || 0;
this.list = append ? this.list.concat(rows) : rows;
this.loadStatus = this.list.length >= this.total ? 'nomore' : 'loadmore';
} catch (e) {
this.loadStatus = 'loadmore';
uni.showToast({ title: '加载失败', icon: 'none' });
} finally {
this.loading = false;
}
},
holidayTypeLabel(val) {
const hit = this.holidayTypeDict.find((d) => String(d.value) === String(val));
return (hit && hit.label) || val || '假期留宿';
},
applyStatusLabel(val) {
const hit = this.applyStatusDict.find((d) => String(d.value) === String(val));
return (hit && hit.label) || val || '-';
},
applyStatusType(val) {
const map = { '0': 'info', '1': 'warning', '2': 'success', '3': 'error', '4': 'info' };
return map[String(val)] || 'info';
},
formatDate(v) {
if (!v) return '-';
return String(v).replace('T', ' ').slice(0, 16);
}
}
};
</script>
<style scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
padding-bottom: 120rpx;
}
.filter-bar {
background: #fff;
}
.content {
padding: 24rpx;
}
.card-list .card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
}
.title {
font-size: 30rpx;
font-weight: 600;
color: #303133;
}
.row {
font-size: 26rpx;
color: #606266;
margin-top: 8rpx;
display: flex;
}
.label {
color: #909399;
min-width: 90rpx;
}
.fab {
position: fixed;
left: 0;
right: 0;
bottom: 40rpx;
display: flex;
justify-content: center;
padding: 0 40rpx;
}
</style>
+283
View File
@@ -0,0 +1,283 @@
<template>
<view class="page-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="filter-bar">
<u-tabs
:list="statusTabs"
:current="tabIndex"
@change="onTabChange"
line-color="#3c9cff"
></u-tabs>
</view>
<view class="search-box">
<u-search
v-model="studentName"
placeholder="学生姓名"
:show-action="true"
action-text="搜索"
@search="refresh"
@custom="refresh"
@clear="refresh"
></u-search>
</view>
<u-loading-page :loading="loading && list.length === 0" loading-text="加载中..."></u-loading-page>
<view v-if="!loading || list.length > 0" class="content">
<u-empty v-if="list.length === 0" text="暂无本班申请" mode="data"></u-empty>
<view v-else class="card-list">
<view v-for="(item, index) in list" :key="item.id || index" class="card">
<view class="card-header">
<view>
<text class="name">{{ item.studentName }}</text>
<text class="no">{{ item.studentNo }}</text>
</view>
<u-tag
:text="applyStatusLabel(item.applyStatus)"
:type="applyStatusType(item.applyStatus)"
size="mini"
></u-tag>
</view>
<view class="row">班级:{{ item.className || '-' }}</view>
<view class="row">宿舍:{{ item.buildingName }}{{ item.roomName }} {{ item.bedName }}</view>
<view class="row">时间:{{ formatDate(item.applyStartDate) }} ~ {{ formatDate(item.applyEndDate) }}</view>
<view class="row">原因:{{ item.stayReason || '-' }}</view>
<view class="actions" v-if="item.applyStatus === '1'">
<u-button size="mini" type="success" text="通过" @click="doApprove(item)"></u-button>
<u-button size="mini" type="warning" text="驳回" @click="openReject(item)"></u-button>
</view>
<view class="actions" v-else-if="item.applyStatus === '2'">
<u-button size="mini" type="error" text="撤销" @click="openRevoke(item)"></u-button>
</view>
</view>
</view>
<u-loadmore v-if="list.length > 0" :status="loadStatus" />
</view>
<u-modal
:show="modal.show"
:title="modal.title"
showCancelButton
@confirm="submitModal"
@cancel="modal.show = false"
>
<view class="modal-body">
<u-textarea v-model="modal.opinion" :placeholder="modal.placeholder" maxlength="200" count></u-textarea>
</view>
</u-modal>
</view>
</template>
<script>
import {
listTeacherHolidayStay,
approveHolidayStay,
rejectHolidayStay,
revokeHolidayStay
} from '@/api/holidayStay.js';
import { getDict } from '@/api/system/dict/data.js';
export default {
data() {
return {
loading: false,
list: [],
total: 0,
pageNum: 1,
pageSize: 10,
loadStatus: 'loadmore',
tabIndex: 1,
applyStatus: '1',
studentName: '',
statusTabs: [
{ name: '全部', value: '' },
{ name: '待审', value: '1' },
{ name: '已通过', value: '2' },
{ name: '已驳回', value: '3' },
{ name: '已撤销', value: '4' }
],
applyStatusDict: [],
modal: {
show: false,
title: '',
mode: '',
id: null,
opinion: '',
placeholder: ''
}
};
},
onShow() {
this.refresh();
},
onReachBottom() {
this.loadMore();
},
async onLoad() {
try {
this.applyStatusDict = (await getDict('xg_holiday_stay_apply_status')) || [];
} catch (e) {
// ignore
}
},
methods: {
goBack() {
uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/index/index' }) });
},
onTabChange(item) {
const idx = typeof item === 'number' ? item : item.index;
this.tabIndex = idx;
this.applyStatus = this.statusTabs[idx].value;
this.refresh();
},
async refresh() {
this.pageNum = 1;
this.list = [];
await this.fetchList();
},
async loadMore() {
if (this.loadStatus !== 'loadmore') return;
this.pageNum += 1;
await this.fetchList(true);
},
async fetchList(append = false) {
this.loading = true;
this.loadStatus = 'loading';
try {
const res = await listTeacherHolidayStay({
pageNum: this.pageNum,
pageSize: this.pageSize,
applyStatus: this.applyStatus || undefined,
studentName: this.studentName || undefined
});
const rows = res.rows || [];
this.total = res.total || 0;
this.list = append ? this.list.concat(rows) : rows;
this.loadStatus = this.list.length >= this.total ? 'nomore' : 'loadmore';
} catch (e) {
this.loadStatus = 'loadmore';
uni.showToast({ title: '加载失败', icon: 'none' });
} finally {
this.loading = false;
}
},
async doApprove(item) {
try {
await approveHolidayStay({ id: item.id });
uni.showToast({ title: '已通过', icon: 'success' });
this.refresh();
} catch (e) {
uni.showToast({ title: (e && e.msg) || '操作失败', icon: 'none' });
}
},
openReject(item) {
this.modal = {
show: true,
title: '驳回申请',
mode: 'reject',
id: item.id,
opinion: '',
placeholder: '请填写驳回意见(选填)'
};
},
openRevoke(item) {
this.modal = {
show: true,
title: '撤销留宿',
mode: 'revoke',
id: item.id,
opinion: '',
placeholder: '请填写撤销原因(必填)'
};
},
async submitModal() {
if (this.modal.mode === 'revoke' && !String(this.modal.opinion || '').trim()) {
uni.showToast({ title: '请填写撤销原因', icon: 'none' });
return;
}
try {
if (this.modal.mode === 'reject') {
await rejectHolidayStay({ id: this.modal.id, auditOpinion: this.modal.opinion });
uni.showToast({ title: '已驳回', icon: 'success' });
} else {
await revokeHolidayStay({ id: this.modal.id, revokeReason: this.modal.opinion });
uni.showToast({ title: '已撤销', icon: 'success' });
}
this.modal.show = false;
this.refresh();
} catch (e) {
uni.showToast({ title: (e && e.msg) || '操作失败', icon: 'none' });
}
},
applyStatusLabel(val) {
const hit = this.applyStatusDict.find((d) => String(d.value) === String(val));
return (hit && hit.label) || val || '-';
},
applyStatusType(val) {
const map = { '0': 'info', '1': 'warning', '2': 'success', '3': 'error', '4': 'info' };
return map[String(val)] || 'info';
},
formatDate(v) {
if (!v) return '-';
return String(v).replace('T', ' ').slice(0, 16);
}
}
};
</script>
<style scoped>
.page-container {
min-height: 100vh;
background: #f5f6f8;
}
.filter-bar,
.search-box {
background: #fff;
}
.search-box {
padding: 16rpx 24rpx;
}
.content {
padding: 24rpx;
}
.card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12rpx;
}
.name {
font-size: 30rpx;
font-weight: 600;
margin-right: 12rpx;
}
.no {
font-size: 24rpx;
color: #909399;
}
.row {
font-size: 26rpx;
color: #606266;
margin-top: 6rpx;
}
.actions {
margin-top: 20rpx;
display: flex;
gap: 16rpx;
}
.modal-body {
padding: 20rpx;
}
</style>
@@ -12,8 +12,9 @@
**主要功能模块:**
#### 1.1 宿舍整体情况
- 违纪类型选择(从API加载)
- 宿舍扣分输入(0-100分)
- 扣分项多选(违纪类型)
- **归属班级选择(必填)**:选项为当前寝室在住学生班级(去重),默认选中第一项
- 宿舍扣分(由扣分项合计,只读,0-100分)
- 卫生等级选择(字典:`xg_dorm_hygiene_grade`)
- 检查附件上传(支持图片,最多15个)
@@ -83,6 +83,32 @@
</view>
</u-popup>
<!-- 归属班级(本寝室在住学生班级) -->
<u-form-item label="归属班级" prop="classId" required>
<view
@click="!isViewMode && classOptions.length && (showClassPicker = true)"
style="width: 100%"
>
<u-input
:value="classDisplay"
:placeholder="classOptions.length ? '请选择归属班级' : '当前寝室无在住学生班级'"
readonly
border="none"
:suffix-icon="isViewMode || !classOptions.length ? '' : 'arrow-down'"
suffix-icon-style="color: #c8c9cc;"
style="pointer-events: none"
/>
</view>
<u-picker
v-if="!isViewMode"
:show="showClassPicker && classOptions.length > 0"
:columns="classColumns"
keyName="text"
@confirm="handleClassConfirm"
@cancel="showClassPicker = false"
></u-picker>
</u-form-item>
<!-- 宿舍扣分 -->
<u-form-item label="宿舍扣分" prop="totalScore">
<u-input
@@ -634,6 +660,8 @@ export default {
formData: {
disciplineTypeId: null,
disciplineTypeName: '',
classId: null,
className: '',
totalScore: 0,
hygieneGrade: 'A',
checkRemarks: '',
@@ -643,9 +671,12 @@ export default {
deductionItems: [],
showDeductionPopup: false,
tempSelectedTypeIds: [],
classOptions: [],
showClassPicker: false,
// 表单验证规则
rules: {
classId: [{ required: true, message: '请选择归属班级', trigger: 'change' }],
hygieneGrade: [{ required: true, message: '请选择卫生等级', trigger: 'change' }],
},
@@ -718,6 +749,19 @@ export default {
return this.deductionItems.map((item) => item.disciplineTypeName).join('、');
},
classColumns() {
return [
this.classOptions.map((item) => ({
text: item.className,
value: item.classId,
})),
];
},
classDisplay() {
return this.formData.className || '';
},
// 卫生等级列
hygieneGradeColumns() {
return [
@@ -919,6 +963,7 @@ export default {
async loadRoomStudents() {
if (!this.roomInfo || !this.roomInfo.id) {
this.roomStudents = [];
this.syncClassOptionsFromStudents([]);
return;
}
@@ -946,21 +991,74 @@ export default {
showAttendancePicker: false,
showGradePicker: false,
}));
this.syncClassOptionsFromStudents(this.roomStudents);
// 加载学生请假信息
await this.loadStudentLeaves();
} else {
this.roomStudents = [];
this.syncClassOptionsFromStudents([]);
}
} catch (error) {
console.error('加载房间学生信息失败:', error);
uni.showToast({ title: '加载学生信息失败', icon: 'none' });
this.roomStudents = [];
this.syncClassOptionsFromStudents([]);
} finally {
this.studentsLoading = false;
}
},
/** 从本房学生提取班级选项,默认选中第一项 */
syncClassOptionsFromStudents(students, preferClassId) {
const map = new Map();
(students || []).forEach((student) => {
if (
student.classId == null ||
student.classId === '' ||
student.classId === 0 ||
student.classId === '0'
) {
return;
}
const key = String(student.classId);
if (!map.has(key)) {
map.set(key, {
classId: student.classId,
className: student.className || key,
});
}
});
this.classOptions = Array.from(map.values());
if (!this.classOptions.length) {
this.formData.classId = null;
this.formData.className = '';
return;
}
const preferred =
preferClassId !== undefined && preferClassId !== null
? preferClassId
: this.formData.classId;
const matched =
preferred != null
? this.classOptions.find((item) => String(item.classId) === String(preferred))
: null;
const selected = matched || this.classOptions[0];
this.formData.classId = selected.classId;
this.formData.className = selected.className;
},
handleClassConfirm(e) {
const selected = e.value && e.value[0];
if (selected) {
this.formData.classId = selected.value;
this.formData.className = selected.text;
}
this.showClassPicker = false;
},
// 加载学生请假信息
async loadStudentLeaves() {
if (!this.checkInfo || !this.checkInfo.checkDate || this.roomStudents.length === 0)
@@ -1008,6 +1106,8 @@ export default {
// 1️⃣ 回显表单基础数据
this.formData.disciplineTypeId = this.existingData.disciplineTypeId || null;
this.formData.disciplineTypeName = this.existingData.disciplineTypeName || '';
this.formData.classId = this.existingData.classId || null;
this.formData.className = this.existingData.className || '';
this.formData.totalScore = this.existingData.totalScore || 0;
this.formData.hygieneGrade = this.existingData.hygieneGrade || 'A';
this.formData.checkRemarks = this.existingData.checkRemarks || '';
@@ -1060,6 +1160,7 @@ export default {
studentId: normalizeStudentId(studentScore.studentId),
studentName: studentScore.studentName,
studentNo: studentScore.studentNo,
classId: studentScore.classId,
className: studentScore.className,
majorName: studentScore.majorName,
collegeName: studentScore.collegeName,
@@ -1091,6 +1192,7 @@ export default {
}
this.roomStudents = students;
this.syncClassOptionsFromStudents(students, this.formData.classId);
console.log('✅ 学生评分数据映射完成');
@@ -2372,6 +2474,20 @@ export default {
return;
}
if (!this.formData.classId) {
uni.showToast({
title: '请选择归属班级(取自当前寝室在住学生)',
icon: 'none',
});
return;
}
const matchedClass = this.classOptions.find(
(item) => String(item.classId) === String(this.formData.classId),
);
if (matchedClass) {
this.formData.className = matchedClass.className;
}
this.submitLoading = true;
this.syncStudentScoreFromViolations();
@@ -2387,8 +2503,11 @@ export default {
studentId: student.studentId,
studentName: student.studentName,
studentNo: student.studentNo,
classId: student.classId,
className: student.className,
majorId: student.majorId,
majorName: student.majorName,
collegeId: student.collegeId,
collegeName: student.collegeName,
bedId: student.bedId,
bedCode: student.bedCode,