From d63c4c08a7571f10433be03f06ed9f4f0323eea9 Mon Sep 17 00:00:00 2001
From: dsmzx <dsmzx@123.com>
Date: 星期二, 25 六月 2024 09:39:03 +0800
Subject: [PATCH] 出库/入库 打印修改查询动态属性方式

---
 controllers/operation.go  |    9 ++++++---
 models/operation.go       |    2 +-
 models/attribute_value.go |    9 ++++++++-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/controllers/operation.go b/controllers/operation.go
index 8db06b8..1e6fb49 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -781,7 +781,7 @@
 	if err != nil {
 		return "", errors.New("鑾峰彇妯$増璁板綍澶辫触:" + err.Error())
 	}
-
+	fmt.Println(template)
 	// 鏍规嵁妯℃澘璺緞鑾峰彇妯℃澘娑堟伅
 	readerCloser, err := http.HttpGetWithReadCloser(template.FileUrl)
 	if err != nil {
@@ -818,6 +818,10 @@
 	f.SetCellValue(sheet, "L3", date[5:7])  // 鏈�
 	f.SetCellValue(sheet, "N3", date[8:10]) // 鏃�
 
+	var entityIDs []string
+	for _, v := range operation.Details {
+		entityIDs = append(entityIDs, v.ProductId)
+	}
 	attributeMap := make(map[string]uint)
 	attributeValueMap := make(map[string]string)
 	attributes, err := models.NewAttributeSearch().SetEntityType(1).FindNotTotal()
@@ -827,7 +831,7 @@
 	for _, v := range attributes {
 		attributeMap[v.Name] = v.ID
 	}
-	attributeValues, err := models.NewAttributeValueSearch().FindNotTotal()
+	attributeValues, err := models.NewAttributeValueSearch().SetEntityIDs(entityIDs).FindNotTotal()
 	if err != nil {
 		return "", errors.New("鑾峰彇鍔ㄦ�佸睘鎬у�煎け璐ワ細" + err.Error())
 	}
@@ -919,7 +923,6 @@
 		logx.Errorf("file upload err: %v", err)
 		return "", err
 	}
-
 	return fileUrl, nil
 }
 
diff --git a/models/attribute_value.go b/models/attribute_value.go
index 960685d..fc6e42a 100644
--- a/models/attribute_value.go
+++ b/models/attribute_value.go
@@ -17,6 +17,7 @@
 
 	AttributeValueSearch struct {
 		AttributeValue
+		Ids      []string
 		Order    string
 		PageNum  int
 		PageSize int
@@ -55,6 +56,10 @@
 	slf.EntityID = entityId
 	return slf
 }
+func (slf *AttributeValueSearch) SetEntityIDs(entityId []string) *AttributeValueSearch {
+	slf.Ids = entityId
+	return slf
+}
 func (slf *AttributeValueSearch) SetAttributeID(attributeId uint) *AttributeValueSearch {
 	slf.AttributeID = attributeId
 	return slf
@@ -78,7 +83,9 @@
 	if slf.Value != "" {
 		db = db.Where("value like ?", "%"+slf.Value+"%")
 	}
-
+	if len(slf.Ids) > 0 {
+		db = db.Where("entity_id in ?", slf.Ids)
+	}
 	if slf.Order != "" {
 		db = db.Order(slf.Order)
 	}
diff --git a/models/operation.go b/models/operation.go
index e2ba2c4..8eb2fb8 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -59,7 +59,7 @@
 		Custodian    string `json:"custodian" gorm:"type:varchar(255);comment:淇濈鍛樺悕绉�"`
 		CreatedBy    string `json:"createBy" gorm:"type:varchar(255);comment:鍒涘缓鑰匲serId"`
 		CheckedBy    string `json:"checkedBy" gorm:"type:varchar(255);comment:楠岃瘉鑰匲serId"`
-		Remark       string `json:"remark" gorm:"-"`
+		Remark       string `json:"remark"`
 
 		IsInternalOutput bool `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
 	}

--
Gitblit v1.8.0