|
@@ -113,7 +113,7 @@ func GetSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
|
|
|
func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
page, size, query := UtilQueryPageSize(c)
|
|
page, size, query := UtilQueryPageSize(c)
|
|
- //category =>根据内容查询 供应对应内容的供应商
|
|
|
|
|
|
+
|
|
emtyPage := &repo.PageResult{
|
|
emtyPage := &repo.PageResult{
|
|
Total: 0,
|
|
Total: 0,
|
|
Size: size,
|
|
Size: size,
|
|
@@ -121,35 +121,36 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
List: []map[string]interface{}{},
|
|
List: []map[string]interface{}{},
|
|
}
|
|
}
|
|
listOut := []map[string]interface{}{}
|
|
listOut := []map[string]interface{}{}
|
|
- if len(query) == 0 {
|
|
|
|
- option := &repo.PageSearchOptions{
|
|
|
|
- CollectName: repo.CollectionSupplier,
|
|
|
|
- Query: query,
|
|
|
|
- Page: page,
|
|
|
|
- Size: size,
|
|
|
|
- Sort: bson.M{"createTime": -1},
|
|
|
|
- }
|
|
|
|
- return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
|
|
|
|
|
|
+
|
|
|
|
+ flag := false
|
|
|
|
+ if query["matId"] != nil || query["craftId"] != nil || query["productId"] != nil {
|
|
|
|
+ flag = true
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ filtter := repo.Map{}
|
|
if _name, ok := query["name"]; ok {
|
|
if _name, ok := query["name"]; ok {
|
|
- delete(query, "name")
|
|
|
|
- query["name"] = bson.M{"$regex": _name.(string)}
|
|
|
|
|
|
+ filtter["name"] = bson.M{"$regex": _name.(string)}
|
|
}
|
|
}
|
|
|
|
|
|
if cate, ok := query["category"]; ok {
|
|
if cate, ok := query["category"]; ok {
|
|
- delete(query, "category")
|
|
|
|
- query["categorys"] = bson.M{"$in": []string{cate.(string)}}
|
|
|
|
|
|
+ filtter["categorys"] = bson.M{"$in": []string{cate.(string)}}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !flag {
|
|
option := &repo.PageSearchOptions{
|
|
option := &repo.PageSearchOptions{
|
|
CollectName: repo.CollectionSupplier,
|
|
CollectName: repo.CollectionSupplier,
|
|
// Query: repo.Map{"categorys": bson.M{"$in": []string{cate.(string)}}},
|
|
// Query: repo.Map{"categorys": bson.M{"$in": []string{cate.(string)}}},
|
|
- Query: query,
|
|
|
|
|
|
+ Query: filtter,
|
|
Page: page,
|
|
Page: page,
|
|
Size: size,
|
|
Size: size,
|
|
Sort: bson.M{"createTime": -1},
|
|
Sort: bson.M{"createTime": -1},
|
|
}
|
|
}
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //category =>根据内容查询 供应对应内容的供应商
|
|
|
|
+
|
|
if query["matId"] != nil {
|
|
if query["matId"] != nil {
|
|
matId := query["matId"].(string)
|
|
matId := query["matId"].(string)
|
|
if len(matId) < 1 {
|
|
if len(matId) < 1 {
|
|
@@ -169,11 +170,6 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
}
|
|
}
|
|
|
|
|
|
if query["craftId"] != nil {
|
|
if query["craftId"] != nil {
|
|
-
|
|
|
|
- // if query["craftId"] == nil {
|
|
|
|
- // return nil, fmt.Errorf("参数错误 craftId 或matId不能为空")
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
cratf := &model.Craft{}
|
|
cratf := &model.Craft{}
|
|
|
|
|
|
ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
@@ -271,13 +267,14 @@ func GetPlanSuppliers(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
return emtyPage, nil
|
|
return emtyPage, nil
|
|
}
|
|
}
|
|
|
|
|
|
- query["_id"] = bson.M{"$in": suppliers}
|
|
|
|
|
|
+ filtter["_id"] = bson.M{"$in": suppliers}
|
|
option := &repo.PageSearchOptions{
|
|
option := &repo.PageSearchOptions{
|
|
CollectName: repo.CollectionSupplier,
|
|
CollectName: repo.CollectionSupplier,
|
|
- Query: repo.Map{"_id": bson.M{"$in": suppliers}},
|
|
|
|
- Page: page,
|
|
|
|
- Size: size,
|
|
|
|
- Sort: bson.M{"createTime": -1},
|
|
|
|
|
|
+ Query: filtter,
|
|
|
|
+ // Query: repo.Map{"_id": bson.M{"$in": suppliers}},
|
|
|
|
+ Page: page,
|
|
|
|
+ Size: size,
|
|
|
|
+ Sort: bson.M{"createTime": -1},
|
|
}
|
|
}
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
|
|
}
|
|
}
|