|
@@ -3,11 +3,10 @@ package client
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- "log"
|
|
|
mongoutil "qfw/mongodb"
|
|
|
- "time"
|
|
|
-
|
|
|
qu "qfw/util"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
. "util"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
@@ -31,8 +30,6 @@ func (this *Client) AdminIndex() {
|
|
|
defer qu.Catch()
|
|
|
user := this.GetSession("user").(map[string]interface{})
|
|
|
entId := qu.IntAll(user["ent_id"])
|
|
|
- // entId = 1869
|
|
|
- log.Println(user)
|
|
|
// entUserId := qu.IntAll(user["id"])
|
|
|
// appid := qu.ObjToString(user["appid"])
|
|
|
// phone := qu.ObjToString(user["phone"])
|
|
@@ -50,6 +47,7 @@ func (this *Client) AdminIndex() {
|
|
|
v["departName"] = dName
|
|
|
}
|
|
|
}
|
|
|
+ v["id"] = qu.SE.EncodeString(strconv.Itoa(userId))
|
|
|
}
|
|
|
this.T["entUserArr"] = *entUserArr
|
|
|
}
|
|
@@ -58,35 +56,44 @@ func (this *Client) AdminIndex() {
|
|
|
|
|
|
func (this *Client) PersonnelIndex() {
|
|
|
defer qu.Catch()
|
|
|
- id, _ := this.GetInteger("id")
|
|
|
- if id == 0 {
|
|
|
+ id := this.GetString("id")
|
|
|
+ if this.Method() == "POST" {
|
|
|
+ start, _ := this.GetInteger("start")
|
|
|
+ limit, _ := this.GetInteger("length")
|
|
|
+ draw, _ := this.GetInteger("draw")
|
|
|
+ entUserId := 0
|
|
|
user := this.GetSession("user").(map[string]interface{})
|
|
|
- entId := qu.IntAll(user["ent_id"])
|
|
|
- entUserId := qu.IntAll(user["id"])
|
|
|
- // entId = 1686
|
|
|
- // entUserId = 2520
|
|
|
- // appid := qu.ObjToString(user["appid"])
|
|
|
- // phone := qu.ObjToString(user["phone"])
|
|
|
- entRuleArr, ok := Mgo.Find("entniche_rule", map[string]interface{}{"entId": entId, "entUserId": entUserId}, `{"_id":-1}`, nil, false, 0, 10)
|
|
|
- if ok && entRuleArr != nil && *entRuleArr != nil && len(*entRuleArr) > 0 {
|
|
|
- this.T["entRuleArr"] = *entRuleArr
|
|
|
+ if id == "" {
|
|
|
+ entUserId = qu.IntAll(user["id"])
|
|
|
+ } else {
|
|
|
+ entUserId, _ = strconv.Atoi(qu.SE.DecodeString(id))
|
|
|
}
|
|
|
- } else {
|
|
|
- user := this.GetSession("user").(map[string]interface{})
|
|
|
entId := qu.IntAll(user["ent_id"])
|
|
|
- entUserId := id
|
|
|
- // entId = 1686
|
|
|
- // entUserId = 2520
|
|
|
- // appid := qu.ObjToString(user["appid"])
|
|
|
- // phone := qu.ObjToString(user["phone"])
|
|
|
- entRuleArr, ok := Mgo.Find("entniche_rule", map[string]interface{}{"entId": entId, "entUserId": entUserId}, `{"_id":-1}`, nil, false, 0, 10)
|
|
|
+ count := Mgo.Count("entniche_rule", map[string]interface{}{"entId": entId, "entUserId": entUserId})
|
|
|
+ entRuleArr, ok := Mgo.Find("entniche_rule", map[string]interface{}{"entId": entId, "entUserId": entUserId}, `{"_id":-1}`, nil, false, start, limit)
|
|
|
if ok && entRuleArr != nil && *entRuleArr != nil && len(*entRuleArr) > 0 {
|
|
|
- this.T["entRuleArr"] = *entRuleArr
|
|
|
+ for _, v := range *entRuleArr {
|
|
|
+ ruleid := mongoutil.BsonIdToSId(v["_id"])
|
|
|
+ v["_id"] = qu.SE.EncodeString(ruleid)
|
|
|
+ }
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "draw": draw,
|
|
|
+ "data": *entRuleArr,
|
|
|
+ "recordsFiltered": count,
|
|
|
+ "recordsTotal": count,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "draw": draw,
|
|
|
+ "data": nil,
|
|
|
+ "recordsFiltered": 0,
|
|
|
+ "recordsTotal": 0,
|
|
|
+ })
|
|
|
}
|
|
|
+ } else {
|
|
|
+ this.T["id"] = id
|
|
|
+ this.Render("/client/personnelIndex.html")
|
|
|
}
|
|
|
- this.T["id"] = id
|
|
|
- this.T["preview_href"] = PreviewHref
|
|
|
- this.Render("/client/personnelIndex.html")
|
|
|
}
|
|
|
|
|
|
// 对外客户删除 部门规则
|
|
@@ -104,7 +111,8 @@ func (c *Client) CuserRuleCreate() {
|
|
|
if c.Method() == "POST" {
|
|
|
user := c.GetSession("user").(map[string]interface{})
|
|
|
data := GetPostForm(c.Request)
|
|
|
- entUserId, err := c.GetInteger("entUserId")
|
|
|
+ entstr := c.GetString("entUserId")
|
|
|
+ entUserId, err := strconv.Atoi(entstr)
|
|
|
if err != nil {
|
|
|
entUserId = 0
|
|
|
}
|
|
@@ -166,7 +174,8 @@ func (c *Client) CuserRuleCreate() {
|
|
|
user := c.GetSession("user").(map[string]interface{})
|
|
|
c.T["did"] = user["ent_id"]
|
|
|
c.T["cid"] = user["id"]
|
|
|
- c.T["entUserId"], _ = c.GetInteger("entUserId")
|
|
|
+ entstr := qu.SE.DecodeString(c.GetString("entUserId"))
|
|
|
+ c.T["entUserId"], _ = strconv.Atoi(entstr)
|
|
|
c.T["province"] = Province
|
|
|
c.T["city"] = ProvinceCitys
|
|
|
c.T["district"] = CityDistricts
|
|
@@ -178,13 +187,14 @@ func (c *Client) CuserRuleCreate() {
|
|
|
c.T["buyerClass"] = BuyerClass
|
|
|
c.T["buyerClassMap"] = BuyerClassMap
|
|
|
c.T["scopeClass"] = ScopeClassMap
|
|
|
+ c.T["preview_href"] = PreviewHref
|
|
|
c.Render("client/cuser_rule_create.html", &c.T)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (c *Client) CuserRuleEdit() {
|
|
|
defer qu.Catch()
|
|
|
- id := c.GetString("id")
|
|
|
+ id := qu.SE.DecodeString(c.GetString("id"))
|
|
|
query := bson.M{"_id": mongoutil.StringTOBsonId(id)}
|
|
|
data, _ := Mgo.FindOneByField("entniche_rule", query, `{}`)
|
|
|
(*data)["id"] = mongoutil.BsonIdToSId((*data)["_id"])
|
|
@@ -202,6 +212,7 @@ func (c *Client) CuserRuleEdit() {
|
|
|
c.T["buyerClass"] = BuyerClass
|
|
|
c.T["buyerClassMap"] = BuyerClassMap
|
|
|
c.T["scopeClass"] = ScopeClassMap
|
|
|
+ c.T["preview_href"] = PreviewHref
|
|
|
c.Render("client/cuser_rule_edit.html", &c.T)
|
|
|
}
|
|
|
|
|
@@ -212,6 +223,7 @@ func (this *Client) DataPreview() {
|
|
|
func (this *Client) ExportLog() {
|
|
|
if this.Method() == "POST" {
|
|
|
id, _ := this.GetInteger("id")
|
|
|
+
|
|
|
start, _ := this.GetInteger("start")
|
|
|
limit, _ := this.GetInteger("length")
|
|
|
draw, _ := this.GetInteger("draw")
|
|
@@ -244,7 +256,7 @@ func (this *Client) ExportLog() {
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- id, _ := this.GetInteger("id")
|
|
|
+ id, _ := strconv.Atoi(qu.SE.DecodeString(this.GetString("id")))
|
|
|
this.T["id"] = id
|
|
|
this.Render("client/exportLog.html", &this.T)
|
|
|
}
|