From 91d7ca06128f996844aa7d2d691d083c944bdf1d Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期三, 03 七月 2024 17:22:16 +0800
Subject: [PATCH] 导入物料/产品->新模版BUG修复

---
 models/operation.go |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/models/operation.go b/models/operation.go
index 740659d..9e2846c 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -95,6 +95,12 @@
 	return &OperationSearch{Orm: mysqlx.GetDB()}
 }
 
+func (slf *OperationSearch) BeforeCreate(tx *gorm.DB) {
+	for k := range slf.Details {
+		slf.Details[k].BaseOperationType = slf.BaseOperationType
+	}
+}
+
 func (slf *OperationSearch) SetOrm(tx *gorm.DB) *OperationSearch {
 	slf.Orm = tx
 	return slf
@@ -196,6 +202,11 @@
 	return slf
 }
 
+func (slf *OperationSearch) SetWarehouseId(warehouseId int) *OperationSearch {
+	slf.WarehouseId = warehouseId
+	return slf
+}
+
 func (slf *OperationSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Operation{})
 
@@ -277,6 +288,10 @@
 		db = db.Where("inventory_dealer_type in (?)", slf.InventoryDealerTypeIds)
 	}
 
+	if slf.WarehouseId != 0 {
+		db = db.Where("warehouse_id = ?", slf.WarehouseId)
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0