Bläddra i källkod

增加应用的启用状态

庄逸洲 5 år sedan
förälder
incheckning
72928daf9c

+ 8 - 3
controllers/login_controller.go Visa fil

@@ -272,9 +272,14 @@ func (this *LoginController) getRedirectURL(app_type int, mobile string, returnU
272 272
 		}
273 273
 		if lastLoginLog != nil {
274 274
 			utils.TraceLog("%+v", lastLoginLog)
275
-			url := service.GetAppURLWithAppType(int(lastLoginLog.AppType))
276
-			if len(url) > 0 {
277
-				return this.appendTokenParamToReturnURL(url, token), nil, admin
275
+			_, getAppRoleErr := service.GetAppRole(admin.Id, lastLoginLog.OrgId, lastLoginLog.AppId)
276
+			if getAppRoleErr != nil {
277
+				utils.ErrorLog("数据错误:查找mobile = %v的用户的应用角色时错误:%v", mobile, getAppRoleErr)
278
+			} else {
279
+				url := service.GetAppURLWithAppType(int(lastLoginLog.AppType))
280
+				if len(url) > 0 {
281
+					return this.appendTokenParamToReturnURL(url, token), nil, admin
282
+				}
278 283
 			}
279 284
 		}
280 285
 		// 如果没有登录记录,则要前往其有权访问的、最高优先级的应用

+ 116 - 39
controllers/org_controller.go Visa fil

@@ -81,6 +81,10 @@ func (this *OrgController) Create() {
81 81
 // @param business_time?:string
82 82
 // @param business_state?:int
83 83
 // @param org_pics?:string (url1@@url2@@url3)
84
+// @param open_xt?:bool 是否开启血透系统
85
+// @param open_cdm?:bool 是否开启慢病系统
86
+// @param open_scrm?:bool 是否开启SCRM
87
+// @param open_mall?:bool 是否开启Mall
84 88
 func (this *OrgController) CreateSubmit() {
85 89
 	adminUserObj := this.GetSession("admin_user")
86 90
 	if adminUserObj == nil {
@@ -116,7 +120,11 @@ func (this *OrgController) CreateSubmit() {
116 120
 	ill := this.GetString("ill")
117 121
 	category, _ := this.GetInt64("category")
118 122
 	contactName := this.GetString("contact_name")
119
-	if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || province <= 0 || city <= 0 || district <= 0 || category <= 0 {
123
+	openXT, _ := this.GetBool("open_xt")
124
+	openCDM, _ := this.GetBool("open_cdm")
125
+	openSCRM, _ := this.GetBool("open_scrm")
126
+	openMall, _ := this.GetBool("open_mall")
127
+	if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || province <= 0 || city <= 0 || district <= 0 || category <= 0 || (!openXT && !openCDM && !openSCRM && !openMall) {
120 128
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121 129
 		this.ServeJSON()
122 130
 		return
@@ -163,13 +171,15 @@ func (this *OrgController) CreateSubmit() {
163 171
 		CreateTime:      time.Now().Unix(),
164 172
 		ModifyTime:      time.Now().Unix(),
165 173
 	}
166
-	createErr := service.CreateOrg(&org, adminUser.Mobile) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
174
+
175
+	createErr := service.CreateOrg(&org, adminUser.Mobile, openXT, openCDM, openSCRM, openMall) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
167 176
 	if createErr != nil {
168 177
 		utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
169 178
 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
170 179
 		this.ServeJSON()
171 180
 	} else {
172
-		redirectURL := beego.AppConfig.String("submodule_domain_dialysis_manage")
181
+		redirectURL := "" // beego.AppConfig.String("submodule_domain_dialysis_manage")
182
+
173 183
 		this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
174 184
 			"url": redirectURL,
175 185
 		})
@@ -233,7 +243,7 @@ func (this *OrgController) CreateApp() {
233 243
 
234 244
 				// 自动创建所有应用
235 245
 				if did_patient_manage_create == false {
236
-					err := service.CreateOrgApp(adminUser.Id, org.Id, 1)
246
+					err := service.CreateOrgApp(adminUser.Id, org.Id, 1, true)
237 247
 					if err != nil {
238 248
 						utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
239 249
 						this.Abort("404")
@@ -241,7 +251,7 @@ func (this *OrgController) CreateApp() {
241 251
 					}
242 252
 				}
243 253
 				if did_dialysis_manage_create == false {
244
-					err := service.CreateOrgApp(adminUser.Id, org.Id, 3)
254
+					err := service.CreateOrgApp(adminUser.Id, org.Id, 3, true)
245 255
 					if err != nil {
246 256
 						utils.ErrorLog("自动创建透析管理应用失败:%v", err)
247 257
 						this.Abort("404")
@@ -249,7 +259,7 @@ func (this *OrgController) CreateApp() {
249 259
 					}
250 260
 				}
251 261
 				if did_cdm_manage_create == false {
252
-					err := service.CreateOrgApp(adminUser.Id, org.Id, 4)
262
+					err := service.CreateOrgApp(adminUser.Id, org.Id, 4, true)
253 263
 					if err != nil {
254 264
 						utils.ErrorLog("自动创建慢病管理应用失败:%v", err)
255 265
 						this.Abort("404")
@@ -257,7 +267,7 @@ func (this *OrgController) CreateApp() {
257 267
 					}
258 268
 				}
259 269
 				if did_mall_manage_create == false {
260
-					err := service.CreateOrgApp(adminUser.Id, org.Id, 5)
270
+					err := service.CreateOrgApp(adminUser.Id, org.Id, 5, true)
261 271
 					if err != nil {
262 272
 						utils.ErrorLog("自动创建微商城应用失败:%v", err)
263 273
 						this.Abort("404")
@@ -303,38 +313,33 @@ func (this *OrgController) ViewApps() {
303 313
 			}
304 314
 			return
305 315
 		} else {
306
-			this.Data["avatar"] = org.OrgLogo         //"/static/images/userData.png"
307
-			this.Data["user_name"] = org.OrgShortName //adminUser.Mobile
316
+			this.Data["avatar"] = org.OrgLogo
317
+			this.Data["user_name"] = org.OrgShortName
318
+			this.Data["is_super_admin"] = adminUser.IsSuperAdmin
319
+			this.Data["org_id"] = org.Id
308 320
 
309
-			if adminUser.IsSuperAdmin {
310
-				this.Data["scrm_role_exist"] = true
311
-				this.Data["xt_role_exist"] = true
312
-				this.Data["cdm_role_exist"] = true
313
-				this.Data["mall_role_exist"] = true
314
-			} else {
315
-				apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
316
-				if getAppsErr != nil {
317
-					utils.ErrorLog("获取 id = %v,org_id = %v 的用户有权限的应用时出错:%v", adminUser.Id, org.Id, getOrgErr)
318
-					this.Abort("404")
319
-					return
321
+			apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
322
+			if getAppsErr != nil {
323
+				utils.ErrorLog("获取 id = %v,org_id = %v 的用户有权限的应用时出错:%v", adminUser.Id, org.Id, getOrgErr)
324
+				this.Abort("404")
325
+				return
326
+			}
327
+			this.Data["scrm_role_exist"] = false
328
+			this.Data["xt_role_exist"] = false
329
+			this.Data["cdm_role_exist"] = false
330
+			this.Data["mall_role_exist"] = false
331
+			for _, app := range apps {
332
+				if app.AppType == 1 && app.OpenStatus == 1 {
333
+					this.Data["scrm_role_exist"] = true
320 334
 				}
321
-				this.Data["scrm_role_exist"] = false
322
-				this.Data["xt_role_exist"] = false
323
-				this.Data["cdm_role_exist"] = false
324
-				this.Data["mall_role_exist"] = false
325
-				for _, app := range apps {
326
-					if app.AppType == 1 {
327
-						this.Data["scrm_role_exist"] = true
328
-					}
329
-					if app.AppType == 3 {
330
-						this.Data["xt_role_exist"] = true
331
-					}
332
-					if app.AppType == 4 {
333
-						this.Data["cdm_role_exist"] = true
334
-					}
335
-					if app.AppType == 5 {
336
-						this.Data["mall_role_exist"] = true
337
-					}
335
+				if app.AppType == 3 && app.OpenStatus == 1 {
336
+					this.Data["xt_role_exist"] = true
337
+				}
338
+				if app.AppType == 4 && app.OpenStatus == 1 {
339
+					this.Data["cdm_role_exist"] = true
340
+				}
341
+				if app.AppType == 5 && app.OpenStatus == 1 {
342
+					this.Data["mall_role_exist"] = true
338 343
 				}
339 344
 			}
340 345
 
@@ -347,7 +352,79 @@ func (this *OrgController) ViewApps() {
347 352
 	}
348 353
 }
349 354
 
350
-// /org/app/create/submit [post]
355
+// /app/open [post]
356
+// @param type:int
357
+func (this *OrgController) OpenAppSubmit() {
358
+	adminUserObj := this.GetSession("admin_user")
359
+	if adminUserObj == nil {
360
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeLoginTimeout)
361
+		this.ServeJSON()
362
+		return
363
+	}
364
+	adminUser := adminUserObj.(*models.AdminUser)
365
+	if !adminUser.IsSuperAdmin {
366
+		utils.ErrorLog("用户%v不是超级管理员,没有权限启用应用", adminUser.Mobile)
367
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
368
+		this.ServeJSON()
369
+		return
370
+	}
371
+
372
+	appType, _ := this.GetInt("type")
373
+	if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
374
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
375
+		this.ServeJSON()
376
+		return
377
+	}
378
+
379
+	org, getOrgErr := service.GetOrgWithAdminUserID(adminUser.Id)
380
+	if getOrgErr != nil {
381
+		utils.ErrorLog("获取id = %v的用户创建的机构时出错:%v", adminUser.Id, getOrgErr)
382
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
383
+		this.ServeJSON()
384
+		return
385
+	} else {
386
+		if org == nil {
387
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMissingOrg)
388
+			this.ServeJSON()
389
+			return
390
+		} else {
391
+			app, getAppErr := service.GetOrgAppWithType(adminUser.Id, org.Id, appType)
392
+			if getAppErr != nil {
393
+				utils.ErrorLog("获取 id=%v 的用户的类型为%v的应用时失败:%v", adminUser.Id, appType)
394
+				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
395
+				this.ServeJSON()
396
+				return
397
+			}
398
+			if app == nil {
399
+				createAppErr := service.CreateOrgApp(adminUser.Id, org.Id, appType, true)
400
+				if createAppErr != nil {
401
+					utils.ErrorLog("id=%v的超级管理员创建类型为%v的应用时失败:%v", adminUser.Id, appType, createAppErr)
402
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
403
+					this.ServeJSON()
404
+				} else {
405
+					this.Data["json"] = enums.MakeSuccessResponseJSON(nil)
406
+					this.ServeJSON()
407
+				}
408
+			} else {
409
+				if app.OpenStatus != 1 {
410
+					app.OpenStatus = 1
411
+					app.ModifyTime = time.Now().Unix()
412
+					updateErr := service.SaveOrgApp(app)
413
+					if updateErr != nil {
414
+						utils.ErrorLog("id=%v的超级管理员开启类型为%v的应用时失败:%v", adminUser.Id, appType, updateErr)
415
+						this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
416
+						this.ServeJSON()
417
+						return
418
+					}
419
+				}
420
+				this.Data["json"] = enums.MakeSuccessResponseJSON(nil)
421
+				this.ServeJSON()
422
+			}
423
+		}
424
+	}
425
+}
426
+
427
+// /org/app/create/submit [post] 已废弃
351 428
 // @param app_type:int
352 429
 func (this *OrgController) CreateAppSubmit() {
353 430
 	adminUserObj := this.GetSession("admin_user")
@@ -400,7 +477,7 @@ func (this *OrgController) CreateAppSubmit() {
400 477
 			}
401 478
 
402 479
 			// 创建应用
403
-			if createErr := service.CreateOrgApp(adminUser.Id, org.Id, appType); createErr != nil {
480
+			if createErr := service.CreateOrgApp(adminUser.Id, org.Id, appType, false); createErr != nil {
404 481
 				utils.ErrorLog("id=%v的超级管理员创建类型为%v的应用时失败:%v", adminUser.Id, appType, createErr)
405 482
 				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
406 483
 				this.ServeJSON()

+ 4 - 4
controllers/verify_token_controller.go Visa fil

@@ -417,7 +417,7 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
417 417
 	// 自动创建所有应用
418 418
 	didCreateNew := false
419 419
 	if did_patient_manage_create == false {
420
-		err := service.CreateOrgApp(adminUserID, orgID, 1)
420
+		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
421 421
 		if err != nil {
422 422
 			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
423 423
 			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
@@ -425,7 +425,7 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
425 425
 		didCreateNew = true
426 426
 	}
427 427
 	if did_dialysis_manage_create == false {
428
-		err := service.CreateOrgApp(adminUserID, orgID, 3)
428
+		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
429 429
 		if err != nil {
430 430
 			utils.ErrorLog("自动创建透析管理应用失败:%v", err)
431 431
 			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
@@ -433,7 +433,7 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
433 433
 		didCreateNew = true
434 434
 	}
435 435
 	if did_cdm_manage_create == false {
436
-		err := service.CreateOrgApp(adminUserID, orgID, 4)
436
+		err := service.CreateOrgApp(adminUserID, orgID, 4, false)
437 437
 		if err != nil {
438 438
 			utils.ErrorLog("自动创建慢病管理应用失败:%v", err)
439 439
 			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
@@ -441,7 +441,7 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
441 441
 		didCreateNew = true
442 442
 	}
443 443
 	if did_mall_manage_create == false {
444
-		err := service.CreateOrgApp(adminUserID, orgID, 5)
444
+		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
445 445
 		if err != nil {
446 446
 			utils.ErrorLog("自动创建微商城应用失败:%v", err)
447 447
 			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}

+ 4 - 3
models/app_models.go Visa fil

@@ -5,9 +5,10 @@ type OrgApp struct {
5 5
 	AppType    int   `gorm:"column:app_type" json:"app_type"`      // 应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理
6 6
 	Creator    int   `json:"creator"`                              // 创建者,即管理员用户的 id
7 7
 	OrgId      int   `gorm:"column:org_id" json:"org_id"`
8
-	Status     int8  `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
9
-	CreateTime int64 `gorm:"column:ctime" json:"ctime"` // 创建时间
10
-	ModifyTime int64 `gorm:"column:mtime" json:"mtime"` // 修改时间
8
+	OpenStatus int   `gorm:"column:open_status" json:"open_status"` // 开启状态 1开启 0关闭
9
+	Status     int8  `json:"status"`                                // 状态 0.无效 1.有效 2.禁用
10
+	CreateTime int64 `gorm:"column:ctime" json:"ctime"`             // 创建时间
11
+	ModifyTime int64 `gorm:"column:mtime" json:"mtime"`             // 修改时间
11 12
 }
12 13
 
13 14
 func (OrgApp) TableName() string {

+ 1 - 0
routers/router.go Visa fil

@@ -44,6 +44,7 @@ func init() {
44 44
 	beego.Router("/org/admin/apps", &controllers.OrgController{}, "get:ViewApps")
45 45
 	beego.Router("/org/app/create", &controllers.OrgController{}, "get:CreateApp")
46 46
 	// beego.Router("/org/app/create/submit", &controllers.OrgController{}, "post:CreateAppSubmit")
47
+	beego.Router("/app/open", &controllers.OrgController{}, "post:OpenAppSubmit")
47 48
 	beego.Router("/get_org_cat", &controllers.OrgCategoryController{}, "get:GetOrgCategories")
48 49
 	beego.Router("/create_app_hint", &controllers.OrgController{}, "get:CreateAppHint")
49 50
 

+ 35 - 7
service/org_service.go Visa fil

@@ -7,7 +7,7 @@ import (
7 7
 	"github.com/jinzhu/gorm"
8 8
 )
9 9
 
10
-func CreateOrg(org *models.Org, mobile string) error {
10
+func CreateOrg(org *models.Org, mobile string, openXT bool, openCDM bool, openSCRM bool, openMall bool) error {
11 11
 	now := time.Now()
12 12
 	tx_admin := writeUserDb.Begin()
13 13
 	if err := tx_admin.Create(org).Error; err != nil {
@@ -30,19 +30,19 @@ func CreateOrg(org *models.Org, mobile string) error {
30 30
 		return err
31 31
 	}
32 32
 
33
-	if err := createOrgApp(tx_admin, &role, mobile, 1); err != nil {
33
+	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
34 34
 		tx_admin.Rollback()
35 35
 		return err
36 36
 	}
37
-	if err := createOrgApp(tx_admin, &role, mobile, 3); err != nil {
37
+	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
38 38
 		tx_admin.Rollback()
39 39
 		return err
40 40
 	}
41
-	if err := createOrgApp(tx_admin, &role, mobile, 4); err != nil {
41
+	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
42 42
 		tx_admin.Rollback()
43 43
 		return err
44 44
 	}
45
-	if err := createOrgApp(tx_admin, &role, mobile, 5); err != nil {
45
+	if err := createOrgApp(tx_admin, &role, mobile, 5, openMall); err != nil {
46 46
 		tx_admin.Rollback()
47 47
 		return err
48 48
 	}
@@ -121,19 +121,25 @@ func DidOrgDidCreateAppWithType(orgID int, appType int) (bool, error) {
121 121
 	}
122 122
 }
123 123
 
124
-func CreateOrgApp(adminUserID int, orgID int, appType int) error {
124
+func CreateOrgApp(adminUserID int, orgID int, appType int, open bool) error {
125 125
 	var user models.AdminUser
126 126
 	err := readUserDb.Where("id = ? AND status = 1", adminUserID).Find(&user).Error
127 127
 	if err != nil {
128 128
 		return err
129 129
 	}
130 130
 
131
+	openStatus := 0
132
+	if open {
133
+		openStatus = 1
134
+	}
135
+
131 136
 	now := time.Now().Unix()
132 137
 	tx := writeUserDb.Begin()
133 138
 	app := models.OrgApp{
134 139
 		Creator:    adminUserID,
135 140
 		OrgId:      orgID,
136 141
 		AppType:    appType,
142
+		OpenStatus: openStatus,
137 143
 		Status:     1,
138 144
 		CreateTime: now,
139 145
 		ModifyTime: now,
@@ -170,12 +176,17 @@ func CreateOrgApp(adminUserID int, orgID int, appType int) error {
170 176
 }
171 177
 
172 178
 //  如果出错,没有 rollback,需自行 rollback
173
-func createOrgApp(tx *gorm.DB, superAdminRole *models.Role, userName string, appType int) error {
179
+func createOrgApp(tx *gorm.DB, superAdminRole *models.Role, userName string, appType int, open bool) error {
180
+	openStatus := 0
181
+	if open {
182
+		openStatus = 1
183
+	}
174 184
 	now := time.Now().Unix()
175 185
 	app := models.OrgApp{
176 186
 		Creator:    superAdminRole.Creator,
177 187
 		OrgId:      superAdminRole.OrgId,
178 188
 		AppType:    appType,
189
+		OpenStatus: openStatus,
179 190
 		Status:     1,
180 191
 		CreateTime: now,
181 192
 		ModifyTime: now,
@@ -240,3 +251,20 @@ func CreateOrgServeSubscibe(subscibe *models.ServeSubscibe) error {
240 251
 	err := writeUserDb.Create(subscibe).Error
241 252
 	return err
242 253
 }
254
+
255
+func GetOrgAppWithType(adminUserID int, orgID int, appType int) (*models.OrgApp, error) {
256
+	var app models.OrgApp
257
+	err := readUserDb.Model(&models.OrgApp{}).Where("creator = ? AND org_id = ? AND app_type = ? AND status = 1", adminUserID, orgID, appType).First(&app).Error
258
+	if err == gorm.ErrRecordNotFound {
259
+		err = nil
260
+	}
261
+	if err != nil {
262
+		return nil, err
263
+	} else {
264
+		return &app, nil
265
+	}
266
+}
267
+
268
+func SaveOrgApp(app *models.OrgApp) error {
269
+	return writeUserDb.Save(app).Error
270
+}

Filskillnaden har hållits tillbaka eftersom den är för stor
+ 2656 - 2627
static/css/index.css


+ 27 - 0
static/js/create_org.js Visa fil

@@ -1,4 +1,6 @@
1 1
 $(function() {
2
+    $("#open_3").attr("checked", "checked");
3
+    
2 4
     $("#province_select").change(function() {
3 5
         $("#city_select option").remove();
4 6
         $("#district_select option").remove();
@@ -117,6 +119,27 @@ $(function() {
117 119
             return;
118 120
         }
119 121
 
122
+        var open_xt = false;
123
+        var open_cdm = false;
124
+        var open_scrm = false;
125
+        var open_mall = false;
126
+        if ($("#open_3").attr("checked") == "checked") {
127
+            open_xt = true
128
+        }
129
+        if ($("#open_4").attr("checked") == "checked") {
130
+            open_cdm = true
131
+        }
132
+        if ($("#open_1").attr("checked") == "checked") {
133
+            open_scrm = true
134
+        }
135
+        if ($("#open_5").attr("checked") == "checked") {
136
+            open_mall = true
137
+        }
138
+        if (!open_xt && !open_cdm && !open_scrm && !open_mall) {
139
+            layer.msg("请选择要启用的应用");
140
+            return;
141
+        }
142
+
120 143
         var postData = {
121 144
             name: $("#org_name").val(),
122 145
             // short_name: $("#org_short_name").val(),
@@ -127,6 +150,10 @@ $(function() {
127 150
             address: $("#address").val(),
128 151
             category: $("#org_category").val(),
129 152
             org_phone: $("#org_phone").val(),
153
+            open_xt: open_xt,
154
+            open_cdm: open_cdm,
155
+            open_scrm: open_scrm,
156
+            open_mall: open_mall,
130 157
         }
131 158
         postRequest("/org/create/submit", postData, doSuccess, doFail);
132 159
 

+ 23 - 2
views/new_main/create_org.html Visa fil

@@ -38,7 +38,7 @@
38 38
         <div class="stewardMsg">
39 39
             <h2 class="stewardMsg_tit">机构信息</h2>
40 40
             <div class="steward_content">
41
-                <p class="tips">以下信息是对外品牌展示的主要内容,请认真填写,后续可以在账号设置中修改。</p>
41
+                <p class="tips">请正确填写一下信息,后续可在账号设置中修改</p>
42 42
                 <div class="cell clearfix">
43 43
                     <label class="cell_tit fl">机构名称</label>
44 44
                     <input id="org_name" type="text" class="cell_input" maxlength="50" />
@@ -98,6 +98,27 @@
98 98
                     <label class="cell_tit fl">机构电话<br/>(选填)</label>
99 99
                     <input id="org_phone" type="text" class="cell_input" maxlength="50" />
100 100
                 </div>
101
+                <div class="cell clearfix">
102
+                    <label class="cell_tit fl">请选择要启用的应用</label>
103
+                    <div class="Checkbox fl">
104
+                        <div class="opt">
105
+                            <input class="magic-checkbox" type="checkbox" name="open_app_checkbox" value="3" id="open_3" />
106
+                            <label for="open_3">血透管理</label>
107
+                        </div>
108
+                        <div class="opt">
109
+                            <input class="magic-checkbox" type="checkbox" name="open_app_checkbox" value="4" id="open_4" />
110
+                            <label for="open_4">慢病管理</label>
111
+                        </div>
112
+                        <div class="opt">
113
+                            <input class="magic-checkbox" type="checkbox" name="open_app_checkbox" value="1" id="open_1" />
114
+                            <label for="open_1">SCRM</label>
115
+                        </div>
116
+                        <div class="opt">
117
+                            <input class="magic-checkbox" type="checkbox" name="open_app_checkbox" value="5" id="open_5" />
118
+                            <label for="open_5">微商城</label>
119
+                        </div>
120
+                    </div>
121
+                </div>
101 122
                 <div class="cell clearfix">
102 123
                     <div class="cellBtn">
103 124
                         <button id="submit" type="button">立即开启智慧管理之旅</button>
@@ -119,7 +140,7 @@
119 140
     <script src="/static/js/layer.js"></script>
120 141
     <script src="/static/js/md5.js"></script>
121 142
     <script src="/static/js/common.js"></script>
122
-    <script src="/static/js/create_org.js?v=0.2.5"></script>
143
+    <script src="/static/js/create_org.js?v=0.2.6"></script>
123 144
 </body>
124 145
 
125 146
 </html>

+ 169 - 6
views/new_main/manage_app.html Visa fil

@@ -9,7 +9,7 @@
9 9
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
10 10
     <title>酷医云-让服务有温度</title>
11 11
     <link rel="stylesheet" href="/static/css/style.css?v=4.0.0" media="screen">
12
-    <link rel="stylesheet" href="/static/css/index.css?v=4.0.1" media="screen">
12
+    <link rel="stylesheet" href="/static/css/index.css?v=4.0.2" media="screen">
13 13
     <link href="/static/css/bootstrap.min.css?v=4.0.0" rel="stylesheet">
14 14
     <link href="/static/css/font-awesome.min.css?v=4.0.0" rel="stylesheet" media="all">
15 15
     <link href="/static/css/animate.min.css?v=4.0.0" rel="stylesheet" media="all">
@@ -35,7 +35,26 @@
35 35
         <h2 class="name">请选择适合您的应用</h2>
36 36
         <div class="apply-content">
37 37
             <ul>
38
-                {{ if .xt_role_exist }}
38
+                {{ if .is_super_admin }}
39
+                <li>
40
+                    <a id="xt_a" href="{{ if .xt_role_exist }}{{.submodule_domain_dialysis_manage}}{{ end }}">
41
+                        <img src="/static/images/apply-3.jpg" alt="">
42
+                        <span class="join" id="enter_xt"> 进入应用 ></span>
43
+                        <h3 class="title">
44
+                            血透管理</h3>
45
+                        <P class="txt">
46
+                            血透管理是基于血透临床应用标准流程研发的血透管理协作平台,用全新的互联网、云技术和友好的用户体验,为血液透析中心提供透前、透中、透后全过程协作支撑,实现无纸化、数字化和规范化的管理,提升血透中心管理水平,改善病人就医体验。
47
+                        </P>
48
+                        <div class="button">
49
+                            {{ if .xt_role_exist }}
50
+                            <button class="close">已启用</button>
51
+                            {{ else }}
52
+                            <button class="open" id="xt_open">启用</button>
53
+                            {{ end }}
54
+                        </div>
55
+                    </a>
56
+                </li>
57
+                {{ else if .xt_role_exist }}
39 58
                 <li>
40 59
                     <a href="{{.submodule_domain_dialysis_manage}}">
41 60
                         <img src="/static/images/apply-3.jpg" alt="">
@@ -48,12 +67,31 @@
48 67
                     </a>
49 68
                 </li>
50 69
                 {{ end }}
51
-                {{ if .cdm_role_exist }}
70
+
71
+                {{ if .is_super_admin }}
72
+                <li>
73
+                    <a id="cdm_a" href="{{ if .cdm_role_exist }}{{.submodule_domain_cdm_manage}}{{ end }}">
74
+                        <img src="/static/images/apply-4.jpg" alt="">
75
+                        <span class="join" id="enter_cdm"> 进入应用 ></span>
76
+                        <h3 class="title">
77
+                            慢病管理</h3>
78
+                        <P class="txt">
79
+                            专注于慢性肾脏病管理,为肾内科、血液透析中心、肾病医院、肾科医生集团、肾科医生工作室等提供完整的慢病管理系统。通过智能医疗设备+移动互联网+大数据+人工智能结合,实现互联网+的全程慢病管理模式。
80
+                        </P>
81
+                        <div class="button">
82
+                            {{ if .cdm_role_exist }}
83
+                            <button class="close">已启用</button>
84
+                            {{ else }}
85
+                            <button class="open" id="cdm_open">启用</button>
86
+                            {{ end }}
87
+                        </div>
88
+                    </a>
89
+                </li>
90
+                {{ else if .cdm_role_exist }}
52 91
                 <li>
53 92
                     <a href="{{.submodule_domain_cdm_manage}}">
54 93
                         <img src="/static/images/apply-4.jpg" alt="">
55 94
                         <span class="join"> 进入应用 ></span>
56
-
57 95
                         <h3 class="title">
58 96
                             慢病管理</h3>
59 97
                         <P class="txt">
@@ -62,7 +100,26 @@
62 100
                     </a>
63 101
                 </li>
64 102
                 {{ end }}
65
-                {{ if .scrm_role_exist }}
103
+
104
+                {{ if .is_super_admin }}
105
+                <li>
106
+                    <a id="scrm_a" href="{{ if .scrm_role_exist }}{{.submodule_domain_patient_manage}}{{ end }}">
107
+                        <img src="/static/images/apply-1.jpg" alt="">
108
+                        <span class="join" id="enter_scrm"> 进入应用 ></span>
109
+                        <h3 class="title">
110
+                            SCRM</h3>
111
+                        <P class="txt">SCRM是社会化病人关系管理系统,是基于移动社交时代全新营销模 式下的病人关系管理系统。以病人为中心, 通过获取、留存、活跃、洞悉、营销和服务
112
+                            六大手段,帮助品牌建立与消费者坚实有效的关系,提升个性化营销能力,有效挖掘用 户价值并推进价值转化。</P>
113
+                    </a>
114
+                    <div class="button">
115
+                        {{ if .scrm_role_exist }}
116
+                        <button class="close">已启用</button>
117
+                        {{ else }}
118
+                        <button class="open" id="scrm_open">启用</button>
119
+                        {{ end }}
120
+                    </div>
121
+                </li>
122
+                {{ else if .scrm_role_exist }}
66 123
                 <li>
67 124
                     <a href="{{.submodule_domain_patient_manage}}">
68 125
                         <img src="/static/images/apply-1.jpg" alt="">
@@ -74,7 +131,25 @@
74 131
                     </a>
75 132
                 </li>
76 133
                 {{ end }}
77
-                {{ if .mall_role_exist }}
134
+
135
+                {{ if .is_super_admin }}
136
+                <li>
137
+                    <a id="mall_a" href="{{ if .mall_role_exist }}{{.submodule_domain_mall_manage}}{{ end }}">
138
+                        <img src="/static/images/apply-2.jpg" alt="">
139
+                        <span class="join" id="enter_mall"> 进入应用 ></span>
140
+                        <h3 class="title">
141
+                            微商城</h3>
142
+                        <P class="txt">微商城是为肾病服务机构定制的O2O商城,帮助机构实现电商业务,实现线上销售、线下服务的模式,提升销量。也可用于产品/服务的展示和传播。</P>
143
+                        <div class="button">
144
+                            {{ if .mall_role_exist }}
145
+                            <button class="close">已启用</button>
146
+                            {{ else }}
147
+                            <button class="open" id="mall_open">启用</button>
148
+                            {{ end }}
149
+                        </div>
150
+                    </a>
151
+                </li>
152
+                {{ else if .mall_role_exist }}
78 153
                 <li>
79 154
                     <a href="{{.submodule_domain_mall_manage}}">
80 155
                         <img src="/static/images/apply-2.jpg" alt="">
@@ -89,5 +164,93 @@
89 164
         </div>
90 165
         <div class="join-right">Copyright © 2016-2018 圣卫士·酷医云</div>
91 166
     </div>
167
+    <script src="/static/js/jquery-2.1.1.min.js"></script>
168
+    <script src="/static/js/bootstrap.min.js?v=3.4.0"></script>
169
+    <script src="/static/js/jquery.metisMenu.js"></script>
170
+    <script src="/static/js/hplus.js?v=2.2.0"></script>
171
+    <script src="/static/js/layer.js"></script>
172
+    <script src="/static/js/common.js"></script>
173
+    <script type="text/javascript">
174
+    $(function() {
175
+        {{ if eq false .xt_role_exist }}
176
+        $("#enter_xt").hide()
177
+        {{ end }}
178
+        {{ if eq false .cdm_role_exist }}
179
+        $("#enter_cdm").hide()
180
+        {{ end }}
181
+        {{ if eq false .scrm_role_exist }}
182
+        $("#enter_scrm").hide()
183
+        {{ end }}
184
+        {{ if eq false .mall_role_exist }}
185
+        $("#enter_mall").hide()
186
+        {{ end }}
187
+
188
+        var xturl = "{{.submodule_domain_dialysis_manage}}"
189
+        var cdmurl = "{{.submodule_domain_cdm_manage}}"
190
+        var scrmurl = "{{.submodule_domain_patient_manage}}"
191
+        var mallurl = "{{.submodule_domain_mall_manage}}"
192
+
193
+        $("#xt_open").click(function() {
194
+            openAppAction(3, function() {
195
+                $("#xt_open").removeClass("open")
196
+                $("#xt_open").addClass("close")
197
+                $("xt_a").attr("href", xturl)
198
+                $("enter_xt").show()
199
+            })
200
+        })
201
+        $("#cdm_open").click(function() {
202
+            openAppAction(4, function() {
203
+                $("#cdm_open").removeClass("open")
204
+                $("#cdm_open").addClass("close")
205
+                $("cdm_a").attr("href", cdmurl)
206
+                $("enter_cdm").show()
207
+            })
208
+        })
209
+        $("#scrm_open").click(function() {
210
+            openAppAction(1, function() {
211
+                $("#scrm_open").removeClass("open")
212
+                $("#scrm_open").addClass("close")
213
+                $("scrm_a").attr("href", scrmurl)
214
+                $("enter_scrm").show()
215
+            })
216
+        })
217
+        $("#mall_open").click(function() {
218
+            openAppAction(5, function() {
219
+                $("#mall_open").removeClass("open")
220
+                $("#mall_open").addClass("close")
221
+                $("mall_a").attr("href", mallurl)
222
+                $("enter_mall").show()
223
+            })
224
+        })
225
+
226
+        function openAppAction(type, success_cb) {
227
+            $.ajax({
228
+                url: "/app/open",
229
+                type: "POST",
230
+                data: {
231
+                    type: type,
232
+                },
233
+                async: false,
234
+                headers: {
235
+                    "X-Xsrftoken": getXSRF()
236
+                },
237
+                dataType: "json",
238
+                success: function(json) {
239
+                    if (json.state == 1) {
240
+                        if (success_cb != null && success_cb != undefined) {
241
+                            success_cb()
242
+                        }
243
+
244
+                    } else {
245
+                        layer.msg("启用失败: " + json.msg);
246
+                    }
247
+                },
248
+                error: function() {
249
+                    layer.msg("连接失败,请检查网络");
250
+                }
251
+            });
252
+        }
253
+    })
254
+    </script>
92 255
 </body>
93 256
 </html>