mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-08 10:26:44 +08:00
测评上传修改上传逻辑与错误信息展示
This commit is contained in:
@@ -199,13 +199,14 @@
|
||||
<div class="bg_body_input">
|
||||
<a-upload
|
||||
name="file"
|
||||
v-model:file-list="fileList"
|
||||
v-model:file-list="files"
|
||||
:headers="headers"
|
||||
:show-upload-list="false"
|
||||
:before-upload="beforeUpload3"
|
||||
@change="handleChange"
|
||||
action="/activityApi/evaluation/import"
|
||||
:data="uploadParameters"
|
||||
ref="uploadRef"
|
||||
>
|
||||
<div class="upload_box">
|
||||
<span>选择文件</span>
|
||||
@@ -234,7 +235,7 @@
|
||||
:class="`${{uploading: 'updatacolor3', done: 'updatacolor' ,error: 'updatacolor2'}[item.status] || 'updatacolor'}`"
|
||||
:style="{width:`${item.status==='uploading'?parseInt(item.percent):100}%`}"></div>
|
||||
<div v-if="item.status"
|
||||
style="right:-62px"
|
||||
style="right:-62px;"
|
||||
:class="`${{uploading: 'updataxq1', done: 'updataxq' ,error: 'updataxq2'}[item.status] || 'updataxq'}`">
|
||||
{{ {uploading: '正在上传', done: '上传完成', error: '上传失败'}[item.status] || '' }}
|
||||
</div>
|
||||
@@ -702,12 +703,15 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
const userInfo = computed(() => store.state.userInfo);
|
||||
const router = useRouter();
|
||||
const state = reactive({
|
||||
saveNotUpload: true,
|
||||
stateUpload: true,
|
||||
uploadParameters: {},
|
||||
uploadList: [],
|
||||
isRegularAdministrator: '',
|
||||
loadNewDown:false,
|
||||
totalNumber: {},
|
||||
sussessIds: [],
|
||||
failedId: '',
|
||||
uploadDownLoad: false,
|
||||
uploadDownId: null,
|
||||
loadData: false,
|
||||
@@ -715,8 +719,6 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
powerStatus:{},
|
||||
saveListPid: '',
|
||||
idValue: null,
|
||||
downloadUrl:null,
|
||||
valueAll: [],
|
||||
uploadStatus: true,
|
||||
uploadId: '',
|
||||
uploadName: '',
|
||||
@@ -775,13 +777,12 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
onMounted(()=>{
|
||||
timeoutUpload(1000*60*5)
|
||||
state.tableLoading = true
|
||||
console.log(userInfo.value,'sssss')
|
||||
listData()
|
||||
})
|
||||
const uploadAdmin = (aaaa)=>{
|
||||
const uploadAdmin = (admin)=>{
|
||||
const aaa = userInfo.value.roleList.map((item)=>item.roleCode)
|
||||
if (aaaa){
|
||||
return aaa.some(t => t == aaaa)
|
||||
if (admin){
|
||||
return aaa.some(t => t == admin)
|
||||
}
|
||||
}
|
||||
const trueFalse = (per,i) => {
|
||||
@@ -1114,9 +1115,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
const bgupload = () => {
|
||||
state.loadNewDown = false
|
||||
state.uploadDownId = null
|
||||
state.downloadUrl = null
|
||||
state.uploadId = ''
|
||||
state.valueAll = []
|
||||
state.uploadList = []
|
||||
state.btShow = true
|
||||
state.bg_check = true;
|
||||
@@ -1124,8 +1123,6 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
}
|
||||
const bgupload1 = (record) => {
|
||||
state.loadNewDown = true
|
||||
state.downloadUrl = null
|
||||
state.valueAll = []
|
||||
state.uploadList = []
|
||||
state.uploadDownId =record.id
|
||||
state.btShowEdit = trueFalse(record.permission,2)
|
||||
@@ -1146,8 +1143,9 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
const of_exit = () => {
|
||||
state.bg_check = false;
|
||||
state.errorMessage = ''
|
||||
// state.uploadDownId = ''
|
||||
// state.uploadId = ''
|
||||
state.saveNotUpload = true
|
||||
state.failedId = ''
|
||||
state.sussessIds = null
|
||||
state.uploadName = ''
|
||||
state.loadData = false
|
||||
state.uploadStatus = true
|
||||
@@ -1164,7 +1162,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
state.bg_results = false
|
||||
}
|
||||
const failedDownload = () => {
|
||||
const ids = [...state.totalNumber.failedIds,...state.totalNumber.importTrue].join(',')
|
||||
const ids = state.totalNumber.successId+','+state.totalNumber.failedId
|
||||
window.open(`/activityApi/evaluation/download-failed?ids=${ids}`)
|
||||
|
||||
}
|
||||
@@ -1173,92 +1171,45 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
message.error('请输入测评标题名称')
|
||||
return
|
||||
}
|
||||
// if(state.totalNumber.failedEntries&&state.valueAll.length!=0){
|
||||
// message.error('请先下载失败数据,并修改后重新上传')
|
||||
// state.bg_results = true
|
||||
// state.bg_check = false
|
||||
// return
|
||||
// }
|
||||
if(state.failedId){
|
||||
message.error('上传报告含有错误报告,请检查后重新上传')
|
||||
return
|
||||
}
|
||||
state.tableLoading = true
|
||||
state.uploadDownLoad = true
|
||||
if(state.valueAll.length != 0 && !state.loadData&&state.loadNewDown){
|
||||
state.totalNumber.failedEntisTrue = '0'
|
||||
if(state.valueAll.length >1){
|
||||
state.totalNumber.failedEntisTrue = state.totalNumber.failedEntries == 0 ? '0' : '1'
|
||||
state.bg_results = true
|
||||
}
|
||||
state.valueAll.forEach((item)=>{
|
||||
if(item.createId){
|
||||
item.createId = userInfo.value.userId
|
||||
}
|
||||
})
|
||||
if( !state.loadData&&state.loadNewDown){
|
||||
// 保存上传文件
|
||||
await boeRequest('/activityApi/evaluation/detail/saveEvaluationDetail post',{
|
||||
evaluationDetailListlist:state.valueAll,
|
||||
pid:state.uploadId,
|
||||
isUpload: state.totalNumber.failedEntisTrue,
|
||||
id:state.uploadId,
|
||||
successIds:state.sussessIds
|
||||
}).then((res)=>{
|
||||
state.uploadDownLoad = false
|
||||
if(res.code == 200){
|
||||
if(res.data.length!=0){
|
||||
if(state.valueAll.length>=1&&state.totalNumber.totalEntries){
|
||||
state.totalNumber.failedEntries = state.totalNumber.failedEntries + res.data.failedIds.length
|
||||
state.totalNumber.successfulEntries = state.totalNumber.successfulEntries - res.data.failedIds.length
|
||||
}else{
|
||||
state.totalNumber.totalEntries = 1
|
||||
state.totalNumber.failedEntries = res.data.failedIds.length
|
||||
state.totalNumber.successfulEntries = res.data.successIds.length
|
||||
}
|
||||
if(res.data.failedIds.length!=0){
|
||||
message.error('请先下载失败数据,并修改后重新上传')
|
||||
}
|
||||
state.totalNumber.failedIds = [...res.data.failedIds,...res.data.successIds]
|
||||
state.bg_results = true
|
||||
state.bg_check = false
|
||||
return
|
||||
}
|
||||
}
|
||||
if(res.data.code == -1){
|
||||
message.error('保存失败')
|
||||
}
|
||||
state.saveNotUpload = false
|
||||
// if(res.code == 200){
|
||||
// state.bg_check = false
|
||||
// return
|
||||
|
||||
// }
|
||||
// if(res.data.code == -1){
|
||||
// message.error('保存失败')
|
||||
// }
|
||||
})
|
||||
}
|
||||
if(state.uploadStatus||state.btShow){
|
||||
state.totalNumber.failedEntisTrue = '0'
|
||||
if(state.valueAll.length >1){
|
||||
state.totalNumber.failedEntisTrue = state.totalNumber.failedEntries == 0 ? '0' : '1'
|
||||
}
|
||||
await boeRequest('/activityApi/evaluation/save post',{
|
||||
isUpload: state.totalNumber.failedEntisTrue,
|
||||
id: state.uploadDownId,
|
||||
createId:userInfo.value.userId,
|
||||
createName:userInfo.value.realName,
|
||||
prefix:'',
|
||||
remarks:state.formData.remarks,
|
||||
evaluationName:state.formData.evaluationName,
|
||||
// detailIds:state.idValue,
|
||||
evaluationDetailList:!state.loadNewDown?state.valueAll:null,
|
||||
workNum: userInfo.value.userNo,
|
||||
// downloadUrls:state.downloadUrl,
|
||||
imagePath:state.formData.cover
|
||||
imagePath:state.formData.cover,
|
||||
successIds:state.saveNotUpload?state.sussessIds:null
|
||||
}).then((res)=>{
|
||||
state.uploadDownLoad = false
|
||||
if(res.data.failedIds!=null||res.data.successIds!=null){
|
||||
if(state.valueAll.length>=1&&state.totalNumber.totalEntries){
|
||||
state.totalNumber.failedEntries = state.totalNumber.failedEntries + res.data.failedIds.length
|
||||
state.totalNumber.successfulEntries = state.totalNumber.successfulEntries - res.data.failedIds.length
|
||||
}else{
|
||||
state.totalNumber.totalEntries = 1
|
||||
state.totalNumber.failedEntries = res.data.failedIds.length
|
||||
state.totalNumber.successfulEntries = res.data.successIds.length
|
||||
}
|
||||
if(res.data.failedIds.length!=0){
|
||||
message.error('请先下载失败数据,并修改后重新上传')
|
||||
}
|
||||
state.totalNumber.failedIds = [...res.data.failedIds,...res.data.successIds]
|
||||
state.bg_results = true
|
||||
if(res.code == 200){
|
||||
state.uploadDownLoad = false
|
||||
state.bg_check = false
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1267,7 +1218,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
}
|
||||
const showUpload = () => {
|
||||
reportUpload()
|
||||
of_exit()
|
||||
// of_exit()
|
||||
}
|
||||
//上传图片
|
||||
const headers = { token: getCookieForName("token") };
|
||||
@@ -1359,38 +1310,14 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
// message.error('无法计算文件MD5,请重试');
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// boeRequest('/activityApi/evaluation/import post formData',formData).then((res)=>{
|
||||
// if(res.code === 200){
|
||||
// if(state.stateType == "application/pdf"){
|
||||
// // state.idValue = res.data.map(item=>item.id)
|
||||
// state.downloadUrl = res.data.map(item=>item.downloadUrl)
|
||||
// state.valueAll = res.data
|
||||
// state.totalNumber.importTrue = []
|
||||
// }else{
|
||||
// // state.idValue = res.data.evaluationDetailList.map(item=>item.id)
|
||||
// state.downloadUrl = res.data.evaluationDetailList.map(item=>item.downloadUrl)
|
||||
// state.totalNumber = res.data
|
||||
// state.totalNumber.importTrue = res.data.failedIds
|
||||
// state.valueAll = res.data.evaluationDetailList
|
||||
// }
|
||||
// state.uploadDownLoad = false
|
||||
// }
|
||||
// })
|
||||
// return false
|
||||
}
|
||||
const handleChange = ({file, fileList,event}) => {
|
||||
console.log(file.response)
|
||||
if(file.response && file.response.code === 200){
|
||||
if(file.type == "application/pdf"){
|
||||
state.downloadUrl = file.response.data.map(item=>item.downloadUrl)
|
||||
state.valueAll = file.response.data
|
||||
state.totalNumber.importTrue = []
|
||||
}else{
|
||||
state.downloadUrl = file.response.data.evaluationDetailList.map(item=>item.downloadUrl)
|
||||
state.totalNumber = file.response.data
|
||||
state.totalNumber.importTrue = file.response.data.failedIds
|
||||
state.valueAll = file.response.data.evaluationDetailList
|
||||
}
|
||||
state.sussessIds = file.response.data.successId.split(',')
|
||||
state.failedId = file.response.data.failedId
|
||||
state.bg_results = true
|
||||
state.uploadDownLoad = false
|
||||
}
|
||||
if(state.stateUpload){
|
||||
@@ -1398,9 +1325,11 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
}
|
||||
state.stateUpload = true
|
||||
};
|
||||
const delUploadList = () => {
|
||||
const uploadRef = ref()
|
||||
const delUploadList = (i) => {
|
||||
state.sussessIds = null
|
||||
state.failedId = ''
|
||||
state.uploadList = []
|
||||
state.valueAll = []
|
||||
}
|
||||
const deleteItem = (record) => {
|
||||
dialog({
|
||||
@@ -1610,6 +1539,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
beforeUpload3,
|
||||
handleChange,
|
||||
delUploadList,
|
||||
uploadRef,
|
||||
bgcheck,
|
||||
deleteItem,
|
||||
emptyItem,
|
||||
@@ -1838,7 +1768,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
.i12_box1 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 17px 0px 17px 21px;
|
||||
padding: 10px 0px 17px 21px;
|
||||
border: 1px solid #eff4fc;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 10px;
|
||||
@@ -1896,6 +1826,9 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
background-color: #4ea6ff;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.updataxq1{
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.updataxq {
|
||||
position: absolute;
|
||||
|
||||
Reference in New Issue
Block a user