Kaynağa Gözat

仓库管理bug修改

mainqaq 2 yıl önce
ebeveyn
işleme
83b60abbf8

+ 39 - 1
controllers/secondary_order_api_contorller.go Dosyayı Görüntüle

@@ -35,6 +35,7 @@ func SecondaryOrderApiRegistRouters() {
35 35
 	beego.Router("/api/secondary/updatedrugout", &SecondaryOrderApiController{}, "get:UpdateDrugOut")               //更改药品自动出库仓库
36 36
 	beego.Router("/api/secondary/getusername", &SecondaryOrderApiController{}, "get:GetuserName")                   //获取仓库管理员信息
37 37
 	beego.Router("/api/secondary/byliinit", &SecondaryOrderApiController{}, "get:Byliinit")                         //初始化旧数据
38
+	beego.Router("/api/secondary/getcreaterid", &SecondaryOrderApiController{}, "get:GetCreaterId")                 //获取当前登录的人的id
38 39
 	beego.Router("/api/secondary/ttttt", &SecondaryOrderApiController{}, "get:TTTTT")
39 40
 
40 41
 }
@@ -642,8 +643,45 @@ func (this *SecondaryOrderApiController) Byliinit() {
642 643
 func (this *SecondaryOrderApiController) GetuserName() {
643 644
 	adminUserInfo := this.GetAdminUserInfo()
644 645
 	viewModels, _, _ := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
646
+	//去除禁用的角色
647
+	tmp := []*service.AdminUserManageViewModel{}
648
+	for i := 0; i < len(viewModels); i++ {
649
+		if viewModels[i].Status == 1 {
650
+			tmp = append(tmp, viewModels[i])
651
+		}
652
+	}
653
+	roles := service.FindRoles(adminUserInfo.CurrentOrgId)
654
+	//去除没有权限的角色
655
+	tmplist := []*service.AdminUserManageViewModel{}
656
+	if roles == nil || len(roles) == 0 {
657
+		this.ServeSuccessJSON(map[string]interface{}{
658
+			"list": tmplist,
659
+		})
660
+		return
661
+	}
662
+	for i := 0; i < len(tmp); i++ {
663
+		boolean := false
664
+		//获取并解析当前用户的角色
665
+		tmproles := strings.Split(tmp[i].RoleIds, ",")
666
+		for j := 0; j < len(tmproles); j++ {
667
+			//判断这些角色是否有权限
668
+			if _, ok := roles[tmproles[j]]; ok {
669
+				boolean = true
670
+			}
671
+		}
672
+		if boolean {
673
+			tmplist = append(tmplist, tmp[i])
674
+		}
675
+	}
645 676
 	this.ServeSuccessJSON(map[string]interface{}{
646
-		"list": viewModels,
677
+		"list": tmplist,
647 678
 	})
679
+	return
680
+}
648 681
 
682
+func (this *SecondaryOrderApiController) GetCreaterId() {
683
+	creater := this.GetAdminUserInfo().AdminUser.Id
684
+	this.ServeSuccessJSON(map[string]interface{}{
685
+		"list": creater,
686
+	})
649 687
 }

+ 1 - 1
controllers/self_drug_api_congtroller.go Dosyayı Görüntüle

@@ -2597,7 +2597,7 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2597 2597
 func (this *SelfDrugApiController) GetDamageByDrugId() {
2598 2598
 
2599 2599
 	drug_id, _ := this.GetInt64("drug_id")
2600
-	warehousing_order := this.GetString("warehousing_order")
2600
+	warehousing_order := this.GetString("warehouseing_order")
2601 2601
 	drug_type, _ := this.GetInt64("type")
2602 2602
 	list, err := service.GetDamageByDrugId(drug_id, warehousing_order, drug_type)
2603 2603
 	if err != nil {

+ 16 - 0
models/secondary_models.go Dosyayı Görüntüle

@@ -69,3 +69,19 @@ type Storehouselist struct {
69 69
 	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
70 70
 	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
71 71
 }
72
+
73
+type RolePurviews struct {
74
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
75
+	RoleId     int64
76
+	OrgId      int64
77
+	AppId      int64
78
+	PurviewIds string `gorm:"column:purview_ids"`
79
+	Status     int8   // 状态 0.无效 1.有效 2.禁用
80
+	CreateTime int64  `gorm:"column:ctime"` // 创建时间
81
+	ModifyTime int64  `gorm:"column:mtime"` // 修改时间
82
+	Role       Role   `gorm:"ForeignKey:RoleId;AssociationForeignKey:ID" json:"role_info"`
83
+}
84
+
85
+func (RolePurviews) TableName() string {
86
+	return "sgj_users.sgj_user_role_purview"
87
+}

+ 11 - 0
service/secondary_service.go Dosyayı Görüntüle

@@ -713,3 +713,14 @@ func Getcreateid(orgid int64) (createid models.UserOrg, err error) {
713 713
 	err = XTReadDB().Select("id,creator").Where("id = ? and status = 1", orgid).Find(&createid).Error
714 714
 	return
715 715
 }
716
+
717
+//根据机构id查询拥有仓库管理权限的角色
718
+func FindRoles(orgid int64) map[string]int {
719
+	role := []models.RolePurviews{}
720
+	roles := make(map[string]int)
721
+	XTReadDB().Select("role_id").Where("purview_ids like \"%299%\" and org_id = ? and status = 1", orgid).Find(&role)
722
+	for i := 0; i < len(role); i++ {
723
+		roles[strconv.FormatInt(role[i].RoleId, 10)] = i
724
+	}
725
+	return roles
726
+}

+ 1 - 1
service/self_drug_service.go Dosyayı Görüntüle

@@ -1000,7 +1000,7 @@ func GetDrugInventoryList(keyword string, page int64, limit int64, orgid int64,
1000 1000
 	if endtime > 0 {
1001 1001
 		db = db.Where("x.start_time<=?", endtime)
1002 1002
 	}
1003
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
1003
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.min_count,x.min_unit,t.dose,t.dose_unit,t.max_unit,t.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Order("x.id desc").Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
1004 1004
 	return list, total, err
1005 1005
 }
1006 1006