diff --git a/src/api/index1.js b/src/api/index1.js index d4bec231..85d83749 100644 --- a/src/api/index1.js +++ b/src/api/index1.js @@ -181,4 +181,7 @@ export const batchImportScore = (obj) => export const getImportStatus = (uuid) => http.get('/admin/student/getImportStatus', { params: { uuid: uuid } }) //导出作业 -// export const exportHomeWork=(obj)=>http.get('admin/student/exportHomeWork',{params:obj}) \ No newline at end of file +// export const exportHomeWork=(obj)=>http.get('admin/student/exportHomeWork',{params:obj}) + +// 面授课导入学员 +export const FaceTeachImportStudent = (obj) => http.post('/admin/student/importStudent', obj, {headers: { "Content-Type": "multipart/form-data" }}) \ No newline at end of file diff --git a/src/components/drawers/AddLevelImportStu.vue b/src/components/drawers/AddLevelImportStu.vue index 833b416a..24d6ff3f 100644 --- a/src/components/drawers/AddLevelImportStu.vue +++ b/src/components/drawers/AddLevelImportStu.vue @@ -27,10 +27,15 @@

@@ -45,26 +50,36 @@

支持扩展名:.xls/.xlsx
-->
-
+ +
京东方商业模型.xls
-
正在上传
+
上传失败
+
{{uploadpercent==100?"上传成功":"正在上传"}}
-
+
-
55%
-
暂停
-
取消
+
{{uploadpercent==-1?0:uploadpercent}}%
+
删除
+
+
+
+
下载失败数据
-
+
+
+
{{succNum}}条数据导入成功,{{errNum}}条数据导入失败
+
+ +
- - + +
+ +
+ +
@@ -136,13 +155,38 @@ export default { type: Boolean, default: false, }, + courseId: { + type: String, + default: "", + }, + courseType: { + type: String, + default: "", + }, }, setup(props, ctx) { const state = reactive({ - template: - process.env.VUE_APP_TEMPLATE + "导入学员模版-1672998102528.xlsx", + template: process.env.VUE_APP_TEMPLATE + "导入学员模版-1672998102528.xlsx", + importStudent: process.env.VUE_APP_BASE_API + "admin/student/importStudent", + uploadpercent: -1, + uploadErr: false, //上传失败 + addLoading: false, + fileList: [], + succNum: 0, //成功数据数 + errNum: 0, //失败数据数 + downloadErrUrl: '', + showBottomBar: false, // 显示底部成功条数和失败条数 + locationHref: location.href.indexOf('http://') !== -1 ? 'http://111.231.196.214:12016/' : location.href.slice(0, location.href.indexOf('/m')) + '/upload/' }); const closeDrawer = () => { + state.fileList = []; + state.uploadpercent = -1; + state.addLoading = false; + state.uploadErr = false; //上传失败 + state.showBottomBar = false; + state.succNum = 0; + state.errNum = 0; + state.downloadErrUrl = ""; ctx.emit("update:AddImpStuvisible", false); }; @@ -151,27 +195,81 @@ export default { }; //上传文件 const handleChange = (info) => { - console.log("info", info, props.id); + console.log("info", info); + state.addLoading = true; + state.uploadErr = false; + state.uploadpercent = parseInt(info.file.percent); + console.log("我是文件上传的进度---------->", info.file.percent); const status = info.file.status; if (status !== "uploading") { console.log(info.file, info.fileList); } if (status === "done") { - const formData = new FormData(); - formData.append("uploadFile", info.file); - // formData.append("offcoursePlanId", props.id); - console.log(info.file); - api.batchImportScore(props.id, formData).then((res) => { - // if (res.data.code === 200) { - // console.log('上传成功') - // } - console.log("上传成绩", res); - }); - message.success(`${info.file.name} file uploaded successfully.`); + console.log('上传成功返回的UUID', info.file.response.data) + console.log('上传成功返回的UUID----->', info) + console.log("我是导入学员接口传递的参数", { + uploadFile: info.file.originFileObj, + targetId: props.courseId, + type: 3 + }) + let i = 0; + let timer = setInterval(() => { + let uid = info.file.response.data; + api + .getImportStatus(uid) + .then((res) => { + console.log("查询导入状态", res); + if (res.data.code === 200) { + if (res.data.data.status !== "START") { + i++; + if (i === 1) { + message.destroy(); + message.success(`${info.file.name}上传成功`); + state.showBottomBar = true; + state.addLoading = false; + } + state.succNum = res.data.data.successNum; + state.errNum = res.data.data.failedNum; + state.downloadErrUrl = res.data.data.url; + clearInterval(timer); + } + } + }) + .catch((err) => { + clearInterval(timer); + state.showBottomBar = true; + state.addLoading = false; + console.log("查询导入状态失败", err); + }); + }, 500); } else if (status === "error") { - message.error(`${info.file.name} file upload failed.`); + state.addLoading = false; + state.uploadErr = true; + message.error(`${info.file.name}上传失败`); } + }; + + // 下载失败数据 + const downloadEeeorData = () => { + console.log(state.locationHref + state.downloadErrUrl) + if(state.downloadErrUrl!==""){ + window.open(state.locationHref + state.downloadErrUrl) + } + } + + //删除 + const removeUpload = () => { + state.showBottomBar = false; + state.fileList = []; + state.uploadpercent = -1; + state.addLoading = false; + state.uploadErr = false; //上传失败 + state.succNum = 0; + state.errNum = 0; + state.downloadErrUrl = ""; + }; + return { ...toRefs(state), afterVisibleChange, @@ -179,6 +277,8 @@ export default { // change, handleChange, BATCH_IMPORT_SCORE, + downloadEeeorData, + removeUpload }; }, }; diff --git a/src/components/drawers/project/ProjectFaceStu.vue b/src/components/drawers/project/ProjectFaceStu.vue index 518f1f12..35257f02 100644 --- a/src/components/drawers/project/ProjectFaceStu.vue +++ b/src/components/drawers/project/ProjectFaceStu.vue @@ -180,7 +180,7 @@ - +