mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-10 11:26:45 +08:00
feat:增加项目-面授课-学员-导入学员
This commit is contained in:
@@ -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})
|
||||
// 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" }})
|
||||
@@ -27,10 +27,15 @@
|
||||
<div style="height: 176px; margin-bottom: 20px">
|
||||
<a-upload-dragger
|
||||
v-model:fileList="fileList"
|
||||
:action="BATCH_IMPORT_SCORE + '?offcoursePlanId=' + id"
|
||||
name="file"
|
||||
:multiple="true"
|
||||
:action="importStudent"
|
||||
name="uploadFile"
|
||||
:multiple="false"
|
||||
@change="handleChange"
|
||||
:data="{
|
||||
targetId: Number(courseId),
|
||||
type: 3
|
||||
}"
|
||||
:showUploadList="false"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<inbox-outlined></inbox-outlined>
|
||||
@@ -45,26 +50,36 @@
|
||||
<div class="tipz">支持扩展名:.xls/.xlsx</div>
|
||||
</div> -->
|
||||
<div class="loadstate">
|
||||
<div class="loadborder">
|
||||
|
||||
<div v-if="uploadpercent!==-1" class="loadborder">
|
||||
<div class="content">
|
||||
<div class="img"></div>
|
||||
<div class="timebox">
|
||||
<div class="timetop">
|
||||
<div class="tit">京东方商业模型.xls</div>
|
||||
<div class="stateloading">正在上传</div>
|
||||
<div v-if="uploadErr" class="stateloading" style="color:red;">上传失败</div>
|
||||
<div v-else class="stateloading">{{uploadpercent==100?"上传成功":"正在上传"}}</div>
|
||||
</div>
|
||||
<div class="prog">
|
||||
<div class="inprogloading"></div>
|
||||
<div class="inprogloading" :style="{width:uploadpercent==-1?0:uploadpercent+'%', background:uploadErr?'#ff7474':'#35ae69'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="curloading">
|
||||
<div class="cur">55%</div>
|
||||
<div class="cancel" style="margin-left: 20px">暂停</div>
|
||||
<div class="cancel" style="margin-left: 15px">取消</div>
|
||||
<div class="cur">{{uploadpercent==-1?0:uploadpercent}}%</div>
|
||||
<div class="cancel" style="margin-left: 20px;cursor: pointer;" @click="removeUpload">删除</div>
|
||||
<div class="cancel" style="margin-left: 15px"></div>
|
||||
</div>
|
||||
<div v-if="errNum!==0" class="defeat">
|
||||
<div class="detext" @click="downloadEeeorData">下载失败数据</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="loadborder">
|
||||
<div v-if="showBottomBar" :class="errNum==0?'succebox':'defeatbox'">
|
||||
<div class="lefimg"></div>
|
||||
<div class="tacl">{{succNum}}条数据导入成功,{{errNum}}条数据导入失败</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="loadborder">
|
||||
<div class="content">
|
||||
<div class="img"></div>
|
||||
<div class="timebox">
|
||||
@@ -111,16 +126,20 @@
|
||||
<div class="succebox">
|
||||
<div class="lefimg"></div>
|
||||
<div class="tacl">20条数据导入成功,5条数据导入失败</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btnn">
|
||||
<button class="btn1">取消</button>
|
||||
<button class="btn2">确定</button>
|
||||
<button class="btn1" @click="closeDrawer">取消</button>
|
||||
<button class="btn2" @click="closeDrawer">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 加载动画 -->
|
||||
<div class="aeLoading" :style="{ display: addLoading ? 'flex' : 'none' }">
|
||||
<a-spin :spinning="addLoading" tip="" />
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
@@ -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
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
<!-- 二维码签到弹窗 -->
|
||||
<SignQR v-model:signQRvisible="signQRvisible" />
|
||||
<!-- 导入学员抽屉 -->
|
||||
<imp-stu v-model:AddImpStuvisible="AddImpStuvisible" />
|
||||
<imp-stu v-model:AddImpStuvisible="AddImpStuvisible" :courseId="projectTaskInfo.courseId" :courseType="2"/>
|
||||
<!-- 批量签到弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="copyModal"
|
||||
|
||||
Reference in New Issue
Block a user