查询优化,新增酸连轧页面

This commit is contained in:
2025-11-17 11:58:42 +08:00
parent e60b62f3e2
commit 23900f38f8
11 changed files with 1523 additions and 380 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -220,8 +220,8 @@
<script>
import { getMaterialCoil, mergeMaterialCoil } from '@/api/wms/coil';
import { listWarehouse } from '@/api/wms/warehouse';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listProduct } from '@/api/wms/product';
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
import { listProductWithBom } from '@/api/wms/product';
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
import CoilSelector from '@/components/CoilSelector';
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
@@ -259,12 +259,9 @@ export default {
currentSelectIndex: -1,
// 库区列表
warehouseList: [],
// 原材料和产品列表
// 原材料和产品列表(实时搜索,不再保存完整备份)
rawMaterialList: [],
productList: [],
// 原始完整列表备份(用于搜索过滤)
allRawMaterials: [],
allProducts: [],
itemSearchLoading: false,
// 只读模式
readonly: false,
@@ -317,8 +314,8 @@ export default {
// 加载库区列表
await this.loadWarehouses();
// 🔥 页面加载时直接加载所有原料和产品列表
await this.loadAllItems();
// 不再一次性加载所有数据,改为实时搜索
// await this.loadAllItems();
// 从路由参数获取coilId、actionId和readonly
const coilId = this.$route.query.coilId;
@@ -378,15 +375,15 @@ export default {
// 清空物品选择
this.$set(this.targetCoil, 'itemId', null);
// 根据材料类型设置物品类型并恢复完整列表
// 根据材料类型设置物品类型
if (value === '成品') {
this.$set(this.targetCoil, 'itemType', 'product');
// 恢复完整产品列表
this.productList = [...this.allProducts];
// 清空列表,等待用户搜索
this.productList = [];
} else if (value === '原料' || value === '废品') {
this.$set(this.targetCoil, 'itemType', 'raw_material');
// 恢复完整原料列表
this.rawMaterialList = [...this.allRawMaterials];
// 清空列表,等待用户搜索
this.rawMaterialList = [];
}
},
@@ -435,10 +432,7 @@ export default {
this.targetCoil.warehouseId = data.warehouseId;
this.targetCoil.actualWarehouseId = data.actualWarehouseId;
// 加载对应的物品列表
if (data.itemType) {
await this.loadItemList(data.itemType);
}
// 不再预加载物品列表,改为实时搜索
}
} catch (error) {
this.$message.error('加载钢卷信息失败');
@@ -576,113 +570,59 @@ export default {
}
},
// 页面加载时一次性加载所有原料和产品列表
async loadAllItems() {
try {
// 同时加载原料和产品
const [rawMaterialRes, productRes] = await Promise.all([
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
]);
// 已移除 loadAllItems改为实时搜索
if (rawMaterialRes.code === 200) {
this.rawMaterialList = rawMaterialRes.rows || [];
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
}
// 已移除 loadItemList改为实时搜索
if (productRes.code === 200) {
this.productList = productRes.rows || [];
this.allProducts = productRes.rows || []; // 保存完整备份
}
} catch (error) {
console.error('加载物品列表失败', error);
}
},
// 加载物品列表(根据类型)
async loadItemList(itemType) {
if (!itemType) {
return;
}
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('merge.vue 加载物品列表失败', error);
} finally {
this.itemSearchLoading = false;
}
},
// 搜索物品(前端过滤,支持名称和规格搜索)
// 实时搜索物品(后端搜索)
async searchItems(query) {
if (!this.targetCoil.itemType) {
this.$message.warning('请先选择材料类型');
return;
}
// 如果没有输入,恢复完整列表
// 如果没有输入,清空列表
if (!query || query.trim() === '') {
if (this.targetCoil.itemType === 'raw_material') {
this.rawMaterialList = [...this.allRawMaterials];
this.rawMaterialList = [];
} else if (this.targetCoil.itemType === 'product') {
this.productList = [...this.allProducts];
this.productList = [];
}
return;
}
// 前端过滤:在已加载的数据中搜索
const searchQuery = query.toLowerCase().trim();
try {
this.itemSearchLoading = true;
const searchQuery = query.trim();
if (this.targetCoil.itemType === 'raw_material') {
// 从备份列表中过滤原材料
this.rawMaterialList = this.allRawMaterials.filter(item => {
// 搜索名称
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
} else if (this.targetCoil.itemType === 'product') {
// 从备份列表中过滤产品
this.productList = this.allProducts.filter(item => {
// 搜索名称
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
if (this.targetCoil.itemType === 'raw_material') {
// 后端搜索原材料(支持名称或规格模糊搜索)
const response = await listRawMaterialWithBom({
pageNum: 1,
pageSize: 20,
rawMaterialName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (this.targetCoil.itemType === 'product') {
// 后端搜索产品(支持名称或规格模糊搜索)
const response = await listProductWithBom({
pageNum: 1,
pageSize: 20,
productName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('搜索物品失败', error);
this.$message.error('搜索失败,请重试');
} finally {
this.itemSearchLoading = false;
}
},

View File

@@ -200,8 +200,8 @@
<script>
import { getMaterialCoil, splitMaterialCoil } from '@/api/wms/coil';
import { listWarehouse } from '@/api/wms/warehouse';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listProduct } from '@/api/wms/product';
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
import { listProductWithBom } from '@/api/wms/product';
import { completeAction } from '@/api/wms/pendingAction';
import CoilSelector from '@/components/CoilSelector';
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
@@ -249,12 +249,9 @@ export default {
coilSelectorVisible: false,
// 库区列表
warehouseList: [],
// 原材料和产品列表
// 原材料和产品列表(实时搜索,不再保存完整备份)
rawMaterialList: [],
productList: [],
// 原始完整列表备份(用于搜索过滤)
allRawMaterials: [],
allProducts: [],
itemSearchLoading: false,
// 只读模式
readonly: false,
@@ -268,8 +265,8 @@ export default {
// 先加载库区列表
await this.loadWarehouses();
// 🔥 页面加载时直接加载所有原料和产品列表
await this.loadAllItems();
// 不再一次性加载所有数据,改为实时搜索
// await this.loadAllItems();
// 从路由参数获取coilId、actionId和readonly
const coilId = this.$route.query.coilId;
@@ -296,15 +293,15 @@ export default {
// 清空物品选择
this.$set(item, 'itemId', null);
// 根据材料类型设置物品类型并恢复完整列表
// 根据材料类型设置物品类型
if (item.materialType === '成品') {
this.$set(item, 'itemType', 'product');
// 恢复完整产品列表
this.productList = [...this.allProducts];
// 清空列表,等待用户搜索
this.productList = [];
} else if (item.materialType === '原料' || item.materialType === '废品') {
this.$set(item, 'itemType', 'raw_material');
// 恢复完整原料列表
this.rawMaterialList = [...this.allRawMaterials];
// 清空列表,等待用户搜索
this.rawMaterialList = [];
}
},
@@ -379,13 +376,12 @@ export default {
return displayName;
},
// 物品类型变化
handleItemTypeChange(index) {
this.splitList[index].itemId = null;
this.loadItemListForSplit(this.splitList[index].itemType);
},
// 物品类型变化(已移除,改为实时搜索)
// handleItemTypeChange(index) {
// this.splitList[index].itemId = null;
// },
// 搜索子卷物品(前端过滤,支持名称和规格搜索)
// 实时搜索子卷物品(后端搜索)
async searchItemsForSplit(query, index) {
const item = this.splitList[index];
@@ -395,109 +391,55 @@ export default {
return;
}
// 如果没有输入,恢复完整列表
// 如果没有输入,清空列表
if (!query || query.trim() === '') {
if (itemType === 'raw_material') {
this.rawMaterialList = [...this.allRawMaterials];
this.rawMaterialList = [];
} else if (itemType === 'product') {
this.productList = [...this.allProducts];
this.productList = [];
}
return;
}
// 前端过滤:在已加载的数据中搜索
const searchQuery = query.toLowerCase().trim();
if (itemType === 'raw_material') {
// 从备份列表中过滤原材料
this.rawMaterialList = this.allRawMaterials.filter(item => {
// 搜索名称
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
} else if (itemType === 'product') {
// 从备份列表中过滤产品
this.productList = this.allProducts.filter(item => {
// 搜索名称
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
}
},
// 页面加载时一次性加载所有原料和产品列表
async loadAllItems() {
try {
// 同时加载原料和产品
const [rawMaterialRes, productRes] = await Promise.all([
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
]);
if (rawMaterialRes.code === 200) {
this.rawMaterialList = rawMaterialRes.rows || [];
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
}
if (productRes.code === 200) {
this.productList = productRes.rows || [];
this.allProducts = productRes.rows || []; // 保存完整备份
}
} catch (error) {
console.error('加载物品列表失败', error);
}
},
// 加载子卷物品列表
async loadItemListForSplit(itemType) {
if (!itemType) {
return;
}
try {
this.itemSearchLoading = true;
const searchQuery = query.trim();
if (itemType === 'raw_material') {
const response = await listRawMaterial({
// 后端搜索原材料(支持名称或规格模糊搜索)
const response = await listRawMaterialWithBom({
pageNum: 1,
pageSize: 100,
withBom: true
pageSize: 20,
rawMaterialName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({
// 后端搜索产品(支持名称或规格模糊搜索)
const response = await listProductWithBom({
pageNum: 1,
pageSize: 100,
withBom: true
pageSize: 20,
productName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('split.vue 加载物品列表失败', error);
console.error('搜索物品失败', error);
this.$message.error('搜索失败,请重试');
} finally {
this.itemSearchLoading = false;
}
},
// 已移除 loadAllItems改为实时搜索
// 已移除 loadItemListForSplit改为实时搜索
// 显示钢卷选择器
showCoilSelector() {
this.coilSelectorVisible = true;
@@ -717,10 +659,7 @@ export default {
// 不复制 itemType 和 itemId让它们由 materialType 自动决定
});
// 加载物品列表
if (this.motherCoil.itemType) {
this.loadItemListForSplit(this.motherCoil.itemType);
}
// 不再预加载物品列表,改为实时搜索
this.$message.success('已复制到所有子卷');
}

View File

@@ -218,8 +218,8 @@
import { getMaterialCoil, updateMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil';
import { completeAction } from '@/api/wms/pendingAction';
import { listWarehouse } from '@/api/wms/warehouse';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listProduct } from '@/api/wms/product';
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
import { listProductWithBom } from '@/api/wms/product';
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
export default {
@@ -300,12 +300,9 @@ export default {
warehouseList: [],
historySteps: [],
actionId: null,
// 原材料和产品列表
// 原材料和产品列表(实时搜索,不再保存完整备份)
rawMaterialList: [],
productList: [],
// 原始完整列表备份(用于搜索过滤)
allRawMaterials: [],
allProducts: [],
itemSearchLoading: false,
// 只读模式
readonly: false
@@ -352,8 +349,8 @@ export default {
// 先加载库区列表
await this.loadWarehouses();
// 🔥 页面加载时直接加载所有原料和产品列表
await this.loadAllItems();
// 不再一次性加载所有数据,改为实时搜索
// await this.loadAllItems();
// 从路由参数获取coilId和actionId
const coilId = this.$route.query.coilId;
@@ -382,12 +379,12 @@ export default {
// 根据材料类型设置物品类型
if (value === '成品') {
this.$set(this.updateForm, 'itemType', 'product');
// 恢复完整产品列表
this.productList = [...this.allProducts];
// 清空列表,等待用户搜索
this.productList = [];
} else if (value === '原料' || value === '废品') {
this.$set(this.updateForm, 'itemType', 'raw_material');
// 恢复完整原料列表
this.rawMaterialList = [...this.allRawMaterials];
// 清空列表,等待用户搜索
this.rawMaterialList = [];
}
},
@@ -406,10 +403,7 @@ export default {
nextWarehouseName: this.getWarehouseName(data.warehouseId),
};
// 加载对应类型的物品列表
if (data.itemType) {
await this.loadItemList(data.itemType);
}
// 不再预加载物品列表,改为实时搜索
// 加载变更历史
this.loadHistory();
@@ -492,115 +486,59 @@ export default {
}
},
// 页面加载时一次性加载所有原料和产品列表
async loadAllItems() {
try {
// 同时加载原料和产品
const [rawMaterialRes, productRes] = await Promise.all([
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
]);
// 已移除 loadAllItems改为实时搜索
if (rawMaterialRes.code === 200) {
this.rawMaterialList = rawMaterialRes.rows || [];
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
}
// 已移除 loadItemList改为实时搜索
if (productRes.code === 200) {
this.productList = productRes.rows || [];
this.allProducts = productRes.rows || []; // 保存完整备份
}
} catch (error) {
console.error('加载物品列表失败', error);
}
},
// 加载物品列表(根据类型)
async loadItemList(itemType) {
if (!itemType) {
return;
}
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
// 使用带参数的接口
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含参数信息
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
// 使用带参数的接口
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含参数信息
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('加载物品列表失败', error);
} finally {
this.itemSearchLoading = false;
}
},
// 搜索物品(前端过滤,支持名称和规格搜索)
// 实时搜索物品(后端搜索)
async searchItems(query) {
if (!this.updateForm.itemType) {
this.$message.warning('请先选择材料类型');
return;
}
// 如果没有输入,恢复完整列表
// 如果没有输入,清空列表
if (!query || query.trim() === '') {
if (this.updateForm.itemType === 'raw_material') {
this.rawMaterialList = [...this.allRawMaterials];
this.rawMaterialList = [];
} else if (this.updateForm.itemType === 'product') {
this.productList = [...this.allProducts];
this.productList = [];
}
return;
}
// 前端过滤:在已加载的数据中搜索
const searchQuery = query.toLowerCase().trim();
try {
this.itemSearchLoading = true;
const searchQuery = query.trim();
if (this.updateForm.itemType === 'raw_material') {
// 从备份列表中过滤原材料
this.rawMaterialList = this.allRawMaterials.filter(item => {
// 搜索名称
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
} else if (this.updateForm.itemType === 'product') {
// 从备份列表中过滤产品
this.productList = this.allProducts.filter(item => {
// 搜索名称
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
// 搜索规格
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
// 搜索 参数 参数
const bomMatch = item.bomItems && item.bomItems.some(bom =>
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
);
return nameMatch || specMatch || bomMatch;
});
if (this.updateForm.itemType === 'raw_material') {
// 后端搜索原材料(支持名称或规格模糊搜索)
const response = await listRawMaterialWithBom({
pageNum: 1,
pageSize: 20,
rawMaterialName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (this.updateForm.itemType === 'product') {
// 后端搜索产品(支持名称或规格模糊搜索)
const response = await listProductWithBom({
pageNum: 1,
pageSize: 20,
productName: searchQuery,
specification: searchQuery // 同时传入,后端会使用 OR 条件
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('搜索物品失败', error);
this.$message.error('搜索失败,请重试');
} finally {
this.itemSearchLoading = false;
}
},