From bc78f7d2ddb4f524b6b1a610d4189439c7312523 Mon Sep 17 00:00:00 2001 From: "962704835@qq.com" Date: Thu, 18 Dec 2025 23:42:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E5=AE=BF=E7=94=B3=E8=AF=B7-=E4=BD=90?= =?UTF-8?q?=E8=AF=81=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0=E4=B8=8E=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/affix.js | 11 + .../outsideAccommodation/applicationForm.vue | 231 +++++++++++------- .../dormitory/outsideAccommodation/index.vue | 33 ++- 3 files changed, 184 insertions(+), 91 deletions(-) diff --git a/api/affix.js b/api/affix.js index 62fbd44..a0f3c20 100644 --- a/api/affix.js +++ b/api/affix.js @@ -7,4 +7,15 @@ export function getAffixItems(data) { 'method': 'post', data: data }) +} + +// 删除附件 +export function deleteAffix (fileId){ + return request( + { + url:'/affix/delete', + method:'post', + data:{id: fileId} + } + ) } \ No newline at end of file diff --git a/pages/dormitory/outsideAccommodation/applicationForm.vue b/pages/dormitory/outsideAccommodation/applicationForm.vue index 2e8e34d..8b68a82 100644 --- a/pages/dormitory/outsideAccommodation/applicationForm.vue +++ b/pages/dormitory/outsideAccommodation/applicationForm.vue @@ -11,6 +11,7 @@ + 基本信息 @@ -44,19 +45,21 @@ 基本信息 + + class="form-input" :disabled="isDetailMode"> - + + + @change="handleGenderChange" :disabled="isDetailMode"> {{ form.gender ? getGenderText(form.gender) : '请选择性别' }} @@ -65,7 +68,7 @@ - + {{ form.birthDate || '请选择出生年月' }} @@ -74,28 +77,28 @@ - + - + - + - + + type="number" :disabled="isDetailMode"> @@ -112,22 +115,24 @@ + rows="5" :disabled="isDetailMode"> - - + + + 上传文件 - {{ file.attachmentName }} - + {{ file.attachmentName || file.trueName }} + + + @@ -137,8 +142,9 @@ - - + + {{ areaText || '请选择省/市/区' }} @@ -165,19 +172,19 @@ + class="form-input" :disabled="isDetailMode"> + class="form-input" :disabled="isDetailMode"> + type="number" :disabled="isDetailMode"> @@ -188,8 +195,9 @@ 家长意见及联系方式 + + v-model="form.parentOpinion" @change="handleParentOpinionChange" :disabled="isDetailMode"> {{ form.parentOpinion ? getParentOpinionText(form.parentOpinion) : '请选择家长意见' }} @@ -198,12 +206,13 @@ - + + + 上传图片 - - + + 只能上传jpg/png文件,且不超过2M @@ -211,13 +220,14 @@ + type="number" :disabled="isDetailMode"> - + + {{ parentAreaText || '请选择省/市/区' }} @@ -226,7 +236,7 @@ + class="form-input" :disabled="isDetailMode"> @@ -248,8 +258,9 @@ - - + + {{ form.promiseDate || '请选择签署日期' }} @@ -269,7 +281,8 @@ - + + @@ -286,12 +299,11 @@ - - - + + - + 申请须知 @@ -310,10 +322,11 @@ - + - - + + + {{ currentSignType === 'student' ? '电子签名' : '承诺签名' }} @@ -329,8 +342,9 @@ - - + + + @@ -349,8 +363,9 @@ - - + + + @@ -394,10 +409,15 @@ checkPic } from "@/utils/checkPic.js"; import uploadFile from "@/plugins/upload.js"; + import { + getAffixItems, deleteAffix + } from "@/api/affix.js"; export default { name: 'OutsideAccommodationApply', data() { return { + // 新增:是否为详情查看模式(核心控制变量) + isDetailMode: false, // 激活的标签页索引 activeTab: 0, // 表单滚动高度 @@ -434,6 +454,8 @@ majorName: '', className: '', studentNo: '', + deptName: '', + teacherName: '', idCard: '', studentPhone: '', accommodationFeeStatus: 1, @@ -442,7 +464,7 @@ outsideAddress: '', emergencyContact: '', emergencyPhone: '', - parentOpinion: '1', // 默认同意 + parentOpinion: 1, // 默认同意 parentPhone: '', parentAddress: '', // 家长省市区拼接结果 parentDetailAddress: '', @@ -455,7 +477,8 @@ status: 0, id: '', applyNo: '', - endDate: '' + endDate: '', + promiseContent: '' }, // 下拉选项 genderOptions: [{ @@ -469,17 +492,16 @@ ], parentOpinionOptions: [{ text: '同意外宿', - value: '1' + value: 1 }, { text: '不同意外宿', - value: '0' + value: 0 } ], // 文件上传相关 affixFiles: [], parentSignFiles: "", - reasonFileList: [], // 页面状态 currentId: null, loading: false, @@ -490,6 +512,9 @@ } }, onLoad(options) { + // 新增:判断是否为详情模式(核心逻辑) + this.isDetailMode = options.type === 'detail'; + // 1. 初始化省市区数据 this.initAreaData(); // 2. 初始化页面高度 @@ -504,8 +529,11 @@ } }, onReady() { - // 1. 打开申请须知弹窗 - this.openNoticePopup(); + // 新增:详情模式下不打开申请须知弹窗 + if (!this.isDetailMode) { + // 1. 打开申请须知弹窗 + this.openNoticePopup(); + } }, methods: { // ========== 省市区选择器核心方法 ========== @@ -872,7 +900,7 @@ const fileInfo = { applyId: this.form.id || '', attachmentName: file.name, - attachmentUrl: file.savePath, // 本地路径 + attachmentUrl: result.savePath, // 本地路径 serverUrl: result.savePath || '', // 服务器返回的文件路径 fileId: result.id || '', // 服务器返回的文件ID fileSize: file.size, @@ -928,22 +956,25 @@ deleteAffixFile(index) { const deletedFile = this.affixFiles[index]; this.affixFiles.splice(index, 1); - this.form.affixId = this.affixFiles.length ? 'uploaded' : ''; - - deleteOutsideAccommodationAttachmentNameAndStuName({ - attachmentName: deletedFile.name, - studentName: this.form.studentName - }).then(() => { - uni.showToast({ - title: '删除成功', - icon: 'success' + // this.form.affixId = this.affixFiles.length ? 'uploaded' : ''; + let fileId = deletedFile.id || deletedFile.fileId + deleteAffix(fileId).then(() => { + deleteOutsideAccommodationAttachmentNameAndStuName({ + attachmentName: deletedFile.trueName || deletedFile.attachmentName, + studentName: this.form.studentName + }).then(() => { + uni.showToast({ + title: '删除成功', + icon: 'success' + }); + }).catch(() => { + uni.showToast({ + title: '删除失败', + icon: 'none' + }); }); - }).catch(() => { - uni.showToast({ - title: '删除失败', - icon: 'none' - }); - }); + }) + }, // 家长附件上传 handleUpload() { @@ -995,6 +1026,8 @@ // url: this.baseUrl + this.form.parentSignAttachment // }]; // } + + this.getAffixs(this.form.affixId) this.loading = false; }).catch(() => { @@ -1018,8 +1051,10 @@ this.form.studentId = res.data.stuId; this.form.studentNo = res.data.stuNo; this.form.majorName = res.data.majorName; + this.form.deptName = res.data.deptName this.form.className = res.data.className; this.form.idCard = res.data.idCard; + this.form.teacherName = res.data.teacherName this.form.studentPhone = res.data.stuPhone; this.form.birthDate = res.data.birthday || ''; @@ -1084,6 +1119,7 @@ }); }); }, + // 获取学生宿舍 getStuDom() { listStudent({ stuNo: this.form.studentNo, @@ -1105,6 +1141,14 @@ }); }); }, + // 获取上传的附件数据 + getAffixs(affix) { + getAffixItems({ + affixId: affix + }).then(file => { + this.affixFiles = file.data; + }) + }, submitForm(status) { // 定义英文字段名和中文提示的映射关系 const fieldMap = { @@ -1184,6 +1228,12 @@ } this.form.endDate = this.getOutsideDefaultEndTime(); + this.form.promiseContent = ` +

