From fc95f268185e82d3f96fe92b4c2ef53cb4c60d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Tue, 10 Nov 2026 17:47:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 10 +++ src/api/initialImport.js | 32 +++++++ src/views/modules/sys/initialImport.vue | 111 ++++++++++++++++++------ 3 files changed, 125 insertions(+), 28 deletions(-) diff --git a/config/index.js b/config/index.js index f046879..9cf561c 100644 --- a/config/index.js +++ b/config/index.js @@ -12,6 +12,16 @@ module.exports = { assetsPublicPath: '/', // 代理列表, 是否开启代理通过[./dev.env.js]配置 proxyTable: devEnv.OPEN_PROXY === false ? {} : { + // V2 价格导入代理先匹配,入站及后端等待均允许 30 分钟。- rqrq + '/proxyApi/**/initialImport/supplierPrice/v2/**': { + target: 'http://127.0.0.1:7002', + changeOrigin: true, + timeout: 30 * 60 * 1000, + proxyTimeout: 30 * 60 * 1000, + pathRewrite: { + '^/proxyApi': '/' + } + }, '/proxyApi': { target: 'http://127.0.0.1:7002', changeOrigin: true, diff --git a/src/api/initialImport.js b/src/api/initialImport.js index f3a04e4..44aef3e 100644 --- a/src/api/initialImport.js +++ b/src/api/initialImport.js @@ -29,6 +29,38 @@ export const saveSupplierPrice = data => http({ timeout: 30 * 60 * 1000 }) +// 新版价格期初导入:旧版三个调用保留,页面改用下面的 V2 接口。- rqrq +const SUPPLIER_PRICE_IMPORT_TIMEOUT = 30 * 60 * 1000 + +export const downloadSupplierPriceTemplateV2 = () => http({ + url: http.adornUrl('/sys/initialImport/supplierPrice/v2/template'), + method: 'get', + responseType: 'blob', + timeout: SUPPLIER_PRICE_IMPORT_TIMEOUT +}) + +export const previewSupplierPriceV2 = (file, site) => { + const formData = new FormData() + formData.append('file', file) + formData.append('site', site) + return http({ + url: http.adornUrl('/sys/initialImport/supplierPrice/v2/preview'), + method: 'post', + data: formData, + headers: { + 'Content-Type': 'multipart/form-data' + }, + timeout: SUPPLIER_PRICE_IMPORT_TIMEOUT + }) +} + +export const saveSupplierPriceV2 = data => http({ + url: http.adornUrl('/sys/initialImport/supplierPrice/v2/save'), + method: 'post', + data: http.adornData(data), + timeout: SUPPLIER_PRICE_IMPORT_TIMEOUT +}) + export const downloadPartSkuTemplate = () => http({ url: http.adornUrl('/sys/initialImport/partSku/template'), method: 'get', diff --git a/src/views/modules/sys/initialImport.vue b/src/views/modules/sys/initialImport.vue index 3017fc5..66fa46b 100644 --- a/src/views/modules/sys/initialImport.vue +++ b/src/views/modules/sys/initialImport.vue @@ -15,6 +15,7 @@ {{ scope.row.name }} @@ -28,9 +29,9 @@ :visible.sync="dialogVisible" :width="dialogWidth" top="5vh" - :show-close="!saving" + :show-close="!importBusy" :close-on-click-modal="false" - :close-on-press-escape="!saving" + :close-on-press-escape="!importBusy" :before-close="handleDialogClose" @closed="handleDialogClosed">
@@ -38,14 +39,14 @@ v-if="isPoOrderImport" v-model="poCustomer" :site="currentSite" - :disabled="previewLoading || saving" + :disabled="importBusy" @input="handlePoCustomerChange" class="po-import-customer-picker" /> 下载导入模板 @@ -56,20 +57,20 @@ :auto-upload="false" :show-file-list="false" :limit="1" - :disabled="previewLoading || saving" + :disabled="importBusy" :on-change="handleFileChange" :on-exceed="handleFileExceed"> + :disabled="importBusy"> 选择导入文件 导出校验结果 @@ -98,7 +99,7 @@ align="left" show-overflow-tooltip /> {{ saveButtonText }} - 关闭 + 关闭
@@ -134,13 +135,13 @@ import { downloadPoOrderTemplate, downloadPartSkuTemplate, - downloadSupplierPriceTemplate, + downloadSupplierPriceTemplateV2, previewPartSku, previewPoOrder, - previewSupplierPrice, + previewSupplierPriceV2, savePartSku, savePoOrderBatch, - saveSupplierPrice + saveSupplierPriceV2 } from '@/api/initialImport' import ComPoOrderCustomerPicker from '@/views/modules/order/com_poOrder_CustomerPicker.vue' @@ -161,7 +162,7 @@ export default { { type: 'supplierPrice', name: '供应商价格期初导入', - description: '导入供应商物料的QTY/PO、MOQ/COLOR、QTY/CARTON、阶梯数量和阶梯价格。' + description: '单次最多2000行,超过请分批导入。按表头导入供应商物料数量、阶梯价、备注、供应商简称和物料属性,SKU仅展示;价格明细相同不生成镜像。' }, // { // type: 'partSku', @@ -193,7 +194,9 @@ export default { missingSuppliers: [], supplierPriceColumns: [ { prop: 'rawCode', label: 'RAW CODE', width: 120, align: 'center' }, - { prop: 'supplier', label: '供应商名称', width: 180, align: 'center' }, + { prop: 'sku', label: 'SKU', width: 120, align: 'center' }, + { prop: 'supplier', label: 'SUPPLIER', width: 140, align: 'left' }, + { prop: 'fullName', label: 'full name', width: 220, align: 'left' }, { 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' }, @@ -214,6 +217,12 @@ export default { { 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' }, + { prop: 'fsc', label: 'fsc', width: 100, align: 'left' }, + { prop: 'fscClaim', label: 'FSC claim', width: 140, align: 'left' }, + { prop: 'leadFreePellet', label: 'Lead free Pellet', width: 140, align: 'left' }, + { prop: 'awareDpp', label: 'AWARE DPP', width: 140, align: 'left' }, + { prop: 'coo', label: 'COO', width: 100, align: 'left' }, + { prop: 'refill', label: 'refill', width: 100, align: 'left' }, { prop: 'remark', label: 'Remark', width: 160, align: 'left' }, { prop: 'latestChanges', label: 'latest changes', width: 160, align: 'left' } ], @@ -224,6 +233,10 @@ export default { } }, computed: { + // 所有导入操作共用忙碌状态,处理期间禁止重复提交、切换文件或关闭弹框。- rqrq + importBusy () { + return this.previewLoading || this.saving || this.templateDownloading || this.exporting + }, currentSite () { return this.$store.state.user.site || '' }, @@ -268,7 +281,7 @@ export default { }, saveDisabled () { // 任意导入类型只要存在黄标行,就不允许继续保存。 - if (this.previewLoading || this.saving || !this.previewRows.length || this.hasInvalidPreviewRows) { + if (this.importBusy || !this.previewRows.length || this.hasInvalidPreviewRows) { return true } if (this.isPoOrderImport) { @@ -300,6 +313,9 @@ export default { return true }, openImportDialog (type) { + if (this.importBusy || this.dialogVisible) { + return + } if (!this.ensureInitialImportAvailable()) { return } @@ -311,6 +327,9 @@ export default { this.dialogVisible = true }, handleFileChange (file) { + if (this.importBusy) { + return + } if (!this.ensureInitialImportAvailable()) { this.clearSelectedFile() return @@ -350,14 +369,14 @@ export default { this.$message.success(`Excel读取成功,共${this.previewRows.length}行`) this.showMissingDataAlert() } else { - this.$message.error((data && data.msg) || 'Excel读取失败') + this.showImportPreviewError((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.showImportPreviewError(message) this.clearSelectedFile() }).finally(() => { this.previewLoading = false @@ -369,7 +388,19 @@ export default { } return this.activeImportType === 'partSku' ? previewPartSku(rawFile, site) - : previewSupplierPrice(rawFile, site) + : previewSupplierPriceV2(rawFile, site) + }, + // 新版价格读取失败需保留提示,方便用户看清公式来源和单元格位置;其他导入沿用原提示。- rqrq + showImportPreviewError (message) { + if (this.activeImportType !== 'supplierPrice') { + this.$message.error(message) + return + } + this.$alert(message, '导入文件读取失败', { + confirmButtonText: '确定', + type: 'error', + customClass: 'initial-import-error-alert' + }).catch(() => {}) }, buildPoOrderColumns (columnMapping) { // 预览表按模板字段展示;物料编码等于 Item,供应商编码仍由 Vendor Name 解析。 @@ -386,6 +417,9 @@ export default { return columns }, handlePoCustomerChange () { + if (this.importBusy) { + return + } if (!this.importFile && !this.previewRows.length) { return } @@ -397,13 +431,16 @@ export default { this.clearSelectedFile() }, handleFileExceed (files) { - if (this.previewLoading || !files || !files.length) { + if (this.importBusy || !files || !files.length) { return } this.clearSelectedFile() this.handleFileChange({ raw: files[0], name: files[0].name }) }, handleDownloadTemplate () { + if (this.importBusy) { + return + } if (!this.ensureInitialImportAvailable()) { return } @@ -443,7 +480,7 @@ export default { } return this.activeImportType === 'partSku' ? downloadPartSkuTemplate - : downloadSupplierPriceTemplate + : downloadSupplierPriceTemplateV2 }, resolveDownloadTemplateFileName () { if (this.isPoOrderImport) { @@ -454,6 +491,9 @@ export default { : '供应商价格期初导入模板.xlsx' }, handleSave () { + if (this.importBusy) { + return + } if (!this.ensureInitialImportAvailable()) { return } @@ -479,7 +519,7 @@ export default { }, performSave (site) { this.saving = true - const saveRequest = this.activeImportType === 'partSku' ? savePartSku : saveSupplierPrice + const saveRequest = this.activeImportType === 'partSku' ? savePartSku : saveSupplierPriceV2 saveRequest({ site, rows: this.previewRows @@ -540,7 +580,8 @@ export default { }, /** * 从保存接口失败结果中取出用户可读错误。 - * HTTP 200 + code=500 时错误在 data.msg;网络/超时时走 axios error。 + * HTTP 200 + code=500 时错误在 data.msg;区分网络中断、请求超时和代理错误。- rqrq + * 请求断开无法判定后端事务结果,提示先确认结果,避免重复导入。 */ resolveImportSaveErrorMessage (error, fallback) { if (!error) { @@ -550,10 +591,21 @@ export default { if (responseData && responseData.msg) { return responseData.msg } - if (error.message && /timeout/i.test(error.message)) { - return '保存超时,请缩小导入行数后重试' + const message = error.message || '' + const timeout = Number(error.config && error.config.timeout) + const timeoutText = timeout > 0 ? `(本次请求等待上限为${Math.ceil(timeout / 60000)}分钟)` : '' + if (error.code === 'ERR_NETWORK' || /network error/i.test(message)) { + return `网络连接已中断,浏览器未收到服务器的最终响应${timeoutText}。后端可能仍在处理,请先确认导入结果,避免重复提交。` + } + if (error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || /timeout/i.test(message)) { + return `等待服务器响应超时${timeoutText},浏览器未收到最终结果。请先确认后端处理结果,避免重复提交。` + } + const status = error.response && error.response.status + if (status === 502 || status === 503 || status === 504) { + const reason = status === 504 ? '代理或网关等待后端响应超时' : '代理或网关暂时无法正常连接后端' + return `${reason}(HTTP ${status})。请先确认后端处理结果,避免重复提交。` } - return error.message || fallback + return message || fallback }, /** * 导入保存失败必须弹确认框,点确定后才关闭,避免 $message 几秒后消失看不清。 @@ -615,6 +667,9 @@ export default { * 结果:下载 Excel,失败行整行标黄,最后一列为错误信息。 */ handleExportPreview () { + if (this.importBusy) { + return + } if (!this.previewRows.length) { this.$message.warning('请先选择导入文件并完成预览') return @@ -640,7 +695,7 @@ export default { } }, /** - * 导出列与弹框预览一致:错误信息放在最左侧,PO 额外带 Excel 行号。 + * 导出列与弹框预览一致:错误信息放在最左侧,PO、价格导入额外带真实 Excel 行号。- rqrq */ buildPreviewExportColumns () { const columns = [{ @@ -649,7 +704,7 @@ export default { width: 280, align: 'left' }] - if (this.isPoOrderImport) { + if (this.isPoOrderImport || this.activeImportType === 'supplierPrice') { columns.push({ prop: 'excelRowNo', label: 'Excel行号' }) } return columns.concat(this.activeColumns || []) @@ -750,7 +805,7 @@ export default { } }, handleDialogClose (done) { - if (!this.saving) { + if (!this.importBusy) { done() } },