caipin 4 anos atrás
pai
commit
a0ff7fada8

+ 6 - 0
comm/functions.go

@@ -41,6 +41,12 @@ func MakeProjectAccountVM(modelsAccount *models.CmProjectAccount) viewmodels.Pro
 	viewAccountData.Role = modelsAccount.Role
 	viewAccountData.Mobile = modelsAccount.Mobile
 	viewAccountData.Telephone = modelsAccount.Telephone
+
+	viewAccountData.BoolAdmin = false
+	if modelsAccount.IsAdmin == 1 {
+		viewAccountData.BoolAdmin = true
+	}
+
 	viewAccountData.IsAdmin = modelsAccount.IsAdmin
 	viewAccountData.AccountGroup = modelsAccount.AccountGroup
 	viewAccountData.Enable = modelsAccount.Enable

+ 3 - 2
services/project_account_service.go

@@ -236,6 +236,7 @@ func (s *projectAccountService) GetAll(projectId int) []viewmodels.ProjectAccoun
 	for _, data := range accountList {
 		//if data.IsAdmin != 1 {
 		account := comm.MakeProjectAccountVM(&data)
+
 		accountListVM = append(accountListVM, account)
 		//}
 	}
@@ -338,8 +339,8 @@ func (s *projectAccountService) SaveBs(viewAccount viewmodels.ProjectAccount, id
 	updateField := []string{"name", "company", "position", "telephone", "account_group"}
 
 	// 是否重新设置管理员
-	if viewAccount.IsAdmin == 1 {
-		account.IsAdmin = viewAccount.IsAdmin
+	if viewAccount.BoolAdmin {
+		account.IsAdmin = 1
 		updateField = append(updateField, "is_admin")
 
 		if err := s.updateAdminZero(projectId); err != nil {

+ 1 - 0
web/viewmodels/project_account.go

@@ -25,6 +25,7 @@ type ProjectAccount struct {
 	Mobile             string `form:"mobile" json:"mobile"`
 	Telephone          string `form:"telephone" json:"telephone"`
 	IsAdmin            int    `form:"isAdmin" json:"isAdmin"`
+	BoolAdmin          bool   `form:"boolAdmin" json:"boolAdmin"`
 	AccountGroup       int    `form:"accountGroup" json:"accountGroup"`
 	Enable             int    `form:"enable" json:"enable"`
 	ContractPermission string `form:"contractPermission" json:"contractPermission"`