|
|
|
|
@ -233,6 +233,11 @@
|
|
|
|
|
<el-input v-model="scope.row.batchNumber" placeholder="自动生成批次号" :readonly="true" size="small" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="inventoryAmount" label="库存数量" width="120" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<span>{{ scope.row.inventoryAmount || 0 }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<!--<el-table-column prop="unitPrice" label="单价(元)" width="140">-->
|
|
|
|
|
<!-- <template #default="scope">-->
|
|
|
|
|
<!-- <el-input-number-->
|
|
|
|
|
@ -289,7 +294,6 @@
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- <MaterialSelect ref="materialSelectRef" v-model="selectedMaterials" :multiple="true" @confirmCallBack="handleMaterialConfirm" />-->
|
|
|
|
|
<product-select ref="productSelectRef" :multiple="true" @confirmCallBack="handleProductSelect" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@ -313,6 +317,7 @@ import { getWmsWarehouseInfoList } from '@/api/wms/warehouseInfo';
|
|
|
|
|
import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo'; // 添加展开行处理函数
|
|
|
|
|
import ProductSelect from '@/components/WmsProductSelect/index.vue';
|
|
|
|
|
import { parseTime } from '@/utils/ruoyi';
|
|
|
|
|
import { getWmsInventoryDetailbyProductId } from '@/api/wms/inventoryDetails';
|
|
|
|
|
|
|
|
|
|
// 添加展开行处理函数
|
|
|
|
|
const handleExpandChange = async (row, expandedRows) => {
|
|
|
|
|
@ -349,23 +354,24 @@ const getProjectName = (projectId) => {
|
|
|
|
|
return project ? project.projectCode : projectId;
|
|
|
|
|
};
|
|
|
|
|
// 处理物料选择回调
|
|
|
|
|
const handleProductSelect = (products) => {
|
|
|
|
|
const handleProductSelect = async (products) => {
|
|
|
|
|
// 重置所有的物料
|
|
|
|
|
// selectedProducts.value = products;
|
|
|
|
|
|
|
|
|
|
// 为每个物料添加批次号
|
|
|
|
|
const timestamp = parseTime(new Date(), '{y}{m}{d}');
|
|
|
|
|
products.forEach((material) => {
|
|
|
|
|
for (const material of products) {
|
|
|
|
|
// 生成批次号:供应商代码 + 时间戳
|
|
|
|
|
// const supplierCode = form.value.supplierName ? form.value.supplier.substring(0, 4) : 'SUPP';
|
|
|
|
|
// const timestamp = new Date().getTime();
|
|
|
|
|
material.batchNumber = `${timestamp}`;
|
|
|
|
|
|
|
|
|
|
// 设置默认单价为采购单价
|
|
|
|
|
material.unitPrice = material.purchasePrice || 0;
|
|
|
|
|
// material.unitPrice = material.purchasePrice || 0;
|
|
|
|
|
material.inStockAmount = 1; // 默认数量为1
|
|
|
|
|
material.totalPrice = (material.unitPrice * material.inStockAmount).toFixed(2);
|
|
|
|
|
});
|
|
|
|
|
// material.totalPrice = (material.unitPrice * material.inStockAmount).toFixed(2);
|
|
|
|
|
const res = await getWmsInventoryDetailbyProductId(material.productId);
|
|
|
|
|
material.inventoryAmount = res.data?.inventoryAmount || 0;
|
|
|
|
|
}
|
|
|
|
|
selectedProducts.value.push(...products);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -390,22 +396,7 @@ const inStockBillFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
|
|
|
|
const addFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
|
|
|
|
// 处理物料选择确认回调
|
|
|
|
|
const handleMaterialConfirm = (materials) => {
|
|
|
|
|
console.log('选中的物料:', materials);
|
|
|
|
|
// 为每个物料添加扩展字段
|
|
|
|
|
materials.forEach((material) => {
|
|
|
|
|
// 生成批次号:供应商代码 + 时间戳
|
|
|
|
|
// const supplierCode = form.value.supplierName ? form.value.supplier.substring(0, 4) : 'SUPP';
|
|
|
|
|
const timestamp = new Date().getTime();
|
|
|
|
|
// material.batchNumber = `${supplierCode}${timestamp}`;
|
|
|
|
|
|
|
|
|
|
// 设置默认单价为采购单价
|
|
|
|
|
material.unitPrice = material.purchasePrice || 0;
|
|
|
|
|
material.inStockAmount = 1; // 默认数量为1
|
|
|
|
|
material.totalPrice = (material.unitPrice * material.inStockAmount).toFixed(2);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 计算总价
|
|
|
|
|
const calculateTotalPrice = (material) => {
|
|
|
|
|
|