From f3d27a2baa065d06d8f392b3a678d5ab3a1ea4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=82=E7=B3=96?= Date: Tue, 4 Nov 2025 17:41:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(hand-factory):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=89=A9=E5=93=81=E7=B1=BB=E5=9E=8B=E9=80=89=E6=8B=A9=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现成品和原材料的选择器组件,包含类型选择、搜索过滤和弹窗交互功能 --- .../klp-material-picker.vue | 466 ++++++++++++++++++ .../components/panels/code/apart.vue | 365 +------------- .../components/panels/code/merge.vue | 409 +-------------- .../components/panels/code/typing.vue | 454 +---------------- 4 files changed, 489 insertions(+), 1205 deletions(-) create mode 100644 apps/hand-factory/components/klp-material-picker/klp-material-picker.vue diff --git a/apps/hand-factory/components/klp-material-picker/klp-material-picker.vue b/apps/hand-factory/components/klp-material-picker/klp-material-picker.vue new file mode 100644 index 0000000..d709601 --- /dev/null +++ b/apps/hand-factory/components/klp-material-picker/klp-material-picker.vue @@ -0,0 +1,466 @@ + + + + + \ No newline at end of file diff --git a/apps/hand-factory/components/panels/code/apart.vue b/apps/hand-factory/components/panels/code/apart.vue index 4584282..549a066 100644 --- a/apps/hand-factory/components/panels/code/apart.vue +++ b/apps/hand-factory/components/panels/code/apart.vue @@ -80,57 +80,18 @@ 目标库位 - 实际库区 - - - - - - 物品类型 - - - {{ item.itemType === 'product' ? '成品' : item.itemType === 'raw_material' ? '原料' : '请选择物品类型' }} - - - - - - - - 选择产品 - - - {{ item.productName || '请选择产品' }} - - - - - - - - 选择原材料 - - - {{ item.rawMaterialName || '请选择原材料' }} - - - + + 毛重 (吨) @@ -159,78 +120,6 @@ - - - - - 选择产品 - - - - - - - - {{ product.productName }} - - - - 未找到匹配的产品 - - - - - - - - - - 选择原材料 - - - - - - - - {{ material.rawMaterialName }} - - - - 未找到匹配的原材料 - - - - - - - - - - 选择物品类型 - - - - - 成品 - - - - 原料 - - - - - - @@ -270,15 +159,6 @@ getMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil.js' - import { - listWarehouse - } from '@/api/wms/warehouse.js' - import { - listProduct - } from '@/api/wms/product.js' - import { - listRawMaterial - } from '@/api/wms/rawMaterial.js' export default { data() { @@ -343,95 +223,7 @@ } }, - onLoad() { - this.loadProducts(); - this.loadRawMaterials(); - }, - - mounted() { - this.loadProducts(); - this.loadRawMaterials(); - }, - methods: { - // 加载产品列表 - 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); - } - }, - - // 加载原材料列表 - async loadRawMaterials() { - console.log('开始加载原材料列表...'); - try { - const res = await listRawMaterial({ - pageNum: 1, - pageSize: 1000 - }); - console.log("原材料返回值", res); - if (res.code === 200) { - this.rawMaterials = res.rows || res.data || []; - this.filteredRawMaterialsInPicker = this.rawMaterials; - console.log('原材料加载成功,数量:', this.rawMaterials.length); - } else { - console.error('原材料加载失败:', res.msg); - } - } catch (err) { - console.error('加载原材料异常:', err); - } - }, - - // 显示物品类型选择器 - showItemTypePickerForItem(index) { - this.currentPickerItemIndex = index; - this.$refs.itemTypePopup.open(); - }, - - // 关闭物品类型选择器 - closeItemTypePickerForItem() { - this.$refs.itemTypePopup.close(); - this.currentPickerItemIndex = -1; - }, - - // 选择物品类型 - selectItemType(type) { - if (this.currentPickerItemIndex === -1) return; - - const item = this.splitCoils[this.currentPickerItemIndex]; - const currentIndex = this.currentPickerItemIndex; - - // 设置物品类型 - this.$set(item, 'itemType', type); - // 清空之前选择的物品 - this.$set(item, 'itemId', undefined); - this.$set(item, 'productName', ''); - this.$set(item, 'rawMaterialName', ''); - - this.closeItemTypePickerForItem(); - - // 根据类型自动弹出对应的选择器 - if (type === 'product') { - this.showProductPickerForItem(currentIndex); - } else if (type === 'raw_material') { - this.showRawMaterialPickerForItem(currentIndex); - } - }, - // 显示BOM弹窗 showBomDialog() { this.$refs.bomPopup.open(); @@ -442,151 +234,6 @@ this.$refs.bomPopup.close(); }, - // 显示产品选择器(为特定分卷) - 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(); - }, - - // 显示原材料选择器(为特定分卷) - showRawMaterialPickerForItem(index) { - this.currentPickerItemIndex = index; - this.rawMaterialSearchKeyword = ''; - this.filteredRawMaterialsInPicker = [...this.rawMaterials]; - this.$refs.rawMaterialPopup.open(); - }, - - // 关闭原材料选择器 - closeRawMaterialPickerForItem() { - this.$refs.rawMaterialPopup.close(); - this.currentPickerItemIndex = -1; - }, - - // 过滤原材料(在选择器中) - filterRawMaterialsInPicker() { - const keyword = this.rawMaterialSearchKeyword.trim().toLowerCase(); - if (!keyword) { - this.filteredRawMaterialsInPicker = [...this.rawMaterials]; - } else { - this.filteredRawMaterialsInPicker = this.rawMaterials.filter(material => { - const name = (material.rawMaterialName || '').toLowerCase(); - return name.includes(keyword); - }); - } - }, - - // 从选择器中选择原材料 - selectRawMaterialFromPicker(material) { - if (this.currentPickerItemIndex === -1) return; - - const item = this.splitCoils[this.currentPickerItemIndex]; - item.itemId = material.rawMaterialId; - item.itemType = 'raw_material'; - item.rawMaterialName = material.rawMaterialName; // 保存原材料名称用于显示 - uni.showToast({ - title: `分卷 ${this.currentPickerItemIndex + 1} 已选择原材料:${material.rawMaterialName}`, - icon: 'success' - }); - this.closeRawMaterialPickerForItem(); - }, - - // 过滤库区(为特定分卷) - filterWarehousesForItem(index) { - console.log(`分卷页面过滤库区,分卷${index + 1},关键词:`, this.splitCoils[index].warehouseKeyword); - console.log('分卷页面当前库区列表:', this.warehouses); - const item = this.splitCoils[index]; - const keyword = item.warehouseKeyword.trim().toLowerCase(); - if (!keyword) { - item.filteredWarehouses = [...this.warehouses]; - } else { - item.filteredWarehouses = this.warehouses.filter(warehouse => { - const name = (warehouse.warehouseName || '').toLowerCase(); - return name.includes(keyword); - }); - } - console.log(`分卷页面过滤后库区数量:`, item.filteredWarehouses.length); - item.showWarehouseList = true; - }, - - // 选择库区(为特定分卷) - selectWarehouseForItem(index, warehouse) { - const item = this.splitCoils[index]; - item.warehouseId = warehouse.warehouseId; - item.warehouseName = warehouse.warehouseName; - item.warehouseKeyword = warehouse.warehouseName; - item.showWarehouseList = false; - }, - - // 关闭所有库区搜索列表 - closeWarehouseList() { - this.splitCoils.forEach(item => { - item.showWarehouseList = false; - }); - }, - - // 显示库区选择器(为特定分卷) - showWarehousePickerForItem(index) { - this.currentPickerItemIndex = index; - this.warehouseSearchKeyword = ''; - this.filteredWarehousesInPicker = [...this.warehouses]; - this.$refs.warehousePopup.open(); - }, - - // 关闭库区选择器 - closeWarehousePickerForItem() { - this.currentPickerItemIndex = -1; - this.$refs.warehousePopup.close(); - }, - - // 在选择器中过滤库区 - 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); - }); - } - }, - // 扫码 handleScan() { uni.scanCode({ diff --git a/apps/hand-factory/components/panels/code/merge.vue b/apps/hand-factory/components/panels/code/merge.vue index de21374..2aaf265 100644 --- a/apps/hand-factory/components/panels/code/merge.vue +++ b/apps/hand-factory/components/panels/code/merge.vue @@ -72,15 +72,7 @@ 目标库位 - - - {{ warehouseName || '请选择目标库位' }} - - - + @@ -90,48 +82,11 @@ ware-type="actual" /> - - - - 物品类型 - - - {{ itemType === 'product' ? '成品' : itemType === 'raw_material' ? '原料' : '请选择物品类型' }} - - - - - - - - 选择产品 - - - {{ selectedProductName || '请选择产品' }} - - - - - - - - 选择原材料 - - - {{ selectedRawMaterialName || '请选择原材料' }} - - - - + @@ -174,131 +129,12 @@ 至少需要扫描 2 个钢卷才能进行合卷操作 - - - - - - 选择库区 - - - - - - - - {{ warehouse.warehouseName }} - - - - 未找到匹配的库区 - - - - - - - - - - 选择产品 - - - - - - - - {{ product.productName }} - - - - 未找到匹配的产品 - - - - - - - - - - 选择原材料 - - - - - - - - {{ material.rawMaterialName }} - - - - 未找到匹配的原材料 - - - - - - - - - - 选择物品类型 - - - - - 成品 - - - - 原料 - - - - -