查询优化,新增酸连轧页面
This commit is contained in:
@@ -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('已复制到所有子卷');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user