This commit is contained in:
guochunsi
2026-01-22 16:30:20 +08:00
parent e38420c2b3
commit 01397747c1
4 changed files with 135 additions and 227 deletions

View File

@@ -1039,7 +1039,7 @@ const edit = (id: string) => {
const majorChange = (id: string) => { const majorChange = (id: string) => {
nextTick(() => { nextTick(() => {
majorChangeRef.value?.init(id) majorChangeRef.value?.init(id)
}) })
} }
// 退学 // 退学

View File

@@ -18,8 +18,8 @@
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="confirm"><span>确认</span></el-button>
<el-button @click="visible = false">取消</el-button> <el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="confirm">确认</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>

View File

@@ -25,14 +25,14 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="姓名" prop="name"> <el-form-item label="姓名" prop="name">
<el-input type="text" v-model="dataForm.name" :disabled="type != 1"></el-input> <el-input type="text" v-model="dataForm.name" disabled></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="身份证号" prop="idNumber"> <el-form-item label="身份证号" prop="idNumber">
<el-input type="text" v-model="dataForm.idNumber" :disabled="type != 2"></el-input> <el-input type="text" v-model="dataForm.idNumber" disabled></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -46,7 +46,7 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="原录取专业" prop="confirmedMajor"> <el-form-item label="原录取专业" prop="confirmedMajor">
<el-select v-model="dataForm.confirmedMajor" filterable clearable placeholder="" :disabled="type != 1" @change="changeM(dataForm.confirmedMajor)"> <el-select v-model="dataForm.confirmedMajor" filterable clearable placeholder="" disabled>
<el-option <el-option
v-for="item in planMajorList" v-for="item in planMajorList"
:key="item.majorCode" :key="item.majorCode"
@@ -75,12 +75,12 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="学费" prop="feeTuition"> <el-form-item label="学费" prop="feeTuition">
<el-input-number v-model="dataForm.feeTuition" controls-position="right" :min="0" :max="999999" :step-strictly="true" :disabled="type == 2"></el-input-number> <el-input-number v-model="dataForm.feeTuition" controls-position="right" :min="0" :max="999999" :step-strictly="true" disabled></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="代办费" prop="feeAgency"> <el-form-item label="代办费" prop="feeAgency">
<el-input-number v-model="dataForm.feeAgency" controls-position="right" :min="0" :max="999999" :step-strictly="true" :disabled="type == 2"></el-input-number> <el-input-number v-model="dataForm.feeAgency" controls-position="right" :min="0" :max="999999" :step-strictly="true" disabled></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -93,8 +93,8 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="审核备注" prop="auditRemarks"> <el-form-item label="备注" prop="auditRemarks">
<el-input type="textarea" v-model="dataForm.auditRemarks" placeholder="审核备注" :rows="2"></el-input> <el-input type="textarea" v-model="dataForm.auditRemarks" placeholder="备注" :rows="2"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -110,17 +110,18 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, nextTick } from 'vue' import { ref, reactive, nextTick } from 'vue'
import { ElNotification } from 'element-plus' import { useMessageBox, useMessage } from '/@/hooks/message'
import { useMessageBox } from '/@/hooks/message'
import { getObj, changeMajor } from '/@/api/recruit/recruitstudentsignup' import { getObj, changeMajor } from '/@/api/recruit/recruitstudentsignup'
import { getList } from "/@/api/recruit/recruitstudentplangroup" import { getList } from "/@/api/recruit/recruitstudentplangroup"
import { listByEdu } from "/@/api/recruit/recruitstudentplan" import { listByEdu } from "/@/api/recruit/recruitstudentplan"
import { getDicts } from "/@/api/admin/dict" import { getDicts } from "/@/api/admin/dict"
import { list as scoreList } from "/@/api/recruit/recruitstudentplancorrectscoreconfig" import { list as scoreList } from "/@/api/recruit/recruitstudentplancorrectscoreconfig"
import { getStatusConfig, AUDIT_STATUS_LIST } from '/@/config/global'
const auditStatusList = AUDIT_STATUS_LIST
// 消息提示 hooks // 消息提示 hooks
const messageBox = useMessageBox() const messageBox = useMessageBox()
const message = useMessage()
// Emits // Emits
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'refreshDataList'): void (e: 'refreshDataList'): void
@@ -133,11 +134,9 @@ const dataFormRef = ref()
const visible = ref(false) const visible = ref(false)
const canSubmit = ref(false) const canSubmit = ref(false)
const title = ref("") const title = ref("")
const type = ref<number | null>(null)
const planList = ref<any[]>([]) const planList = ref<any[]>([])
const planMajorList = ref<any[]>([]) const planMajorList = ref<any[]>([])
const agencyFeeList = ref<any[]>([]) const agencyFeeList = ref<any[]>([])
const tuitionFeeList = ref<any[]>([])
const schoolCodeList = ref<any[]>([]) const schoolCodeList = ref<any[]>([])
const dataForm = reactive({ const dataForm = reactive({
@@ -210,7 +209,7 @@ const dataForm = reactive({
feeAgency: 0 feeAgency: 0
}) })
const dataRule = { const dataRule = reactive({
groupId: [ groupId: [
{ required: true, message: '招生计划不能为空', trigger: 'change' } { required: true, message: '招生计划不能为空', trigger: 'change' }
], ],
@@ -229,7 +228,7 @@ const dataRule = {
newConfirmedMajor: [ newConfirmedMajor: [
{ required: true, message: '新录取专业不能为空', trigger: 'change' } { required: true, message: '新录取专业不能为空', trigger: 'change' }
] ]
} })
// 初始化数据 // 初始化数据
const initData = () => { const initData = () => {
@@ -238,56 +237,45 @@ const initData = () => {
}) })
} }
// 改变新专业 // 根据新专业和文化程度更新学费
const changeCM = (id: string) => { const updateTuitionByNewMajorAndEducation = () => {
if (id) { if (!dataForm.newConfirmedMajor || !dataForm.degreeOfEducation) {
let flag = false return
planMajorList.value.forEach((e: any) => { }
if (dataForm.newConfirmedMajor == e.majorCode && e.isZd == "1" && String(dataForm.degreeOfEducation) == "1") {
flag = true // 查找选中的新专业
} const selectedMajor = planMajorList.value.find((major: any) => major.majorCode === dataForm.newConfirmedMajor)
}) if (!selectedMajor) {
if (String(dataForm.degreeOfEducation) == "1") { return
dataForm.feeTuition = 0 }
tuitionFeeList.value.forEach((e: any) => {
if (e.label == "0" && flag) { // 根据文化程度选择对应的学费字段
dataForm.feeTuition = e.value // '1' = 初中 -> czFee
} // '2' = 高中 -> gzFee
}) // '3' = 技职校 -> jzxFee
} if (dataForm.degreeOfEducation === '1' && selectedMajor.czFee !== undefined && selectedMajor.czFee !== null) {
dataForm.feeTuition = selectedMajor.czFee
} else if (dataForm.degreeOfEducation === '2' && selectedMajor.gzFee !== undefined && selectedMajor.gzFee !== null) {
dataForm.feeTuition = selectedMajor.gzFee
} else if (dataForm.degreeOfEducation === '3' && selectedMajor.jzxFee !== undefined && selectedMajor.jzxFee !== null) {
dataForm.feeTuition = selectedMajor.jzxFee
} }
} }
// 改变专业 // 改变专业
const changeM = (id: string) => { const changeCM = (id: string) => {
if (id) { if (id) {
dataForm.confirmedMajor = id // 从新专业中获取学费
// 是初中生并且是中德班 updateTuitionByNewMajorAndEducation()
let flag = false
planMajorList.value.forEach((e: any) => {
if (dataForm.confirmedMajor == e.majorCode && e.isZd == "1" && String(dataForm.degreeOfEducation) == "1") {
flag = true
}
})
if (String(dataForm.degreeOfEducation) == "1") {
dataForm.feeTuition = 0
tuitionFeeList.value.forEach((e: any) => {
if (e.label == "0" && flag) {
dataForm.feeTuition = e.value
}
})
}
} }
} }
// 表单提交 // 表单提交
const dataFormSubmit = async () => { const dataFormSubmit = async () => {
const titleText = "确认调整录取专业么?" const titleText = "确认调整录取专业么?"
if (dataForm.confirmedMajor == dataForm.newConfirmedMajor) { if (dataForm.confirmedMajor == dataForm.newConfirmedMajor) {
ElNotification.error({ message.error('新专业不能和原专业相同')
title: '错误',
message: '新专业不能和原专业相同'
})
return return
} }
try { try {
@@ -297,10 +285,7 @@ const dataFormSubmit = async () => {
canSubmit.value = false canSubmit.value = false
if (dataForm.id) { if (dataForm.id) {
changeMajor(dataForm).then(() => { changeMajor(dataForm).then(() => {
ElNotification.success({ message.success('操作成功')
title: '成功',
message: '操作成功'
})
visible.value = false visible.value = false
emit('refreshDataList') emit('refreshDataList')
}).catch(() => { }).catch(() => {
@@ -316,7 +301,7 @@ const dataFormSubmit = async () => {
// 初始化方法 // 初始化方法
const init = (id: string | null) => { const init = (id: string | null) => {
dataForm.id = id || null dataForm.id = id || ""
visible.value = true visible.value = true
canSubmit.value = true canSubmit.value = true
initData() initData()
@@ -326,48 +311,43 @@ const init = (id: string | null) => {
// 获取数据字典代办费 // 获取数据字典代办费
getDicts('agency_fee').then((res: any) => { getDicts('agency_fee').then((res: any) => {
agencyFeeList.value = res.data agencyFeeList.value = res.data
// 获取数据字典学费 getObj(dataForm.id).then((response: any) => {
getDicts('tuition_fee').then((res: any) => { Object.assign(dataForm, response.data)
tuitionFeeList.value = res.data title.value = dataForm.serialNumber
getObj(dataForm.id).then((response: any) => { // 获取文化程度对应的专业
Object.assign(dataForm, response.data) planMajorList.value = []
title.value = dataForm.serialNumber
// 获取文化程度对应的专业
planMajorList.value = []
agencyFeeList.value.forEach((e: any) => { agencyFeeList.value.forEach((e: any) => {
if (String(dataForm.degreeOfEducation) == String(e.label)) { if (String(dataForm.degreeOfEducation) == String(e.label)) {
dataForm.feeAgency = e.value dataForm.feeAgency = e.value
} }
}) })
tuitionFeeList.value.forEach((e: any) => { listByEdu({ groupId: dataForm.groupId, degreeOfEducation: dataForm.degreeOfEducation }).then((e: any) => {
if (String(dataForm.degreeOfEducation) == String(e.label) && (String(dataForm.degreeOfEducation) != "1")) { planMajorList.value = e.data
dataForm.feeTuition = e.value // 加载专业列表后,如果已有新专业,更新学费
} if (dataForm.newConfirmedMajor) {
}) updateTuitionByNewMajorAndEducation()
listByEdu({ groupId: dataForm.groupId, degreeOfEducation: dataForm.degreeOfEducation }).then((e: any) => { }
planMajorList.value = e.data
})
// 获取招生计划下的学校和分数线 // 获取招生计划下的学校和分数线
scoreList({ groupId: dataForm.groupId }).then((data: any) => { scoreList({ groupId: dataForm.groupId }).then((data: any) => {
schoolCodeList.value = data.data schoolCodeList.value = data.data
}) })
if ("1" == dataForm.degreeOfEducation) { const educationPrefixMap: Record<string, string> = {
title.value = "C" + title.value '1': 'C', // 初中
} else if ("2" == dataForm.degreeOfEducation) { '2': 'G', // 高中
title.value = "G" + title.value '3': 'J' // 技职校
} else if ("3" == dataForm.degreeOfEducation) { }
title.value = "J" + title.value const prefix = educationPrefixMap[String(dataForm.degreeOfEducation)]
if (prefix) {
title.value = prefix + title.value
}
// 从字典数据获取录取状态标签
const auditStatusConfig = getStatusConfig(auditStatusList, dataForm.auditStatus)
if (auditStatusConfig && auditStatusConfig.label) {
title.value = auditStatusConfig.label + " " + title.value
} }
if ("-20" == dataForm.auditStatus) {
title.value = "未录取 " + title.value
} else if ("0" == dataForm.auditStatus) {
title.value = "待审核 " + title.value
} else if ("20" == dataForm.auditStatus) {
title.value = "已录取 " + title.value
}
}) })
}) })
}) })

View File

@@ -4,8 +4,8 @@
:close-on-click-modal="false" :close-on-click-modal="false"
v-model="visible" v-model="visible"
append-to-body append-to-body
width="900px"> width="70%">
<el-form :model="dataForm" :rules="dataRule" ref="dataFormRef" @keyup.enter="dataFormSubmit" <el-form :model="dataForm" :rules="dataRule" ref="dataFormRef" @keyup.enter="() => dataFormSubmit('1')"
label-width="100px"> label-width="100px">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
@@ -43,7 +43,7 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="6">
<el-form-item label="成绩单" prop="scorePhoto"> <el-form-item label="成绩单" prop="scorePhoto">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
@@ -56,13 +56,13 @@
:http-request="httpRequest" :http-request="httpRequest"
:on-success="uploadSuccess"> :on-success="uploadSuccess">
<div v-if="dataForm.scorePhoto" class="avatar-wrapper"> <div v-if="dataForm.scorePhoto" class="avatar-wrapper">
<img :src="dataForm.scorePhoto" class="avatar"/> <img :src="baseUrl + dataForm.scorePhoto" class="avatar"/>
</div> </div>
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="6">
<el-form-item label="毕业证" prop="graPic"> <el-form-item label="毕业证" prop="graPic">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
@@ -75,13 +75,13 @@
:http-request="httpRequest" :http-request="httpRequest"
:on-success="upload2Success"> :on-success="upload2Success">
<div v-if="dataForm.graPic" class="avatar-wrapper"> <div v-if="dataForm.graPic" class="avatar-wrapper">
<img :src="dataForm.graPic" class="avatar"/> <img :src="baseUrl + dataForm.graPic" class="avatar"/>
</div> </div>
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="6">
<el-form-item label="在常营业执照" prop="yyPic"> <el-form-item label="在常营业执照" prop="yyPic">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
@@ -94,16 +94,14 @@
:http-request="httpRequest" :http-request="httpRequest"
:on-success="upload3Success"> :on-success="upload3Success">
<div v-if="dataForm.yyPic" class="avatar-wrapper"> <div v-if="dataForm.yyPic" class="avatar-wrapper">
<img :src="dataForm.yyPic" class="avatar" @click="handlePictureCardPreview({ url: dataForm.yyPic })" /> <img :src="baseUrl + dataForm.yyPic" class="avatar"/>
</div> </div>
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> <el-col :span="6">
<el-row> <el-form-item label="在常社保证明" prop="sbPic">
<el-col :span="8">
<el-form-item label="在常就业社保证明" prop="sbPic">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
class="avatar-uploader" class="avatar-uploader"
@@ -115,13 +113,16 @@
:http-request="httpRequest" :http-request="httpRequest"
:on-success="upload5Success"> :on-success="upload5Success">
<div v-if="dataForm.sbPic" class="avatar-wrapper"> <div v-if="dataForm.sbPic" class="avatar-wrapper">
<img :src="dataForm.sbPic" class="avatar"/> <img :src="baseUrl + dataForm.sbPic" class="avatar"/>
</div> </div>
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> </el-row>
<el-row>
<el-col >
<el-form-item label="在常租赁合同/房产证明" prop="housePic"> <el-form-item label="在常租赁合同/房产证明" prop="housePic">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
@@ -141,7 +142,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col>
<el-form-item label="户口本" prop="householdPic"> <el-form-item label="户口本" prop="householdPic">
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
@@ -173,8 +174,8 @@
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="visible = false">取消</el-button> <el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit('1')" v-auth="'recruit_recruitstudentsignup_edit'" v-if="canSubmit">保存</el-button> <el-button type="primary" @click="dataFormSubmit('1')" v-auth="'recruit_recruitstudentsignup_edit'" v-if="canSubmit">保存</el-button>
<el-button type="success" plain @click="dataFormSubmit('2')" v-auth="'signup_material_exam'" v-if="canSubmit">通过</el-button> <el-button type="success" icon="CircleCheck" @click="dataFormSubmit('2')" v-auth="'signup_material_exam'" v-if="canSubmit">通过</el-button>
<el-button type="danger" plain @click="dataFormSubmit('3')" v-auth="'signup_material_exam'" v-if="canSubmit">驳回</el-button> <el-button type="danger" icon="CircleClose" @click="dataFormSubmit('3')" v-auth="'signup_material_exam'" v-if="canSubmit">驳回</el-button>
</div> </div>
</template> </template>
@@ -186,7 +187,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, nextTick, computed, onMounted } from 'vue' import { ref, reactive, nextTick, computed, onMounted } from 'vue'
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useUserInfo } from '/@/stores/userInfo' import { useUserInfo } from '/@/stores/userInfo'
import { useMessage } from '/@/hooks/message' import { useMessage } from '/@/hooks/message'
@@ -204,7 +205,8 @@ const message = useMessage()
// 使用 Pinia store // 使用 Pinia store
const userInfoStore = useUserInfo() const userInfoStore = useUserInfo()
const { userInfos } = storeToRefs(userInfoStore) const { userInfos } = storeToRefs(userInfoStore)
const uploadUrl = import.meta.env.VITE_API_URL + '/recruit/file/uploadAttachment' const baseUrl = import.meta.env.VITE_API_URL
const uploadUrl = baseUrl + '/recruit/file/uploadAttachment'
// 创建权限对象 // 创建权限对象
const permissions = computed(() => { const permissions = computed(() => {
@@ -240,15 +242,6 @@ const type = ref<number | null>(null)
const contactNameList = ref<any[]>([]) const contactNameList = ref<any[]>([])
const planList = ref<any[]>([]) const planList = ref<any[]>([])
const form = reactive({
attachment: '',
graPic: "",
yyPic: "",
housePic: "",
sbPic: "",
hkPic: ""
})
const houseList = ref<any[]>([]) const houseList = ref<any[]>([])
const hkPicList = ref<any[]>([]) const hkPicList = ref<any[]>([])
@@ -261,69 +254,18 @@ const dataForm = reactive({
zlshRemark: "", zlshRemark: "",
groupId: "", groupId: "",
name: "", name: "",
oldName: "", contactName: "",
gender: "",
nationality: "",
degreeOfEducation: "",
isLeagueMember: "",
schoolOfGraduation: "",
isAccommodation: "",
examRegistrationNumbers: "",
isMinimumLivingSecurity: "",
score: "",
postcode: "",
residenceType: "",
correctedScore: "",
placeScore: "",
schoolFrom: "",
idNumber: "",
residenceProvince: "",
residenceCity: "",
residenceArea: "",
residenceDetail: "",
homeAddressProvince: "",
homeAddressCity: "",
homeAddressArea: "",
homeAddressDetail: "",
parentName: "",
parentTelOne: "",
parentTelTwo: "",
selfTel: "",
wishMajorOne: "",
wishMajorTwo: "",
wishMajorThree: "",
confirmedMajor: "",
sevenMajor: "",
sixMajor: "",
fiveMajor: "",
fourMajor: "",
threeMajor: "",
twoMajor: "",
feeContribute: 0,
scorePhoto: "", scorePhoto: "",
graPic: "", graPic: "",
yyPic: "", yyPic: "",
housePic: "", housePic: "",
sbPic: "", sbPic: "",
contactName: "",
oldSerialNumber: "",
colorDiscrimination: "",
nutrition: "",
height: "",
weight: "",
pastMedicalHistory: "",
eyesightLeft: "",
eyesightRight: "",
correctEyesightLeft: "",
correctEyesightRight: "",
remarks: "",
auditRemarks: "",
serialNumber: "",
auditStatus: "",
schoolCode: "",
newConfirmedMajor: "",
householdPic: "", householdPic: "",
zlsh: "" zlsh: "",
// 以下字段从后端获取,用于显示和判断
serialNumber: "",
degreeOfEducation: "",
auditStatus: ""
}) })
const dataRule = { const dataRule = {
@@ -372,17 +314,6 @@ const handlePictureCardPreview = (file: any) => {
dialogUploadVisible.value = true dialogUploadVisible.value = true
} }
// 删除 avatar 模式的图片
const handleRemoveAvatar = (field: string) => {
const formObj = form as any
const dataFormObj = dataForm as any
if (field === 'scorePhoto') {
formObj.attachment = ""
} else {
formObj[field] = ""
}
dataFormObj[field] = ""
}
// 通用移除文件处理(多文件) // 通用移除文件处理(多文件)
const handleRemoveMultiple = (fileList: any[], dataFormField: string) => { const handleRemoveMultiple = (fileList: any[], dataFormField: string) => {
@@ -393,7 +324,8 @@ const handleRemoveMultiple = (fileList: any[], dataFormField: string) => {
fileList.forEach((e: any) => { fileList.forEach((e: any) => {
if (e.url != file.url) { if (e.url != file.url) {
arr.push(e) arr.push(e)
strArr.push(e.url) // 保存时使用原始路径
strArr.push(e.originalUrl || (e.url.startsWith(baseUrl) ? e.url.substring(baseUrl.length) : e.url))
} }
}) })
fileList.splice(0, fileList.length, ...arr) fileList.splice(0, fileList.length, ...arr)
@@ -437,39 +369,38 @@ const httpRequest = (options: any) => {
} }
// 通用上传成功回调(单文件 - avatar模式 // 通用上传成功回调(单文件 - avatar模式
const handleUploadSuccess = (formField: string, dataFormField: string) => { const handleUploadSuccess = (dataFormField: string) => {
return (res: any) => { return (res: any) => {
const fileUrl = res.data.fileUrl const fileUrl = res.data.fileUrl
const formObj = form as any
const dataFormObj = dataForm as any const dataFormObj = dataForm as any
formObj[formField] = fileUrl
dataFormObj[dataFormField] = fileUrl dataFormObj[dataFormField] = fileUrl
} }
} }
// 通用上传成功回调(多文件) // 通用上传成功回调(多文件)
const handleUploadSuccessMultiple = (fileList: any[], formField: string, dataFormField: string) => { const handleUploadSuccessMultiple = (fileList: any[], dataFormField: string) => {
return (res: any) => { return (res: any) => {
const fileUrl = res.data.fileUrl const fileUrl = res.data.fileUrl // 后端返回的原始路径
const formObj = form as any
const dataFormObj = dataForm as any const dataFormObj = dataForm as any
formObj[formField] = fileUrl // 添加到文件列表,显示时添加 baseUrl 前缀,同时保存原始路径用于提交
fileList.push({ url: fileUrl }) fileList.push({ url: baseUrl + fileUrl, name: '', originalUrl: fileUrl })
// 保存时使用原始路径
const arr: string[] = [] const arr: string[] = []
fileList.forEach((e: any) => { fileList.forEach((e: any) => {
arr.push(e.url) // 优先使用保存的原始路径,如果没有则从 url 中提取
arr.push(e.originalUrl || (e.url.startsWith(baseUrl) ? e.url.substring(baseUrl.length) : e.url))
}) })
dataFormObj[dataFormField] = arr.join(",") dataFormObj[dataFormField] = arr.join(",")
} }
} }
// 上传成功回调 // 上传成功回调
const uploadSuccess = handleUploadSuccess('attachment', 'scorePhoto') const uploadSuccess = handleUploadSuccess('scorePhoto')
const upload2Success = handleUploadSuccess('graPic', 'graPic') const upload2Success = handleUploadSuccess('graPic')
const upload3Success = handleUploadSuccess('yyPic', 'yyPic') const upload3Success = handleUploadSuccess('yyPic')
const upload4Success = handleUploadSuccessMultiple(houseList.value, 'housePic', 'housePic') const upload4Success = handleUploadSuccessMultiple(houseList.value, 'housePic')
const upload5Success = handleUploadSuccess('sbPic', 'sbPic') const upload5Success = handleUploadSuccess('sbPic')
const upload6Success = handleUploadSuccessMultiple(hkPicList.value, 'hkPic', 'householdPic') const upload6Success = handleUploadSuccessMultiple(hkPicList.value, 'householdPic')
// 初始化数据 // 初始化数据
const initData = () => { const initData = () => {
@@ -516,16 +447,18 @@ const init = (id: string | null) => {
title.value = dataForm.serialNumber title.value = dataForm.serialNumber
// avatar 模式直接使用 dataForm 中的字段,不需要 fileList // avatar 模式直接使用 dataForm 中的字段,不需要 fileList
// 多图上传需要初始化列表 // 多图上传需要初始化列表
if (dataForm.housePic != '') { if (dataForm.housePic && dataForm.housePic != '') {
const arr = dataForm.housePic.split(",") const arr = dataForm.housePic.split(",").filter((item: string) => item && item.trim())
arr.forEach((e: string) => { arr.forEach((e: string) => {
houseList.value.push({ url: e }) // 保存原始路径,显示时添加 baseUrl 前缀
houseList.value.push({ url: baseUrl + e, name: '', originalUrl: e })
}) })
} }
if (dataForm.householdPic != '') { if (dataForm.householdPic && dataForm.householdPic != '') {
const arr2 = dataForm.householdPic.split(",") const arr2 = dataForm.householdPic.split(",").filter((item: string) => item && item.trim())
arr2.forEach((e: string) => { arr2.forEach((e: string) => {
hkPicList.value.push({ url: e }) // 保存原始路径,显示时添加 baseUrl 前缀
hkPicList.value.push({ url: baseUrl + e, name: '', originalUrl: e })
}) })
} }
@@ -564,6 +497,7 @@ defineExpose({
} }
} }
.avatar-uploader { .avatar-uploader {
:deep(.el-upload) { :deep(.el-upload) {
border: 1px dashed var(--el-border-color); border: 1px dashed var(--el-border-color);
@@ -572,9 +506,8 @@ defineExpose({
position: relative; position: relative;
overflow: hidden; overflow: hidden;
transition: var(--el-transition-duration-fast); transition: var(--el-transition-duration-fast);
width: 178px; width: 148px;
height: 178px; height: 148px;
&:hover { &:hover {
border-color: var(--el-color-primary); border-color: var(--el-color-primary);
} }
@@ -584,26 +517,21 @@ defineExpose({
.avatar-uploader-icon { .avatar-uploader-icon {
font-size: 28px; font-size: 28px;
color: #8c939d; color: #8c939d;
width: 178px; width: 148px;
height: 178px; height: 148px;
line-height: 178px; line-height: 148px;
text-align: center; text-align: center;
} }
.avatar-wrapper { .avatar-wrapper {
width: 178px; width: 148px;
height: 178px; height: 148px;
.avatar { .avatar {
width: 178px; width: 148px;
height: 178px; height: 148px;
display: block; display: block;
object-fit: cover; object-fit: cover;
cursor: pointer; cursor: pointer;
} }
} }
.dialog-footer {
text-align: right;
}
</style> </style>