Browse Source

错误不抛异常,前端显示

java8
han\hanst 1 month ago
parent
commit
87ea9c16cb
  1. 84
      src/views/modules/ecss/del_upload_excel.vue

84
src/views/modules/ecss/del_upload_excel.vue

@ -33,13 +33,13 @@
<p style="margin-top: 10px; color: #666;">正在解析文件请稍候...</p>
</div>
<div v-if="showPreview" style="margin-top: 20px; margin-bottom: 30px;">
<div v-if="showPreview" style="margin-top: 10px; margin-bottom: 10px;">
<!-- 可导入的发票表格 -->
<div v-if="validInvoices.length > 0">
<h4 style="color: #67C23A; margin-bottom: 15px;">
<span style="color: #67C23A; ">
<i class="el-icon-success" style="margin-right: 8px;"></i>
可导入的发票 ({{ validInvoices.length }}个发票)
</h4>
</span>
<el-table :data="validInvoices" border style="width: 100%" max-height="300" :show-overflow-tooltip="true" class="delClass valid-table">
<el-table-column label="操作" width="40" fixed="left">
<template slot-scope="scope">
@ -162,11 +162,11 @@
</div>
<!-- 物料不存在的发票表格 -->
<div v-if="invalidInvoices.length > 0" style="margin-top: 30px;">
<h4 style="color: #F56C6C; margin-bottom: 15px;">
<div v-if="invalidInvoices.length > 0" style="margin-top: 10px;margin-bottom: 10px">
<span style="color: #F56C6C;">
<i class="el-icon-warning" style="margin-right: 8px;"></i>
物料不存在的发票 ({{ invalidInvoices.length }}个发票将不会导入)
</h4>
</span>
<el-table :data="invalidInvoices" border style="width: 100%" max-height="300" :show-overflow-tooltip="true" class="delClass invalid-table">
<el-table-column prop="cmcInvoice" label="发票号" width="120" fixed="left">
<template slot-scope="scope">
@ -224,6 +224,44 @@
<el-table-column prop="shippingMode" label="运输方式" min-width="80"></el-table-column>
</el-table>
</div>
<!-- Sheet错误信息展示 -->
<div v-if="sheetErrors.length > 0" style="margin-bottom: 5px;">
<span style="color: #E6A23C; ">
<i class="el-icon-warning" style="margin-right: 8px;"></i>
Sheet处理警告 ({{ sheetErrors.length }}个Sheet存在问题)
</span>
<el-table :data="sheetErrors" border style="width: 100%" max-height="400" class="delClass warning-table">
<el-table-column prop="sheetName" label="Sheet名称" width="150" fixed="left" >
<template slot-scope="scope">
<span style="font-weight: bold;">{{ scope.row.sheetName }}</span>
</template>
</el-table-column>
<el-table-column prop="errorMessage" label="原因" min-width="300">
<template slot-scope="scope">
<div>
<el-tooltip
v-if="scope.row.errorDetails && scope.row.errorDetails.length > 0"
placement="top"
effect="light">
<div slot="content" style="max-width: 500px; line-height: 1.6;">
<div style="font-weight: bold; margin-bottom: 8px; color: #E6A23C;">详细错误信息 ({{ scope.row.errorDetails.length }})</div>
<div v-for="(detail, index) in scope.row.errorDetails" :key="index" style="margin-bottom: 6px;">
<span style="color: #E6A23C; font-weight: bold;">{{ index + 1 }}.</span> {{ detail }}
</div>
</div>
<div style="font-size: 12px; color: #909399; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<span v-for="(detail, index) in scope.row.errorDetails" :key="index">
<span v-if="index > 0">; </span>
<span style="color: #E6A23C; font-weight: bold;">{{ index + 1 }}.</span> {{ detail }}
</span>
</div>
</el-tooltip>
</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
<span slot="footer" class="dialog-footer" style="margin-top: 10px">
@ -531,6 +569,7 @@
saveButtonLoading: false, //
confirmSaveButtonLoading: false, //
deletedInvoices: [], //
sheetErrors: [], // Sheet
customSearchData: {},
customerList : [],//
customerAddrs : [],//
@ -1079,9 +1118,26 @@
if (data.code === 0) {
this.previewData = data.data || []
this.sheetErrors = data.sheetErrors || []
this.showPreview = true
//
this.deletedInvoices = []
// Sheet
if (this.sheetErrors.length > 0) {
const skippedCount = this.sheetErrors.filter(e => e.skipped).length
const errorCount = this.sheetErrors.filter(e => !e.skipped).length
let message = `文件解析完成,但有 ${this.sheetErrors.length} 个Sheet存在问题`
if (skippedCount > 0) {
message += `${skippedCount}个已跳过`
}
if (errorCount > 0) {
message += `${skippedCount > 0 ? ',' : '('}${errorCount}个处理失败`
}
message += '),请查看详细信息'
this.$message.warning(message)
}
//
this.previewData.forEach(item => {
this.$set(item, 'selectedTemplate', '')
@ -1230,6 +1286,7 @@
cancelPreview() {
this.showPreview = false
this.previewData = []
this.sheetErrors = []
this.fileList = []
this.selectedFile = null
this.deletedInvoices = []
@ -1243,6 +1300,7 @@
//
clearPreviewData() {
this.previewData = []
this.sheetErrors = []
this.showPreview = false
this.selectedFile = null
this.fileList = []
@ -1655,4 +1713,18 @@
background-color: #FDF2F2 !important;
}
/* Sheet错误表格样式 */
.warning-table .el-table__header {
background-color: #FDF6EC !important;
}
.warning-table .el-table th {
background-color: #FDF6EC !important;
color: #E6A23C !important;
}
.warning-table .el-table .el-table__row:hover > td {
background-color: #FEF5E7 !important;
}
</style>
Loading…
Cancel
Save