mainqaq 3 lat temu
rodzic
commit
e41612983a

+ 7 - 6
controllers/supply_order_api_contorller.go Wyświetl plik

@@ -99,12 +99,13 @@ func (this *SupplyOrderApiController) GetSupplyList() {
99 99
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "page或limit参数不能为空")
100 100
 		return
101 101
 	}
102
-	code := this.GetString("code")   //供应商编号
103
-	sname := this.GetString("sname") //供应商名称
104
-	cname := this.GetString("cname") //联系人名字
102
+	//code := this.GetString("code")   //供应商编号
103
+	//sname := this.GetString("sname") //供应商名称
104
+	//cname := this.GetString("cname") //联系人名字
105
+	keyword := this.GetString("keyword") //供应商编号\供应商名称\联系人名字
105 106
 	orgId := this.GetAdminUserInfo().CurrentOrgId
106 107
 	//获取分页的数据
107
-	list, total, err := service.GetSupplyList(ctype, page, limit, code, sname, cname)
108
+	list, total, err := service.GetSupplyList(ctype, page, limit, keyword)
108 109
 	//获取供应商类别
109 110
 	costClassify := "供应商类别"
110 111
 	drugTypeParent, _ := service.GetDrugDataConfig(0, costClassify)
@@ -235,13 +236,13 @@ func (this *SupplyOrderApiController) UpdateSupply() {
235 236
 	}
236 237
 	//supplierType, _ := this.GetInt64("suppliertype") //供应商类别
237 238
 	if dataBody["suppliertype"] == "" || dataBody["suppliertype"] == 0 {
238
-		var tmp int64 = 0
239
+		var tmp float64 = 0
239 240
 		dataBody["suppliertype"] = tmp
240 241
 	}
241 242
 	if dataBody["vatrate"] == "" {
242 243
 		dataBody["vatrate"] = 0
243 244
 	}
244
-	supplierType := dataBody["suppliertype"].(int64) //供应商类别
245
+	supplierType := int64(dataBody["suppliertype"].(float64)) //供应商类别
245 246
 	//vatRate, _ := this.GetFloat("vatrate")           //增值税税率
246 247
 	vatRate, _ := dataBody["suppliertype"].(float64) //增值税税率
247 248
 	//number := this.GetString("number")               //纳税人识别号

+ 7 - 15
service/supply_service.go Wyświetl plik

@@ -13,26 +13,18 @@ func FindName(code string) (fistname models.SpSupplierContacts, err error) {
13 13
 }
14 14
 
15 15
 //供应商分页
16
-func GetSupplyList(ctype int64, page int64, limit int64, code string, sname string, cname string) (supplylist []*models.SpSupplierName, total int64, err error) {
17
-	db := XTReadDB().Model(&supplylist).Where("sgj_xt.xt_supplier_name.status = 1 ")
16
+func GetSupplyList(ctype int64, page int64, limit int64, keyword string) (supplylist []*models.SpSupplierName, total int64, err error) {
17
+	db := XTReadDB().Model(&supplylist).Where("xt_supplier_name.status = 1 ")
18 18
 
19 19
 	offset := (page - 1) * limit
20 20
 
21
-	if cname != "" {
22
-		cname = "%" + cname + "%" //联系人
23
-		db = db.Joins("join sgj_xt.xt_supplier_contacts on sgj_xt.xt_supplier_contacts.supplier_code = sgj_xt.xt_supplier_name.supplier_code")
24
-		db = db.Where("sgj_xt.xt_supplier_contacts.name like ? and sgj_xt.xt_supplier_contacts.status = 1 ", cname).Group("sgj_xt.xt_supplier_name.id")
21
+	if len(keyword) > 0 {
22
+		keyword = "%" + keyword + "%" //联系人
23
+		db = db.Joins("join xt_supplier_contacts on xt_supplier_contacts.supplier_code = xt_supplier_name.supplier_code")
24
+		db = db.Where("xt_supplier_contacts.name like ? or xt_supplier_name.supplier_code like ? or xt_supplier_name.supplier_name like ? ", keyword, keyword, keyword).Group("xt_supplier_name.id")
25 25
 	}
26 26
 	if ctype > 0 {
27
-		db = db.Where("sgj_xt.xt_supplier_name.supplier_type = ?", ctype)
28
-	}
29
-	if code != "" {
30
-		code = "%" + code + "%" //供应商编码
31
-		db = db.Where("sgj_xt.xt_supplier_name.supplier_code = ?", code)
32
-	}
33
-	if sname != "" {
34
-		sname = "%" + sname + "%" //供应商名称
35
-		db = db.Where("sgj_xt.xt_supplier_name.supplier_name = ?", sname)
27
+		db = db.Where("xt_supplier_name.supplier_type = ?", ctype)
36 28
 	}
37 29
 	err = db.Count(&total).Offset(offset).Limit(limit).Find(&supplylist).Error
38 30
 	return supplylist, total, err