优化导入

This commit is contained in:
龙运模
2025-05-12 10:28:28 +08:00
parent c4ff355d1e
commit c24b7fdfc3
19 changed files with 112 additions and 43 deletions
+32 -7
View File
@@ -1,7 +1,7 @@
<template> <template>
<slot name="header"></slot> <slot name="header"></slot>
<el-dialog v-bind="$attrs" :title="title" v-model="visible" :width="560" destroy-on-close draggable @closed="visible=false"> <el-dialog v-bind="$attrs" :title="title" v-model="visible" :width="560" destroy-on-close draggable @closed="closeVisible">
<div class="importBody"> <div class="importBody">
<el-upload <el-upload
class="upload" class="upload"
@@ -26,7 +26,7 @@
<div class="el-upload__text"> <div class="el-upload__text">
<el-icon class="trueIcon el-icon&#45;&#45;upload"> <el-icon class="trueIcon el-icon&#45;&#45;upload">
<sc-icon-FormXls /> <sc-icon-FormXls />
<div class="deleteFile" @click="deleteFile"><el-icon class="icon"><el-icon-Close/></el-icon></div> <div class="deleteFile" @click="deleteFile" v-if="!progressTrue"><el-icon class="icon"><el-icon-Close/></el-icon></div>
</el-icon> </el-icon>
<div class="el-upload__text">{{text}}</div> <div class="el-upload__text">{{text}}</div>
</div> </div>
@@ -48,7 +48,7 @@
</div> </div>
<div class="errText" v-if="errorShow"> <div class="errText" v-if="errorShow">
<div class="deleteErr" @click="errorClick"><el-icon class="icon"><el-icon-Close/></el-icon></div> <div class="deleteErr" @click="errorClick"><el-icon class="icon"><el-icon-Close/></el-icon></div>
<el-scrollbar max-height="120px"> <el-scrollbar ref="scrollbar" max-height="120px">
<div v-for="em in errorList" :key="em"> <div v-for="em in errorList" :key="em">
<div :class="em.status==0?'text danger':'text success'" v-html="em.msg"></div> <div :class="em.status==0?'text danger':'text success'" v-html="em.msg"></div>
</div> </div>
@@ -58,8 +58,8 @@
</el-upload> </el-upload>
</div> </div>
<template #footer> <template #footer>
<el-button @click="visible=false">取 消</el-button> <el-button @click="closeVisible">取 消</el-button>
<el-button type="primary" :disabled="!importTrue || progressShow || httpDisabled" @click="save">确定导入</el-button> <el-button type="primary" :disabled="!importTrue || progressTrue || httpDisabled" @click="save">确定导入</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
@@ -91,6 +91,7 @@ export default {
importDis:false, importDis:false,
importTrue:false, importTrue:false,
progressShow:false, progressShow:false,
progressTrue:false,
errorShow:false, errorShow:false,
importInfo:{}, importInfo:{},
errorList:[], errorList:[],
@@ -116,13 +117,18 @@ export default {
if(this.type == res.data.type){ if(this.type == res.data.type){
this.importInfo = res.data; this.importInfo = res.data;
this.progressShow = true; this.progressShow = true;
this.progressTrue = true;
this.importTrue = true;
if(res.data.status == 0 || res.data.status == 1){ if(res.data.status == 0 || res.data.status == 1){
this.errorShow = true; this.errorShow = true;
let text = res.data; let text = res.data;
this.errorList.push(text); this.errorList.push(text);
this.scrollDown();
} }
if(res.data.rate == 100){ if(res.data.rate == 100){
this.progressShow = false; // this.progressShow = false;
this.progressTrue = false;
this.$emit('importSuccess'); this.$emit('importSuccess');
} }
} }
@@ -153,6 +159,7 @@ export default {
this.params = formData; this.params = formData;
this.importTrue = true; this.importTrue = true;
this.importDis = true; this.importDis = true;
this.progressShow = false;
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@@ -161,6 +168,7 @@ export default {
this.importTrue = false; this.importTrue = false;
setTimeout(()=>{ setTimeout(()=>{
this.importDis = false; this.importDis = false;
this.$emit('importSuccess',{refresh:false});
this.errorClick(); this.errorClick();
},100) },100)
}, },
@@ -168,6 +176,11 @@ export default {
this.errorShow= false; this.errorShow= false;
this.errorList= [] this.errorList= []
}, },
closeVisible(){
this.visible = false;
this.progressShow = false;
this.importTrue = false;
},
save(){ save(){
this.errorClick(); this.errorClick();
this.$emit('parentParams',this.params); this.$emit('parentParams',this.params);
@@ -179,7 +192,19 @@ export default {
// 上传失败 // 上传失败
handleError(){ handleError(){
this.$message.warning('上传失败请重新上传'); this.$message.warning('上传失败请重新上传');
} },
scrollDown() {
this.$nextTick(() => {
const wrap = this.$refs.scrollbar;
if(wrap){
const e = wrap.$el.querySelector('.el-scrollbar__wrap')
if(e){
e.scrollTop = e.scrollHeight;
}
}
})
},
} }
} }
</script> </script>
+4 -2
View File
@@ -237,9 +237,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+5 -2
View File
@@ -178,8 +178,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+4 -2
View File
@@ -223,9 +223,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
@@ -179,8 +179,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+4 -2
View File
@@ -282,9 +282,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
@@ -178,8 +178,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+5 -2
View File
@@ -178,8 +178,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
@@ -114,9 +114,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//表格选择后回调事件 //表格选择后回调事件
+4 -2
View File
@@ -131,9 +131,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//表格选择后回调事件 //表格选择后回调事件
@@ -109,9 +109,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//表格选择后回调事件 //表格选择后回调事件
selectionChange(selection){ selectionChange(selection){
+4 -2
View File
@@ -211,9 +211,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//添加 //添加
+4 -2
View File
@@ -285,9 +285,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
@@ -247,9 +247,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
table_edit(row){ table_edit(row){
@@ -226,9 +226,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+4 -2
View File
@@ -303,9 +303,11 @@
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.httpDisabled = false; this.httpDisabled = false;
this.$refs.table.refresh() if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
@@ -179,8 +179,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑
+6 -2
View File
@@ -211,13 +211,17 @@ export default {
}; };
updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat); updateOrAppend(params, 'is_save_repeat', this.importParams.is_save_repeat);
this.httpDisabled = true;
const res = await this.$API.shipment.out.import.post(params); const res = await this.$API.shipment.out.import.post(params);
if(res.code == 200){ if(res.code == 200){
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
// 删除 // 删除
batch_del(){ batch_del(){
@@ -179,8 +179,11 @@ export default {
this.$message.success('上传成功,开始导入数据'); this.$message.success('上传成功,开始导入数据');
} }
}, },
importSuccess(){ importSuccess(refresh){
this.$refs.table.refresh() this.httpDisabled = false;
if(!refresh){
this.$refs.table.refresh()
}
}, },
//编辑 //编辑