diff --git a/src/api/case.js b/src/api/case.js index a201cc90..37e6312f 100644 --- a/src/api/case.js +++ b/src/api/case.js @@ -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); diff --git a/src/components/drawers/InitiateRecommend.vue b/src/components/drawers/InitiateRecommend.vue index b762f287..7575440e 100644 --- a/src/components/drawers/InitiateRecommend.vue +++ b/src/components/drawers/InitiateRecommend.vue @@ -105,23 +105,21 @@
+ :showUploadList="false" :multiple="false"> 上传文件 支持文件格式:.xls/.xlsx
-
+
{{ state.fileName }} - 上传完成 + {{ state.status }}
- +
-
+
导入 1039 条,成功 1007 条,失败 32 条。
@@ -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}上传失败`); } };