From f9f2218320b4aab0ec55831398ae0c531cd3373d Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Wed, 10 Jun 2026 09:51:32 +0800 Subject: [PATCH] bu --- src/views/modules/ecss/del_upload_excel.vue | 100 ++++++++++++++++-- .../modules/ecss/del_upload_excel_tx.vue | 100 ++++++++++++++++-- 2 files changed, 188 insertions(+), 12 deletions(-) diff --git a/src/views/modules/ecss/del_upload_excel.vue b/src/views/modules/ecss/del_upload_excel.vue index 8c1b1f9..570dc3d 100644 --- a/src/views/modules/ecss/del_upload_excel.vue +++ b/src/views/modules/ecss/del_upload_excel.vue @@ -333,6 +333,15 @@ clearable> + + + + + 查询 @@ -626,7 +635,8 @@ customerTemplateList: [],//客户模板列表 templateSearchData: { templateName: '', - customerName: '' + customerName: '', + buNo: '' },//模板搜索条件 cacheKey: '', // 缓存键 cacheTimer: null, // 缓存定时器 @@ -1368,6 +1378,7 @@ // 为行选择客户模板 selectTemplateForRow(row) { this.currentRow = row + this.templateSearchData.buNo = this.pageData.buNo || '' this.getCustomerTemplateList() this.templateFlag = true }, @@ -1411,12 +1422,78 @@ this.overseasAddressFlag = true }, + // 按BU映射模板的bu_no规则 + getTemplateBuNoByBu(buNo) { + const sourceBu = (buNo || '').toString().trim() + if (!sourceBu) { + return '' + } + const upperBu = sourceBu.toUpperCase() + const buCodeMatch = upperBu.match(/\d{2}/) + const buCode = buCodeMatch ? buCodeMatch[0] : '' + + if (['01', '03'].includes(buCode) || upperBu.includes('RFID') || upperBu.includes('LABEL') || upperBu.includes('软标')) { + return '03-RFID,01-Label' + } + if (['02', '05'].includes(buCode) || upperBu.includes('HARD') || upperBu.includes('ALPHA') || upperBu.includes('硬标')) { + return '02-Hardtag,05-Alpha' + } + if (buCode === '04' || upperBu.includes('MHM') || upperBu.includes('天线')) { + return '04-MHM' + } + return sourceBu + }, + + // 解析逗号分隔的bu_no + parseTemplateBuNoList(templateBuNo) { + return (templateBuNo || '') + .toString() + .split(',') + .map(item => item.trim()) + .filter(item => item) + }, + + // 构造模板查询参数 + buildTemplateSearchParams(searchParams = {}) { + const mergedBuNo = searchParams.buNo !== undefined + ? searchParams.buNo + : (this.templateSearchData.buNo || this.pageData.buNo || '') + const templateBuNo = this.getTemplateBuNoByBu(mergedBuNo) + const params = { + templateName: searchParams.templateName !== undefined ? searchParams.templateName : this.templateSearchData.templateName, + customerName: searchParams.customerName !== undefined ? searchParams.customerName : this.templateSearchData.customerName + } + + if (mergedBuNo) { + params.buNo = mergedBuNo + } + if (templateBuNo) { + params.templateBuNo = templateBuNo + } + return params + }, + + // 前端兜底:只保留命中当前BU组的模板 + filterTemplateListByBu(templateList, selectedBuNo) { + const expectedBuList = this.parseTemplateBuNoList(this.getTemplateBuNoByBu(selectedBuNo)) + if (expectedBuList.length === 0) { + return templateList || [] + } + return (templateList || []).filter(item => { + const itemBuList = this.parseTemplateBuNoList(item.bu_no || item.buNo) + return itemBuList.some(itemBu => expectedBuList.includes(itemBu)) + }) + }, + // 获取客户模板列表 async getCustomerTemplateList(searchParams = {}) { + const requestParams = this.buildTemplateSearchParams(searchParams) try { - const { data } = await getCustomerTemplateList(searchParams) + const { data } = await getCustomerTemplateList(requestParams) if (data && data.code === 0) { - this.customerTemplateList = data.rows || [] + this.customerTemplateList = this.filterTemplateListByBu(data.rows || [], requestParams.buNo) + } else { + this.customerTemplateList = [] } } catch (error) { console.error('获取客户模板列表失败:', error) @@ -1428,7 +1505,8 @@ searchTemplateList() { const searchParams = { templateName: this.templateSearchData.templateName, - customerName: this.templateSearchData.customerName + customerName: this.templateSearchData.customerName, + buNo: this.templateSearchData.buNo || this.pageData.buNo || '' } this.getCustomerTemplateList(searchParams) }, @@ -1437,7 +1515,8 @@ resetTemplateSearch() { this.templateSearchData = { templateName: '', - customerName: '' + customerName: '', + buNo: this.pageData.buNo || '' } this.getCustomerTemplateList() }, @@ -1641,6 +1720,13 @@ return } + const selectedBuNo = this.pageData.buNo || this.templateSearchData.buNo + const templateBuNo = this.getTemplateBuNoByBu(selectedBuNo) + if (!templateBuNo) { + this.$message.warning('请先选择BU') + return + } + // 判断操作类型,给用户明确提示 const isNewTemplate = !row.originalTemplateName || row.originalTemplateName === '' const isNameChanged = row.originalTemplateName && row.selectedTemplate !== row.originalTemplateName @@ -1682,7 +1768,9 @@ overseasShipper: row.selectedOverseasShipper || '', overseasAddress: row.selectedOverseasAddress || '', cnative: row.selectedCnative || '', - salesArea: row.selectedSalesArea || '' + salesArea: row.selectedSalesArea || '', + buNo: selectedBuNo || '', + templateBuNo: templateBuNo } try { diff --git a/src/views/modules/ecss/del_upload_excel_tx.vue b/src/views/modules/ecss/del_upload_excel_tx.vue index 6f2e549..5579b5e 100644 --- a/src/views/modules/ecss/del_upload_excel_tx.vue +++ b/src/views/modules/ecss/del_upload_excel_tx.vue @@ -333,6 +333,15 @@ clearable> + + + + + 查询 @@ -626,7 +635,8 @@ customerTemplateList: [],//客户模板列表 templateSearchData: { templateName: '', - customerName: '' + customerName: '', + buNo: '' },//模板搜索条件 cacheKey: '', // 缓存键 cacheTimer: null, // 缓存定时器 @@ -1368,6 +1378,7 @@ // 为行选择客户模板 selectTemplateForRow(row) { this.currentRow = row + this.templateSearchData.buNo = this.pageData.buNo || '' this.getCustomerTemplateList() this.templateFlag = true }, @@ -1411,12 +1422,78 @@ this.overseasAddressFlag = true }, + // 按BU映射模板的bu_no规则 + getTemplateBuNoByBu(buNo) { + const sourceBu = (buNo || '').toString().trim() + if (!sourceBu) { + return '' + } + const upperBu = sourceBu.toUpperCase() + const buCodeMatch = upperBu.match(/\d{2}/) + const buCode = buCodeMatch ? buCodeMatch[0] : '' + + if (['01', '03'].includes(buCode) || upperBu.includes('RFID') || upperBu.includes('LABEL') || upperBu.includes('软标')) { + return '03-RFID,01-Label' + } + if (['02', '05'].includes(buCode) || upperBu.includes('HARD') || upperBu.includes('ALPHA') || upperBu.includes('硬标')) { + return '02-Hardtag,05-Alpha' + } + if (buCode === '04' || upperBu.includes('MHM') || upperBu.includes('天线')) { + return '04-MHM' + } + return sourceBu + }, + + // 解析逗号分隔的bu_no + parseTemplateBuNoList(templateBuNo) { + return (templateBuNo || '') + .toString() + .split(',') + .map(item => item.trim()) + .filter(item => item) + }, + + // 构造模板查询参数 + buildTemplateSearchParams(searchParams = {}) { + const mergedBuNo = searchParams.buNo !== undefined + ? searchParams.buNo + : (this.templateSearchData.buNo || this.pageData.buNo || '') + const templateBuNo = this.getTemplateBuNoByBu(mergedBuNo) + const params = { + templateName: searchParams.templateName !== undefined ? searchParams.templateName : this.templateSearchData.templateName, + customerName: searchParams.customerName !== undefined ? searchParams.customerName : this.templateSearchData.customerName + } + + if (mergedBuNo) { + params.buNo = mergedBuNo + } + if (templateBuNo) { + params.templateBuNo = templateBuNo + } + return params + }, + + // 前端兜底:只保留命中当前BU组的模板 + filterTemplateListByBu(templateList, selectedBuNo) { + const expectedBuList = this.parseTemplateBuNoList(this.getTemplateBuNoByBu(selectedBuNo)) + if (expectedBuList.length === 0) { + return templateList || [] + } + return (templateList || []).filter(item => { + const itemBuList = this.parseTemplateBuNoList(item.bu_no || item.buNo) + return itemBuList.some(itemBu => expectedBuList.includes(itemBu)) + }) + }, + // 获取客户模板列表 async getCustomerTemplateList(searchParams = {}) { + const requestParams = this.buildTemplateSearchParams(searchParams) try { - const { data } = await getCustomerTemplateList(searchParams) + const { data } = await getCustomerTemplateList(requestParams) if (data && data.code === 0) { - this.customerTemplateList = data.rows || [] + this.customerTemplateList = this.filterTemplateListByBu(data.rows || [], requestParams.buNo) + } else { + this.customerTemplateList = [] } } catch (error) { console.error('获取客户模板列表失败:', error) @@ -1428,7 +1505,8 @@ searchTemplateList() { const searchParams = { templateName: this.templateSearchData.templateName, - customerName: this.templateSearchData.customerName + customerName: this.templateSearchData.customerName, + buNo: this.templateSearchData.buNo || this.pageData.buNo || '' } this.getCustomerTemplateList(searchParams) }, @@ -1437,7 +1515,8 @@ resetTemplateSearch() { this.templateSearchData = { templateName: '', - customerName: '' + customerName: '', + buNo: this.pageData.buNo || '' } this.getCustomerTemplateList() }, @@ -1641,6 +1720,13 @@ return } + const selectedBuNo = this.pageData.buNo || this.templateSearchData.buNo + const templateBuNo = this.getTemplateBuNoByBu(selectedBuNo) + if (!templateBuNo) { + this.$message.warning('请先选择BU') + return + } + // 判断操作类型,给用户明确提示 const isNewTemplate = !row.originalTemplateName || row.originalTemplateName === '' const isNameChanged = row.originalTemplateName && row.selectedTemplate !== row.originalTemplateName @@ -1682,7 +1768,9 @@ overseasShipper: row.selectedOverseasShipper || '', overseasAddress: row.selectedOverseasAddress || '', cnative: row.selectedCnative || '', - salesArea: row.selectedSalesArea || '' + salesArea: row.selectedSalesArea || '', + buNo: selectedBuNo || '', + templateBuNo: templateBuNo } try {