Răsfoiți Sursa

后端: 增项:全部和新增准入范围模糊按code和name模糊查询、分页

baichengfei 5 ani în urmă
părinte
comite
18d939dc09

+ 20 - 8
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercertappendsub.go

@@ -106,7 +106,7 @@ func (this *OilSupplierCertAppendSubController) GetListInAndApp() {
 				OR (SupplierCertId =  ` + SupplierCertId + ` AND SupplierTypeCode = '` + SupplierTypeCode + `' AND SupplierCertAppendId = ` + SupplierCertAppendId + `)) `
 	//" SupplierCertId = "+ SupplierCertId+ " and SupplierTypeCode = "+ SupplierTypeCode
 	if searchCode != "" {
-		where += " and Code like '" + searchCode + "%' "
+		where += " and (Code like '" + strings.Replace(searchCode, " ", "", -1) + "%' or Name like '%" + strings.Replace(searchCode, " ", "", -1) + "%')"
 	}
 
 	svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
@@ -141,7 +141,7 @@ func (this *OilSupplierCertAppendSubController) GetMyList() {
 	searchCode := this.GetString("searchCode")
 	where := " SupplierCertId = " + SupplierCertId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and SupplierCertAppendId = " + SuppAppendId
 	if searchCode != "" {
-		where += " and Code like '" + searchCode + "%' "
+		where += " and (Code like '" + strings.Replace(searchCode, " ", "", -1) + "%' or Name like '%" + strings.Replace(searchCode, " ", "", -1) + "%')"
 	}
 	svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
 	var list []suppliercertsub.OilSupplierCertSub
@@ -167,7 +167,7 @@ func (this *OilSupplierCertAppendSubController) GetMyList() {
 func (this *OilSupplierCertAppendSubController) GetListAppend() {
 
 	//获取分页信息
-	//page := this.GetPageInfoForm()
+	page := this.GetPageInfoForm()
 	//where := " 1=1 "
 	//orderby := "Id"
 	//asc := false
@@ -187,14 +187,26 @@ func (this *OilSupplierCertAppendSubController) GetListAppend() {
 	SupplierCertAppendId := this.GetString("SupplierCertAppendId")
 	SupplierCertId := this.GetString("SupCertId")
 	SupplierTypeCode := this.GetString("SupTypeCode")
-	suwhere := " SupplierCertId = " + SupplierCertId + " and SupplierCertAppendId= " + SupplierCertAppendId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and Type in(2,3) "
+	searchCode := this.GetString("searchCode")
+	where := " SupplierCertId = " + SupplierCertId + " and SupplierCertAppendId= " + SupplierCertAppendId + " and SupplierTypeCode = '" + SupplierTypeCode + "' and Type in(2,3) "
+	if searchCode != "" {
+		where += " and (Code like '" + strings.Replace(searchCode, " ", "", -1) + "%' or Name like '%" + strings.Replace(searchCode, " ", "", -1) + "%')"
+	}
 	svc := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
 	var list []suppliercertsub.OilSupplierCertSub
 	//svc.GetEntitysByWhere(OilSupplierCertAppendSubName, where, &list)
-	svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
-	var datainfo ErrorDataInfo
-	datainfo.Item = list
-	this.Data["json"] = &datainfo
+	//svc.GetEntitysByOrderbyWhere(OilSupplierCertSubName, suwhere, "CreateOn asc", &list)
+	total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "CreateOn", false, &list, where)
+	var dataInfo DataInfo
+	if list == nil {
+		dataInfo.Items = []suppliercertsub.OilSupplierCertSub{}
+	} else {
+		dataInfo.Items = list
+	}
+	dataInfo.CurrentItemCount = total
+	dataInfo.PageIndex = page.CurrentPage
+	dataInfo.ItemsPerPage = page.Size
+	this.Data["json"] = &dataInfo
 	this.ServeJSON()
 }