对接培训记录导入
This commit is contained in:
parent
3eadd103e6
commit
54deac0735
|
@ -48,7 +48,7 @@ export function importVehicleModelTraining(data) {
|
|||
return request({
|
||||
url: '/admin/vehicleModelTraining/import',
|
||||
method: 'post',
|
||||
data
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-position="top">
|
||||
<div class="applyFormContainer">
|
||||
<el-form-item prop="employeeNumber">
|
||||
<el-upload class="upload-demo" drag
|
||||
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" multiple>
|
||||
<el-upload class="upload-demo" drag action="#" :http-request="requestDocUpload"
|
||||
:file-list="docUploadList" :before-upload="beforeDocUpload"
|
||||
:on-remove="removeDocUpload">
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">
|
||||
将文件拖曳至此区域,或 <em>点击上传</em>
|
||||
</div>
|
||||
<div class="el-upload__text">
|
||||
支持扩展名:rar.zip.doc.docx.pdf.jpg...
|
||||
</div>
|
||||
支持扩展名:.xlsx
|
||||
</div>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
@ -37,7 +38,7 @@
|
|||
|
||||
<div class="submitTool">
|
||||
<el-button class="cancelApplyBtn" @click="handleCancel">取消</el-button>
|
||||
<el-button class="submitApplyBtn" @click="handleSubmit">提交</el-button>
|
||||
<!-- <el-button class="submitApplyBtn" @click="handleSubmit">提交</el-button> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -46,6 +47,7 @@
|
|||
import { reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { importVehicleModelTraining } from "@/api/qualification/vehicleTrain"
|
||||
|
||||
const router = useRouter()
|
||||
const levelList = ref([
|
||||
|
@ -60,6 +62,49 @@ const data = reactive({
|
|||
},
|
||||
})
|
||||
const { ruleForm, rules } = toRefs(data)
|
||||
|
||||
const docUploadList = ref([])
|
||||
// const baseUrl = import.meta.env.VITE_APP_BASE_API // 上传的图片服务器地址
|
||||
|
||||
// 自定义上传文件资料
|
||||
const requestDocUpload = (file) => {
|
||||
var formData = new FormData();
|
||||
formData.append('file', file.file);
|
||||
importVehicleModelTraining(formData).then(res => {
|
||||
console.log('导入结果', res)
|
||||
if (res.code == 200) {
|
||||
// docUploadList.value.push({ name: res.originalFilenames, url: baseUrl + res.fileNames })
|
||||
// ruleForm.value.docList.push({ fileName: res.originalFilenames, relatedData: res.fileNames, fileType: res.suffix, fileSuffix: res.suffix, fileSize: res.size })
|
||||
}
|
||||
// const cur = loadingNotifys.value.findIndex(item => item.name === file.file.name)
|
||||
// loadingNotifys.value[cur].notify.close()
|
||||
// proxy.$modal.msgSuccess(file.file.name + ' 上传成功')
|
||||
// loadingNotifys.value.splice(cur, 1)
|
||||
})
|
||||
}
|
||||
//自定义上传文件资料校验
|
||||
const beforeDocUpload = (file) => {
|
||||
console.log('fsdfsa', file)
|
||||
const type = [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
];
|
||||
const isXlsx = type.includes(file.type);
|
||||
// 检验文件格式
|
||||
if (!isXlsx) {
|
||||
proxy.$modal.msgError("文件格式错误,请上传.xlsx后缀的文件。");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 移除已上传文件列表
|
||||
const removeDocUpload = (file, fileList) => {
|
||||
docUploadList.value = docUploadList.value.filter(
|
||||
item => item.name != file.name
|
||||
);
|
||||
// this.form.docList = this.form.docList.filter(
|
||||
// item => item.fileName != file.name
|
||||
// );
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
proxy.resetForm("ruleFormRef")
|
||||
router.push({
|
||||
|
@ -258,9 +303,8 @@ const handleSubmit = () => {
|
|||
background: #0090ff05;
|
||||
padding: 140px 450px !important;
|
||||
}
|
||||
|
||||
|
||||
.el-form-item__error {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user