From 20481d28a6711cab4eff014700937a20961a860f Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Thu, 30 Oct 2025 17:07:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=AF=8F=E4=B8=80=E6=AD=A5=E7=9A=84?= =?UTF-8?q?=E9=92=A2=E5=8D=B7=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=EF=BC=8C=E6=96=B0=E6=AD=A5=E9=AA=A4=E9=87=87?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/panels/code/apart.vue | 239 ++++++++++++++---- .../components/panels/code/merge.vue | 214 ++++++++++++---- .../components/panels/code/typing.vue | 222 +++++++++++----- 3 files changed, 509 insertions(+), 166 deletions(-) diff --git a/apps/hand-factory/components/panels/code/apart.vue b/apps/hand-factory/components/panels/code/apart.vue index cec66d6..d318bac 100644 --- a/apps/hand-factory/components/panels/code/apart.vue +++ b/apps/hand-factory/components/panels/code/apart.vue @@ -33,17 +33,9 @@ - - - ⚠️ - - 历史二维码 - 此二维码已失效,不允许进行分卷操作 - - - + 分卷配置 @@ -110,6 +102,21 @@ + + + + 选择产品 + + + {{ item.productName || '请选择产品' }} + + + + + 毛重 (kg) + + + + + + 选择产品 + + + + + + + + {{ product.productName }} + + + + 未找到匹配的产品 + + + + @@ -185,6 +224,7 @@ import { getGenerateRecord } from '@/api/wms/code.js' import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js' import { listWarehouse } from '@/api/wms/warehouse.js' +import { listProduct } from '@/api/wms/product.js' export default { data() { @@ -223,9 +263,11 @@ export default { warehouses: [], warehouseSearchKeyword: '', filteredWarehousesInPicker: [], + products: [], // 产品列表 + productSearchKeyword: '', + filteredProductsInPicker: [], currentPickerItemIndex: -1, - loading: false, - qrcodeStatus: 1 // 二维码状态:0=历史码,1=当前有效码 + loading: false } }, @@ -266,6 +308,111 @@ export default { } }, + // 加载产品列表 + async loadProducts() { + console.log('开始加载产品列表...'); + try { + const res = await listProduct({ pageNum: 1, pageSize: 1000 }); + console.log("产品返回值", res); + if (res.code === 200) { + this.products = res.rows || res.data || []; + this.filteredProductsInPicker = this.products; + console.log('产品加载成功,数量:', this.products.length); + } else { + console.error('产品加载失败:', res.msg); + } + } catch (err) { + console.error('加载产品异常:', err); + } + }, + + // 过滤库区(在选择器中) + filterWarehousesInPicker() { + const keyword = this.warehouseSearchKeyword.trim().toLowerCase(); + if (!keyword) { + this.filteredWarehousesInPicker = [...this.warehouses]; + } else { + this.filteredWarehousesInPicker = this.warehouses.filter(warehouse => { + const name = (warehouse.warehouseName || '').toLowerCase(); + return name.includes(keyword); + }); + } + }, + + // 从选择器中选择库区 + async selectWarehouseFromPicker(warehouse) { + if (this.currentPickerItemIndex === -1) return; + + const item = this.splitCoils[this.currentPickerItemIndex]; + item.warehouseId = warehouse.warehouseId; + item.warehouseName = warehouse.warehouseName; + this.closeWarehousePickerForItem(); + + // 检查是否选择了成品库区 + if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) { + // 加载产品列表 + await this.loadProducts(); + // 弹出产品选择框 + this.showProductPickerForItem(this.currentPickerItemIndex); + } + }, + + // 显示库区选择器(为特定分卷) + showWarehousePickerForItem(index) { + this.currentPickerItemIndex = index; + this.warehouseSearchKeyword = ''; + this.filteredWarehousesInPicker = [...this.warehouses]; + this.$refs.warehousePopup.open(); + }, + + // 关闭库区选择器 + closeWarehousePickerForItem() { + this.$refs.warehousePopup.close(); + this.currentPickerItemIndex = -1; + }, + + // 显示产品选择器(为特定分卷) + showProductPickerForItem(index) { + this.currentPickerItemIndex = index; + this.productSearchKeyword = ''; + this.filteredProductsInPicker = [...this.products]; + this.$refs.productPopup.open(); + }, + + // 关闭产品选择器 + closeProductPickerForItem() { + this.$refs.productPopup.close(); + this.currentPickerItemIndex = -1; + }, + + // 过滤产品(在选择器中) + filterProductsInPicker() { + const keyword = this.productSearchKeyword.trim().toLowerCase(); + if (!keyword) { + this.filteredProductsInPicker = [...this.products]; + } else { + this.filteredProductsInPicker = this.products.filter(product => { + const name = (product.productName || '').toLowerCase(); + return name.includes(keyword); + }); + } + }, + + // 从选择器中选择产品 + selectProductFromPicker(product) { + if (this.currentPickerItemIndex === -1) return; + + const item = this.splitCoils[this.currentPickerItemIndex]; + item.itemId = product.productId; + item.itemType = 'product'; + item.productName = product.productName; // 保存产品名称用于显示 + uni.showToast({ + title: `分卷 ${this.currentPickerItemIndex + 1} 已选择产品:${product.productName}`, + icon: 'success' + }); + this.closeProductPickerForItem(); + }, + // 过滤库区(为特定分卷) filterWarehousesForItem(index) { console.log(`分卷页面过滤库区,分卷${index + 1},关键词:`, this.splitCoils[index].warehouseKeyword); @@ -352,56 +499,56 @@ export default { throw new Error('未找到二维码记录'); } - // 2. 解析content获取enter_coil_no和current_coil_no + // 2. 解析content获取enter_coil_no、current_coil_no和coil_id const qrcodeRecord = qrcodeRes.data; const content = JSON.parse(qrcodeRecord.content); const enterCoilNo = content.enter_coil_no; const currentCoilNo = content.current_coil_no; - - // 保存二维码状态 - this.qrcodeStatus = qrcodeRecord.status || 1; - - // 如果是历史码,直接拒绝 - if (this.qrcodeStatus === 0) { - uni.showModal({ - title: '历史二维码', - content: '此二维码已失效,不允许进行分卷操作,请使用最新二维码', - showCancel: false - }); - return; - } + const coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null; if (!enterCoilNo) { throw new Error('二维码中未包含有效的入场钢卷号'); } - // 3. 通过追溯接口获取准确的钢卷信息 + // 3. 通过追溯接口获取钢卷信息 const traceRes = await getMaterialCoilTrace(enterCoilNo, currentCoilNo); if (traceRes.code !== 200 || !traceRes.data || !traceRes.data.records || traceRes.data.records.length === 0) { throw new Error('未找到钢卷信息'); } - // 4. 找到当前数据 + // 4. 根据二维码内容匹配对应的钢卷数据 let coilData = null; - for (const record of traceRes.data.records) { - if (record.dataType === 1 && record.currentCoilNo === currentCoilNo) { - coilData = record; - break; - } + const records = traceRes.data.records; + + // 优先使用coil_id精确匹配 + if (coilId) { + coilData = records.find(record => String(record.coilId) === String(coilId)); + } + + // 如果没找到,使用currentCoilNo匹配 + if (!coilData && currentCoilNo) { + coilData = records.find(record => record.currentCoilNo === currentCoilNo); + } + + // 如果还是没找到,取第一条记录 + if (!coilData && records.length > 0) { + coilData = records[0]; } if (!coilData) { - for (const record of traceRes.data.records) { - if (record.dataType === 1) { - coilData = record; - break; - } - } + throw new Error('未找到对应的钢卷数据'); } - if (!coilData) { - coilData = traceRes.data.records[0]; + // 5. 检查是否为历史数据 + if (coilData.dataType === 0) { + uni.showModal({ + title: '历史数据', + content: '此为历史记录,不允许进行分卷操作', + showCancel: false + }); + return; } + this.coilDetail = coilData; this.form.coilId = coilData.coilId; @@ -501,11 +648,11 @@ export default { // 提交分卷 handleConfirm() { - // 历史二维码不允许分卷 - if (this.qrcodeStatus === 0) { + // 历史数据不允许分卷 + if (this.coilDetail.dataType === 0) { uni.showModal({ - title: '历史二维码', - content: '此二维码已失效,不允许进行分卷操作,请使用最新二维码', + title: '历史数据', + content: '此为历史记录,不允许进行分卷操作', showCancel: false }); return; @@ -542,8 +689,8 @@ export default { currentCoilNo: item.currentCoilNo, team: item.team, hasMergeSplit: 1, - itemType: this.coilDetail.itemType, - itemId: this.coilDetail.itemId, + itemType: item.itemType || this.coilDetail.itemType, // 优先使用分卷的itemType + itemId: item.itemId || this.coilDetail.itemId, // 优先使用分卷的itemId warehouseId: item.warehouseId || this.coilDetail.warehouseId, // 使用分卷的库区或原库区 grossWeight: item.grossWeight ? Number(item.grossWeight) : null, netWeight: item.netWeight ? Number(item.netWeight) : null diff --git a/apps/hand-factory/components/panels/code/merge.vue b/apps/hand-factory/components/panels/code/merge.vue index 7688f59..aa1a8fb 100644 --- a/apps/hand-factory/components/panels/code/merge.vue +++ b/apps/hand-factory/components/panels/code/merge.vue @@ -11,15 +11,6 @@ - - - ⚠️ - - 包含历史二维码 - 列表中包含已失效的二维码,不允许进行合卷操作,请移除后重试 - - - @@ -29,12 +20,11 @@ - {{ index + 1 }} + {{ index + 1 }} 入场钢卷号: {{ coil.enterCoilNo }} - 历史码 当前钢卷号: @@ -93,6 +83,20 @@ + + + 选择产品 + + + {{ selectedProductName || '请选择产品' }} + + + + + 毛重 (kg) @@ -166,6 +170,38 @@ + + + + + + 选择产品 + + + + + + + + {{ product.productName }} + + + + 未找到匹配的产品 + + + + @@ -173,6 +209,7 @@ import { getGenerateRecord } from '@/api/wms/code.js' import { updateMaterialCoil, getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js' import { listWarehouse } from '@/api/wms/warehouse.js' +import { listProduct } from '@/api/wms/product.js' export default { data() { @@ -188,18 +225,18 @@ export default { showWarehouseList: false, warehouseSearchKeyword: '', filteredWarehousesInPicker: [], + products: [], // 产品列表 + productSearchKeyword: '', + filteredProductsInPicker: [], + itemType: '', // 合卷后的物品类型 + itemId: undefined, // 合卷后的物品ID + selectedProductName: '', // 已选择的产品名称 grossWeight: '', netWeight: '', loading: false } }, - computed: { - // 是否包含历史二维码 - hasHistoryQrcode() { - return this.scannedCoils.some(coil => coil.qrcodeStatus === 0); - } - }, onLoad() { this.loadWarehouses(); @@ -234,6 +271,61 @@ export default { } }, + // 加载产品列表 + async loadProducts() { + console.log('开始加载产品列表...'); + try { + const res = await listProduct({ pageNum: 1, pageSize: 1000 }); + console.log("产品返回值", res); + if (res.code === 200) { + this.products = res.rows || res.data || []; + this.filteredProductsInPicker = this.products; + console.log('产品加载成功,数量:', this.products.length); + } else { + console.error('产品加载失败:', res.msg); + } + } catch (err) { + console.error('加载产品异常:', err); + } + }, + + // 显示产品选择器 + showProductPicker() { + this.productSearchKeyword = ''; + this.filteredProductsInPicker = [...this.products]; + this.$refs.productPopup.open(); + }, + + // 关闭产品选择器 + closeProductPicker() { + this.$refs.productPopup.close(); + }, + + // 过滤产品(在选择器中) + filterProductsInPicker() { + const keyword = this.productSearchKeyword.trim().toLowerCase(); + if (!keyword) { + this.filteredProductsInPicker = [...this.products]; + } else { + this.filteredProductsInPicker = this.products.filter(product => { + const name = (product.productName || '').toLowerCase(); + return name.includes(keyword); + }); + } + }, + + // 从选择器中选择产品 + selectProductFromPicker(product) { + this.itemId = product.productId; + this.itemType = 'product'; + this.selectedProductName = product.productName; + uni.showToast({ + title: `已选择产品:${product.productName}`, + icon: 'success' + }); + this.closeProductPicker(); + }, + // 过滤库区 filterWarehouses() { console.log('合卷页面过滤库区,关键词:', this.warehouseKeyword); @@ -290,11 +382,21 @@ export default { }, // 从选择器中选择库区 - selectWarehouseFromPicker(warehouse) { + async selectWarehouseFromPicker(warehouse) { this.warehouseId = warehouse.warehouseId; this.warehouseName = warehouse.warehouseName; this.warehouseKeyword = warehouse.warehouseName; this.closeWarehousePicker(); + + // 检查是否选择了成品库区 + if (warehouse.warehouseName && warehouse.warehouseName.includes('成品')) { + // 切换为产品类型 + this.itemType = 'product'; + // 加载产品列表 + await this.loadProducts(); + // 弹出产品选择框 + this.showProductPicker(); + } }, // 扫码 @@ -311,56 +413,57 @@ export default { throw new Error('未找到二维码记录'); } - // 2. 解析content获取enter_coil_no和current_coil_no + // 2. 解析content获取enter_coil_no、current_coil_no和coil_id const qrcodeRecord = qrcodeRes.data; const content = JSON.parse(qrcodeRecord.content); const enterCoilNo = content.enter_coil_no; const currentCoilNo = content.current_coil_no; - const qrcodeStatus = qrcodeRecord.status || 1; - - // 如果是历史码,提示用户 - if (qrcodeStatus === 0) { - uni.showModal({ - title: '历史二维码', - content: '此二维码已失效,不允许进行合卷操作,请使用最新二维码', - showCancel: false - }); - return; - } + const coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null; if (!enterCoilNo) { throw new Error('二维码中未包含有效的入场钢卷号'); } - // 3. 通过追溯接口获取准确的钢卷信息 + // 3. 通过追溯接口获取钢卷信息 const traceRes = await getMaterialCoilTrace(enterCoilNo, currentCoilNo); if (traceRes.code !== 200 || !traceRes.data || !traceRes.data.records || traceRes.data.records.length === 0) { throw new Error('未找到钢卷信息'); } - // 4. 找到当前数据 + // 4. 根据二维码内容匹配对应的钢卷数据 let coilData = null; - for (const record of traceRes.data.records) { - if (record.dataType === 1 && record.currentCoilNo === currentCoilNo) { - coilData = record; - break; - } + const records = traceRes.data.records; + + // 优先使用coil_id精确匹配 + if (coilId) { + coilData = records.find(record => String(record.coilId) === String(coilId)); + } + + // 如果没找到,使用currentCoilNo匹配 + if (!coilData && currentCoilNo) { + coilData = records.find(record => record.currentCoilNo === currentCoilNo); + } + + // 如果还是没找到,取第一条记录 + if (!coilData && records.length > 0) { + coilData = records[0]; } if (!coilData) { - for (const record of traceRes.data.records) { - if (record.dataType === 1) { - coilData = record; - break; - } - } + throw new Error('未找到对应的钢卷数据'); } - if (!coilData) { - coilData = traceRes.data.records[0]; + // 5. 检查是否为历史数据 + if (coilData.dataType === 0) { + uni.showModal({ + title: '历史数据', + content: '此为历史记录,不允许进行合卷操作', + showCancel: false + }); + return; } - // 5. 检查是否已扫描过 + // 6. 检查是否已扫描过 const exists = this.scannedCoils.some(coil => coil.coilId === coilData.coilId); if (exists) { uni.showToast({ @@ -370,9 +473,6 @@ export default { return; } - // 保存二维码状态到钢卷数据中 - coilData.qrcodeStatus = qrcodeStatus; - this.scannedCoils.push(coilData); console.log('钢卷详情:', coilData); @@ -425,6 +525,9 @@ export default { this.warehouseId = undefined; this.warehouseName = ''; this.warehouseKeyword = ''; + this.itemType = ''; + this.itemId = undefined; + this.selectedProductName = ''; this.grossWeight = ''; this.netWeight = ''; this.showWarehouseList = false; @@ -435,11 +538,12 @@ export default { // 提交合卷 handleConfirm() { - // 检查是否包含历史二维码 - if (this.hasHistoryQrcode) { + // 检查是否包含历史数据 + const hasHistoryData = this.scannedCoils.some(coil => coil.dataType === 0); + if (hasHistoryData) { uni.showModal({ - title: '包含历史二维码', - content: '列表中包含已失效的二维码,不允许进行合卷操作,请移除后重试', + title: '包含历史数据', + content: '列表中包含历史记录,不允许进行合卷操作,请移除后重试', showCancel: false }); return; @@ -481,8 +585,8 @@ export default { currentCoilNo: this.mergedCoilNo, team: this.team, hasMergeSplit: 2, // 2表示合卷 - itemType: this.scannedCoils[0].itemType, - itemId: this.scannedCoils[0].itemId, + itemType: this.itemType || this.scannedCoils[0].itemType, // 优先使用选择的itemType + itemId: this.itemId || this.scannedCoils[0].itemId, // 优先使用选择的itemId warehouseId: this.warehouseId || this.scannedCoils[0].warehouseId, // 使用选择的库区或第一个钢卷的库区 grossWeight: this.grossWeight ? Number(this.grossWeight) : null, netWeight: this.netWeight ? Number(this.netWeight) : null, diff --git a/apps/hand-factory/components/panels/code/typing.vue b/apps/hand-factory/components/panels/code/typing.vue index dcee7c4..63d3b41 100644 --- a/apps/hand-factory/components/panels/code/typing.vue +++ b/apps/hand-factory/components/panels/code/typing.vue @@ -44,21 +44,12 @@ - - - ⚠️ - - 历史二维码 - 此二维码已失效,已为您加载最新物料信息,仅可查看,无法修改 - - - - + ⚠️ 历史数据 - 此钢卷为历史数据,仅可查看,无法修改 + 此为历史记录,仅供查看,不允许进行修改操作 @@ -76,8 +67,8 @@ v-model="form.currentCoilNo" placeholder="请输入当前钢卷号" class="form-input" - :disabled="coilDetail.dataType === 0 || qrcodeStatus === 0" - :class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }" + :disabled="coilDetail.dataType === 0" + :class="{ 'form-input-disabled': coilDetail.dataType === 0 }" /> @@ -88,8 +79,8 @@ v-model="form.team" placeholder="请输入班组名称" class="form-input" - :disabled="coilDetail.dataType === 0 || qrcodeStatus === 0" - :class="{ 'form-input-disabled': coilDetail.dataType === 0 || qrcodeStatus === 0 }" + :disabled="coilDetail.dataType === 0" + :class="{ 'form-input-disabled': coilDetail.dataType === 0 }" /> @@ -98,13 +89,28 @@ 目标库区 {{ currentWarehouseName || '请选择目标库区' }} - + + + + + + + 选择产品 + + + {{ selectedProductName || '请选择产品' }} + + @@ -113,11 +119,11 @@ 毛重 (kg) @@ -126,11 +132,11 @@ 净重 (kg) @@ -144,7 +150,7 @@