+
@@ -9,7 +9,7 @@
- {{ material.rawMaterialId }}
+
{{ material.rawMaterialName }}
{{ material.rawMaterialCode }}
{{ material.specification }}
@@ -51,23 +51,36 @@ export default {
data() {
return {
showDetail: false,
- material: {},
+ // material: {},
};
},
computed: {
...mapState({
materialMap: state => state.category.rawMaterialMap // 假设vuex中为material模块
}),
- },
- watch: {
- materialId: {
- handler: function (newVal) {
- const res = this.materialMap[this.materialId] ? this.materialMap[this.materialId] : {};
- this.material = res;
- },
- immediate: true
+ material() {
+ // 检查 materialMap 是否已加载
+ if (!this.materialMap || Object.keys(this.materialMap).length === 0) {
+ return {};
+ }
+ if (!this.materialId) {
+ return {};
+ }
+ return this.materialMap[this.materialId.toString()] || {};
+ },
+ loading() {
+ return !this.materialMap || Object.keys(this.materialMap).length === 0
}
- }
+ },
+ // watch: {
+ // materialId: {
+ // handler: function (newVal) {
+ // const res = this.materialMap[newVal.toString()] ? this.materialMap[newVal.toString()] : {};
+ // this.material = res;
+ // },
+ // immediate: true
+ // }
+ // }
}
diff --git a/klp-ui/src/store/modules/category.js b/klp-ui/src/store/modules/category.js
index 94061017..42ffac95 100644
--- a/klp-ui/src/store/modules/category.js
+++ b/klp-ui/src/store/modules/category.js
@@ -48,38 +48,104 @@ const actions = {
});
},
getProductMap({ state, commit }) {
+ // 若已有缓存数据,直接返回
if (Object.keys(state.productMap).length > 0) {
return Promise.resolve(state.productMap);
}
- return listProduct({ pageNum: 1, pageSize: 10000 }).then(res => {
- const map = {};
- res.rows.forEach(item => {
- map[item.productId] = item;
+
+ const pageSize = 2000; // 每次获取2000条
+ const allRows = []; // 存储所有批次的列表数据
+ const productMap = {}; // 最终的产品映射表
+
+ // 异步处理分批次获取逻辑
+ const fetchAllProducts = async () => {
+ // 1. 获取第一页数据,拿到总条数total
+ let currentPage = 1;
+ const firstRes = await listProduct({ pageNum: currentPage, pageSize });
+ const total = firstRes.total || 0;
+ const firstRows = firstRes.rows || [];
+
+ // 处理第一页数据
+ allRows.push(...firstRows);
+ firstRows.forEach(item => {
+ productMap[item.productId.toString()] = item;
});
- commit('SET_PRODUCT_MAP', map);
- commit('SET_PRODUCT_LIST', res.rows || []);
- return map;
- });
+
+ // 2. 计算总页数,循环获取剩余页面数据
+ const totalPages = Math.ceil(total / pageSize);
+ for (currentPage = 2; currentPage <= totalPages; currentPage++) {
+ const res = await listProduct({ pageNum: currentPage, pageSize });
+ const rows = res.rows || [];
+
+ // 合并当前页数据到总列表和映射表
+ allRows.push(...rows);
+ rows.forEach(item => {
+ productMap[item.productId.toString()] = item;
+ });
+ }
+
+ // 3. 所有数据获取完成后,更新状态
+ commit('SET_PRODUCT_MAP', productMap);
+ commit('SET_PRODUCT_LIST', allRows);
+
+ return productMap;
+ };
+
+ // 返回Promise,确保外部可通过.then获取结果
+ return fetchAllProducts();
},
getRawMaterialMap({ state, commit }) {
+ // 若已有缓存数据,直接返回
if (Object.keys(state.rawMaterialMap).length > 0) {
return Promise.resolve(state.rawMaterialMap);
}
- return listRawMaterial({ pageNum: 1, pageSize: 10000 }).then(res => {
- const map = {};
- res.rows.forEach(item => {
- map[item.rawMaterialId] = item;
+
+ const pageSize = 2000; // 每次获取2000条
+ const allRows = []; // 存储所有批次的原材料列表
+ const rawMaterialMap = {}; // 最终的原材料映射表
+
+ // 异步处理分批次获取逻辑
+ const fetchAllRawMaterials = async () => {
+ // 1. 获取第一页数据,拿到总条数total
+ let currentPage = 1;
+ const firstRes = await listRawMaterial({ pageNum: currentPage, pageSize });
+ const total = firstRes.total || 0;
+ const firstRows = firstRes.rows || [];
+
+ // 处理第一页数据
+ allRows.push(...firstRows);
+ firstRows.forEach(item => {
+ rawMaterialMap[item.rawMaterialId.toString()] = item;
});
- commit('SET_RAW_MATERIAL_MAP', map);
- commit('SET_RAW_MATERIAL_LIST', res.rows || []);
- return map;
- });
+
+ // 2. 计算总页数,循环获取剩余页面数据
+ const totalPages = Math.ceil(total / pageSize);
+ for (currentPage = 2; currentPage <= totalPages; currentPage++) {
+ const res = await listRawMaterial({ pageNum: currentPage, pageSize });
+ const rows = res.rows || [];
+
+ // 合并当前页数据到总列表和映射表
+ allRows.push(...rows);
+ rows.forEach(item => {
+ rawMaterialMap[item.rawMaterialId.toString()] = item;
+ });
+ }
+
+ // 3. 所有数据获取完成后,更新状态
+ commit('SET_RAW_MATERIAL_MAP', rawMaterialMap);
+ commit('SET_RAW_MATERIAL_LIST', allRows);
+
+ return rawMaterialMap;
+ };
+
+ // 返回Promise,确保外部可通过.then获取结果
+ return fetchAllRawMaterials();
},
getBomMap({ state, commit }) {
if (Object.keys(state.bomMap).length > 0) {
return Promise.resolve(state.bomMap);
}
- return listBomItem({ pageNum: 1, pageSize: 10000 }).then(res => {
+ return listBomItem({ pageNum: 1, pageSize: 100000 }).then(res => {
console.log('bomItem', res)
const map = {};
res.rows.forEach(item => {
@@ -115,9 +181,9 @@ export function findItemWithBom(itemType, itemId) {
return null;
}
const bomItems = state.bomMap[bomId];
-
- return {
- ...item,
+
+ return {
+ ...item,
boms: bomItems || [],
itemName: itemType === 'product' ? item.productName : item.rawMaterialName,
itemType,
diff --git a/klp-ui/src/views/login.vue b/klp-ui/src/views/login.vue
index 0d58924b..bd8e85da 100644
--- a/klp-ui/src/views/login.vue
+++ b/klp-ui/src/views/login.vue
@@ -144,12 +144,12 @@ export default {
Cookies.remove('rememberMe');
}
this.$store.dispatch("Login", this.loginForm).then(() => {
- this.$store.dispatch('category/getCategoryList');
+ // this.$store.dispatch('category/getCategoryList');
this.$store.dispatch('category/getProductMap');
this.$store.dispatch('category/getRawMaterialMap');
- this.$store.dispatch('category/getBomMap');
- this.$store.dispatch('finance/getFinancialAccounts');
- this.$store.dispatch('craft/getProcessList');
+ // this.$store.dispatch('category/getBomMap');
+ // this.$store.dispatch('finance/getFinancialAccounts');
+ // this.$store.dispatch('craft/getProcessList');
this.$router.push({ path: this.redirect || "/" }).catch(() => { });
}).catch(() => {
this.loading = false;
diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsProductServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsProductServiceImpl.java
index 14365c80..5b20f9c6 100644
--- a/klp-wms/src/main/java/com/klp/service/impl/WmsProductServiceImpl.java
+++ b/klp-wms/src/main/java/com/klp/service/impl/WmsProductServiceImpl.java
@@ -58,7 +58,7 @@ public class WmsProductServiceImpl implements IWmsProductService {
* 查询产品列表
*/
@Override
- @Cacheable(cacheNames = "wms:product:list", key = "#bo.toString() + ':' + #pageQuery.pageNum + ':' + #pageQuery.pageSize", unless = "#result == null")
+// @Cacheable(cacheNames = "wms:product:list", key = "#bo.toString() + ':' + #pageQuery.pageNum + ':' + #pageQuery.pageSize", unless = "#result == null")
public TableDataInfo queryPageList(WmsProductBo bo, PageQuery pageQuery) {
LambdaQueryWrapper lqw = buildQueryWrapper(bo);
Page result = baseMapper.selectVoPage(pageQuery.build(), lqw);
diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsRawMaterialServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsRawMaterialServiceImpl.java
index 8bf68d4a..cecc6ec5 100644
--- a/klp-wms/src/main/java/com/klp/service/impl/WmsRawMaterialServiceImpl.java
+++ b/klp-wms/src/main/java/com/klp/service/impl/WmsRawMaterialServiceImpl.java
@@ -64,7 +64,7 @@ public class WmsRawMaterialServiceImpl implements IWmsRawMaterialService {
* 查询原材料列表
*/
@Override
- @Cacheable(cacheNames = "wms:rawMaterial:list", key = "#bo.toString() + ':' + #pageQuery.pageNum + ':' + #pageQuery.pageSize", unless = "#result == null")
+// @Cacheable(cacheNames = "wms:rawMaterial:list", key = "#bo.toString() + ':' + #pageQuery.pageNum + ':' + #pageQuery.pageSize", unless = "#result == null")
public TableDataInfo queryPageList(WmsRawMaterialBo bo, PageQuery pageQuery) {
LambdaQueryWrapper lqw = buildQueryWrapper(bo);
Page result = baseMapper.selectVoPage(pageQuery.build(), lqw);