|
|
@ -14,7 +14,7 @@ |
|
|
</el-row> |
|
|
</el-row> |
|
|
</el-form> |
|
|
</el-form> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<el-button type="primary" @click="saveUploadFile()">保存</el-button> |
|
|
|
|
|
|
|
|
<el-button type="primary" :loading="uploadLoading" @click="saveUploadFile()">保存</el-button> |
|
|
<el-button type="primary" @click="closeDialog">关闭</el-button> |
|
|
<el-button type="primary" @click="closeDialog">关闭</el-button> |
|
|
</span> |
|
|
</span> |
|
|
</el-dialog> |
|
|
</el-dialog> |
|
|
@ -38,10 +38,12 @@ export default { |
|
|
titleCon: '文件导入', |
|
|
titleCon: '文件导入', |
|
|
visible: false, |
|
|
visible: false, |
|
|
fileList: [], |
|
|
fileList: [], |
|
|
|
|
|
uploadLoading: false, |
|
|
pageData: { |
|
|
pageData: { |
|
|
flag: '', |
|
|
flag: '', |
|
|
createBy: '', |
|
|
createBy: '', |
|
|
site: '' |
|
|
|
|
|
|
|
|
site: '', |
|
|
|
|
|
buNo: '', |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -68,6 +70,7 @@ export default { |
|
|
/*关闭modal*/ |
|
|
/*关闭modal*/ |
|
|
closeDialog () { |
|
|
closeDialog () { |
|
|
this.fileList = [] |
|
|
this.fileList = [] |
|
|
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
// 刷新报工的页面 |
|
|
// 刷新报工的页面 |
|
|
this.$emit('refreshPageTables') |
|
|
this.$emit('refreshPageTables') |
|
|
// 关闭当前的页面 |
|
|
// 关闭当前的页面 |
|
|
@ -75,64 +78,47 @@ export default { |
|
|
}, |
|
|
}, |
|
|
/*保修当前的数据*/ |
|
|
/*保修当前的数据*/ |
|
|
saveUploadFile () { |
|
|
saveUploadFile () { |
|
|
|
|
|
this.uploadLoading = true |
|
|
/*判断文件是否上传*/ |
|
|
/*判断文件是否上传*/ |
|
|
if (null == this.fileList || 0 == this.fileList.length) { |
|
|
if (null == this.fileList || 0 == this.fileList.length) { |
|
|
this.$message.error("请先上传文件!") |
|
|
this.$message.error("请先上传文件!") |
|
|
|
|
|
this.uploadLoading = false |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
const formData = new FormData() |
|
|
const formData = new FormData() |
|
|
formData.append("file", this.fileList[0].raw) |
|
|
formData.append("file", this.fileList[0].raw) |
|
|
formData.append("createBy", this.pageData.createBy) |
|
|
formData.append("createBy", this.pageData.createBy) |
|
|
formData.append("site", this.pageData.site) |
|
|
formData.append("site", this.pageData.site) |
|
|
|
|
|
formData.append("buNo", this.pageData.buNo) |
|
|
|
|
|
|
|
|
|
|
|
// 根据 flag 发不同的接口 |
|
|
|
|
|
let promise |
|
|
if (this.pageData.flag === 'item') { |
|
|
if (this.pageData.flag === 'item') { |
|
|
uploadExcel(formData).then(({data}) => { |
|
|
|
|
|
if (data.code === 0) { |
|
|
|
|
|
this.$message.success(data.msg) |
|
|
|
|
|
// 清空文件上传记录 |
|
|
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
|
|
// 关闭窗口并刷新页面 |
|
|
|
|
|
this.closeDialog() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$message.warning(data.msg) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
promise = uploadExcel(formData) |
|
|
} else if (this.pageData.flag === 'template') { |
|
|
} else if (this.pageData.flag === 'template') { |
|
|
uploadTemplateExcel(formData).then(({data}) => { |
|
|
|
|
|
if (data.code === 0) { |
|
|
|
|
|
this.$message.success(data.msg) |
|
|
|
|
|
// 清空文件上传记录 |
|
|
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
|
|
// 关闭窗口并刷新页面 |
|
|
|
|
|
this.closeDialog() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$message.warning(data.msg) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
promise = uploadTemplateExcel(formData) |
|
|
} else if (this.pageData.flag === 'partAttribute') { |
|
|
} else if (this.pageData.flag === 'partAttribute') { |
|
|
uploadPartAttributeExcel(formData).then(({data}) => { |
|
|
|
|
|
if (data.code === 0) { |
|
|
|
|
|
this.$message.success(data.msg) |
|
|
|
|
|
// 清空文件上传记录 |
|
|
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
|
|
// 关闭窗口并刷新页面 |
|
|
|
|
|
this.closeDialog() |
|
|
|
|
|
}else { |
|
|
|
|
|
this.$message.warning(data.msg) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
promise = uploadPartAttributeExcel(formData) |
|
|
} else if (this.pageData.flag === 'familyAttribute') { |
|
|
} else if (this.pageData.flag === 'familyAttribute') { |
|
|
uploadFamilyAttributeExcel(formData).then(({data}) => { |
|
|
|
|
|
|
|
|
promise = uploadFamilyAttributeExcel(formData) |
|
|
|
|
|
} |
|
|
|
|
|
promise |
|
|
|
|
|
.then(({ data }) => { |
|
|
if (data.code === 0) { |
|
|
if (data.code === 0) { |
|
|
this.$message.success(data.msg) |
|
|
this.$message.success(data.msg) |
|
|
// 清空文件上传记录 |
|
|
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
this.$refs.uploadFile.clearFiles() |
|
|
// 关闭窗口并刷新页面 |
|
|
|
|
|
this.closeDialog() |
|
|
this.closeDialog() |
|
|
} else { |
|
|
} else { |
|
|
this.$message.warning(data.msg) |
|
|
this.$message.warning(data.msg) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
this.$message.error("上传失败,请稍后重试") |
|
|
|
|
|
console.error(err) |
|
|
|
|
|
}) |
|
|
|
|
|
.finally(() => { |
|
|
|
|
|
this.uploadLoading = false // 请求结束时再关 loading |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 下载 |
|
|
// 下载 |
|
|
async downloadFile () { |
|
|
async downloadFile () { |
|
|
|