Jianghan 3 anos atrás
pai
commit
bcce37a3fb

+ 16 - 5
src/service/oprd_service.go

@@ -21,7 +21,7 @@ type OprdData struct {
 
 var Field = map[string]interface{}{"city": 1, "district": 1, "title": 1, "publishtime": 1, "projectname": 1, "projectcode": 1,
 	"budget": 1, "bidamount": 1, "bidopentime": 1, "buyer": 1, "buyertagname": 1, "buyerperson": 1, "buyertel": 1, "agency": 1,
-	"s_winner": 1, "winnerperson": 1, "winnertel": 1}
+	"s_winner": 1, "winnerperson": 1, "winnertel": 1, "subtype": 1, "toptype": 1}
 
 func (o *OprdData) ModifyData() {
 	defer qu.Catch()
@@ -76,7 +76,7 @@ func (o *OprdData) DelData() {
 			"msg": "id: " + id + ",错误!",
 		})
 	} else {
-		info, _ := util.Mgo.FindById("oprd_bidding", id, nil)
+		info, _ := util.OprdMgo.FindById("oprd_bidding", id, nil)
 		delete(*info, "_id")
 		user := o.GetSession("user").(map[string]interface{})
 		log_data := map[string]interface{}{
@@ -110,16 +110,27 @@ func (o *OprdData) SaveData() {
 	id := o.GetString("id")
 	old_data, _ := util.OprdMgo.FindById("oprd_bidding", id, Field)
 	delete(*old_data, "_id")
+	delMap := make(map[string]interface{})
 	for k, v := range updata {
-		if k == "publishtime" || k == "bidopentime" {
+		if v == "del" {
+			delMap[k] = ""
+			delete(updata, k)
+		} else if k == "publishtime" || k == "bidopentime" {
 			(updata)[k] = qu.IntAll(v)
 		} else if k == "budget" || k == "bidamount" {
 			(updata)[k] = qu.Float64All(v)
 		}
 	}
 	util.FormatNumber(updata)
-	qu.Debug(id, updata)
-	rep := util.OprdMgo.UpdateById("oprd_bidding", id, map[string]interface{}{"$set": updata})
+	updataMap := make(map[string]interface{})
+	if len(delMap) > 0 {
+		updataMap["$unset"] = delMap
+	}
+	if len(updata) > 0 {
+		updataMap["$set"] = updata
+	}
+	qu.Debug(id, updataMap)
+	rep := util.OprdMgo.UpdateById("oprd_bidding", id, updataMap)
 	if !rep {
 		o.ServeJson(map[string]interface{}{
 			"rep": rep,

+ 4 - 1
src/web/templates/oprd/bidding_modify.html

@@ -118,8 +118,11 @@
 
         var updata = {}
         // 删除、修改
+        console.log(edit_data["bidamount"], data["bidamount"])
         for (let editDataKey in edit_data) {
-            if (data[editDataKey] !== edit_data[editDataKey]) {
+            if (data[editDataKey] === undefined) {
+                updata[editDataKey] = "del"
+            }else if (data[editDataKey] !== edit_data[editDataKey]) {
                 updata[editDataKey] = data[editDataKey]
             }
         }