1.自觉遵守国家法律、法规;

+

2.自觉遵守学生行为规范和学校的规章制度,遵守社会公德;

+

3.自觉遵守外宿住址所在社区的有关管理规定;

+

4.本人申请外宿,属个人自愿行为,外宿期间发生的一切事故,造成本人、他人或集体的人身、财产损害的,学校不负责任。

+ ` const submitForm = { ...this.form, status: this.form.status != 0 ? this.form.status : status @@ -1195,11 +1245,11 @@ addOutsideAccommodationApply(submitForm); requestPromise.then((response) => { - if (this.reasonFileList.length > 0) { - this.reasonFileList.forEach(item => { + if (this.affixFiles.length > 0) { + this.affixFiles.forEach(item => { item.applyId = this.form.id || response.data.id; }); - batchAddOutsideAccommodationAttachment(this.reasonFileList); + batchAddOutsideAccommodationAttachment(this.affixFiles); } uni.showToast({ @@ -1251,7 +1301,6 @@ this.affixFiles = []; this.parentSignFiles = ""; - this.reasonFileList = []; this.areaText = ''; this.parentAreaText = ''; @@ -1548,6 +1597,12 @@ .area-picker:active { border-color: #409EFF; } + + /* 新增:禁用状态样式(可选) */ + .area-picker.disabled { + opacity: 0.7; + pointer-events: none; + } .picker-text { flex: 1; @@ -1633,8 +1688,8 @@ color: #ef4444; border: 1px solid #fee2e2; border-radius: 6rpx; - padding: 8rpx 16rpx; - font-size: 24rpx; + /* padding: 8rpx 16rpx; */ + /* font-size: 24rpx; */ } /* 上传提示 */ @@ -1909,46 +1964,58 @@ padding: 12rpx 24rpx; font-size: 26rpx; } + /* 添加过渡样式 */ - .popup-fade-enter-active, .popup-fade-leave-active { + .popup-fade-enter-active, + .popup-fade-leave-active { transition: opacity 0.3s ease; } - .popup-fade-enter-from, .popup-fade-leave-to { + + .popup-fade-enter-from, + .popup-fade-leave-to { opacity: 0; } - - .popup-slide-enter-active, .popup-slide-leave-active { + + .popup-slide-enter-active, + .popup-slide-leave-active { transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); } + .popup-slide-enter-from { opacity: 0; transform: translate(-50%, -50%) translateY(50px); } + .popup-slide-leave-to { opacity: 0; transform: translate(-50%, -50%) translateY(50px); } + /* 蒙层渐入渐出动画 */ - .popup-fade-enter-active, + .popup-fade-enter-active, .popup-fade-leave-active { transition: opacity 0.3s ease; } + /* 进入前/离开后状态(透明) */ - .popup-fade-enter, + .popup-fade-enter, .popup-fade-leave-to { opacity: 0; } - + /* 弹窗滑入滑出动画(核心) */ - .popup-slide-enter-active, + .popup-slide-enter-active, .popup-slide-leave-active { - transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* 缓动曲线更丝滑 */ + transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); + /* 缓动曲线更丝滑 */ } + /* 进入前状态:透明 + 向下偏移50px */ .popup-slide-enter { opacity: 0; transform: translate(-50%, -50%) translateY(50px); } + /* 离开后状态:透明 + 向下偏移50px */ .popup-slide-leave-to { opacity: 0; diff --git a/pages/dormitory/outsideAccommodation/index.vue b/pages/dormitory/outsideAccommodation/index.vue index c0cfb4d..5b17360 100644 --- a/pages/dormitory/outsideAccommodation/index.vue +++ b/pages/dormitory/outsideAccommodation/index.vue @@ -166,10 +166,17 @@ - - 查看详情 - + + + 修改 + + + + + 查看详情 + +
@@ -243,7 +250,7 @@ return this.validDataList.length > 0; } }, - onLoad() { + onShow() { this.getUser(); }, methods: { @@ -438,7 +445,7 @@ }, /** 查看详情 */ - detail(item) { + detail(item, text) { const id = this.getSafeValue(item, 'id'); if (!id) { uni.showToast({ @@ -447,9 +454,15 @@ }); return; } - uni.navigateTo({ - url: `/pages/dormitory/outsideAccommodation/applicationForm?id=${id}` - }); + if (text == '详情') { + uni.navigateTo({ + url: `/pages/dormitory/outsideAccommodation/applicationForm?id=${id}&type=detail` + }); + } else { + uni.navigateTo({ + url: `/pages/dormitory/outsideAccommodation/applicationForm?id=${id}` + }); + } }, // 跳转添加页面 addOutsideAccommodation() { @@ -895,6 +908,8 @@ .detail-btn { color: #409eff; font-size: 26rpx; + padding: 0 20rpx; + margin-left: 20rpx; } /* 适配小屏幕 */