mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 03:46:45 +08:00
案例导入的修改
This commit is contained in:
@@ -2,7 +2,13 @@ import http from "./configSys";
|
||||
|
||||
// 案例列表
|
||||
export const RECOMMEND_PAGE = "/systemapi/xboe/m/boe/cases/recommend/page post";
|
||||
//发起案例列表或案例管理列表
|
||||
export const isTopList = (data) => http.post('/xboe/m/boe/cases/isTopList', data, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
//下载失败数据
|
||||
export const downloadErrorData = (params = {}) => http.post("/xboe/m/boe/cases/recommend/download", params);
|
||||
export const downloadErrorData = (params) => http.get('/xboe/m/boe/cases/recommend/download', { params })
|
||||
//推送消息
|
||||
export const recommendLaunch = (params = {}) => http.post("/xboe/m/boe/cases/recommend/launch", params);
|
||||
export const recommendLaunch = (data = {}) => http.post("/xboe/m/boe/cases/recommend/launch", data);
|
||||
|
||||
@@ -105,23 +105,21 @@
|
||||
</div>
|
||||
<div class="upload">
|
||||
<a-upload :file-list="state.fileList" :action="state.uploadAction" name="file" @change="handleChange"
|
||||
:showUploadList="false" :multiple="false" :data="{
|
||||
result: '123456'
|
||||
}">
|
||||
:showUploadList="false" :multiple="false">
|
||||
<a-button style="width: 150px;">
|
||||
上传文件
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<span class="ant-upload-hint">支持文件格式:.xls/.xlsx</span>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress" v-if="state.status">
|
||||
<div class="nameAndProgress" style="display: flex;justify-content: space-between;padding-right: 36px;">
|
||||
<span>{{ state.fileName }}</span>
|
||||
<span>上传完成</span>
|
||||
<span>{{ state.status }}</span>
|
||||
</div>
|
||||
<a-progress :percent="state.uploadpercent" status="active" />
|
||||
<a-progress :percent="state.uploadpercent" status="active" :strokeColor="state.progressColor" />
|
||||
</div>
|
||||
<div class="importDetail" style="display: flex;flex-direction: column;">
|
||||
<div class="importDetail" style="display: flex;flex-direction: column;" v-if="state.status">
|
||||
<span>导入 1039 条,成功 1007 条,失败 <span style="color: red;">32</span> 条。</span>
|
||||
<div class="defeat">
|
||||
<div class="detext" @click="downloadErrorInfo">
|
||||
@@ -138,7 +136,7 @@ import { reactive, ref, watch, computed, nextTick } from 'vue';
|
||||
import { Form, message } from "ant-design-vue";
|
||||
import axios from "axios";
|
||||
import Cookies from "vue-cookies";
|
||||
import { downloadErrorData } from '@/api/case'
|
||||
import { downloadErrorData,isTopList } from '@/api/case'
|
||||
import useDownload from '@/hooks/useDownload'
|
||||
import CommonRecommend from "@/components/CaseManage/CommonRecommend";
|
||||
defineProps({
|
||||
@@ -154,6 +152,8 @@ defineProps({
|
||||
const emit = defineEmits(['update:visible'])
|
||||
|
||||
const state = reactive({
|
||||
status:'',//上传的状态
|
||||
progressColor: '',//进度条颜色
|
||||
type: 1,//添加学员
|
||||
stage: '',//
|
||||
importId: '',//导入id
|
||||
@@ -167,7 +167,7 @@ const state = reactive({
|
||||
fileName: '',//下载的名字
|
||||
uploadAction: process.env.VUE_APP_NEW_API + '/xboe/m/boe/cases/recommend/import',//下载地址
|
||||
addLoading: false,
|
||||
fileList: [],
|
||||
fileList: [],//上传列表
|
||||
member: false,//收起和展开
|
||||
screenHeight: document.body.clientHeight,
|
||||
projectParams: {
|
||||
@@ -246,26 +246,23 @@ const onSelectChange = (selectedRowKeys, selectedRow) => {
|
||||
|
||||
// 请求列表数据是formdata类型的
|
||||
const getTopList = () => {
|
||||
console.log(state.selectedRowKeys);
|
||||
|
||||
axios({
|
||||
method: "post",
|
||||
url: "/systemapi/xboe/m/boe/cases/isTopList",
|
||||
data: { ...searchDataInfo },
|
||||
headers: {
|
||||
token: Cookies.get("token"),
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then((res) => {
|
||||
// axios({
|
||||
// method: "post",
|
||||
// url: "/systemapi/xboe/m/boe/cases/isTopList",
|
||||
// data: { ...searchDataInfo },
|
||||
// headers: {
|
||||
// token: Cookies.get("token"),
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// },
|
||||
// })
|
||||
isTopList(searchDataInfo).then((res) => {
|
||||
loading.value = true;
|
||||
console.log(res);
|
||||
res?.data?.result?.list?.forEach(element => {
|
||||
element.key = element.id
|
||||
});
|
||||
state.dataSource = res?.data?.result?.list || []
|
||||
total.value = res?.data?.result?.count || 0
|
||||
console.log(total.value);
|
||||
console.log(state.dataSource);
|
||||
total.value = res?.data?.result?.count
|
||||
}).catch((err) => {
|
||||
message.error(err);
|
||||
loading.value = false;
|
||||
@@ -282,7 +279,10 @@ const handleSearch = (num) => {
|
||||
|
||||
//下载模版
|
||||
const downloadErrorInfo = () => {
|
||||
// if (!state.importId) return
|
||||
if (!state.importId) {
|
||||
message.warn('暂无失败数据')
|
||||
return
|
||||
}
|
||||
downloadErrorData({ importId: state.importId }).then((res) => {
|
||||
if (res.status != 200) return
|
||||
useDownload(res, '失败数据.xsl')
|
||||
@@ -318,6 +318,11 @@ const hideModal = () => {
|
||||
const handleChange = (info) => {
|
||||
console.log("info", info);
|
||||
state.imptProgress = true
|
||||
state.status = '正在上传'
|
||||
state.progressColor = ''
|
||||
state.fileList = []
|
||||
state.fileList = info.fileList
|
||||
state.fileName = info.file.name;
|
||||
|
||||
if (info) {
|
||||
var FileExt = info.file.name.replace(/.+\./, "");
|
||||
@@ -329,49 +334,49 @@ const handleChange = (info) => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
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") {
|
||||
state.fileName = info.file.name;
|
||||
let i = 0;
|
||||
state.timers = setInterval(() => {
|
||||
// let uid = info.file.response.data;
|
||||
// caseImport(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);
|
||||
// });
|
||||
}, 500);
|
||||
state.importId = info.file.response.result
|
||||
message.success(`${info.file.name}上传成功`);
|
||||
state.progressColor = '#52c41a'
|
||||
state.status = '上传成功'
|
||||
// let i = 0;
|
||||
// state.timers = setInterval(() => {
|
||||
// let uid = info.file.response.data;
|
||||
// caseImport(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);
|
||||
// });
|
||||
// }, 500);
|
||||
} else if (status === "error") {
|
||||
state.addLoading = false;
|
||||
state.uploadErr = true;
|
||||
state.progressColor = 'red'
|
||||
state.status = '上传失败'
|
||||
message.error(`${info.file.name}上传失败`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user