|
|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<div class="customer-css"> |
|
|
|
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog"> |
|
|
|
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" @close="handleDialogClose" width="390px" style="height: 520px;" class="customer-dialog"> |
|
|
|
<el-form :inline="true" label-position="top" label-width="80px"> |
|
|
|
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button> |
|
|
|
<el-form-item label="BU" v-if="pageData.flag !== 'poPartPrint'"> |
|
|
|
@ -24,7 +24,7 @@ |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<el-button type="primary" @click="saveUploadFile()">保存</el-button> |
|
|
|
<el-button type="primary" @click="saveUploadFile()" :loading="uploadLoading">保存</el-button> |
|
|
|
<el-button type="primary" @click="closeDialog">关闭</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
@ -51,6 +51,7 @@ export default { |
|
|
|
fileList: [], |
|
|
|
bu: '', |
|
|
|
userBuList:[], |
|
|
|
uploadLoading: false, // 上传loading状态 |
|
|
|
pageData: { |
|
|
|
flag: '', |
|
|
|
createBy: '', |
|
|
|
@ -94,12 +95,41 @@ export default { |
|
|
|
}, |
|
|
|
/*关闭modal*/ |
|
|
|
closeDialog(){ |
|
|
|
// 清空文件列表数据 |
|
|
|
this.fileList = []; |
|
|
|
// 清空 el-upload 组件的文件列表 |
|
|
|
if (this.$refs.uploadFile) { |
|
|
|
this.$refs.uploadFile.clearFiles(); |
|
|
|
} |
|
|
|
// 重置 BU 选择 |
|
|
|
this.bu = ''; |
|
|
|
// 重置loading状态 |
|
|
|
this.uploadLoading = false; |
|
|
|
// 刷新报工的页面 |
|
|
|
this.$emit('refreshPageTables'); |
|
|
|
// 关闭当前的页面 |
|
|
|
this.visible = false; |
|
|
|
}, |
|
|
|
|
|
|
|
/*对话框关闭事件 - 确保清理所有数据*/ |
|
|
|
handleDialogClose(){ |
|
|
|
// 清空文件列表数据 |
|
|
|
this.fileList = []; |
|
|
|
// 清空 el-upload 组件的文件列表 |
|
|
|
if (this.$refs.uploadFile) { |
|
|
|
this.$refs.uploadFile.clearFiles(); |
|
|
|
} |
|
|
|
// 重置 BU 选择 |
|
|
|
this.bu = ''; |
|
|
|
// 重置loading状态 |
|
|
|
this.uploadLoading = false; |
|
|
|
// 重置 pageData |
|
|
|
this.pageData = { |
|
|
|
flag: '', |
|
|
|
createBy: '', |
|
|
|
site: '' |
|
|
|
}; |
|
|
|
}, |
|
|
|
/*保修当前的数据*/ |
|
|
|
saveUploadFile(){ |
|
|
|
if (this.pageData.flag !== 'poPartPrint' && (this.bu === '' || this.bu == null)){ |
|
|
|
@ -111,6 +141,10 @@ export default { |
|
|
|
this.$message.error("请先上传文件!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// 开启loading |
|
|
|
this.uploadLoading = true; |
|
|
|
|
|
|
|
const formData = new FormData(); |
|
|
|
formData.append("file", this.fileList[0].raw); |
|
|
|
formData.append("createBy", this.pageData.createBy); |
|
|
|
@ -126,6 +160,11 @@ export default { |
|
|
|
}else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}).catch((error) => { |
|
|
|
this.$message.error('上传失败:' + (error.message || '网络错误')); |
|
|
|
}).finally(() => { |
|
|
|
// 关闭loading |
|
|
|
this.uploadLoading = false; |
|
|
|
}) |
|
|
|
} else if (this.pageData.flag === 'template') { |
|
|
|
formData.set('site',this.bu) |
|
|
|
@ -139,6 +178,11 @@ export default { |
|
|
|
}else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}).catch((error) => { |
|
|
|
this.$message.error('上传失败:' + (error.message || '网络错误')); |
|
|
|
}).finally(() => { |
|
|
|
// 关闭loading |
|
|
|
this.uploadLoading = false; |
|
|
|
}) |
|
|
|
} else if (this.pageData.flag === 'partAttribute') { |
|
|
|
uploadPartAttributeExcel(formData).then(({data}) => { |
|
|
|
@ -151,6 +195,11 @@ export default { |
|
|
|
} else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}).catch((error) => { |
|
|
|
this.$message.error('上传失败:' + (error.message || '网络错误')); |
|
|
|
}).finally(() => { |
|
|
|
// 关闭loading |
|
|
|
this.uploadLoading = false; |
|
|
|
}) |
|
|
|
} else if (this.pageData.flag === 'poPartPrint') { |
|
|
|
// 采购标签导入 |
|
|
|
@ -174,9 +223,14 @@ export default { |
|
|
|
} else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}).catch((error) => { |
|
|
|
this.$message.error('上传失败:' + (error.message || '网络错误')); |
|
|
|
}).finally(() => { |
|
|
|
// 关闭loading |
|
|
|
this.uploadLoading = false; |
|
|
|
}) |
|
|
|
} |
|
|
|
this.bu = ''; |
|
|
|
// 不要在这里重置 bu,因为已经在 closeDialog 中重置了 |
|
|
|
}, |
|
|
|
// 下载 |
|
|
|
async downloadFile(){ |
|
|
|
|