maxiaoshan 5 سال پیش
والد
کامیت
4be5f585ca
4فایلهای تغییر یافته به همراه25 افزوده شده و 19 حذف شده
  1. 0 1
      dataprocess/src/front/front.go
  2. 3 1
      dataprocess/src/front/menu.go
  3. 13 15
      dataprocess/src/front/role.go
  4. 9 2
      dataprocess/src/web/templates/login.html

+ 0 - 1
dataprocess/src/front/front.go

@@ -75,7 +75,6 @@ func (f *Front) Login() {
 	} else {
 		f.Render("login.html")
 	}
-
 }
 
 func (f *Front) Index() {

+ 3 - 1
dataprocess/src/front/menu.go

@@ -65,6 +65,9 @@ func (f *Front) MenuDel() {
 		},
 	}
 	b := Mgo.Update("menu_first", query, set, false, false)
+	if b { //删除一级菜单下的二级菜单
+		Mgo.Update("menu_second", `{"s_pid":"`+_id+`"}`, set, false, true)
+	}
 	f.ServeJson(map[string]interface{}{
 		"rep": b,
 	})
@@ -82,7 +85,6 @@ func (f *Front) MenuSecond() {
 		f.T["id"] = id
 		f.Render("com/menu_second.html", &f.T)
 	}
-
 }
 
 func (f *Front) MenuSecondSave() {

+ 13 - 15
dataprocess/src/front/role.go

@@ -1,17 +1,17 @@
 package front
 
 import (
-	. "../util"
 	"encoding/json"
-	"github.com/go-xweb/log"
 	qu "qfw/util"
 
+	. "../util"
+
 	"gopkg.in/mgo.v2/bson"
 )
 
 func (f *Front) RoleManager() {
 	defer qu.Catch()
-	_ = f.Render("com/role.html")
+	f.Render("com/role.html")
 }
 
 func (f *Front) RoleEdit(role string) {
@@ -24,7 +24,7 @@ func (f *Front) RoleEdit(role string) {
 		f.ServeJson(map[string]interface{}{
 			"data": data,
 		})
-	}else {
+	} else {
 		f.T["role"] = role
 		f.Render("com/role_edit.html", &f.T)
 	}
@@ -32,7 +32,7 @@ func (f *Front) RoleEdit(role string) {
 
 func (f *Front) RoleFirst() {
 	defer qu.Catch()
-	data, _ := Mgo.Find("menu_first", `{}`, nil, nil, false, -1, -1)
+	data, _ := Mgo.Find("menu_first", `{"delete":false}`, nil, nil, false, -1, -1)
 	f.ServeJson(map[string]interface{}{
 		"data": data,
 	})
@@ -41,7 +41,6 @@ func (f *Front) RoleFirst() {
 func (f *Front) RoleSecond() {
 	defer qu.Catch()
 	pid := f.GetString("_pid")
-	log.Error("s_pid=", pid)
 	query := bson.M{
 		"s_pid": pid,
 	}
@@ -55,8 +54,8 @@ func (f *Front) RoleSave() {
 	defer qu.Catch()
 	pid := f.GetString("_id")
 	role := f.GetString("role")
-	secondStr := f.GetString("secondStr")			//右边 选中的
-	secondStr1 := f.GetString("secondStr1")		//左边 未选中的
+	secondStr := f.GetString("secondStr")   //右边 选中的
+	secondStr1 := f.GetString("secondStr1") //左边 未选中的
 
 	secondmenus := make([]string, 0)
 	secondmenus1 := make([]string, 0)
@@ -165,21 +164,20 @@ func (f *Front) RoleSecondEdit() {
 		})
 	} else {
 		maps := map[string]interface{}{
-			"s_pid":       menuid,
+			"s_pid":        menuid,
 			"role." + role: true,
 		}
 		data, _ := Mgo.Find("menu_second", maps, nil, nil, false, -1, -1)
 		maps1 := map[string]interface{}{
-			"s_pid":       menuid,
+			"s_pid":        menuid,
 			"role." + role: false,
 		}
-		names, _ := Mgo.FindById("menu_first", menuid, `{s_name:1}`)
-		name := *names
-		name1 := name["s_name"]
+		name, _ := Mgo.FindById("menu_first", menuid, `{s_name:1}`)
+		s_name := (*name)["s_name"]
 		data1, _ := Mgo.Find("menu_second", maps1, nil, nil, false, -1, -1)
 		f.ServeJson(map[string]interface{}{
-			"name": name1,
-			"data": data,
+			"name":  s_name,
+			"data":  data,
 			"data1": data1,
 		})
 	}

+ 9 - 2
dataprocess/src/web/templates/login.html

@@ -48,7 +48,7 @@
       <div class="row">
         <!-- /.col -->
         <div class="col-xs-12">
-          <button type="button" class="btn btn-primary btn-block btn-flat" onclick="login()">登录</button>
+          <button type="button" id="logina" class="btn btn-primary btn-block btn-flat" onclick="login()">登录</button>
         </div>
         <!-- /.col -->
       </div>
@@ -71,8 +71,15 @@ $(function () {
     	radioClass: 'iradio_square-blue',
     	increaseArea: '20%' /* optional */
  	});
+	
+	document.onkeydown = function (event) {
+        var e = event || window.event;
+        if (e && e.keyCode == 13) { //回车键的键值为13
+           login();
+        }
+    }; 
 });
-
+	
 function login(){
 	var email = $("#email").val().trim().replace(/\s/g,"");
 	var pwd = $("#pwd").val().trim().replace(/\s/g,"");