案例导入的修改

This commit is contained in:
NiSen
2023-06-21 17:15:06 +08:00
parent f0e57ef8d3
commit cc26f4449f
2 changed files with 73 additions and 62 deletions

View File

@@ -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);

View File

@@ -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,18 +334,18 @@ 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(() => {
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) => {
@@ -368,10 +373,10 @@ const handleChange = (info) => {
// state.addLoading = false;
// console.log("查询导入状态失败", err);
// });
}, 500);
// }, 500);
} else if (status === "error") {
state.addLoading = false;
state.uploadErr = true;
state.progressColor = 'red'
state.status = '上传失败'
message.error(`${info.file.name}上传失败`);
}
};