فهرست منبع

添加供应商的自动添加

491520313@qq.com 1 هفته پیش
والد
کامیت
aa5d085073
1فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 15 1
      sku3d/sku3d/api/a-excel.go

+ 15 - 1
sku3d/sku3d/api/a-excel.go

@@ -266,7 +266,21 @@ func ParseMatObject(ctx *repo.RepoSession, row []string, headers []string, cates
 		}
 	}
 	if len(row11Cate.IdStr) <= 0 {
-		return imageMat, fmt.Errorf("%s的首选供应商未找到定义", row[MainSupplierIndex])
+		oid := primitive.NewObjectID()
+		super := &model.Category{
+			Id:       oid,
+			Name:     row[MainSupplierIndex],
+			IdStr:    oid.Hex(),
+			CusNum:   "0000",
+			Children: []*model.Category{},
+		}
+		for _, cate := range cates {
+			if cate.Name == "首选供应商" {
+				cate.Children = append(cate.Children, super)
+				break
+			}
+		}
+		row11Cate = super
 	}
 	//添加首先供应商
 	imageMat.Categories = append(imageMat.Categories, row11Cate.IdStr)