mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-15 05:46:45 +08:00
feat:登录项目和学习路径导入学员
This commit is contained in:
@@ -31,13 +31,27 @@
|
||||
name="uploadFile"
|
||||
:multiple="false"
|
||||
@change="handleChange"
|
||||
:data=" courseType==1?{
|
||||
stageId: Number(courseId),
|
||||
type: 3
|
||||
}:{
|
||||
targetId: Number(courseId),
|
||||
type: 3
|
||||
}"
|
||||
:data="
|
||||
courseType == 1
|
||||
? {
|
||||
stageId: Number(courseId),
|
||||
type: 3,
|
||||
}
|
||||
: courseType == 3
|
||||
? {
|
||||
targetId: Number(courseId),
|
||||
type: 1,
|
||||
}
|
||||
: courseType == 4
|
||||
? {
|
||||
targetId: Number(courseId),
|
||||
type: 2,
|
||||
}
|
||||
: {
|
||||
targetId: Number(courseId),
|
||||
type: 3,
|
||||
}
|
||||
"
|
||||
:showUploadList="false"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
@@ -53,33 +67,61 @@
|
||||
<div class="tipz">支持扩展名:.xls/.xlsx</div>
|
||||
</div> -->
|
||||
<div class="loadstate">
|
||||
|
||||
<div v-if="uploadpercent!==-1" 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 v-if="uploadErr" class="stateloading" style="color:red;">上传失败</div>
|
||||
<div v-else class="stateloading">{{uploadpercent==100?"上传成功":"正在上传"}}</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" :style="{width:uploadpercent==-1?0:uploadpercent+'%', background:uploadErr?'#ff7474':'#35ae69'}"></div>
|
||||
<div
|
||||
class="inprogloading"
|
||||
:style="{
|
||||
width: uploadpercent == -1 ? 0 : uploadpercent + '%',
|
||||
background: uploadErr ? '#ff7474' : '#35ae69',
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="curloading">
|
||||
<div class="cur">{{uploadpercent==-1?0:uploadpercent}}%</div>
|
||||
<div class="cancel" style="margin-left: 20px;cursor: pointer;" @click="removeUpload">删除</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 v-if="errNum !== 0" class="defeat">
|
||||
<div class="detext" @click="downloadEeeorData">
|
||||
下载失败数据
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showBottomBar" :class="errNum==0?'succebox':'defeatbox'">
|
||||
<div
|
||||
v-if="showBottomBar"
|
||||
:class="errNum == 0 ? 'succebox' : 'defeatbox'"
|
||||
>
|
||||
<div class="lefimg"></div>
|
||||
<div class="tacl">{{succNum}}条数据导入成功,{{errNum}}条数据导入失败</div>
|
||||
<div class="tacl">
|
||||
{{ succNum }}条数据导入成功,{{ errNum }}条数据导入失败
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="loadborder">
|
||||
@@ -169,19 +211,24 @@ export default {
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const state = reactive({
|
||||
template: process.env.VUE_APP_TEMPLATE + "导入学员模版-1672998102528.xlsx",
|
||||
importStudent: process.env.VUE_APP_BASE_API + "admin/student/importStudent",
|
||||
template:
|
||||
process.env.VUE_APP_TEMPLATE + "导入学员模版-1672998102528.xlsx",
|
||||
importStudent:
|
||||
process.env.VUE_APP_BASE_API + "admin/student/importStudent",
|
||||
timers: "", // 定时器,用于清空定时器使用
|
||||
isAddStudent: false, // 用于判断用户是否关闭弹框需要重新获取学员列表
|
||||
uploadpercent: -1,
|
||||
uploadErr: false, //上传失败
|
||||
addLoading: false,
|
||||
fileList: [],
|
||||
fileList: [],
|
||||
succNum: 0, //成功数据数
|
||||
errNum: 0, //失败数据数
|
||||
downloadErrUrl: '',
|
||||
downloadErrUrl: "",
|
||||
showBottomBar: false, // 显示底部成功条数和失败条数
|
||||
locationHref: location.href.indexOf('http://') !== -1 ? 'http://111.231.196.214:12016/' : location.href.slice(0, location.href.indexOf('/m')) + '/upload/'
|
||||
locationHref:
|
||||
location.href.indexOf("http://") !== -1
|
||||
? "http://111.231.196.214:12016/"
|
||||
: location.href.slice(0, location.href.indexOf("/m")) + "/upload/",
|
||||
});
|
||||
const closeDrawer = () => {
|
||||
clearInterval(state.timers);
|
||||
@@ -206,14 +253,14 @@ export default {
|
||||
const handleChange = (info) => {
|
||||
console.log("info", info);
|
||||
|
||||
if(info){
|
||||
var FileExt = info.file.name.replace(/.+\./, "");
|
||||
if (['xls','xlsx'].indexOf(FileExt.toLowerCase()) === -1){
|
||||
if (info) {
|
||||
var FileExt = info.file.name.replace(/.+\./, "");
|
||||
if (["xls", "xlsx"].indexOf(FileExt.toLowerCase()) === -1) {
|
||||
state.fileList = [];
|
||||
state.uploadpercent = -1;
|
||||
message.destroy()
|
||||
message.error("请上传正确的文件格式")
|
||||
return
|
||||
state.uploadpercent = -1;
|
||||
message.destroy();
|
||||
message.error("请上传正确的文件格式");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,59 +273,58 @@ export default {
|
||||
console.log(info.file, info.fileList);
|
||||
}
|
||||
if (status === "done") {
|
||||
console.log('上传成功返回的UUID', info.file.response.data)
|
||||
console.log('上传成功返回的UUID----->', info)
|
||||
console.log("上传成功返回的UUID", info.file.response.data);
|
||||
console.log("上传成功返回的UUID----->", info);
|
||||
console.log("我是导入学员接口传递的参数", {
|
||||
uploadFile: info.file.originFileObj,
|
||||
targetId: props.courseId,
|
||||
type: 3
|
||||
})
|
||||
type: 3,
|
||||
});
|
||||
let i = 0;
|
||||
state.timers = 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.isAddStudent = true;
|
||||
}
|
||||
state.succNum = res.data.data.successNum;
|
||||
state.errNum = res.data.data.failedNum;
|
||||
state.downloadErrUrl = res.data.data.url;
|
||||
clearInterval(state.timers);
|
||||
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.isAddStudent = true;
|
||||
}
|
||||
state.succNum = res.data.data.successNum;
|
||||
state.errNum = res.data.data.failedNum;
|
||||
state.downloadErrUrl = res.data.data.url;
|
||||
clearInterval(state.timers);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
clearInterval(state.timers);
|
||||
state.showBottomBar = true;
|
||||
state.addLoading = false;
|
||||
console.log("查询导入状态失败", err);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
clearInterval(state.timers);
|
||||
state.showBottomBar = true;
|
||||
state.addLoading = false;
|
||||
console.log("查询导入状态失败", err);
|
||||
});
|
||||
}, 500);
|
||||
} else if (status === "error") {
|
||||
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)
|
||||
console.log(state.locationHref + state.downloadErrUrl);
|
||||
if (state.downloadErrUrl !== "") {
|
||||
window.open(state.locationHref + state.downloadErrUrl);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//删除
|
||||
const removeUpload = () => {
|
||||
@@ -301,7 +347,7 @@ export default {
|
||||
handleChange,
|
||||
BATCH_IMPORT_SCORE,
|
||||
downloadEeeorData,
|
||||
removeUpload
|
||||
removeUpload,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user