|
|
|
@ -36,7 +36,12 @@ |
|
|
|
<div v-if="showPreview" style="margin-top: 20px; margin-bottom: 30px;"> |
|
|
|
<h4>文件预览 - 按发票号汇总 (共{{ previewData.length }}个发票)</h4> |
|
|
|
|
|
|
|
<el-table :data="previewData" border style="width: 100%" max-height="400" :show-overflow-tooltip="true"> |
|
|
|
<el-table :data="previewData" border style="width: 100%" max-height="400" :show-overflow-tooltip="true" class="delClass"> |
|
|
|
<el-table-column label="操作" width="40" fixed="left"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<a type="text" size="small" style="color: red" @click="deleteRow(scope.$index, scope.row)">删除</a> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="cmcInvoice" label="发票号" width="120" fixed="left"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span :style="scope.row.exists ? 'color: red; font-weight: bold;' : ''"> |
|
|
|
@ -109,7 +114,7 @@ |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="运抵国" width="90"> |
|
|
|
<el-table-column label="运抵国" width="80"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedCnative" |
|
|
|
@ -121,7 +126,7 @@ |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="贸易国" min-width="90"> |
|
|
|
<el-table-column label="贸易国" min-width="80"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedSalesArea" |
|
|
|
@ -151,7 +156,7 @@ |
|
|
|
:data="customerTemplateList" |
|
|
|
stripe |
|
|
|
highlight-current-row |
|
|
|
border |
|
|
|
border class="delClass" |
|
|
|
@row-dblclick="rowDblclickTemplate" |
|
|
|
style="width: 100%;"> |
|
|
|
<el-table-column |
|
|
|
@ -374,6 +379,7 @@ |
|
|
|
showPreview: false, // 是否显示预览 |
|
|
|
selectedFile: null, // 选择的文件 |
|
|
|
previewLoading: false, // 预览加载状态 |
|
|
|
deletedInvoices: [], // 被删除的发票号列表 |
|
|
|
customSearchData: {}, |
|
|
|
customerList : [],//所有客户 |
|
|
|
customerAddrs : [],//地址 |
|
|
|
@ -464,6 +470,7 @@ |
|
|
|
} : null, |
|
|
|
showPreview: this.showPreview, |
|
|
|
previewData: this.previewData, |
|
|
|
deletedInvoices: this.deletedInvoices, |
|
|
|
fileList: this.fileList.map(file => ({ |
|
|
|
name: file.name, |
|
|
|
size: file.size, |
|
|
|
@ -487,20 +494,25 @@ |
|
|
|
if (parsedData.pageData) { |
|
|
|
// 恢复基础表单数据 |
|
|
|
Object.assign(this.pageData, parsedData.pageData); |
|
|
|
|
|
|
|
|
|
|
|
// 恢复预览数据和文件状态 |
|
|
|
if (parsedData.previewData && parsedData.previewData.length > 0) { |
|
|
|
this.previewData = parsedData.previewData; |
|
|
|
this.showPreview = parsedData.showPreview || false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 恢复删除的发票号列表 |
|
|
|
if (parsedData.deletedInvoices) { |
|
|
|
this.deletedInvoices = parsedData.deletedInvoices; |
|
|
|
} |
|
|
|
|
|
|
|
// 恢复文件列表信息(用于界面显示) |
|
|
|
if (parsedData.fileList && parsedData.fileList.length > 0) { |
|
|
|
// 记录缓存的文件信息,用于后续比对 |
|
|
|
this.cachedFileInfo = parsedData.fileInfo; |
|
|
|
this.cachedFileList = parsedData.fileList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -523,7 +535,7 @@ |
|
|
|
checkAndRestoreFileState() { |
|
|
|
// 检查上传组件中是否有文件 |
|
|
|
const uploadFiles = this.$refs.uploadFile.uploadFiles; |
|
|
|
|
|
|
|
|
|
|
|
if (this.cachedFileInfo && this.cachedFileList.length > 0) { |
|
|
|
// 如果有缓存的文件信息,检查当前上传组件中的文件 |
|
|
|
if (uploadFiles && uploadFiles.length > 0) { |
|
|
|
@ -531,7 +543,7 @@ |
|
|
|
const isSameFile = currentFile.name === this.cachedFileInfo.name && |
|
|
|
currentFile.size === this.cachedFileInfo.size && |
|
|
|
currentFile.lastModified === this.cachedFileInfo.lastModified; |
|
|
|
|
|
|
|
|
|
|
|
if (isSameFile) { |
|
|
|
// 是同一个文件,恢复文件相关状态 |
|
|
|
this.selectedFile = currentFile; |
|
|
|
@ -554,7 +566,7 @@ |
|
|
|
console.log('没有找到文件,清除预览状态'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 保存当前状态 |
|
|
|
this.saveToCache(); |
|
|
|
}, |
|
|
|
@ -577,7 +589,7 @@ |
|
|
|
} |
|
|
|
// 在获取BU列表后尝试加载缓存 |
|
|
|
this.loadFromCache(); |
|
|
|
|
|
|
|
|
|
|
|
// 检查并恢复文件状态 |
|
|
|
this.$nextTick(() => { |
|
|
|
this.checkAndRestoreFileState(); |
|
|
|
@ -598,6 +610,7 @@ |
|
|
|
this.previewData = [] |
|
|
|
this.showPreview = false |
|
|
|
this.selectedFile = null |
|
|
|
this.deletedInvoices = [] |
|
|
|
this.pageData.customerName='' |
|
|
|
this.pageData.cnative='' |
|
|
|
this.pageData.localShipAddress='', |
|
|
|
@ -743,7 +756,7 @@ |
|
|
|
this.saveToCache() |
|
|
|
// 关闭当前的页面 |
|
|
|
this.visible = false |
|
|
|
// 注意:这里不清除任何数据,让数据保留到下次打开 |
|
|
|
this.$emit('refreshTable') |
|
|
|
}, |
|
|
|
deleteFile(){ |
|
|
|
// 只有在明确需要清除数据时才调用此方法 |
|
|
|
@ -751,6 +764,7 @@ |
|
|
|
this.previewData = [] |
|
|
|
this.showPreview = false |
|
|
|
this.selectedFile = null |
|
|
|
this.deletedInvoices = [] |
|
|
|
this.cachedFileInfo = null |
|
|
|
this.cachedFileList = [] |
|
|
|
// 清空文件上传记录 |
|
|
|
@ -888,6 +902,8 @@ |
|
|
|
if (data.code === 0) { |
|
|
|
this.previewData = data.data || [] |
|
|
|
this.showPreview = true |
|
|
|
// 清空删除列表,因为这是新的文件预览 |
|
|
|
this.deletedInvoices = [] |
|
|
|
// 为每个发票号初始化客户信息 |
|
|
|
this.previewData.forEach(item => { |
|
|
|
this.$set(item, 'selectedTemplate', '') |
|
|
|
@ -940,7 +956,9 @@ |
|
|
|
const formData = new FormData() |
|
|
|
formData.append("buNo", this.pageData.buNo) |
|
|
|
formData.append("username", this.$store.state.user.name) |
|
|
|
formData.append("file", this.selectedFile.raw) |
|
|
|
formData.append("file", this.fileList[0].raw) |
|
|
|
// 添加被删除的发票号列表 |
|
|
|
formData.append("deletedInvoices", JSON.stringify(this.deletedInvoices)) |
|
|
|
// 为每个发票设置客户信息 |
|
|
|
this.previewData.forEach((item, index) => { |
|
|
|
formData.append(`customerName_${item.cmcInvoice}`, item.selectedCustomer) |
|
|
|
@ -1017,6 +1035,7 @@ |
|
|
|
this.previewData = [] |
|
|
|
this.fileList = [] |
|
|
|
this.selectedFile = null |
|
|
|
this.deletedInvoices = [] |
|
|
|
this.cachedFileInfo = null |
|
|
|
this.cachedFileList = [] |
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
@ -1030,6 +1049,7 @@ |
|
|
|
this.showPreview = false |
|
|
|
this.selectedFile = null |
|
|
|
this.fileList = [] |
|
|
|
this.deletedInvoices = [] |
|
|
|
this.previewLoading = false |
|
|
|
this.cachedFileInfo = null |
|
|
|
this.cachedFileList = [] |
|
|
|
@ -1146,6 +1166,27 @@ |
|
|
|
this.closeEditDialog() |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除行 |
|
|
|
deleteRow(index, row) { |
|
|
|
this.$confirm(`确定要删除发票号 "${row.cmcInvoice}" 吗?删除后将不会提交到后台。`, '删除确认', { |
|
|
|
confirmButtonText: '确定删除', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
// 记录被删除的发票号 |
|
|
|
if (!this.deletedInvoices.includes(row.cmcInvoice)) { |
|
|
|
this.deletedInvoices.push(row.cmcInvoice) |
|
|
|
} |
|
|
|
// 从预览数据中移除该行 |
|
|
|
this.previewData.splice(index, 1) |
|
|
|
this.$message.success(`发票号 "${row.cmcInvoice}" 已删除`) |
|
|
|
// 保存到缓存 |
|
|
|
this.saveToCache() |
|
|
|
}).catch(() => { |
|
|
|
// 用户取消删除 |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 下载 |
|
|
|
async downloadFile () { |
|
|
|
let file = { |
|
|
|
@ -1191,6 +1232,12 @@ |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style scoped> |
|
|
|
/deep/ .delClass .cell { |
|
|
|
line-height: 24px !important; |
|
|
|
font-size: 12px !important; |
|
|
|
height: 24px !important; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .customer-upload .el-upload .el-upload-dragger { |
|
|
|
width: 580px; |
|
|
|
} |
|
|
|
@ -1315,6 +1362,4 @@ |
|
|
|
color: #c0c4cc; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style> |