From e38420c2b3b4443eda15cb388163c787a90affb5 Mon Sep 17 00:00:00 2001
From: guochunsi <1595020186@qq.com>
Date: Thu, 22 Jan 2026 15:18:27 +0800
Subject: [PATCH] a
---
.../recruit/recruitstudentsignup/update.vue | 371 ++++++++----------
1 file changed, 164 insertions(+), 207 deletions(-)
diff --git a/src/views/recruit/recruitstudentsignup/update.vue b/src/views/recruit/recruitstudentsignup/update.vue
index 395f814..0a7359e 100644
--- a/src/views/recruit/recruitstudentsignup/update.vue
+++ b/src/views/recruit/recruitstudentsignup/update.vue
@@ -46,57 +46,57 @@
-
+
+
![]()
+
+
-
+
+
![]()
+
+
-
+
+
![]()
+
+
@@ -105,26 +105,26 @@
-
+
+
![]()
+
+
import { ref, reactive, nextTick, computed, onMounted } from 'vue'
-import { Plus } from '@element-plus/icons-vue'
-import { ElNotification } from 'element-plus'
+import { Plus, Delete } from '@element-plus/icons-vue'
import { storeToRefs } from 'pinia'
import { useUserInfo } from '/@/stores/userInfo'
+import { useMessage } from '/@/hooks/message'
import { Session } from '/@/utils/storage'
import axios from 'axios'
import { getObj, materialExam } from '/@/api/recruit/recruitstudentsignup'
import { getList } from '/@/api/recruit/recruitstudentplangroup'
import { queryAllTeacher } from '/@/api/professional/professionaluser/teacherbase'
+import { AUDIT_STATUS_LIST, getStatusConfig } from '/@/config/global'
+
+const auditStatusList = AUDIT_STATUS_LIST
+// 消息提示 hooks
+const message = useMessage()
// 使用 Pinia store
const userInfoStore = useUserInfo()
const { userInfos } = storeToRefs(userInfoStore)
+const uploadUrl = import.meta.env.VITE_API_URL + '/recruit/file/uploadAttachment'
// 创建权限对象
const permissions = computed(() => {
@@ -243,11 +249,7 @@ const form = reactive({
hkPic: ""
})
-const fileList = ref([])
-const graPicList = ref([])
-const yyPicList = ref([])
const houseList = ref([])
-const sbPicList = ref([])
const hkPicList = ref([])
const fileReader = ref(null)
@@ -348,7 +350,7 @@ const dataRule = {
// 初始化 FileReader
onMounted(() => {
if (!window.FileReader) {
- console.error('Your browser does not support FileReader API!')
+ message.error('您的浏览器不支持 FileReader API!')
} else {
fileReader.value = new FileReader()
}
@@ -358,10 +360,7 @@ onMounted(() => {
const beforeUpload = (file: File) => {
const isLt5M = file.size < 10 * 1024 * 1024
if (!isLt5M) {
- ElNotification.error({
- title: '错误',
- message: '文件大小不能超过10M'
- })
+ message.error('文件大小不能超过10M')
return false
}
return true
@@ -373,68 +372,38 @@ const handlePictureCardPreview = (file: any) => {
dialogUploadVisible.value = true
}
-// 移除文件处理
-const removeHandler = (file: any) => {
- const index = fileList.value.findIndex((item: any) => item.url === file.url)
- if (index > -1) {
- fileList.value.splice(index, 1)
+// 删除 avatar 模式的图片
+const handleRemoveAvatar = (field: string) => {
+ const formObj = form as any
+ const dataFormObj = dataForm as any
+ if (field === 'scorePhoto') {
+ formObj.attachment = ""
+ } else {
+ formObj[field] = ""
}
- form.attachment = ""
- dataForm.scorePhoto = ""
+ dataFormObj[field] = ""
}
-const remove2Handler = (file: any) => {
- const index = graPicList.value.findIndex((item: any) => item.url === file.url)
- if (index > -1) {
- graPicList.value.splice(index, 1)
+// 通用移除文件处理(多文件)
+const handleRemoveMultiple = (fileList: any[], dataFormField: string) => {
+ return (file: any) => {
+ const arr: any[] = []
+ const strArr: string[] = []
+ const dataFormObj = dataForm as any
+ fileList.forEach((e: any) => {
+ if (e.url != file.url) {
+ arr.push(e)
+ strArr.push(e.url)
+ }
+ })
+ fileList.splice(0, fileList.length, ...arr)
+ dataFormObj[dataFormField] = strArr.join(",")
}
- form.graPic = ""
- dataForm.graPic = ""
}
-const remove3Handler = (file: any) => {
- const index = yyPicList.value.findIndex((item: any) => item.url === file.url)
- if (index > -1) {
- yyPicList.value.splice(index, 1)
- }
- form.yyPic = ""
- dataForm.yyPic = ""
-}
-
-const remove4Handler = (file: any) => {
- const arr: any[] = []
- const strArr: string[] = []
- houseList.value.forEach((e: any) => {
- if (e.url != file.url) {
- arr.push(e)
- strArr.push(e.url)
- }
- })
- houseList.value = arr
- dataForm.housePic = strArr.join(",")
-}
-
-const remove5Handler = (file: any) => {
- const index = sbPicList.value.findIndex((item: any) => item.url === file.url)
- if (index > -1) {
- sbPicList.value.splice(index, 1)
- }
- form.sbPic = ""
- dataForm.sbPic = ""
-}
-
-const remove6Handler = (file: any) => {
- const arr: any[] = []
- const strArr: string[] = []
- hkPicList.value.forEach((e: any) => {
- if (e.url != file.url) {
- arr.push(e)
- strArr.push(e.url)
- }
- })
- hkPicList.value = arr
- dataForm.householdPic = strArr.join(",")
-}
+// 移除文件处理(多图上传)
+const remove4Handler = handleRemoveMultiple(houseList.value, 'housePic')
+const remove6Handler = handleRemoveMultiple(hkPicList.value, 'householdPic')
// 自定义上传请求
const httpRequest = (options: any) => {
@@ -444,8 +413,9 @@ const httpRequest = (options: any) => {
fileReader.value.onload = () => {
const base64Str = fileReader.value?.result as string
const config = {
- url: '/recruit/file/uploadAttachment',
+ url: uploadUrl,
method: 'post',
+ headers: headers.value,
data: {
base64Str: base64Str.split(',')[1]
},
@@ -466,66 +436,40 @@ const httpRequest = (options: any) => {
}
}
+// 通用上传成功回调(单文件 - avatar模式)
+const handleUploadSuccess = (formField: string, dataFormField: string) => {
+ return (res: any) => {
+ const fileUrl = res.data.fileUrl
+ const formObj = form as any
+ const dataFormObj = dataForm as any
+ formObj[formField] = fileUrl
+ dataFormObj[dataFormField] = fileUrl
+ }
+}
+
+// 通用上传成功回调(多文件)
+const handleUploadSuccessMultiple = (fileList: any[], formField: string, dataFormField: string) => {
+ return (res: any) => {
+ const fileUrl = res.data.fileUrl
+ const formObj = form as any
+ const dataFormObj = dataForm as any
+ formObj[formField] = fileUrl
+ fileList.push({ url: fileUrl })
+ const arr: string[] = []
+ fileList.forEach((e: any) => {
+ arr.push(e.url)
+ })
+ dataFormObj[dataFormField] = arr.join(",")
+ }
+}
+
// 上传成功回调
-const uploadSuccess = (res: any, file: any) => {
- form.attachment = res.data.fileUrl
- if (fileList.value.length > 0) {
- fileList.value[0] = { url: form.attachment, name: "" }
- } else {
- fileList.value.push({ url: form.attachment, name: "" })
- }
- dataForm.scorePhoto = form.attachment
-}
-
-const upload2Success = (res: any, file: any) => {
- form.graPic = res.data.fileUrl
- if (graPicList.value.length > 0) {
- graPicList.value[0] = { url: form.graPic, name: "" }
- } else {
- graPicList.value.push({ url: form.graPic, name: "" })
- }
- dataForm.graPic = form.graPic
-}
-
-const upload3Success = (res: any, file: any) => {
- form.yyPic = res.data.fileUrl
- if (yyPicList.value.length > 0) {
- yyPicList.value[0] = { url: form.yyPic, name: "" }
- } else {
- yyPicList.value.push({ url: form.yyPic, name: "" })
- }
- dataForm.yyPic = form.yyPic
-}
-
-const upload4Success = (res: any, file: any) => {
- form.housePic = res.data.fileUrl
- houseList.value.push({ url: form.housePic })
- const arr: string[] = []
- houseList.value.forEach((e: any) => {
- arr.push(e.url)
- })
- dataForm.housePic = arr.join(",")
-}
-
-const upload5Success = (res: any, file: any) => {
- form.sbPic = res.data.fileUrl
- if (sbPicList.value.length > 0) {
- sbPicList.value[0] = { url: form.sbPic, name: "" }
- } else {
- sbPicList.value.push({ url: form.sbPic, name: "" })
- }
- dataForm.sbPic = form.sbPic
-}
-
-const upload6Success = (res: any, file: any) => {
- form.hkPic = res.data.fileUrl
- hkPicList.value.push({ url: form.hkPic })
- const arr: string[] = []
- hkPicList.value.forEach((e: any) => {
- arr.push(e.url)
- })
- dataForm.householdPic = arr.join(",")
-}
+const uploadSuccess = handleUploadSuccess('attachment', 'scorePhoto')
+const upload2Success = handleUploadSuccess('graPic', 'graPic')
+const upload3Success = handleUploadSuccess('yyPic', 'yyPic')
+const upload4Success = handleUploadSuccessMultiple(houseList.value, 'housePic', 'housePic')
+const upload5Success = handleUploadSuccess('sbPic', 'sbPic')
+const upload6Success = handleUploadSuccessMultiple(hkPicList.value, 'hkPic', 'householdPic')
// 初始化数据
const initData = () => {
@@ -540,20 +484,14 @@ const initData = () => {
// 表单提交
const dataFormSubmit = (submitType: string) => {
- if (dataForm.zlshRemark == '' && submitType == '3') {
- ElNotification.error({
- title: '错误',
- message: '请填写驳回理由'
- })
+ if ((dataForm.zlshRemark == '' || !dataForm.zlshRemark) && submitType == '3') {
+ message.error('请填写驳回理由')
return
}
dataForm.zlsh = submitType
canSubmit.value = false
materialExam(dataForm).then(() => {
- ElNotification.success({
- title: '成功',
- message: '操作成功'
- })
+ message.success('操作成功')
visible.value = false
emit('refreshDataList')
}).catch(() => {
@@ -563,7 +501,7 @@ const dataFormSubmit = (submitType: string) => {
// 初始化方法
const init = (id: string | null) => {
- dataForm.id = id || null
+ dataForm.id = id || ""
visible.value = true
canSubmit.value = true
initData()
@@ -571,32 +509,19 @@ const init = (id: string | null) => {
dataFormRef.value?.resetFields()
if (dataForm.id) {
getObj(dataForm.id).then((response: any) => {
- fileList.value = []
- graPicList.value = []
- yyPicList.value = []
+ // 清空多图上传的列表
houseList.value = []
- sbPicList.value = []
hkPicList.value = []
Object.assign(dataForm, response.data)
title.value = dataForm.serialNumber
- if (dataForm.scorePhoto != '') {
- fileList.value.push({ url: dataForm.scorePhoto, name: "" })
- }
- if (dataForm.graPic != '') {
- graPicList.value.push({ url: dataForm.graPic, name: "" })
- }
- if (dataForm.yyPic != '') {
- yyPicList.value.push({ url: dataForm.yyPic, name: "" })
- }
+ // avatar 模式直接使用 dataForm 中的字段,不需要 fileList
+ // 多图上传需要初始化列表
if (dataForm.housePic != '') {
const arr = dataForm.housePic.split(",")
arr.forEach((e: string) => {
houseList.value.push({ url: e })
})
}
- if (dataForm.sbPic != '') {
- sbPicList.value.push({ url: dataForm.sbPic, name: "" })
- }
if (dataForm.householdPic != '') {
const arr2 = dataForm.householdPic.split(",")
arr2.forEach((e: string) => {
@@ -604,21 +529,22 @@ const init = (id: string | null) => {
})
}
- if ("1" == String(dataForm.degreeOfEducation)) {
- title.value = "C" + title.value
- } else if ("2" == String(dataForm.degreeOfEducation)) {
- title.value = "G" + title.value
- } else if ("3" == String(dataForm.degreeOfEducation)) {
- title.value = "J" + title.value
+ const educationPrefixMap: Record = {
+ '1': 'C', // 初中
+ '2': 'G', // 高中
+ '3': 'J' // 技职校
+ }
+ const prefix = educationPrefixMap[String(dataForm.degreeOfEducation)]
+ if (prefix) {
+ title.value = prefix + title.value
}
contactNameflag.value = false
- if ("-20" == String(dataForm.auditStatus)) {
- title.value = "未录取 " + title.value
- } else if ("0" == String(dataForm.auditStatus)) {
- title.value = "待审核 " + title.value
- } else if ("20" == String(dataForm.auditStatus)) {
- title.value = "已录取 " + title.value
- contactNameflag.value = true
+ const auditStatusConfig = getStatusConfig(auditStatusList, dataForm.auditStatus)
+ if (auditStatusConfig) {
+ title.value = auditStatusConfig.label + " " + title.value
+ if (auditStatusConfig.value == '20') {
+ contactNameflag.value = true
+ }
}
})
}
@@ -637,16 +563,47 @@ defineExpose({
margin-bottom:18px!important;
}
}
-.avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 100px;
- height: 100px;
- line-height: 100px;
- text-align: center;
-}
+
+ .avatar-uploader {
+ :deep(.el-upload) {
+ border: 1px dashed var(--el-border-color);
+ border-radius: 6px;
+ cursor: pointer;
+ position: relative;
+ overflow: hidden;
+ transition: var(--el-transition-duration-fast);
+ width: 178px;
+ height: 178px;
+
+ &:hover {
+ border-color: var(--el-color-primary);
+ }
+ }
+ }
-.dialog-footer {
- text-align: right;
-}
+ .avatar-uploader-icon {
+ font-size: 28px;
+ color: #8c939d;
+ width: 178px;
+ height: 178px;
+ line-height: 178px;
+ text-align: center;
+ }
+
+ .avatar-wrapper {
+ width: 178px;
+ height: 178px;
+
+ .avatar {
+ width: 178px;
+ height: 178px;
+ display: block;
+ object-fit: cover;
+ cursor: pointer;
+ }
+ }
+
+ .dialog-footer {
+ text-align: right;
+ }