BOM展示

This commit is contained in:
砂糖
2025-07-31 18:07:51 +08:00
parent b1f40f09e9
commit f02967ebbf
23 changed files with 262 additions and 40 deletions

View File

@@ -1,13 +1,15 @@
import { listCategory } from '@/api/wms/category';
import { listProduct } from '@/api/wms/product';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listBomItem } from '@/api/wms/bomItem';
const state = {
categoryList: [],
productMap: {},
rawMaterialMap: {},
productList: [],
rawMaterialList: []
rawMaterialList: [],
bomMap: {}
};
const mutations = {
@@ -25,6 +27,9 @@ const mutations = {
},
SET_RAW_MATERIAL_LIST(state, list) {
state.rawMaterialList = list;
},
SET_BOM_MAP(state, map) {
state.bomMap = map;
}
};
@@ -33,7 +38,7 @@ const actions = {
if (state.categoryList.length > 0) {
return Promise.resolve(state.categoryList);
}
return listCategory().then(res => {
return listCategory({ pageNum: 1, pageSize: 10000 }).then(res => {
commit('SET_CATEGORY_LIST', res.rows || []);
return res.rows || [];
});
@@ -42,7 +47,7 @@ const actions = {
if (Object.keys(state.productMap).length > 0) {
return Promise.resolve(state.productMap);
}
return listProduct().then(res => {
return listProduct({ pageNum: 1, pageSize: 10000 }).then(res => {
const map = {};
res.rows.forEach(item => {
map[item.productId] = item;
@@ -56,7 +61,7 @@ const actions = {
if (Object.keys(state.rawMaterialMap).length > 0) {
return Promise.resolve(state.rawMaterialMap);
}
return listRawMaterial().then(res => {
return listRawMaterial({ pageNum: 1, pageSize: 10000 }).then(res => {
const map = {};
res.rows.forEach(item => {
map[item.rawMaterialId] = item;
@@ -65,6 +70,23 @@ const actions = {
commit('SET_RAW_MATERIAL_LIST', res.rows || []);
return map;
});
},
getBomMap({ state, commit }) {
if (Object.keys(state.bomMap).length > 0) {
return Promise.resolve(state.bomMap);
}
return listBomItem({ pageNum: 1, pageSize: 10000 }).then(res => {
console.log('bomItem', res)
const map = {};
res.rows.forEach(item => {
if (!map[item.bomId]) {
map[item.bomId] = [];
}
map[item.bomId].push(item);
});
commit('SET_BOM_MAP', map);
return map;
})
}
};
export default {