Browse Source

部门 地点删除控制

lining 6 năm trước cách đây
mục cha
commit
2237184d96

+ 9 - 0
src/dashoo.cn/backend/api/business/limscustomerposition/limscustomerpositionService.go

@@ -9,6 +9,10 @@ type LimsCustomerpositionService struct {
 	MyServiceBase
 }
 
+type Id_Int struct {
+	Id int
+}
+
 func GetLimsCustomerpositionService(xormEngine *xorm.Engine) *LimsCustomerpositionService {
 	s := new(LimsCustomerpositionService)
 	s.DBE = xormEngine
@@ -29,5 +33,10 @@ func (s *LimsCustomerpositionService) GetPositionList(tableName, ThrUnitIds stri
 	return entitys
 }
 
+func (s *LimsCustomerpositionService) IsEquipment(id string) bool {
+	mod := new(Id_Int)
+	s.DBE.Sql(`select count(1) Id from s5OVELimsCheckEquipmentList where PositionID = ` + id).Get(mod)
+	return mod.Id > 0
+}
 
 

+ 7 - 0
src/dashoo.cn/backend/api/business/organize/organizeService.go

@@ -81,6 +81,13 @@ func (s *OrganizeService) IsHaveEquiUse(id string) bool {
 	return mod.Id > 0
 }
 
+//判断是否有检测地点
+func (s *OrganizeService) IsPositionCheck(id string) bool {
+	mod := new(Id_Int)
+	s.DBE.Sql(`select count(1) Id from s5OVELimsCustomerPosition where ThrUnitId = ` + id).Get(mod)
+	return mod.Id > 0
+}
+
 func (s *OrganizeService) GetListbandparentname(pageIndex, itemsPerPage int64, order, searchstring string) (int64, []Base_Organizebandparentname) {
 	var err error
 	var total int64

+ 8 - 1
src/dashoo.cn/backend/api/controllers/casbin/organize.go

@@ -125,7 +125,7 @@ func (this *OrganizesController) Listbandparentname() {
 	depids := svc.GetAllChildById(topid)
 	where := "1=1 "
 	if IsInnerOrganize == "1" {
-		where = " and ( a.Createuserid=" + this.User.Id + " or a.id in (" + depids + "))"
+		where = where + " and ( a.Createuserid=" + this.User.Id + " or a.id in (" + depids + "))"
 	}
 	keyword := this.GetString("keyword")
 	parentid := this.GetString("parentid")
@@ -287,6 +287,13 @@ func (this *OrganizesController) Delete() {
 		this.ServeJSON()
 		return
 	}
+	if svc.IsPositionCheck(id) {
+		errinfo.Message = "操作失败!此组织下有检测地点,请先删除检测地点"
+		errinfo.Code = -4
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
 	var entity organize.Base_Organize
 	var entityempty organize.Base_Organize
 	err := svc.DeleteEntityAndBackup(id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username)

+ 7 - 0
src/dashoo.cn/backend/api/controllers/lims/Limscustomerposition.go

@@ -439,6 +439,13 @@ func (this *LimsCustomerpositionController) DeleteEntity() {
 		return
 	}
 
+	if svc.IsEquipment(Id) {
+		errinfo.Message = "操作失败!此地点下有设备,请先删除设备"
+		errinfo.Code = -4
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
 	var model limscustomerposition.LimsCustomerPosition
 	var entityempty limscustomerposition.LimsCustomerPosition
 	opdesc := "删除-" + Id