|
|
|
@ -1,74 +1,19 @@ |
|
|
|
<template> |
|
|
|
<div class="customer-css"> |
|
|
|
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" |
|
|
|
width="600px" class="customer-dialog" @close="deleteFile"> |
|
|
|
<el-form label-position="top" > |
|
|
|
:width="showPreview ? '1200px' : '600px'" class="customer-dialog" @close="deleteFile"> |
|
|
|
<el-form label-position="top"> |
|
|
|
<el-row :gutter="16"> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="BU"> |
|
|
|
<el-select v-model="pageData.buNo" placeholder="请选择" style="width: 100%"> |
|
|
|
<el-option v-for = "i in buList" :key = "i.buNo" :label = "i.buDesc" :value = "i.buNo"></el-option> |
|
|
|
<el-select v-model="pageData.buNo" placeholder="请选择" style="width: 100%"> |
|
|
|
<el-option v-for="i in buList" :key="i.buNo" :label="i.buDesc" :value="i.buNo"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12" > |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label=" "> |
|
|
|
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button> |
|
|
|
</el-form-item> </el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item :label="''" > |
|
|
|
<template #label> |
|
|
|
<span slot="label" style="" class="big-label"> |
|
|
|
<a href="#" @click="customFlag=true">客户</a> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="2" v-model="pageData.customerName"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item :label="''" > |
|
|
|
<template #label> |
|
|
|
<span slot="label" style="" class="big-label"> |
|
|
|
<a href="#" @click="overseasShipperFlag=true">收货单位</a> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="2" v-model="pageData.overseasShipper"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="12" style="margin-top: 30px"> |
|
|
|
<el-form-item :label="''" > |
|
|
|
<template #label> |
|
|
|
<span slot="label" style="" class="big-label"> |
|
|
|
<a href="#" @click="localShipAddressFlag=true">客户地址</a> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="3" v-model="pageData.localShipAddress"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="12" style="margin-top: 30px"> |
|
|
|
<el-form-item :label="''" > |
|
|
|
<template #label> |
|
|
|
<span slot="label" style="" class="big-label"> |
|
|
|
<a href="#" @click="overseasAddressFlag=true">收货单位地址</a> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
<el-input type="textarea" |
|
|
|
:rows="3" v-model="pageData.overseasAddress"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12" style="margin-top: 60px"> |
|
|
|
<el-form-item :label="'贸易国'" > |
|
|
|
<el-input v-model="pageData.salesArea" ></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item :label="'运抵国'" style="margin-top: 60px"> |
|
|
|
<el-input v-model="pageData.cnative" ></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" style="margin-top: 10px"> |
|
|
|
@ -80,13 +25,169 @@ |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<!-- 预览数据表格 --> |
|
|
|
<!-- 加载状态 --> |
|
|
|
<div v-if="previewLoading" style="margin-top: 20px; text-align: center; padding: 40px;"> |
|
|
|
<i class="el-icon-loading" style="font-size: 24px; color: #409EFF;"></i> |
|
|
|
<p style="margin-top: 10px; color: #666;">正在解析文件,请稍候...</p> |
|
|
|
</div> |
|
|
|
|
|
|
|
<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-column prop="cmcInvoice" label="发票号" width="120" fixed="left"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span :style="scope.row.exists ? 'color: red; font-weight: bold;' : ''"> |
|
|
|
{{ scope.row.cmcInvoice }} |
|
|
|
<el-tag v-if="scope.row.exists" type="danger" size="mini">已存在</el-tag> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="destination" label="目的地" width="100"></el-table-column> |
|
|
|
<el-table-column label="客户模板" width="150"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedTemplate" |
|
|
|
placeholder="请选择客户模板" |
|
|
|
@dblclick.native="selectTemplateForRow(scope.row)" |
|
|
|
size="small" |
|
|
|
style="cursor: pointer;"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="客户" width="150"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedCustomer" |
|
|
|
placeholder="请选择客户" |
|
|
|
@dblclick.native="selectCustomerForRow(scope.row)" |
|
|
|
size="small" |
|
|
|
style="cursor: pointer;"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="客户地址" width="160"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedLocalAddress" |
|
|
|
placeholder="请选择客户地址" |
|
|
|
@dblclick.native="selectLocalAddressForRow(scope.row)" |
|
|
|
size="small" |
|
|
|
style="cursor: pointer;"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="收货单位" width="150"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedOverseasShipper" |
|
|
|
placeholder="请选择收货单位" |
|
|
|
@dblclick.native="selectOverseasShipperForRow(scope.row)" |
|
|
|
size="small" |
|
|
|
style="cursor: pointer;"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="收货单位地址" width="160"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.selectedOverseasAddress" |
|
|
|
placeholder="请选择收货单位地址" |
|
|
|
@dblclick.native="selectOverseasAddressForRow(scope.row)" |
|
|
|
size="small" |
|
|
|
style="cursor: pointer;"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="运抵国" width="90"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input v-model="scope.row.selectedCnative" placeholder="运抵国" size="small"></el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="贸易国" min-width="90"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input v-model="scope.row.selectedSalesArea" placeholder="贸易国" size="small"></el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
|
|
|
|
<span slot="footer" class="dialog-footer" style="margin-top: 10px"> |
|
|
|
<el-button type="primary" @click="saveUploadFile">保存</el-button> |
|
|
|
<el-button type="primary" @click="closeDialog">关闭</el-button> |
|
|
|
<el-button v-if="!showPreview" type="primary" @click="saveUploadFile">保存</el-button> |
|
|
|
<el-button v-if="showPreview" type="primary" @click="saveFromPreview">确认保存</el-button> |
|
|
|
<el-button v-if="showPreview" @click="cancelPreview">取消预览</el-button> |
|
|
|
<el-button v-if="!showPreview" type="primary" @click="closeDialog">关闭</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="客户" @close="closeCustomDialog" :visible.sync="customFlag" width="500px" v-drag> |
|
|
|
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择客户模板` : '客户模板'" |
|
|
|
@close="templateFlag = false; currentRow = null" :visible.sync="templateFlag" width="850px" v-drag> |
|
|
|
<el-table |
|
|
|
:height="400" |
|
|
|
:data="customerTemplateList" |
|
|
|
stripe |
|
|
|
highlight-current-row |
|
|
|
border |
|
|
|
@row-dblclick="rowDblclickTemplate" |
|
|
|
style="width: 100%;"> |
|
|
|
<el-table-column |
|
|
|
prop="template_name" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="150" |
|
|
|
label="模板名称"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="ccusname" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="150" |
|
|
|
label="客户名称"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="localShipAddress" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="120" |
|
|
|
label="客户地址"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="overseasShipper" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="120" |
|
|
|
label="收货单位"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="overseasAddress" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="120" |
|
|
|
label="收货地址"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="salesArea" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="80" |
|
|
|
label="贸易国"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
prop="cnative" |
|
|
|
header-align="center" |
|
|
|
align="left" |
|
|
|
width="80" |
|
|
|
label="运抵国"> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button @click="templateFlag = false; currentRow = null">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择客户` : '客户'" @close="closeCustomDialog" :visible.sync="customFlag" width="500px" v-drag> |
|
|
|
<el-form inline="inline" label-position="top" :model="customSearchData" style="margin-left: 7px;margin-top: -5px;"> |
|
|
|
<el-form-item label="客户名称"> |
|
|
|
<el-input v-model="customSearchData.ccusname" clearable style="width: 150px"></el-input> |
|
|
|
@ -122,7 +223,7 @@ |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="客户地址" @close="localShipAddressFlag = false" :visible.sync="localShipAddressFlag" width="500px" v-drag> |
|
|
|
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择客户地址` : '客户地址'" @close="localShipAddressFlag = false; currentRow = null" :visible.sync="localShipAddressFlag" width="500px" v-drag> |
|
|
|
<el-table |
|
|
|
:height="400" |
|
|
|
:data="customerAddrs" |
|
|
|
@ -139,11 +240,11 @@ |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button @click="localShipAddressFlag = false">关闭</el-button> |
|
|
|
<el-button @click="localShipAddressFlag = false; currentRow = null">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="收货单位地址" @close="overseasAddressFlag = false" :visible.sync="overseasAddressFlag" width="500px" v-drag> |
|
|
|
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择收货单位地址` : '收货单位地址'" @close="overseasAddressFlag = false; currentRow = null" :visible.sync="overseasAddressFlag" width="500px" v-drag> |
|
|
|
<el-table |
|
|
|
:height="400" |
|
|
|
:data="customerAddrs" |
|
|
|
@ -160,11 +261,11 @@ |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button @click="overseasAddressFlag = false">关闭</el-button> |
|
|
|
<el-button @click="overseasAddressFlag = false; currentRow = null">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="收货单位" @close="overseasShipperFlag = false" :visible.sync="overseasShipperFlag" width="500px" v-drag> |
|
|
|
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择收货单位` : '收货单位'" @close="overseasShipperFlag = false; currentRow = null" :visible.sync="overseasShipperFlag" width="500px" v-drag> |
|
|
|
<el-table |
|
|
|
:height="400" |
|
|
|
:data="customerAddrs" |
|
|
|
@ -188,7 +289,7 @@ |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-footer style="height:40px;margin-top: 10px;text-align:center"> |
|
|
|
<el-button @click="overseasShipperFlag = false">关闭</el-button> |
|
|
|
<el-button @click="overseasShipperFlag = false; currentRow = null">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
@ -196,7 +297,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import {queryFileId} from "@/api/qc/qc.js" |
|
|
|
import {saveEcssCoDelNotifyByExcel,getCustomerList,getCustomers,getCustomerAdd} from '@/api/ecss/ecss.js' |
|
|
|
import {previewExcel,saveEcssCoDelNotifyByExcel,getCustomerList,getCustomers,getCustomerAdd,getCustomerTemplateList} from '@/api/ecss/ecss.js' |
|
|
|
import {downLoadObjectFile} from '@/api/eam/eam_object_list.js' |
|
|
|
import {getBuList}from '@/api/factory/site.js' |
|
|
|
export default { |
|
|
|
@ -218,6 +319,10 @@ |
|
|
|
cnative:'', |
|
|
|
salesArea:'', |
|
|
|
}, |
|
|
|
previewData: [], // 预览数据 |
|
|
|
showPreview: false, // 是否显示预览 |
|
|
|
selectedFile: null, // 选择的文件 |
|
|
|
previewLoading: false, // 预览加载状态 |
|
|
|
customSearchData: {}, |
|
|
|
customerList : [],//所有客户 |
|
|
|
customerAddrs : [],//地址 |
|
|
|
@ -227,8 +332,11 @@ |
|
|
|
localShipAddressFlag:false, |
|
|
|
overseasShipperFlag:false, |
|
|
|
overseasAddressFlag:false, |
|
|
|
templateFlag:false, |
|
|
|
customerTemplateList: [],//客户模板列表 |
|
|
|
cacheKey: '', // 缓存键 |
|
|
|
cacheTimer: null, // 缓存定时器 |
|
|
|
currentRow: null, // 当前编辑的行 |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
@ -314,6 +422,10 @@ |
|
|
|
// 初始化组件的参数 |
|
|
|
init () { |
|
|
|
this.fileList = [] |
|
|
|
this.previewData = [] |
|
|
|
this.showPreview = false |
|
|
|
this.selectedFile = null |
|
|
|
this.previewLoading = false |
|
|
|
this.cacheKey = this.generateCacheKey(); |
|
|
|
|
|
|
|
let tempData = { |
|
|
|
@ -385,29 +497,79 @@ |
|
|
|
}, |
|
|
|
closeCustomDialog () { |
|
|
|
this.customFlag = false |
|
|
|
this.currentRow = null |
|
|
|
}, |
|
|
|
rowDblclickTemplate(row) { |
|
|
|
console.log(row) |
|
|
|
if (this.currentRow) { |
|
|
|
// 使用模板设置当前行的所有信息 |
|
|
|
this.currentRow.selectedTemplate = row.template_name |
|
|
|
this.currentRow.selectedCustomer = row.ccusname || '' |
|
|
|
this.currentRow.selectedLocalAddress = row.localShipAddress || '' |
|
|
|
this.currentRow.selectedOverseasShipper = row.overseasShipper || '' |
|
|
|
this.currentRow.selectedOverseasAddress = row.overseasAddress || '' |
|
|
|
this.currentRow.selectedCnative = row.cnative || '' |
|
|
|
this.currentRow.selectedSalesArea = row.salesArea || '' |
|
|
|
|
|
|
|
// 如果模板中有客户信息,自动获取该客户的地址和收货单位信息 |
|
|
|
if (row.ccusname) { |
|
|
|
this.getCusPersonsForRow(row.ccusname) |
|
|
|
} |
|
|
|
} |
|
|
|
this.templateFlag = false |
|
|
|
this.currentRow = null |
|
|
|
}, |
|
|
|
|
|
|
|
rowDblclick (row) { |
|
|
|
this.pageData.customerName=row.ccusname |
|
|
|
this.pageData.cnative='', |
|
|
|
this.pageData.localShipAddress='', |
|
|
|
this.pageData.overseasShipper='', |
|
|
|
this.pageData.overseasAddress='', |
|
|
|
this.pageData.salesArea = row.country |
|
|
|
this.getCusPersons() |
|
|
|
if (this.currentRow) { |
|
|
|
// 预览模式下,为当前行设置客户信息 |
|
|
|
this.currentRow.selectedCustomer = row.ccusname |
|
|
|
this.currentRow.selectedSalesArea = row.country |
|
|
|
this.currentRow.selectedLocalAddress = '' |
|
|
|
this.currentRow.selectedOverseasShipper = '' |
|
|
|
this.currentRow.selectedOverseasAddress = '' |
|
|
|
this.currentRow.selectedCnative = '' |
|
|
|
this.getCusPersonsForRow(row.ccusname) |
|
|
|
} else { |
|
|
|
// 普通模式下,设置全局信息 |
|
|
|
this.pageData.customerName=row.ccusname |
|
|
|
this.pageData.cnative='', |
|
|
|
this.pageData.localShipAddress='', |
|
|
|
this.pageData.overseasShipper='', |
|
|
|
this.pageData.overseasAddress='', |
|
|
|
this.pageData.salesArea = row.country |
|
|
|
this.getCusPersons() |
|
|
|
} |
|
|
|
this.customFlag = false |
|
|
|
}, |
|
|
|
rowDblclick2 (row) { |
|
|
|
this.pageData.localShipAddress=row.cDeliverAdd |
|
|
|
if (this.currentRow) { |
|
|
|
this.currentRow.selectedLocalAddress = row.cDeliverAdd |
|
|
|
} else { |
|
|
|
this.pageData.localShipAddress = row.cDeliverAdd |
|
|
|
} |
|
|
|
this.localShipAddressFlag = false |
|
|
|
this.currentRow = null |
|
|
|
}, |
|
|
|
rowDblclick3 (row) { |
|
|
|
this.pageData.overseasAddress=row.cDeliverAdd |
|
|
|
if (this.currentRow) { |
|
|
|
this.currentRow.selectedOverseasAddress = row.cDeliverAdd |
|
|
|
} else { |
|
|
|
this.pageData.overseasAddress = row.cDeliverAdd |
|
|
|
} |
|
|
|
this.overseasAddressFlag = false |
|
|
|
this.currentRow = null |
|
|
|
}, |
|
|
|
rowDblclick4 (row) { |
|
|
|
this.pageData.overseasShipper=row.cDeliverUnit |
|
|
|
this.pageData.cnative=row.deliverycountry |
|
|
|
if (this.currentRow) { |
|
|
|
this.currentRow.selectedOverseasShipper = row.cDeliverUnit |
|
|
|
this.currentRow.selectedCnative = row.deliverycountry |
|
|
|
} else { |
|
|
|
this.pageData.overseasShipper = row.cDeliverUnit |
|
|
|
this.pageData.cnative = row.deliverycountry |
|
|
|
} |
|
|
|
this.overseasShipperFlag = false |
|
|
|
this.currentRow = null |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传之前 |
|
|
|
@ -422,6 +584,8 @@ |
|
|
|
// 选择上传文件时 |
|
|
|
onChange (file) { |
|
|
|
this.fileList.push(file) |
|
|
|
this.selectedFile = file |
|
|
|
this.previewFile(file) |
|
|
|
}, |
|
|
|
|
|
|
|
// 关闭modal |
|
|
|
@ -529,6 +693,7 @@ |
|
|
|
if (successList.length > 0){ |
|
|
|
this.clearCache(); |
|
|
|
} |
|
|
|
this.clearPreviewData(); |
|
|
|
this.closeDialog(); |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -542,6 +707,248 @@ |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 预览文件 |
|
|
|
async previewFile(file) { |
|
|
|
if (!file || !file.raw) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.pageData.buNo) { |
|
|
|
this.$message.error('请先选择BU!') |
|
|
|
this.fileList = [] |
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.previewLoading = true // 开始加载 |
|
|
|
|
|
|
|
const formData = new FormData() |
|
|
|
formData.append("file", file.raw) |
|
|
|
formData.append("buNo", this.pageData.buNo) |
|
|
|
|
|
|
|
try { |
|
|
|
const { data } = await previewExcel(formData) |
|
|
|
|
|
|
|
if (data.code === 0) { |
|
|
|
this.previewData = data.data || [] |
|
|
|
this.showPreview = true |
|
|
|
// 为每个发票号初始化客户信息 |
|
|
|
this.previewData.forEach(item => { |
|
|
|
this.$set(item, 'selectedTemplate', '') |
|
|
|
this.$set(item, 'selectedCustomer', '') |
|
|
|
this.$set(item, 'selectedLocalAddress', '') |
|
|
|
this.$set(item, 'selectedOverseasShipper', '') |
|
|
|
this.$set(item, 'selectedOverseasAddress', '') |
|
|
|
this.$set(item, 'selectedCnative', '') |
|
|
|
this.$set(item, 'selectedSalesArea','') |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '文件预览失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.$message.error('文件预览失败:' + error.message) |
|
|
|
} finally { |
|
|
|
this.previewLoading = false // 结束加载 |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 从预览数据保存 |
|
|
|
saveFromPreview() { |
|
|
|
// 验证每个发票的必填信息 |
|
|
|
for (let item of this.previewData) { |
|
|
|
if (!item.selectedCustomer) { |
|
|
|
this.$message.error(`发票号 ${item.cmcInvoice} 请选择客户`) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!item.selectedLocalAddress) { |
|
|
|
this.$message.error(`发票号 ${item.cmcInvoice} 请填写客户地址`) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!item.selectedOverseasShipper) { |
|
|
|
this.$message.error(`发票号 ${item.cmcInvoice} 请填写收货单位`) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!item.selectedOverseasAddress) { |
|
|
|
this.$message.error(`发票号 ${item.cmcInvoice} 请填写收货单位地址`) |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!item.selectedCnative) { |
|
|
|
this.$message.error(`发票号 ${item.cmcInvoice} 请填写运抵国`) |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 发送保存请求 |
|
|
|
const formData = new FormData() |
|
|
|
formData.append("buNo", this.pageData.buNo) |
|
|
|
formData.append("username", this.$store.state.user.name) |
|
|
|
formData.append("file", this.selectedFile.raw) |
|
|
|
// 为每个发票设置客户信息 |
|
|
|
this.previewData.forEach((item, index) => { |
|
|
|
formData.append(`customerName_${item.cmcInvoice}`, item.selectedCustomer) |
|
|
|
formData.append(`localShipAddress_${item.cmcInvoice}`, item.selectedLocalAddress) |
|
|
|
formData.append(`overseasShipper_${item.cmcInvoice}`, item.selectedOverseasShipper) |
|
|
|
formData.append(`overseasAddress_${item.cmcInvoice}`, item.selectedOverseasAddress) |
|
|
|
formData.append(`cnative_${item.cmcInvoice}`, item.selectedCnative) |
|
|
|
formData.append(`salesArea_${item.cmcInvoice}`, item.selectedSalesArea) |
|
|
|
}) |
|
|
|
|
|
|
|
saveEcssCoDelNotifyByExcel(formData).then(({ data }) => { |
|
|
|
if (data.code === 0) { |
|
|
|
const { resultMap } = data; |
|
|
|
const successList = resultMap.success || []; |
|
|
|
const failList = resultMap.fail || []; |
|
|
|
|
|
|
|
// 紧凑样式 |
|
|
|
let html = ` |
|
|
|
<div style="max-height:380px;overflow:auto;font-size:12px;line-height:1.4;"> |
|
|
|
`; |
|
|
|
|
|
|
|
if (successList.length > 0) { |
|
|
|
html += `<div style="margin-bottom:6px;"> |
|
|
|
<div style="color:green;font-weight:bold;margin-bottom:3px;"> |
|
|
|
✅ 成功(${successList.length}) |
|
|
|
</div> |
|
|
|
<table border="1" cellspacing="0" cellpadding="2" |
|
|
|
style="border-collapse:collapse;width:100%;"> |
|
|
|
`; |
|
|
|
successList.forEach(item => { |
|
|
|
html += `<tr><td style="color:green;padding:2px 4px;">${item}</td></tr>`; |
|
|
|
}); |
|
|
|
html += `</table></div>`; |
|
|
|
} |
|
|
|
|
|
|
|
if (failList.length > 0) { |
|
|
|
html += `<div> |
|
|
|
<div style="color:red;font-weight:bold;margin-bottom:3px;"> |
|
|
|
❌ 失败(${failList.length}) |
|
|
|
</div> |
|
|
|
<table border="1" cellspacing="0" cellpadding="2" |
|
|
|
style="border-collapse:collapse;width:100%;"> |
|
|
|
`; |
|
|
|
failList.forEach(item => { |
|
|
|
html += `<tr><td style="color:red;padding:2px 4px;">${item}</td></tr>`; |
|
|
|
}); |
|
|
|
html += `</table></div>`; |
|
|
|
} |
|
|
|
|
|
|
|
html += `</div>`; |
|
|
|
|
|
|
|
this.$alert(html, '导入结果', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
callback: () => { |
|
|
|
if (successList.length > 0){ |
|
|
|
this.clearCache(); |
|
|
|
this.clearPreviewData(); |
|
|
|
this.closeDialog(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 取消预览 |
|
|
|
cancelPreview() { |
|
|
|
this.showPreview = false |
|
|
|
this.previewData = [] |
|
|
|
this.fileList = [] |
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
}, |
|
|
|
|
|
|
|
// 清除预览数据 |
|
|
|
clearPreviewData() { |
|
|
|
this.previewData = [] |
|
|
|
this.showPreview = false |
|
|
|
this.selectedFile = null |
|
|
|
this.fileList = [] |
|
|
|
this.previewLoading = false |
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
}, |
|
|
|
|
|
|
|
// 为行选择客户模板 |
|
|
|
selectTemplateForRow(row) { |
|
|
|
this.currentRow = row |
|
|
|
this.getCustomerTemplateList() |
|
|
|
this.templateFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 为行选择客户 |
|
|
|
selectCustomerForRow(row) { |
|
|
|
this.currentRow = row |
|
|
|
this.customFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 为行选择客户地址 |
|
|
|
selectLocalAddressForRow(row) { |
|
|
|
if (!row.selectedCustomer) { |
|
|
|
this.$message.warning('请先选择客户') |
|
|
|
return |
|
|
|
} |
|
|
|
this.currentRow = row |
|
|
|
this.getCusPersonsForRow(row.selectedCustomer) |
|
|
|
this.localShipAddressFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 为行选择收货单位 |
|
|
|
selectOverseasShipperForRow(row) { |
|
|
|
if (!row.selectedCustomer) { |
|
|
|
this.$message.warning('请先选择客户') |
|
|
|
return |
|
|
|
} |
|
|
|
this.currentRow = row |
|
|
|
this.getCusPersonsForRow(row.selectedCustomer) |
|
|
|
this.overseasShipperFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 为行选择收货单位地址 |
|
|
|
selectOverseasAddressForRow(row) { |
|
|
|
if (!row.selectedCustomer) { |
|
|
|
this.$message.warning('请先选择客户') |
|
|
|
return |
|
|
|
} |
|
|
|
this.currentRow = row |
|
|
|
this.getCusPersonsForRow(row.selectedCustomer) |
|
|
|
this.overseasAddressFlag = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取客户模板列表 |
|
|
|
async getCustomerTemplateList() { |
|
|
|
try { |
|
|
|
const { data } = await getCustomerTemplateList({}) |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.customerTemplateList = data.rows || [] |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('获取客户模板列表失败:', error) |
|
|
|
this.customerTemplateList = [] |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取特定客户的地址信息 |
|
|
|
getCusPersonsForRow(customerName) { |
|
|
|
let cusData = {ccusname: customerName} |
|
|
|
getCustomers(cusData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.customerPersons = data.rows |
|
|
|
this.customerPersons.forEach(o => { |
|
|
|
if (!this.customerMap.has(o.ccontactname)) { |
|
|
|
this.customerMap.set(o.ccontactname, o.cnative); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
getCustomerAdd(cusData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.customerAddrs = data.rows |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 下载 |
|
|
|
async downloadFile () { |
|
|
|
let file = { |
|
|
|
|