You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

899 lines
30 KiB

<template>
<div class="mod-initial-import">
<div class="page-toolbar">
<div>
<div class="page-title">期初导入</div>
<div class="page-subtitle">按业务类型导入系统启用前的基础数据</div>
</div>
</div>
<div class="rq">
<el-table :data="importItems" border style="width: 100%">
<el-table-column prop="name" label="期初导入功能" min-width="220" />
<el-table-column prop="description" label="说明" min-width="520" show-overflow-tooltip />
<el-table-column label="操作" width="220" align="center">
<template slot-scope="scope">
<el-button
type="primary"
icon="el-icon-upload2"
@click="openImportDialog(scope.row.type)">
{{ scope.row.name }}
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-dialog
:title="dialogTitle"
v-drag
:visible.sync="dialogVisible"
:width="dialogWidth"
top="5vh"
:show-close="!saving"
:close-on-click-modal="false"
:close-on-press-escape="!saving"
:before-close="handleDialogClose"
@closed="handleDialogClosed">
<div class="dialog-toolbar">
<com-po-order-customer-picker
v-if="isPoOrderImport"
v-model="poCustomer"
:site="currentSite"
:disabled="previewLoading || saving"
@input="handlePoCustomerChange"
class="po-import-customer-picker" />
<el-button
type="primary"
icon="el-icon-download"
:loading="templateDownloading"
:disabled="previewLoading || saving"
@click="handleDownloadTemplate">
下载导入模板
</el-button>
<el-upload
ref="initialImportUpload"
action="#"
accept=".xls,.xlsx"
:auto-upload="false"
:show-file-list="false"
:limit="1"
:disabled="previewLoading || saving"
:on-change="handleFileChange"
:on-exceed="handleFileExceed">
<el-button
icon="el-icon-upload2"
:loading="previewLoading"
:disabled="previewLoading || saving">
选择导入文件
</el-button>
</el-upload>
<el-button
icon="el-icon-download"
:loading="exporting"
:disabled="previewLoading || saving || exporting || !previewRows.length"
@click="handleExportPreview">
导出校验结果
</el-button>
<span class="file-name" :title="fileName">{{ fileName || '未选择文件' }}</span>
<span v-if="hasInvalidPreviewRows" class="invalid-hint">存在校验失败行,请先导出并修正后再保存</span>
<span class="preview-count">
已读取 {{ previewRows.length }} 行<span v-if="previewRows.length > previewDisplayLimit">,表格显示前{{ previewDisplayLimit }}行</span>
<span v-if="invalidPreviewCount">,其中 {{ invalidPreviewCount }} 行校验失败</span>
</span>
</div>
<el-table
v-loading="previewLoading"
:data="previewDisplayRows"
border
height="520"
size="mini"
empty-text="请选择Excel文件进行预览"
:row-class-name="previewRowClassName"
class="initial-import-preview">
<el-table-column
prop="validationMessage"
label="错误信息"
min-width="280"
fixed="left"
align="left"
show-overflow-tooltip />
<el-table-column
v-if="isPoOrderImport"
prop="excelRowNo"
label="Excel行号"
width="90"
fixed="left"
align="center" />
<el-table-column
v-for="column in activeColumns"
:key="column.prop"
:prop="column.prop"
:label="column.label"
:min-width="column.width"
:align="column.align"
show-overflow-tooltip />
</el-table>
<div v-if="isPoOrderImport && saveProgressText" class="save-progress">{{ saveProgressText }}</div>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
icon="el-icon-check"
:loading="saving"
:disabled="saveDisabled"
@click="handleSave">
{{ saveButtonText }}
</el-button>
<el-button :disabled="previewLoading || saving" @click="dialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
downloadPoOrderTemplate,
downloadPartSkuTemplate,
downloadSupplierPriceTemplate,
previewPartSku,
previewPoOrder,
previewSupplierPrice,
savePartSku,
savePoOrderBatch,
saveSupplierPrice
} from '@/api/initialImport'
import ComPoOrderCustomerPicker from '@/views/modules/order/com_poOrder_CustomerPicker.vue'
/**
* 期初导入可用截止日(含当天)。本地日历日晚于该日期后,三个导入入口均禁止使用。
*/
const INITIAL_IMPORT_DEADLINE = '2099-10-10'
const INITIAL_IMPORT_EXPIRED_MSG = '期初导入功能已超过可用日期'
export default {
name: 'SysInitialImport',
components: {
ComPoOrderCustomerPicker
},
data () {
return {
importItems: [
{
type: 'supplierPrice',
name: '供应商价格期初导入',
description: '导入供应商物料的QTY/PO、MOQ/COLOR、QTY/CARTON、阶梯数量和阶梯价格。'
},
// {
// type: 'partSku',
// name: '物料SKU导入',
// description: '按Item更新物料SKU,不存在的SKU会自动新增。'
// },
{
type: 'poOrder',
name: 'PO订单导入',
description: '按Customer下载动态模板并批量创建PO订单。'
}
],
activeImportType: '',
dialogVisible: false,
previewLoading: false,
saving: false,
templateDownloading: false,
exporting: false,
fileName: '',
importFile: null,
poCustomer: '',
previewRows: [],
previewDisplayLimit: 500,
poOrderColumns: [],
saveProgressText: '',
// 保存成功后先关弹框,等关闭动画结束再弹出绿色提示,避免提示被弹框盖住或一起消失。
pendingSuccessMessage: '',
missingItems: [],
missingSuppliers: [],
supplierPriceColumns: [
{ prop: 'rawCode', label: 'RAW CODE', width: 120, align: 'center' },
{ prop: 'supplier', label: '供应商名称', width: 180, align: 'center' },
{ prop: 'moqColor', label: 'MOQ/COLOR', width: 80, align: 'center' },
{ prop: 'qtyPo', label: 'QTY/PO', width: 80, align: 'center' },
{ prop: 'qtyCarton', label: 'QTY/CARTON', width: 90, align: 'center' },
{ prop: 'startDate', label: 'START DATE', width: 100, align: 'center' },
{ prop: 'tierQty1', label: 'Tier_QTY_1', width: 80, align: 'center' },
{ prop: 'tierQty2', label: 'Tier_QTY_2', width: 80, align: 'center' },
{ prop: 'tierQty3', label: 'Tier_QTY_3', width: 80, align: 'center' },
{ prop: 'tierQty4', label: 'Tier_QTY_4', width: 80, align: 'center' },
{ prop: 'tierQty5', label: 'Tier_QTY_5', width: 80, align: 'center' },
{ prop: 'tierQty6', label: 'Tier_QTY_6', width: 80, align: 'center' },
{ prop: 'tierQty7', label: 'Tier_QTY_7', width: 80, align: 'center' },
{ prop: 'tierQty8', label: 'Tier_QTY_8', width: 80, align: 'center' },
{ prop: 'priceTier1', label: 'Price_Tier_1', width: 90, align: 'center' },
{ prop: 'priceTier2', label: 'Price_Tier_2', width: 90, align: 'center' },
{ prop: 'priceTier3', label: 'Price_Tier_3', width: 90, align: 'center' },
{ prop: 'priceTier4', label: 'Price_Tier_4', width: 90, align: 'center' },
{ prop: 'priceTier5', label: 'Price_Tier_5', width: 90, align: 'center' },
{ prop: 'priceTier6', label: 'Price_Tier_6', width: 90, align: 'center' },
{ prop: 'priceTier7', label: 'Price_Tier_7', width: 90, align: 'center' },
{ prop: 'priceTier8', label: 'Price_Tier_8', width: 90, align: 'center' }
],
partSkuColumns: [
{ prop: 'item', label: 'ITEM', width: 220, align: 'left' },
{ prop: 'sku', label: 'SKU', width: 220, align: 'left' }
]
}
},
computed: {
currentSite () {
return this.$store.state.user.site || ''
},
isPoOrderImport () {
return this.activeImportType === 'poOrder'
},
activeColumns () {
let columns
if (this.isPoOrderImport) {
columns = this.poOrderColumns
} else if (this.activeImportType === 'partSku') {
columns = this.partSkuColumns
} else {
columns = this.supplierPriceColumns
}
// 预览业务列不含错误信息;弹框里错误信息单独固定在最左侧。
return (columns || []).filter(column => column.prop !== 'validationMessage')
},
invalidPreviewCount () {
return this.previewRows.filter(row => this.isPreviewRowInvalid(row)).length
},
hasInvalidPreviewRows () {
return this.invalidPreviewCount > 0
},
previewDisplayRows () {
return this.previewRows.slice(0, this.previewDisplayLimit)
},
dialogTitle () {
if (this.activeImportType === 'poOrder') {
return 'PO订单导入'
}
return this.activeImportType === 'partSku' ? '物料SKU导入' : '供应商价格期初导入'
},
dialogWidth () {
if (this.activeImportType === 'poOrder') {
return '94%'
}
return this.activeImportType === 'partSku' ? '860px' : '94%'
},
saveButtonText () {
return '保存'
},
saveDisabled () {
// 任意导入类型只要存在黄标行,就不允许继续保存。
if (this.previewLoading || this.saving || !this.previewRows.length || this.hasInvalidPreviewRows) {
return true
}
if (this.isPoOrderImport) {
return !this.poCustomer
}
return false
}
},
methods: {
/**
* 取浏览器本地日历日 YYYY-MM-DD。
* 不用 toISOString,避免 UTC 把日期提前或推后一天。
*/
getLocalDateText () {
const now = new Date()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
return `${now.getFullYear()}-${month}-${day}`
},
/**
* 导入按钮点击拦截:超过 2026-10-08 则报错并阻止后续导入。
* @returns {boolean} true 表示仍在可用期内
*/
ensureInitialImportAvailable () {
if (this.getLocalDateText() > INITIAL_IMPORT_DEADLINE) {
this.$message.error(INITIAL_IMPORT_EXPIRED_MSG)
return false
}
return true
},
openImportDialog (type) {
if (!this.ensureInitialImportAvailable()) {
return
}
if (type !== 'supplierPrice' && type !== 'partSku' && type !== 'poOrder') {
return
}
this.resetDialog()
this.activeImportType = type
this.dialogVisible = true
},
handleFileChange (file) {
if (!this.ensureInitialImportAvailable()) {
this.clearSelectedFile()
return
}
const rawFile = file && file.raw
if (!rawFile) {
return
}
const site = this.$store.state.user.site
if (!site) {
this.$message.error('当前登录用户没有Site')
this.clearSelectedFile()
return
}
this.fileName = file.name || ''
this.importFile = rawFile
this.saveProgressText = ''
if (this.isPoOrderImport && !this.poCustomer) {
this.$message.warning('请先选择 Customer')
this.clearSelectedFile()
return
}
this.previewRows = []
this.poOrderColumns = []
this.missingItems = []
this.missingSuppliers = []
this.previewLoading = true
const previewRequest = this.resolvePreviewRequest(rawFile, site)
previewRequest.then(({ data }) => {
if (data && data.code === 0) {
this.previewRows = data.data || []
this.missingItems = data.missingItems || []
this.missingSuppliers = data.missingSuppliers || []
if (this.isPoOrderImport) {
this.poOrderColumns = this.buildPoOrderColumns(data.columnMapping || {})
}
this.$message.success(`Excel读取成功,共${this.previewRows.length}行`)
this.showMissingDataAlert()
} else {
this.$message.error((data && data.msg) || 'Excel读取失败')
this.clearSelectedFile()
}
}).catch(error => {
const message = error && error.response && error.response.data && error.response.data.msg
? error.response.data.msg
: 'Excel读取失败,请检查文件格式'
this.$message.error(message)
this.clearSelectedFile()
}).finally(() => {
this.previewLoading = false
})
},
resolvePreviewRequest (rawFile, site) {
if (this.isPoOrderImport) {
return previewPoOrder(rawFile, site, this.poCustomer)
}
return this.activeImportType === 'partSku'
? previewPartSku(rawFile, site)
: previewSupplierPrice(rawFile, site)
},
buildPoOrderColumns (columnMapping) {
// 预览表按模板字段展示;物料编码等于 Item,供应商编码仍由 Vendor Name 解析。
const columns = Object.keys(columnMapping).map(prop => ({
prop,
label: columnMapping[prop],
width: 130,
align: 'left'
}))
columns.push(
{ prop: 'part_no', label: '物料编码', width: 140, align: 'left' },
{ prop: 'supplier_no', label: '供应商编码', width: 140, align: 'left' }
)
return columns
},
handlePoCustomerChange () {
if (!this.importFile && !this.previewRows.length) {
return
}
this.previewRows = []
this.poOrderColumns = []
this.missingItems = []
this.missingSuppliers = []
this.saveProgressText = ''
this.clearSelectedFile()
},
handleFileExceed (files) {
if (this.previewLoading || !files || !files.length) {
return
}
this.clearSelectedFile()
this.handleFileChange({ raw: files[0], name: files[0].name })
},
handleDownloadTemplate () {
if (!this.ensureInitialImportAvailable()) {
return
}
const site = this.currentSite
if (!site) {
this.$message.error('当前登录用户没有Site')
return
}
if (this.isPoOrderImport && !this.poCustomer) {
this.$message.warning('请先选择 Customer')
return
}
this.templateDownloading = true
const downloadRequest = this.resolveDownloadTemplateRequest()
const downloadFileName = this.resolveDownloadTemplateFileName()
downloadRequest().then(response => {
const blob = new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = downloadFileName
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
}).catch(() => {
this.$message.error('模板下载失败,请联系管理员')
}).finally(() => {
this.templateDownloading = false
})
},
resolveDownloadTemplateRequest () {
if (this.isPoOrderImport) {
return () => downloadPoOrderTemplate(this.currentSite, this.poCustomer)
}
return this.activeImportType === 'partSku'
? downloadPartSkuTemplate
: downloadSupplierPriceTemplate
},
resolveDownloadTemplateFileName () {
if (this.isPoOrderImport) {
return `PO订单导入模板_${this.poCustomer}.xlsx`
}
return this.activeImportType === 'partSku'
? '物料SKU期初导入模板.xlsx'
: '供应商价格期初导入模板.xlsx'
},
handleSave () {
if (!this.ensureInitialImportAvailable()) {
return
}
if (!this.previewRows.length) {
this.$message.warning('请先选择导入文件并完成预览')
return
}
// 三个导入统一:有黄标行一律禁止保存,避免把失败数据写入系统。
if (this.hasInvalidPreviewRows) {
this.$message.warning(`有${this.invalidPreviewCount}行校验未通过,请修正Excel后重新预览。可先导出校验结果`)
return
}
if (this.isPoOrderImport) {
this.performPoOrderImport()
return
}
const site = this.$store.state.user.site
if (!site) {
this.$message.error('当前登录用户没有Site')
return
}
this.performSave(site)
},
performSave (site) {
this.saving = true
const saveRequest = this.activeImportType === 'partSku' ? savePartSku : saveSupplierPrice
saveRequest({
site,
rows: this.previewRows
}).then(({ data }) => {
if (data && data.code === 0) {
this.closeImportDialogAfterSuccess()
} else {
this.showImportSaveError((data && data.msg) || '保存失败')
}
}).catch(error => {
this.showImportSaveError(this.resolveImportSaveErrorMessage(error, '保存失败,请稍后重试'))
}).finally(() => {
this.saving = false
})
},
async performPoOrderImport () {
if (!this.previewRows.length) {
this.$message.warning('请先选择导入文件并完成预览')
return
}
if (!this.currentSite) {
this.$message.error('当前登录用户没有Site')
return
}
if (!this.poCustomer) {
this.$message.warning('请先选择 Customer')
return
}
this.saving = true
this.saveProgressText = ''
const batchSize = 500
const totalCount = this.previewRows.length
let savedCount = 0
try {
while (this.previewRows.length) {
const rows = this.previewRows.slice(0, batchSize)
const { data } = await savePoOrderBatch({
site: this.currentSite,
customer: this.poCustomer,
rows
})
if (!(data && data.code === 0)) {
throw new Error((data && data.msg) || `第${Math.floor(savedCount / batchSize) + 1}批保存失败`)
}
savedCount += Number(data.savedCount == null ? rows.length : data.savedCount)
// 已成功提交的行立即从待保存列表移除。若后续批次失败,用户再次点击保存时
// 只会续传剩余行,避免前面已提交的数据被重复创建。
this.previewRows.splice(0, rows.length)
this.saveProgressText = `正在分批保存:${savedCount}/${totalCount}`
}
this.closeImportDialogAfterSuccess()
} catch (error) {
const message = this.resolveImportSaveErrorMessage(error, '保存失败,请稍后重试')
this.showImportSaveError(`已保存${savedCount}行,后续批次停止:${message}`)
} finally {
this.saving = false
}
},
/**
* 从保存接口失败结果中取出用户可读错误。
* HTTP 200 + code=500 时错误在 data.msg;网络/超时时走 axios error。
*/
resolveImportSaveErrorMessage (error, fallback) {
if (!error) {
return fallback
}
const responseData = error.response && error.response.data
if (responseData && responseData.msg) {
return responseData.msg
}
if (error.message && /timeout/i.test(error.message)) {
return '保存超时,请缩小导入行数后重试'
}
return error.message || fallback
},
/**
* 导入保存失败必须弹确认框,点确定后才关闭,避免 $message 几秒后消失看不清。
*/
showImportSaveError (message) {
const text = message || '保存失败'
const content = this.$createElement(
'div',
{ style: { maxHeight: '360px', overflowY: 'auto', whiteSpace: 'pre-wrap', wordBreak: 'break-all', lineHeight: '1.6', textAlign: 'left' } },
text
)
this.$alert(content, '导入保存失败', {
confirmButtonText: '确定',
type: 'error',
customClass: 'initial-import-error-alert'
}).catch(() => {})
},
/**
* 预览后弹出缺失主数据提示。
* PO 订单导入不再校验 Item 是否存在,因此不展示 Item 缺失清单。
*/
showMissingDataAlert () {
const showMissingItems = this.missingItems.length && !this.isPoOrderImport
const showMissingSuppliers = (this.activeImportType === 'supplierPrice' || this.isPoOrderImport) &&
this.missingSuppliers.length
if (!showMissingItems && !showMissingSuppliers) {
return
}
const messages = []
if (showMissingItems) {
messages.push(`以下Item不存在:${this.missingItems.join('、')}`)
}
if (showMissingSuppliers) {
const supplierLabel = this.isPoOrderImport ? 'Vendor Name' : '供应商名称'
messages.push(`以下${supplierLabel}不存在:${this.missingSuppliers.join('、')}`)
}
const content = this.$createElement(
'div',
{ style: { maxHeight: '360px', overflowY: 'auto', wordBreak: 'break-all', lineHeight: '1.6' } },
messages.map(message => this.$createElement('p', { style: { margin: '0 0 8px' } }, message))
)
this.$alert(content, '数据校验提示', {
confirmButtonText: '确定',
type: 'warning'
}).catch(() => {})
},
previewRowClassName ({ row }) {
return this.isPreviewRowInvalid(row) ? 'initial-import-warning-row' : ''
},
/**
* 预览行是否校验失败。只认 valid === false,与页面黄标规则一致。
*/
isPreviewRowInvalid (row) {
return !!(row && row.valid === false)
},
/**
* 导出当前预览数据及校验结果。
* 触发条件:已完成预览且存在数据行。
* 结果:下载 Excel,失败行整行标黄,最后一列为错误信息。
*/
handleExportPreview () {
if (!this.previewRows.length) {
this.$message.warning('请先选择导入文件并完成预览')
return
}
this.exporting = true
try {
const columns = this.buildPreviewExportColumns()
const xml = this.buildPreviewExportXml(columns, this.previewRows)
const blob = new Blob(['\ufeff' + xml], { type: 'application/vnd.ms-excel;charset=utf-8' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = this.resolvePreviewExportFileName()
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
this.$message.success('校验结果已导出')
} catch (error) {
this.$message.error((error && error.message) || '导出失败,请稍后重试')
} finally {
this.exporting = false
}
},
/**
* 导出列与弹框预览一致:错误信息放在最左侧,PO 额外带 Excel 行号。
*/
buildPreviewExportColumns () {
const columns = [{
prop: 'validationMessage',
label: '错误信息',
width: 280,
align: 'left'
}]
if (this.isPoOrderImport) {
columns.push({ prop: 'excelRowNo', label: 'Excel行号' })
}
return columns.concat(this.activeColumns || [])
},
resolvePreviewExportFileName () {
const now = new Date()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
const hour = String(now.getHours()).padStart(2, '0')
const minute = String(now.getMinutes()).padStart(2, '0')
const second = String(now.getSeconds()).padStart(2, '0')
return `${this.dialogTitle}校验结果_${now.getFullYear()}${month}${day}${hour}${minute}${second}.xls`
},
/**
* 生成带行底色的 SpreadsheetML,Excel 打开后失败行仍为黄色。
* 入参 columns 为导出列;rows 为当前全部预览行(不只表格显示的前 500 行)。
*/
buildPreviewExportXml (columns, rows) {
const headerCells = columns.map(column => {
const width = column.prop === 'validationMessage' ? 280 : 80
return `<Column ss:AutoFitWidth="0" ss:Width="${width}"/>`
}).join('')
const headerRow = '<Row ss:StyleID="Header">' + columns.map(column => {
return `<Cell><Data ss:Type="String">${this.escapeExcelXml(column.label)}</Data></Cell>`
}).join('') + '</Row>'
const dataRows = (rows || []).map(row => {
const styleAttr = this.isPreviewRowInvalid(row) ? ' ss:StyleID="Warn"' : ''
const cells = columns.map(column => {
const value = this.formatExportCellValue(row, column.prop)
return `<Cell><Data ss:Type="String">${this.escapeExcelXml(value)}</Data></Cell>`
}).join('')
return `<Row${styleAttr}>${cells}</Row>`
}).join('')
return `<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center" ss:WrapText="1"/>
</Style>
<Style ss:ID="Header">
<Font ss:Bold="1"/>
<Interior ss:Color="#D9D9D9" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="Warn">
<Interior ss:Color="#FFF7D6" ss:Pattern="Solid"/>
</Style>
</Styles>
<Worksheet ss:Name="校验结果">
<Table>${headerCells}${headerRow}${dataRows}</Table>
</Worksheet>
</Workbook>`
},
/**
* 导出单元格文本。空值输出空串,避免 Excel 出现 undefined。
*/
formatExportCellValue (row, prop) {
if (!row || !prop) {
return ''
}
const value = row[prop]
if (value == null || value === '') {
return ''
}
return String(value)
},
/**
* SpreadsheetML 特殊字符转义,防止错误信息里的符号破坏 XML。
*/
escapeExcelXml (value) {
return String(value == null ? '' : value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
},
/**
* 导入保存成功:先关弹框,提示文案等 closed 后再弹出。
*/
closeImportDialogAfterSuccess () {
this.saving = false
this.pendingSuccessMessage = '导入成功'
this.dialogVisible = false
},
/**
* 弹框关闭动画结束后再清理状态。
* 若本次是保存成功关闭,再弹出绿色“导入成功”,避免和弹框一起消失。
*/
handleDialogClosed () {
const successMessage = this.pendingSuccessMessage
this.pendingSuccessMessage = ''
this.resetDialog()
if (successMessage) {
this.$message.success(successMessage)
}
},
handleDialogClose (done) {
if (!this.saving) {
done()
}
},
clearSelectedFile () {
this.fileName = ''
this.importFile = null
if (this.$refs.initialImportUpload) {
this.$refs.initialImportUpload.clearFiles()
}
},
resetDialog () {
this.activeImportType = ''
this.previewLoading = false
this.saving = false
this.templateDownloading = false
this.exporting = false
this.previewRows = []
this.missingItems = []
this.missingSuppliers = []
this.poOrderColumns = []
this.saveProgressText = ''
this.poCustomer = ''
this.clearSelectedFile()
}
}
}
</script>
<style scoped>
.mod-initial-import {
padding: 16px;
}
.page-toolbar {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin-bottom: 14px;
}
.page-title {
color: #303133;
font-size: 18px;
font-weight: 600;
}
.page-subtitle {
margin-top: 4px;
color: #909399;
font-size: 13px;
}
.dialog-toolbar {
display: flex;
align-items: center;
flex-wrap: wrap;
min-height: 40px;
margin-bottom: 12px;
gap: 10px;
}
.po-import-customer-picker {
width: 100%;
}
.po-import-customer-picker /deep/ .el-form-item {
margin-bottom: 0;
}
.file-name {
display: inline-block;
max-width: 360px;
overflow: hidden;
color: #606266;
text-overflow: ellipsis;
white-space: nowrap;
}
.invalid-hint {
color: #e6a23c;
font-size: 13px;
}
.preview-count {
margin-left: auto;
color: #606266;
font-variant-numeric: tabular-nums;
}
.initial-import-preview {
width: 100%;
}
.initial-import-preview /deep/ .initial-import-warning-row > td {
background-color: #fff7d6 !important;
}
.initial-import-preview /deep/ .initial-import-warning-row:hover > td {
background-color: #fff0b3 !important;
}
.save-progress {
margin-top: 10px;
color: #606266;
font-size: 13px;
text-align: right;
}
.po-import-result {
min-height: 180px;
padding: 12px;
color: #606266;
font-size: 13px;
border: 1px solid #ebeef5;
border-radius: 4px;
background-color: #fafafa;
}
.po-import-errors {
max-height: 160px;
margin-top: 8px;
overflow: auto;
}
.po-import-error-row {
line-height: 1.6;
}
.po-import-error-more {
color: #909399;
}
.dialog-footer {
text-align: right;
}
</style>
<style>
/* MessageBox 挂到 body,不能写 scoped,否则超长 SQL 错误会撑破弹框。 */
.initial-import-error-alert .el-message-box__message {
max-height: 360px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
line-height: 1.6;
text-align: left;
}
</style>