|
|
@@ -0,0 +1,432 @@
|
|
|
+<template>
|
|
|
+ <view class="dorm-application-tab">
|
|
|
+ <!-- 搜索区域 -->
|
|
|
+ <view class="search-container">
|
|
|
+ <u-search
|
|
|
+ v-model="searchKeyword"
|
|
|
+ placeholder="请输入姓名或学号"
|
|
|
+ :show-action="true"
|
|
|
+ action-text="搜索"
|
|
|
+ :animation="true"
|
|
|
+ @search="handleQuery"
|
|
|
+ @custom="handleQuery"
|
|
|
+ @clear="handleClear"
|
|
|
+ ></u-search>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 加载状态 -->
|
|
|
+ <u-loading-page
|
|
|
+ :loading="loading && dataList.length === 0"
|
|
|
+ loading-text="加载中..."
|
|
|
+ ></u-loading-page>
|
|
|
+
|
|
|
+ <!-- 列表内容 -->
|
|
|
+ <view v-if="!loading || dataList.length > 0" class="content-wrapper">
|
|
|
+ <!-- 空状态 -->
|
|
|
+ <view v-if="dataList.length === 0" class="empty-container">
|
|
|
+ <u-empty text="暂无调宿/退宿申请记录" mode="data"></u-empty>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 列表 -->
|
|
|
+ <scroll-view
|
|
|
+ v-else
|
|
|
+ scroll-y
|
|
|
+ class="scroll-view"
|
|
|
+ :lower-threshold="50"
|
|
|
+ @scrolltolower="handleLoadMore"
|
|
|
+ >
|
|
|
+ <view class="list-container">
|
|
|
+ <view
|
|
|
+ v-for="(item, index) in dataList"
|
|
|
+ :key="item.id || index"
|
|
|
+ class="list-card"
|
|
|
+ >
|
|
|
+ <!-- 卡片头部 -->
|
|
|
+ <view class="card-header">
|
|
|
+ <view class="student-info">
|
|
|
+ <text class="student-name">{{ item.studentName || '-' }}</text>
|
|
|
+ <text class="student-no">{{ item.studentNo || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <u-tag
|
|
|
+ :text="getApplicationTypeText(item.applicationType)"
|
|
|
+ :type="getApplicationTypeTagType(item.applicationType)"
|
|
|
+ size="mini"
|
|
|
+ ></u-tag>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 卡片内容 -->
|
|
|
+ <view class="card-content">
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">学院:</text>
|
|
|
+ <text class="value">{{ item.collegeName || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">专业:</text>
|
|
|
+ <text class="value">{{ item.majorName || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">班级:</text>
|
|
|
+ <text class="value">{{ item.className || '-' }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">当前宿舍:</text>
|
|
|
+ <text class="value">
|
|
|
+ {{ item.currentBuildingName }}{{ item.currentRoomNo
|
|
|
+ }}{{ item.currentBedNo }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view v-if="item.applicationType === '1'" class="info-row">
|
|
|
+ <text class="label">目标宿舍:</text>
|
|
|
+ <text class="value">
|
|
|
+ {{ item.targetBuildingName }}{{ item.targetRoomNo
|
|
|
+ }}{{ item.targetBedNo }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">审批状态:</text>
|
|
|
+ <u-tag
|
|
|
+ :text="getApprovalStatusText(item.applicationStatus)"
|
|
|
+ :type="getApprovalStatusTagType(item.applicationStatus)"
|
|
|
+ size="mini"
|
|
|
+ ></u-tag>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">申请时间:</text>
|
|
|
+ <text class="value">{{ formatTime(item.applyTime) }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <view class="card-actions">
|
|
|
+ <u-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ plain
|
|
|
+ @click="handleViewApproval(item)"
|
|
|
+ >
|
|
|
+ <u-icon
|
|
|
+ name="list"
|
|
|
+ size="16"
|
|
|
+ color="#fff"
|
|
|
+ style="margin-right: 4px"
|
|
|
+ ></u-icon>
|
|
|
+ 审批记录
|
|
|
+ </u-button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 加载更多提示 -->
|
|
|
+ <view class="load-more-wrapper">
|
|
|
+ <u-loadmore :status="loadMoreStatus" :load-text="loadMoreText" />
|
|
|
+ </view>
|
|
|
+ </scroll-view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 审批记录组件 -->
|
|
|
+ <approval-record ref="approvalRecordRef"></approval-record>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { request } from '@/common/request.js';
|
|
|
+import { getDict, getDictLabel, getDictTagType } from '@/common/dict.js';
|
|
|
+import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'DormApplicationTab',
|
|
|
+ components: {
|
|
|
+ ApprovalRecord,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ dataList: [],
|
|
|
+ total: 0,
|
|
|
+ searchKeyword: '', // 搜索关键字(姓名或学号)
|
|
|
+
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ studentName: '',
|
|
|
+ studentNo: '',
|
|
|
+ },
|
|
|
+
|
|
|
+ // 加载更多状态
|
|
|
+ loadMoreStatus: 'loadmore',
|
|
|
+ loadMoreText: {
|
|
|
+ loadmore: '点击加载更多',
|
|
|
+ loading: '正在加载...',
|
|
|
+ nomore: '没有更多了',
|
|
|
+ },
|
|
|
+
|
|
|
+ // 字典数据
|
|
|
+ dictApplicationType: [],
|
|
|
+ dictApprovalStatus: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ async created() {
|
|
|
+ await this.loadDictData();
|
|
|
+ await this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ // 加载字典数据
|
|
|
+ async loadDictData() {
|
|
|
+ try {
|
|
|
+ this.dictApplicationType = await getDict('dorm_application_type');
|
|
|
+ this.dictApprovalStatus = await getDict('student_leave_approval_status');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载字典数据失败:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取列表数据
|
|
|
+ async getList() {
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ // 根据搜索关键字设置查询参数
|
|
|
+ const params = {
|
|
|
+ ...this.queryParams,
|
|
|
+ studentName: this.searchKeyword,
|
|
|
+ studentNo: this.searchKeyword,
|
|
|
+ };
|
|
|
+
|
|
|
+ const res = await request({
|
|
|
+ url: '/studentDynamics/dormApplicationList',
|
|
|
+ method: 'GET',
|
|
|
+ params: params,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ if (this.queryParams.pageNum === 1) {
|
|
|
+ this.dataList = res.rows || [];
|
|
|
+ } else {
|
|
|
+ this.dataList = [...this.dataList, ...(res.rows || [])];
|
|
|
+ }
|
|
|
+ this.total = res.total || 0;
|
|
|
+
|
|
|
+ // 更新加载更多状态
|
|
|
+ if (this.dataList.length >= this.total) {
|
|
|
+ this.loadMoreStatus = 'nomore';
|
|
|
+ } else {
|
|
|
+ this.loadMoreStatus = 'loadmore';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res?.msg || '获取数据失败',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取调宿退宿申请列表失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取数据失败',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 加载更多
|
|
|
+ handleLoadMore() {
|
|
|
+ if (this.loadMoreStatus === 'nomore' || this.loadMoreStatus === 'loading') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loadMoreStatus = 'loading';
|
|
|
+ this.queryParams.pageNum++;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 搜索操作
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.dataList = [];
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 清空搜索
|
|
|
+ handleClear() {
|
|
|
+ this.searchKeyword = '';
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 格式化时间
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取申请类型文本
|
|
|
+ getApplicationTypeText(value) {
|
|
|
+ return getDictLabel(this.dictApplicationType, value) || '-';
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取申请类型标签类型
|
|
|
+ getApplicationTypeTagType(value) {
|
|
|
+ const fallbackMap = {
|
|
|
+ 1: 'primary', // 调宿
|
|
|
+ 2: 'warning', // 退宿
|
|
|
+ };
|
|
|
+ return getDictTagType(this.dictApplicationType, value, fallbackMap);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取审批状态文本
|
|
|
+ getApprovalStatusText(value) {
|
|
|
+ return getDictLabel(this.dictApprovalStatus, value) || '-';
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取审批状态标签类型
|
|
|
+ getApprovalStatusTagType(value) {
|
|
|
+ const fallbackMap = {
|
|
|
+ 0: 'warning', // 待审批
|
|
|
+ 1: 'success', // 已通过
|
|
|
+ 2: 'error', // 已驳回
|
|
|
+ };
|
|
|
+ return getDictTagType(this.dictApprovalStatus, value, fallbackMap);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 查看审批记录
|
|
|
+ handleViewApproval(item) {
|
|
|
+ console.log('查看审批记录:', item);
|
|
|
+ if (!item.id) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '数据异常,无法查看审批记录',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 调用审批记录组件,传入业务ID
|
|
|
+ this.$refs.approvalRecordRef.init(item.id);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.dorm-application-tab {
|
|
|
+ background-color: #f5f6fa;
|
|
|
+ min-height: calc(100vh - 176rpx);
|
|
|
+}
|
|
|
+
|
|
|
+.search-container {
|
|
|
+ padding: 20rpx;
|
|
|
+ background-color: #fff;
|
|
|
+ box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
|
|
+}
|
|
|
+
|
|
|
+.content-wrapper {
|
|
|
+ padding: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-container {
|
|
|
+ padding: 100rpx 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.scroll-view {
|
|
|
+ height: calc(100vh - 176rpx - 88rpx); // 减去搜索栏高度
|
|
|
+}
|
|
|
+
|
|
|
+.list-container {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 20rpx;
|
|
|
+ padding-bottom: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.list-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;
|
|
|
+}
|
|
|
+
|
|
|
+.student-info {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 16rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.student-name {
|
|
|
+ font-size: 32rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #303133;
|
|
|
+}
|
|
|
+
|
|
|
+.student-no {
|
|
|
+ font-size: 26rpx;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+.card-content {
|
|
|
+ padding: 24rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.info-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.label {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #606266;
|
|
|
+ min-width: 140rpx;
|
|
|
+ margin-right: 16rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.value {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #303133;
|
|
|
+ flex: 1;
|
|
|
+ word-break: break-all;
|
|
|
+}
|
|
|
+
|
|
|
+.card-actions {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ align-items: center;
|
|
|
+ padding: 20rpx 24rpx;
|
|
|
+ border-top: 1px solid #f0f0f0;
|
|
|
+}
|
|
|
+
|
|
|
+.load-more-wrapper {
|
|
|
+ padding: 20rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
+// uview组件样式调整
|
|
|
+::v-deep .u-search {
|
|
|
+ background-color: #f5f6fa;
|
|
|
+}
|
|
|
+</style>
|