|
@@ -14,6 +14,7 @@ import {
|
|
|
} from '@/constants/order'
|
|
|
import { MATERIAL_DETAIL_EVENTS, DIALOG_EVENTS } from './events'
|
|
|
import { getMaterialFullList } from '@/api/order/sales-order'
|
|
|
+import { getBrandStockList } from '@/api/forecast/brand-stock'
|
|
|
import {
|
|
|
formatAmount,
|
|
|
formatFloatNumber,
|
|
@@ -360,7 +361,10 @@ export default {
|
|
|
|
|
|
// 设置防抖定时器
|
|
|
this.searchTimer = setTimeout(async () => {
|
|
|
- await this.searchMaterials(query)
|
|
|
+ // 优先使用品牌库存接口进行搜索
|
|
|
+ await this.searchBrandStock(query)
|
|
|
+ // 保留原有接口调用以便将来切换
|
|
|
+ // await this.searchMaterials(query)
|
|
|
}, 300)
|
|
|
},
|
|
|
|
|
@@ -417,6 +421,65 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 使用品牌库存接口搜索物料
|
|
|
+ * @description 调用品牌库存汇总列表接口,按名称等关键字进行搜索
|
|
|
+ * @param {string} keyword - 搜索关键词
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async searchBrandStock(keyword) {
|
|
|
+ try {
|
|
|
+ this.materialLoading = true
|
|
|
+
|
|
|
+ // 默认按物料中文名(cname)模糊查询;如需按其他名称字段查询,可在此扩展
|
|
|
+ const response = await getBrandStockList(1, 20, {
|
|
|
+ cname: keyword
|
|
|
+ // 也可根据需要启用以下字段之一进行检索(注意后端查询条件关系)
|
|
|
+ // brandName: keyword,
|
|
|
+ // storageName: keyword,
|
|
|
+ // typeNo: keyword,
|
|
|
+ // brandItem: keyword,
|
|
|
+ // productDescription: keyword,
|
|
|
+ // goodsTypeName: keyword,
|
|
|
+ // salesCompanyName: keyword
|
|
|
+ })
|
|
|
+
|
|
|
+ if (response?.data?.success && response.data.data) {
|
|
|
+ const pageData = response.data.data
|
|
|
+ const list = pageData.records || []
|
|
|
+
|
|
|
+ this.materialOptions = list.map(item => ({
|
|
|
+ id: item.id,
|
|
|
+ itemId: item.goodsId,
|
|
|
+ itemCode: item.code,
|
|
|
+ itemName: item.cname,
|
|
|
+ specs: item.typeNo || '',
|
|
|
+ unit: '',
|
|
|
+ mainItemCategoryName: item.goodsTypeName || '',
|
|
|
+ mainItemCategoryId: item.goodsTypeId,
|
|
|
+ mainItemCategoryCode: '',
|
|
|
+ unitPrice: '0',
|
|
|
+ description: item.productDescription || '',
|
|
|
+ warehouseId: item.storageId,
|
|
|
+ warehouseCode: '',
|
|
|
+ warehouseName: item.storageName,
|
|
|
+ availableQuantity: parseFloat(item.balanceQuantity || '0') || 0,
|
|
|
+ // 保留原始数据以备后用
|
|
|
+ _raw: item
|
|
|
+ }))
|
|
|
+ } else {
|
|
|
+ this.materialOptions = []
|
|
|
+ const errorMsg = response?.data?.msg || '搜索库存物料失败'
|
|
|
+ this.$message.warning(errorMsg)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.materialOptions = []
|
|
|
+ this.$message.error('网络错误,搜索库存物料失败')
|
|
|
+ } finally {
|
|
|
+ this.materialLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
* 处理导入选中物料
|
|
|
* @description 将选中的物料导入到物料明细表中
|
|
|
* @returns {void}
|
|
@@ -484,7 +547,7 @@ export default {
|
|
|
unitPrice: material.unitPrice || 0,
|
|
|
orderQuantity: 1,
|
|
|
confirmQuantity: 1,
|
|
|
- availableQuantity: 0,
|
|
|
+ availableQuantity: typeof material.availableQuantity === 'number' ? material.availableQuantity : 0,
|
|
|
taxRate: 0,
|
|
|
taxAmount: 0,
|
|
|
totalAmount: 0,
|