diff --git a/src/views/erp/stock/in/components/StockInItemForm.vue b/src/views/erp/stock/in/components/StockInItemForm.vue index 35129660..0dd20319 100644 --- a/src/views/erp/stock/in/components/StockInItemForm.vue +++ b/src/views/erp/stock/in/components/StockInItemForm.vue @@ -37,20 +37,17 @@ @@ -156,6 +153,36 @@ const productList = ref([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 const defaultWarehouse = ref(undefined) // 默认仓库 +const productCascaderProps = { + emitPath: false, + value: 'value', + label: 'label', + children: 'children' +} + +const productCascaderOptions = computed(() => { + const map = new Map() + for (const item of productList.value) { + const categoryKey = item.categoryId ?? item.categoryName ?? '' + const categoryLabel = item.categoryName ?? String(categoryKey) + if (!map.has(categoryKey)) { + map.set(categoryKey, { + value: categoryKey, + label: categoryLabel, + children: [] + }) + } + const group = map.get(categoryKey) + if (group) { + group.children.push({ + value: item.id, + label: item.name + }) + } + } + return Array.from(map.values()) +}) + /** 初始化设置入库项 */ watch( () => props.items, diff --git a/src/views/erp/stock/out/components/StockOutItemForm.vue b/src/views/erp/stock/out/components/StockOutItemForm.vue index e8c4332b..86dd62f7 100644 --- a/src/views/erp/stock/out/components/StockOutItemForm.vue +++ b/src/views/erp/stock/out/components/StockOutItemForm.vue @@ -37,20 +37,17 @@ @@ -156,6 +153,36 @@ const productList = ref([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 const defaultWarehouse = ref(undefined) // 默认仓库 +const productCascaderProps = { + emitPath: false, + value: 'value', + label: 'label', + children: 'children' +} + +const productCascaderOptions = computed(() => { + const map = new Map() + for (const item of productList.value) { + const categoryKey = item.categoryId ?? item.categoryName ?? '' + const categoryLabel = item.categoryName ?? String(categoryKey) + if (!map.has(categoryKey)) { + map.set(categoryKey, { + value: categoryKey, + label: categoryLabel, + children: [] + }) + } + const group = map.get(categoryKey) + if (group) { + group.children.push({ + value: item.id, + label: item.name + }) + } + } + return Array.from(map.values()) +}) + /** 初始化设置出库项 */ watch( () => props.items,