Browse Source

后端: 判断页面内容是否可编辑,按类别参数区分。排除不同类别的已入库申请。

baichengfei 5 years ago
parent
commit
7dfbd9925a

+ 11 - 17
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -48,7 +48,7 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName
 	} else {
 		sql += ` order by ` + orderby + ` DESC `
 	}
-	if pageIndex != 0 && itemsPerPage !=0 {
+	if pageIndex != 0 && itemsPerPage != 0 {
 		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
 	}
 	s.DBE.SQL(sql).Find(entitiesPtr)
@@ -101,7 +101,7 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl2(supplierTableNam
 	} else {
 		sql += ` order by ` + orderby + ` DESC `
 	}
-	if pageIndex != 0 && itemsPerPage !=0 {
+	if pageIndex != 0 && itemsPerPage != 0 {
 		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
 	}
 	s.DBE.SQL(sql).Find(entitiesPtr)
@@ -123,8 +123,6 @@ func (s *OilSupplierService) CheckRepeatApplyInfo(supplierTableName, supplierCer
 
 	//获取分页信息
 
-
-
 	where2 := " b.SupplierTypeCode = '" + typeCode
 
 	where := ""
@@ -170,15 +168,12 @@ func (s *OilSupplierService) CheckRepeatApplyInfo(supplierTableName, supplierCer
 		s.DBE.SQL(sql).Find(entitiesPtr)
 	}
 
-
 }
 
 func (s *OilSupplierService) CheckUpdateRepeatApplyInfo(supplierTableName, supplierCertTableName, typeCode, supplierId, SupplierName, CommercialNo, OrganCode, BankAccount, CompanyUrl string, entitiesPtr interface{}) {
 
 	//获取分页信息
 
-
-
 	where2 := " a.Id != '" + supplierId + "'"
 
 	where := ""
@@ -225,17 +220,17 @@ func (s *OilSupplierService) CheckUpdateRepeatApplyInfo(supplierTableName, suppl
 	}
 }
 
-func (s *OilSupplierService) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int) (bool){
+func (s *OilSupplierService) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int, typeCode string) bool {
 	session := s.DBE.NewSession()
 	sessionSvc := GetOilSupplierSession(session)
 	defer session.Close()
 	session.Begin()
-	result := sessionSvc.CanUpdateSupplier(oilSupplierCertTableName, supplierId)
+	result := sessionSvc.CanUpdateSupplier(oilSupplierCertTableName, supplierId, typeCode)
 	session.Commit()
 	return result
 }
 
-func (s *OilSupplierService) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) ([]string){
+func (s *OilSupplierService) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) []string {
 	session := s.DBE.NewSession()
 	sessionSvc := GetOilSupplierSession(session)
 	defer session.Close()
@@ -245,14 +240,13 @@ func (s *OilSupplierService) GetUpdateCols(oilSupplierCertTableName string, supp
 	return cols
 }
 
-func (s *OilSupplierService) GetProOrTreeList(ids string, entitiesPtr interface{}){
-	where := " Id in ("+ids+")"
+func (s *OilSupplierService) GetProOrTreeList(ids string, entitiesPtr interface{}) {
+	where := " Id in (" + ids + ")"
 	sql := "SELECT Id, FullName, ParentId FROM Base_Organize where " + where
 	s.DBE.SQL(sql).Find(entitiesPtr)
 	return
 }
 
-
 func (s *OilSupplierService) GetMyTodoEntitie(supplierTableName, supplierCertTableName string, entitiesPtr interface{}, where string) bool {
 
 	var sql string
@@ -261,7 +255,7 @@ func (s *OilSupplierService) GetMyTodoEntitie(supplierTableName, supplierCertTab
 	sql += ` left join ` + supplierCertTableName + " b on b.SupplierId = a.Id"
 	sql += ` where ` + where
 
-	has,_ := s.DBE.SQL(sql).Get(entitiesPtr)
+	has, _ := s.DBE.SQL(sql).Get(entitiesPtr)
 	return has
 }
 
@@ -272,7 +266,7 @@ func (s *OilSupplierService) GetExpireFile(supplierTableName, supplierFileTableN
 	sql += ` FROM ` + supplierTableName + ` a `
 	sql += ` left join ` + supplierFileTableName + " b ON a.Id=b.SupplierId "
 	sql += ` where ` + where
-    sql += ` GROUP BY a.Id, a.SupplierName, a.Mobile `
+	sql += ` GROUP BY a.Id, a.SupplierName, a.Mobile `
 	err := s.DBE.SQL(sql).Find(entitiesPtr)
 	return err
 }
@@ -328,7 +322,7 @@ func (s *OilSupplierService) GetProcessInfoWithOrderBytbl(supplierTableName, sup
 	} else {
 		sql += ` order by ` + orderby + ` DESC `
 	}
-	if (pageIndex != 0 && itemsPerPage != 0) {
+	if pageIndex != 0 && itemsPerPage != 0 {
 		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
 	}
 	s.DBE.SQL(sql).Find(entitiesPtr)
@@ -346,7 +340,7 @@ func (s *OilSupplierService) GetProcessInfoWithOrderBytbl(supplierTableName, sup
 	return total
 }
 
-func (s *OilSupplierService) GetCertIds( entitiesPtr interface{}, where string) {
+func (s *OilSupplierService) GetCertIds(entitiesPtr interface{}, where string) {
 
 	sql := "SELECT GROUP_CONCAT(DISTINCT SupplierCertId) as Ids from OilSupplierCertSub where " + where + " ORDER BY SupplierCertId"
 

+ 5 - 2
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierSession.go

@@ -16,8 +16,11 @@ func GetOilSupplierSession(session *xorm.Session) *OilSupplierSession {
 	return s
 }
 
-func (s *OilSupplierSession) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int) (bool){
+func (s *OilSupplierSession) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int, typeCode string) bool {
 	sql := "select count(*) from " + oilSupplierCertTableName + " where SupplierId='" + strconv.Itoa(supplierId) + "' and status > 0"
+	if typeCode != "" {
+		sql = sql + " and SupplierTypeCode=" + typeCode
+	}
 	resultsSlice, _ := s.Session.Query(sql)
 	var total int64
 	if len(resultsSlice) > 0 {
@@ -30,7 +33,7 @@ func (s *OilSupplierSession) CanUpdateSupplier(oilSupplierCertTableName string,
 	return total <= 0
 }
 
-func (s *OilSupplierSession) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) ([]string){
+func (s *OilSupplierSession) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) []string {
 	// canEdit := s.CanUpdateSupplier(oilSupplierCertTableName, supplierId)
 	cols := []string{
 		"SupplierName",

+ 13 - 14
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -1208,7 +1208,7 @@ func (this *OilSupplierController) GetMyTaskEntityList() {
 	var list []supplier.OilSupplierView
 	svc := supplier.GetOilSupplierService(utils.DBE)
 	var total int64 = 0
-	if (certIdList != "") {
+	if certIdList != "" {
 		where += " and b.Id in (" + certIdList + ")"
 		total = svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
 
@@ -1398,7 +1398,6 @@ func (this *OilSupplierController) GetDictListByStatus() {
 	isInvestigate := paramSvc.GetBaseparameterMessage("GFGL1", "paramset", "isInvestigate")
 	dictList["isInvestigate"] = isInvestigate
 
-
 	var datainfo DataInfo
 	datainfo.Items = dictList
 	this.Data["json"] = &datainfo
@@ -1608,7 +1607,7 @@ func (this *OilSupplierController) AddEntity() {
 	modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
 	modelCert.InStyle = modelCertVM.InStyle
 
-	if 	modelCert.InStyle == suppliercert.PINGSHEN {
+	if modelCert.InStyle == suppliercert.PINGSHEN {
 		modelCert.IsPay = 0
 	} else {
 		modelCert.IsPay = 2
@@ -1697,7 +1696,7 @@ func (this *OilSupplierController) UpdateEntity() {
 		var info register.OilCorporateInfo
 		info.CommercialNo = model.CommercialNo
 		info.SupplierName = model.SupplierName
-		svc.UpdateEntityBywheretbl(OilCorporateInfoName, &info, cols, "CommercialNo = '" + oldModel.CommercialNo + "'")
+		svc.UpdateEntityBywheretbl(OilCorporateInfoName, &info, cols, "CommercialNo = '"+oldModel.CommercialNo+"'")
 	}
 
 	//判断基本信息是否可修改
@@ -1712,10 +1711,10 @@ func (this *OilSupplierController) UpdateEntity() {
 	//}
 
 	if err == nil {
-		svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle +  "' where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'") // "', IsPay= " + isPay +
+		svc.DBE.Exec("update OilSupplierCert set InStyle='" + instyle + "' where SupplierId=" + id + " and SupplierTypeCode='" + typeCode + "'") // "', IsPay= " + isPay +
 		//一级变二级删除一级准入范围
 		if model.Grade == "2" {
-			svc.DeleteEntityBytbl(OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and SupplierId = " + id)
+			svc.DeleteEntityBytbl(OilSupplierCertSubName, "SupplierTypeCode = '01' and GoodsLevel = '1' and SupplierId = "+id)
 		}
 		//供应商类型改变对资质的检查
 		errinfo.Message = "修改成功!"
@@ -1842,7 +1841,7 @@ func (this *OilSupplierController) DeleteAllEntity() {
 		return
 	}
 	svc := supplier.GetOilSupplierService(utils.DBE)
-	deleteWhere := "SupplierId="+Id+" and SupplierTypeCode='"+SupplierTypeCode+"'"
+	deleteWhere := "SupplierId=" + Id + " and SupplierTypeCode='" + SupplierTypeCode + "'"
 	err := svc.DeleteEntityBytbl(OilSupplierCertSubName, deleteWhere)
 	err = svc.DeleteEntityBytbl(OilSupplierFileName, deleteWhere)
 
@@ -1938,9 +1937,10 @@ func (this *OilSupplierController) IsCanApply() {
 // @Description
 // @Success 200 {string} Count
 // @Failure 403 :id 为空
-// @router /iscanupdatesupplier/:supplierid [get]
+// @router /iscanupdatesupplier/:supplierid/:typecode [get]
 func (this *OilSupplierController) CanUpdateSupplier() {
 	supplierId := this.Ctx.Input.Param(":supplierid")
+	typeCode := this.Ctx.Input.Param(":typecode")
 	var errinfo ErrorInfo
 	if supplierId == "" {
 		errinfo.Message = "操作失败!请求信息不完整"
@@ -1952,7 +1952,7 @@ func (this *OilSupplierController) CanUpdateSupplier() {
 
 	Id, _ := strconv.Atoi(supplierId)
 	svc := supplier.GetOilSupplierService(utils.DBE)
-	canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id)
+	canUpdate := svc.CanUpdateSupplier(OilSupplierCertName, Id, typeCode) // 区分物资类01 基建类02 服务类03
 
 	if canUpdate {
 		errinfo.Message = "可以修改"
@@ -2331,10 +2331,10 @@ func (this *OilSupplierController) ImportExcel() {
 	}
 
 	svc := supplier.GetOilSupplierService(utils.DBE)
-    log.Printf("url:==" + url) // http://60.30.245.229//upfile/dc1/2,063156edd288
-    extranetIP := utils.Cfg.MustValue("server", "extranetIP")
+	log.Printf("url:==" + url) // http://60.30.245.229//upfile/dc1/2,063156edd288
+	extranetIP := utils.Cfg.MustValue("server", "extranetIP")
 	localIP := utils.Cfg.MustValue("server", "localIP")
-    if strings.Index(url, extranetIP) >= 0 {
+	if strings.Index(url, extranetIP) >= 0 {
 		url = strings.Replace(url, extranetIP, localIP, 1)
 	}
 	_dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
@@ -2420,7 +2420,6 @@ func (this *OilSupplierController) GetSceneFileList() {
 	this.Data["json"] = &errinfo
 	this.ServeJSON()
 
-
 }
 
 // @Title 获取已使用的银行账号
@@ -2471,4 +2470,4 @@ func (this *OilSupplierController) GetCommercialNoIsExist() {
 		this.Data["json"] = &errorInfo
 		this.ServeJSON()
 	}
-}
+}