把上传作证校验去掉了

This commit is contained in:
2025-12-16 00:45:23 +08:00
parent d8c9f6072a
commit 0ffbd2d804

View File

@@ -11,7 +11,7 @@
</el-alert> </el-alert>
<!-- 核心表单 --> <!-- 核心表单 -->
<el-form :model="form" :rules="formRules" ref="formRef" class="form-wrapper" v-loading="loading"> <el-form ref="formRef" v-loading="loading" :model="form" :rules="formRules" class="form-wrapper">
<!-- 基本信息卡片 --> <!-- 基本信息卡片 -->
<el-card shadow="hover" style="margin-bottom: 20px"> <el-card shadow="hover" style="margin-bottom: 20px">
<el-descriptions title="基本信息" :column="3" border label-width="120px"> <el-descriptions title="基本信息" :column="3" border label-width="120px">
@@ -33,8 +33,8 @@
<el-descriptions-item label="性别" required> <el-descriptions-item label="性别" required>
<el-form-item prop="gender" class="no-label-form-item"> <el-form-item prop="gender" class="no-label-form-item">
<el-select v-model="form.gender" placeholder="请选择性别" clearable style="width: 100%"> <el-select v-model="form.gender" placeholder="请选择性别" clearable style="width: 100%">
<el-option label="男" value="1"></el-option> <el-option label="男" value="1" />
<el-option label="女" value="0"></el-option> <el-option label="女" value="0" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-descriptions-item> </el-descriptions-item>
@@ -131,8 +131,7 @@
<!-- <img :src="baseUrl + form.studentSignature" alt="电子签名" <!-- <img :src="baseUrl + form.studentSignature" alt="电子签名"
style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" /> --> style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" /> -->
<el-image style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" <el-image style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee"
:src="baseUrl + form.studentSignature" :preview-src-list="[baseUrl + form.studentSignature]"> :src="baseUrl + form.studentSignature" :preview-src-list="[baseUrl + form.studentSignature]" />
</el-image>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
@@ -196,7 +195,7 @@
<!-- <file-upload v-model="form.parentSignAttachment" :text="`上传文件`" /> --> <!-- <file-upload v-model="form.parentSignAttachment" :text="`上传文件`" /> -->
<el-upload class="upload-demo" :action="uploadImgUrl" :on-success="handleAvatarSuccess" <el-upload class="upload-demo" :action="uploadImgUrl" :on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload" :file-list="fileList" list-type="picture"> :before-upload="beforeAvatarUpload" :file-list="fileList" list-type="picture">
<el-button size="small" type="primary"><i class='el-icon-upload2'></i>点击上传</el-button> <el-button size="small" type="primary"><i class="el-icon-upload2" />点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过2M</div> <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过2M</div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
@@ -232,7 +231,7 @@
<el-card shadow="hover" style="margin-bottom: 20px"> <el-card shadow="hover" style="margin-bottom: 20px">
<el-descriptions title="本人承诺" :column="1" border label-width="120px"> <el-descriptions title="本人承诺" :column="1" border label-width="120px">
<el-descriptions-item label="承诺内容"> <el-descriptions-item label="承诺内容">
<el-card shadow="none" class="promise-card" v-if="form.promiseContent == ''"> <el-card v-if="form.promiseContent == ''" shadow="none" class="promise-card">
<p>1. 自觉遵守国家法律法规</p> <p>1. 自觉遵守国家法律法规</p>
<p>2. 自觉遵守学生行为规范和学校的规章制度遵守社会公德</p> <p>2. 自觉遵守学生行为规范和学校的规章制度遵守社会公德</p>
<p>3. 自觉遵守外宿住址所在社区的有关管理规定</p> <p>3. 自觉遵守外宿住址所在社区的有关管理规定</p>
@@ -240,8 +239,7 @@
4. 本人申请外宿属个人自愿行为外宿期间发生的一切事故造成本人他人或集体的人身财产损害的学校不负责任 4. 本人申请外宿属个人自愿行为外宿期间发生的一切事故造成本人他人或集体的人身财产损害的学校不负责任
</p> </p>
</el-card> </el-card>
<el-card shadow="none" class="promise-card" v-else v-html="form.promiseContent"> <el-card v-else shadow="none" class="promise-card" v-html="form.promiseContent" />
</el-card>
</el-descriptions-item> </el-descriptions-item>
<!-- 承诺签名 --> <!-- 承诺签名 -->
@@ -255,8 +253,7 @@
<!-- <img :src="baseUrl + form.studentPromiseSign" alt="承诺签名" <!-- <img :src="baseUrl + form.studentPromiseSign" alt="承诺签名"
style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" /> --> style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" /> -->
<el-image style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee" <el-image style="width: 100px; height: 50px; margin-left: 10px; border: 1px solid #eee"
:src="baseUrl + form.studentPromiseSign" :preview-src-list="[baseUrl + form.studentPromiseSign]"> :src="baseUrl + form.studentPromiseSign" :preview-src-list="[baseUrl + form.studentPromiseSign]" />
</el-image>
</div> </div>
<el-form-item prop="promiseDate" class="no-label-form-item date-item"> <el-form-item prop="promiseDate" class="no-label-form-item date-item">
<el-date-picker v-model="form.promiseDate" type="date" value-format="yyyy-MM-dd" placeholder="签署日期" <el-date-picker v-model="form.promiseDate" type="date" value-format="yyyy-MM-dd" placeholder="签署日期"
@@ -274,11 +271,11 @@
<i class="el-icon-folder" /> <i class="el-icon-folder" />
保存 保存
</el-button> </el-button>
<el-button type="primary" size="medium" @click="submitForm(1)" v-if="form.status == 0"> <el-button v-if="form.status == 0" type="primary" size="medium" @click="submitForm(1)">
<i class="el-icon-check" /> <i class="el-icon-check" />
提交申请 提交申请
</el-button> </el-button>
<el-button type="default" size="medium" @click="resetForm" style="margin-left: 10px" v-if="!currentId"> <el-button v-if="!currentId" type="default" size="medium" style="margin-left: 10px" @click="resetForm">
<i class="el-icon-refresh" /> <i class="el-icon-refresh" />
重置表单 重置表单
</el-button> </el-button>
@@ -294,7 +291,7 @@
</div> </div>
<div class="sign-modal-body"> <div class="sign-modal-body">
<!-- 纯原生Canvas无任何框架包裹 --> <!-- 纯原生Canvas无任何框架包裹 -->
<canvas id="studentCanvas" width="400" height="200" style="border: 1px solid #ccc; background: #fff"></canvas> <canvas id="studentCanvas" width="400" height="200" style="border: 1px solid #ccc; background: #fff" />
</div> </div>
<div class="sign-modal-footer"> <div class="sign-modal-footer">
<button class="btn-clear" @click="clearStudentCanvas">清除</button> <button class="btn-clear" @click="clearStudentCanvas">清除</button>
@@ -311,7 +308,7 @@
<span class="close-btn" @click="closePromiseSignModal">×</span> <span class="close-btn" @click="closePromiseSignModal">×</span>
</div> </div>
<div class="sign-modal-body"> <div class="sign-modal-body">
<canvas id="promiseCanvas" width="400" height="200" style="border: 1px solid #ccc; background: #fff"></canvas> <canvas id="promiseCanvas" width="400" height="200" style="border: 1px solid #ccc; background: #fff" />
</div> </div>
<div class="sign-modal-footer"> <div class="sign-modal-footer">
<button class="btn-clear" @click="clearPromiseCanvas">清除</button> <button class="btn-clear" @click="clearPromiseCanvas">清除</button>
@@ -323,20 +320,20 @@
</template> </template>
<script> <script>
import { getOwnLog } from '@/api/dormitory/new/stuDom'
import { import {
addOutsideAccommodationApply,
getOutsideAccommodationApply,
getOwnInfo, getOwnInfo,
listStudent, listStudent,
getOutsideAccommodationApply, updateOutsideAccommodationApply
updateOutsideAccommodationApply,
addOutsideAccommodationApply
} from '@/api/dormitory/outsideAccommodation/outsideAccommodationApply' } from '@/api/dormitory/outsideAccommodation/outsideAccommodationApply'
import { batchAddOutsideAccommodationAttachment, deleteOutsideAccommodationAttachmentNameAndStuName } from "@/api/dormitory/outsideAccommodation/outsideAccommodationAttachment"; import { batchAddOutsideAccommodationAttachment, deleteOutsideAccommodationAttachmentNameAndStuName } from '@/api/dormitory/outsideAccommodation/outsideAccommodationAttachment'
import { getUserProfile } from '@/api/system/user' // 获取当前登录用户 import { getUserProfile } from '@/api/system/user'; // 获取当前登录用户
import { getOwnLog } from '@/api/dormitory/new/stuDom' import AffixIndex from '@/views/dormitory/outsideAccommodation/outsideAccommodationApply/components/affix/index'
import { import {
pcaTextArr // 省市区联动数据,纯汉字 pcaTextArr // 省市区联动数据,纯汉字
} from 'element-china-area-data' } from 'element-china-area-data'
import AffixIndex from "@/views/dormitory/outsideAccommodation/outsideAccommodationApply/components/affix/index"
export default { export default {
name: 'OutsideAccommodationApply', name: 'OutsideAccommodationApply',
@@ -411,7 +408,7 @@ export default {
promiseDate: [{ required: true, message: '请选择签署日期', trigger: 'change' }], promiseDate: [{ required: true, message: '请选择签署日期', trigger: 'change' }],
studentSignature: [{ required: true, message: '请完成电子签名', trigger: 'change' }], studentSignature: [{ required: true, message: '请完成电子签名', trigger: 'change' }],
studentPromiseSign: [{ required: true, message: '请完成承诺签名', trigger: 'change' }], studentPromiseSign: [{ required: true, message: '请完成承诺签名', trigger: 'change' }],
affixId: [{ required: true, message: '请上传佐证材料', trigger: 'blur' }], // affixId: [{ required: true, message: '请上传佐证材料', trigger: 'change' }],
parentSignAttachment: [ parentSignAttachment: [
{ {
required: true, required: true,
@@ -442,12 +439,12 @@ export default {
}, },
watch: { watch: {
// 监听路由参数变化,只要有新的 id 就更新 // 监听路由参数变化,只要有新的 id 就更新
"$route.query.id": { '$route.query.id': {
immediate: true, // 初始化时立即执行一次 immediate: true, // 初始化时立即执行一次
handler(newId, oldId) { handler(newId, oldId) {
if (newId) { if (newId) {
this.loading = true; this.loading = true
this.currentId = newId; this.currentId = newId
// 调用接口加载数据 // 调用接口加载数据
getOutsideAccommodationApply(this.currentId).then(res => { getOutsideAccommodationApply(this.currentId).then(res => {
this.form = { this.form = {
@@ -455,7 +452,7 @@ export default {
// 字符串转回数组(按后端存储的分隔符拆分),地址 // 字符串转回数组(按后端存储的分隔符拆分),地址
address: res.data.address ? res.data.address.split('/') : [], address: res.data.address ? res.data.address.split('/') : [],
parentAddress: res.data.parentAddress ? res.data.parentAddress.split('/') : [] parentAddress: res.data.parentAddress ? res.data.parentAddress.split('/') : []
}; }
const fileName = this.form.parentSignAttachment.split('/').pop() const fileName = this.form.parentSignAttachment.split('/').pop()
// 回显家长签字附件 // 回显家长签字附件
this.fileList = [{ name: fileName, url: this.baseUrl + this.form.parentSignAttachment }] this.fileList = [{ name: fileName, url: this.baseUrl + this.form.parentSignAttachment }]
@@ -464,7 +461,7 @@ export default {
}) })
} else { } else {
// 若 id 为空,可做清空处理 // 若 id 为空,可做清空处理
this.currentId = null; this.currentId = null
// 延迟执行重置,确保 formRef 已挂载 // 延迟执行重置,确保 formRef 已挂载
this.$nextTick(() => { this.$nextTick(() => {
this.resetForm() this.resetForm()
@@ -528,7 +525,7 @@ export default {
} }
} else { } else {
// 匹配记录无学年名称 // 匹配记录无学年名称
this.form.accommodationFee = `已交未知年度住宿费 暂无有效学年信息` this.form.accommodationFee = '已交未知年度住宿费 暂无有效学年信息'
} }
} else { } else {
// 无匹配roomId的记录兜底处理 // 无匹配roomId的记录兜底处理
@@ -709,9 +706,9 @@ export default {
if (valid) { if (valid) {
// 生成申请编号等逻辑不变 // 生成申请编号等逻辑不变
if (!this.form.applyNo) { if (!this.form.applyNo) {
const year = new Date().getFullYear(); const year = new Date().getFullYear()
const randomNo = Math.floor(Math.random() * 1000000).toString().padStart(6, '0'); const randomNo = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
this.form.applyNo = `WS${year}${randomNo}`; this.form.applyNo = `WS${year}${randomNo}`
} }
this.form.endDate = this.getOutsideDefaultEndTime() this.form.endDate = this.getOutsideDefaultEndTime()
this.form.promiseContent = ` this.form.promiseContent = `
@@ -725,36 +722,36 @@ export default {
address: this.form.address ? this.form.address.join('/') : '', address: this.form.address ? this.form.address.join('/') : '',
parentAddress: this.form.parentAddress ? this.form.parentAddress.join('/') : '', parentAddress: this.form.parentAddress ? this.form.parentAddress.join('/') : '',
status: this.form.status != 0 ? this.form.status : status status: this.form.status != 0 ? this.form.status : status
}; }
this.loading = true; this.loading = true
// 封装请求逻辑为Promise确保完成后再操作 // 封装请求逻辑为Promise确保完成后再操作
const requestPromise = this.form.id != null const requestPromise = this.form.id != null
? updateOutsideAccommodationApply(submitForm) ? updateOutsideAccommodationApply(submitForm)
: addOutsideAccommodationApply(submitForm); : addOutsideAccommodationApply(submitForm)
requestPromise.then((response) => { requestPromise.then((response) => {
// 附件处理逻辑不变 // 附件处理逻辑不变
if (this.reasonFileList && this.reasonFileList.length > 0) { if (this.reasonFileList && this.reasonFileList.length > 0) {
this.reasonFileList.forEach(element => { this.reasonFileList.forEach(element => {
element.applyId = this.form.id || response.data.id; element.applyId = this.form.id || response.data.id
}); })
batchAddOutsideAccommodationAttachment(this.reasonFileList); batchAddOutsideAccommodationAttachment(this.reasonFileList)
} }
this.loading = false; this.loading = false
this.$modal.msgSuccess(this.form.id ? '修改成功' : '新增成功'); this.$modal.msgSuccess(this.form.id ? '修改成功' : '新增成功')
// 延迟跳转:给后端数据落地留时间(关键!) // 延迟跳转:给后端数据落地留时间(关键!)
setTimeout(() => { setTimeout(() => {
this.goBack(); this.goBack()
}, 800); // 800ms延迟确保后端写入完成 }, 800) // 800ms延迟确保后端写入完成
}).catch(error => { }).catch(error => {
this.loading = false; this.loading = false
this.$message.error('提交失败:' + (error.msg || '服务器处理异常')); this.$message.error('提交失败:' + (error.msg || '服务器处理异常'))
// 失败时不跳转,避免用户重复操作 // 失败时不跳转,避免用户重复操作
// this.goBack(); // this.goBack();
}) })
} else { } else {
this.loading = false; this.loading = false
this.$message.error('表单填写有误,请检查!') this.$message.error('表单填写有误,请检查!')
} }
}) })
@@ -768,49 +765,47 @@ export default {
} }
this.reasonFileList = [] this.reasonFileList = []
this.fileList = [] this.fileList = []
this.form.affixId = "" this.form.affixId = ''
this.form.studentSignature = '' this.form.studentSignature = ''
this.form.studentPromiseSign = '' this.form.studentPromiseSign = ''
this.clearStudentCanvas() this.clearStudentCanvas()
this.clearPromiseCanvas() this.clearPromiseCanvas()
}, },
handleAffix(affixId) { // 处理 AffixIndex 组件回传:既支持 v-model 返回的 affixId也支持文件信息对象
this.form.affixId = affixId handleAffix(payload) {
}, if (typeof payload === 'string' || typeof payload === 'number') {
// 处理组件传递的文件信息 this.form.affixId = payload
handleAffix(fileInfo) { return
}
const fileInfo = payload
if (!fileInfo || !fileInfo.fileName || !fileInfo.filePath) { if (!fileInfo || !fileInfo.fileName || !fileInfo.filePath) {
console.warn('无效的文件信息,跳过添加') this.$message.warning('附件标识异常或文件信息缺失,请重新上传')
return // 不添加空数据 return
} }
// 构建与后端实体匹配的data对象 const data = {
let data = { applyId: this.form.id || null,
// id: null, // 主键(后端自增) attachmentName: fileInfo.fileName,
applyId: this.form.id || null, // 关联申请表ID从主表单获取 attachmentUrl: fileInfo.filePath,
attachmentName: fileInfo.fileName, // 文件名(从组件传递的信息中获取) filePath: fileInfo.filePath,
attachmentUrl: fileInfo.filePath, // 文件路径相对路径关联sys_file表 fileSize: fileInfo.originalFile?.size || 0,
fileSize: fileInfo.originalFile?.size || 0, // 若需要可从fileInfo.originalFile.size获取单位字节 fileSuffix: fileInfo.fileType,
fileSuffix: fileInfo.fileType, // 文件类型如docx、pdf processInstanceId: this.form.processInstanceId || '',
processInstanceId: this.form.processInstanceId || '', // 申请编号(从主表单获取) studentName: this.form.studentName || '',
studentName: this.form.studentName || '', // 学生姓名(从主表单获取) studentNo: this.form.studentNo || ''
studentNo: this.form.studentNo || '' // 学号(从主表单获取)
} }
// 避免重复添加根据filePath去重
const isDuplicate = this.reasonFileList.some((item) => item.filePath === data.filePath) const isDuplicate = this.reasonFileList.some((item) => item.filePath === data.filePath)
if (!isDuplicate) { if (isDuplicate) {
this.reasonFileList.push(data)
console.log('附件添加成功:', this.reasonFileList)
} else {
this.$message.warning('该文件已添加,请勿重复上传') this.$message.warning('该文件已添加,请勿重复上传')
return
} }
this.reasonFileList.push(data)
}, },
// 处理子组件传递的删除文件事件 // 处理子组件传递的删除文件事件
handleDeleteFile(fileName) { handleDeleteFile(fileName) {
// 接收文件名后,可执行后续逻辑,删除在数据库的数据 // 接收文件名后,可执行后续逻辑,删除在数据库的数据
if (fileName) { if (fileName) {
deleteOutsideAccommodationAttachmentNameAndStuName({ attachmentName: fileName, studentName: this.form.studentName }).then(res => { deleteOutsideAccommodationAttachmentNameAndStuName({ attachmentName: fileName, studentName: this.form.studentName }).then(res => {
this.$message.success(`成功删除文件:${fileName}`); this.$message.success(`成功删除文件:${fileName}`)
}) })
} }
}, },
@@ -819,15 +814,15 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
// 如果Affix组件有ref比如ref="affixComponent"主动调用clearData // 如果Affix组件有ref比如ref="affixComponent"主动调用clearData
if (this.$refs.affixComponent) { if (this.$refs.affixComponent) {
this.$refs.affixComponent.clearData(); this.$refs.affixComponent.clearData()
} }
// 2. 优化退出逻辑先关闭tab再返回避免重复操作 // 2. 优化退出逻辑先关闭tab再返回避免重复操作
this.$tab.closePage().then(() => { this.$tab.closePage().then(() => {
// 仅当需要返回上一页时执行(根据业务场景选择) // 仅当需要返回上一页时执行(根据业务场景选择)
// this.$router.back(); // this.$router.back();
}); })
}); })
}, },
// 保存学生签名 // 保存学生签名
saveStudentSignature() { saveStudentSignature() {
@@ -957,30 +952,30 @@ export default {
} }
}, },
beforeAvatarUpload(file) { beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg' || 'image/png'; const isJPG = file.type === 'image/jpeg' || 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) { if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG、PNG 格式!'); this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
} }
if (!isLt2M) { if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!'); this.$message.error('上传头像图片大小不能超过 2MB!')
} }
return isJPG && isLt2M; return isJPG && isLt2M
}, },
/** /**
* 生成外宿默认结束时间次年8月31日 * 生成外宿默认结束时间次年8月31日
* @returns {String} 格式化日期yyyy-MM-dd * @returns {String} 格式化日期yyyy-MM-dd
*/ */
getOutsideDefaultEndTime() { getOutsideDefaultEndTime() {
const now = new Date(); const now = new Date()
const currentYear = now.getFullYear(); const currentYear = now.getFullYear()
// 计算次年(当前年+1 // 计算次年(当前年+1
const nextYear = currentYear + 1; const nextYear = currentYear + 1
// 8月对应的索引是70=1月1=2月...7=8月 // 8月对应的索引是70=1月1=2月...7=8月
const endDate = new Date(nextYear, 7, 31); // 次年8月31日 const endDate = new Date(nextYear, 7, 31) // 次年8月31日
// 格式化为 yyyy-MM-dd适配 el-date-picker 的 value-format // 格式化为 yyyy-MM-dd适配 el-date-picker 的 value-format
return this.formatDate(endDate); return this.formatDate(endDate)
}, },
/** /**
@@ -989,10 +984,10 @@ export default {
* @returns {String} yyyy-MM-dd * @returns {String} yyyy-MM-dd
*/ */
formatDate(date) { formatDate(date) {
const year = date.getFullYear(); const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份补零 const month = String(date.getMonth() + 1).padStart(2, '0') // 月份补零
const day = String(date.getDate()).padStart(2, '0'); // 日期补零 const day = String(date.getDate()).padStart(2, '0') // 日期补零
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`
} }
} }
} }