From 1da082138ce384d17b93169cfe108386603e72d0 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期三, 23 七月 2025 08:49:10 +0800 Subject: [PATCH] 修改 --- src/views/work/onlineEducation/offlineEducation/components/recordDialog.vue | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 109 insertions(+), 5 deletions(-) diff --git a/src/views/work/onlineEducation/offlineEducation/components/recordDialog.vue b/src/views/work/onlineEducation/offlineEducation/components/recordDialog.vue index b887e2a..4b21526 100644 --- a/src/views/work/onlineEducation/offlineEducation/components/recordDialog.vue +++ b/src/views/work/onlineEducation/offlineEducation/components/recordDialog.vue @@ -55,7 +55,18 @@ <el-input v-model.trim="state.form.courseName" :disabled="disabled" placeholder="请输入课程名称" ></el-input> </el-form-item> <el-form-item label="培训等级:" prop="level" > - <el-input v-model.trim="state.form.level" :disabled="disabled" placeholder="请输入培训等级" ></el-input> + <el-select + v-model="state.form.level" + style="width: 100%" + > + <el-option + v-for="item in state.levelList" + :key="item.id" + :label="item.name" + :value="item.id" + /> + </el-select> +<!-- <el-input v-model.trim="state.form.level" :disabled="disabled" placeholder="请输入培训等级" ></el-input>--> </el-form-item> <el-form-item label="要求课时(分):" prop="period" > <el-input v-model.trim="state.form.period" :disabled="disabled" placeholder="请输入要求课时(分)" ></el-input> @@ -71,6 +82,14 @@ <el-radio :label="0">不合格</el-radio> <el-radio :label="1">合格</el-radio> </el-radio-group> + </el-form-item> + <el-form-item label="培训记录:" prop="passed" > + <el-upload accept=".jpg,.jpeg,.png,.doc,.docx,.pdf,.xls,xlsx,ppt,pptx" style="width: 100%" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile)" :on-exceed="showTip" v-model:file-list="state.fileList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles)" > + <el-button type="primary">点击上传</el-button> +<!-- <template #tip>--> +<!-- <div class="el-upload__tip">尺寸小于5M,最多可上传1份</div>--> +<!-- </template>--> + </el-upload> </el-form-item> </el-form> <template #footer v-if="state.title !='查看'"> @@ -95,6 +114,8 @@ import {addStudent, checkStuIdNo, checkStuPhone, editStudent} from "@/api/onlineEducation/student"; import {addRecord, editRecord} from "@/api/onlineEducation/examRecord"; import {getCompany} from "@/api/onlineEducation/company"; +import {delPic} from "@/api/onlineEducation/banner"; +import {getToken} from "@/utils/auth"; const emit = defineEmits(["getList"]); const dialogVisible = ref(false) @@ -121,7 +142,8 @@ passed: 0, studentName: '', courseName: '', - companyId: null + companyId: null, + files: [] }, formRules:{ @@ -144,6 +166,20 @@ companyPageNum: 1, // 当前页码 companyPageSize: 10, // 每页显示的数量 hasMoreItems: null, // 是否还有更多选项 + levelList: [ + { + id: 1, + name: '公司级' + }, + { + id: 2, + name: '部门级' + }, + ], + uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile', + header: { + Authorization: getToken() + }, }) onMounted(() => { @@ -173,7 +209,16 @@ if( type === 'view'){ disabled.value = true; } - state.form = value + + state.form = JSON.parse(JSON.stringify(value)) + state.form.studentId = value.student.id + state.form.studentName = value.student.name + state.fileList = value.files.map(i => { + return { + name: i.fileName, + path: i.filePath + } + }) // state.form.studentName = value.company.name; console.log("ba",state.form) } @@ -197,8 +242,7 @@ ElMessage.warning(res.message) } }else if(state.title == '编辑'){ - const {id, name, phone, sex, companyId, empno, post, duty, idNo} = state.form - const data = {id, name, phone, sex, companyId, empno, post, duty, idNo} + const {...data} = state.form const res = await editRecord(data) if(res.code == 200){ ElMessage.success(res.message) @@ -245,6 +289,7 @@ state.stuPageNum = 1; state.stuPageSize = 10; state.studentList = []; + state.fileList = [] superRef.value.clearValidate(); superRef.value.resetFields() dialogVisible.value = false; @@ -311,7 +356,66 @@ ElMessage.warning(res.message) } } +const handleAvatarSuccess = (response,uploadFile) => { + if(response.code == 200){ + state.form.files = state.fileList.map(item => { + return { + fileName: item.response ? item.response?.data.originName: item.name, + filePath: item.response ? item.response?.data.path: item.path + } + }) + }else{ + // state.fileList = [] + // state.form.files = [] + ElMessage({ + type: 'warning', + message: res.message + }) + } +} +const showTip =()=>{ + ElMessage({ + type: 'warning', + message: '超出文件上传数量' + }); +} +const picSize = async (rawFile) => { + if(rawFile.size / 1024 / 1024 > 5){ + ElMessage({ + type: 'warning', + message: '文件大小不能超过5M' + }); + return false + } +}; +const handleRemove = async (file, uploadFiles) => { + state.form.files = state.fileList.map(item => { + return { + fileName: item.response ? item.response?.data.originName: item.name, + filePath: item.response ? item.response?.data.path: item.path + } + }) + // let path = state.form.filePath; + // await delPic({path: path}).then(res => { + // if(res.code == 200){ + // // ElMessage({ + // // type: 'success', + // // message: '文件已删除' + // // }) + // state.form.fileName = '' + // state.form.filePath = '' + // }else{ + // ElMessage({ + // type: 'warning', + // message: res.message + // }) + // } + // }).catch(() => { + // state.form.fileName = '' + // state.form.filePath = '' + // }); +} defineExpose({ -- Gitblit v1.9.2