diff --git a/src/api/qualification/vehicleTrain.js b/src/api/qualification/vehicleTrain.js index 36e58bb..4176274 100644 --- a/src/api/qualification/vehicleTrain.js +++ b/src/api/qualification/vehicleTrain.js @@ -48,7 +48,10 @@ export function importVehicleModelTraining(data) { return request({ url: '/admin/vehicleModelTraining/import', method: 'post', - params: data + data, + headers: { + 'Content-Type': 'multipart/form-data' + } }) } diff --git a/src/views/qualification/vehicleTrain/importForm.vue b/src/views/qualification/vehicleTrain/importForm.vue index 4af77d4..3e48949 100644 --- a/src/views/qualification/vehicleTrain/importForm.vue +++ b/src/views/qualification/vehicleTrain/importForm.vue @@ -37,8 +37,7 @@
- 取消 - + 取消
@@ -64,27 +63,24 @@ const data = reactive({ const { ruleForm, rules } = toRefs(data) const docUploadList = ref([]) -// const baseUrl = import.meta.env.VITE_APP_BASE_API // 上传的图片服务器地址 // 自定义上传文件资料 -const requestDocUpload = (file) => { +const requestDocUpload = (options) => { + const { file } = options var formData = new FormData(); - formData.append('file', file.file); + formData.append('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 }) + router.push({ + path: '/qualification/vehicleTrain' + }) + } else { + proxy.$modal.msgError(res.msg); } - // 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' ]; @@ -100,9 +96,6 @@ 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 = () => { @@ -110,31 +103,7 @@ const handleCancel = () => { router.push({ path: '/qualification/vehicleTrain' }) -} -const handleSubmit = () => { - proxy.$refs["ruleFormRef"].validate(valid => { - if (valid) { - router.push({ - path: '/qualification/vehicleTrain' - }) - // if (form.value.roleId != undefined) { - // form.value.menuIds = getMenuAllCheckedKeys() - // updateRole(form.value).then(response => { - // proxy.$modal.msgSuccess("修改成功") - // open.value = false - // getList() - // }) - // } else { - // form.value.menuIds = getMenuAllCheckedKeys() - // addRole(form.value).then(response => { - // proxy.$modal.msgSuccess("新增成功") - // open.value = false - // getList() - // }) - // } - } - }) -} +}