xuzhiheng 3 years ago
parent
commit
879d509608
2 changed files with 37 additions and 34 deletions
  1. 21 18
      src/client/customerRule.go
  2. 16 16
      src/web/templates/client/cuser_rule_edit.html

+ 21 - 18
src/client/customerRule.go

@@ -140,7 +140,7 @@ func (c *CustomerRule) ProductData() {
 	defer qu.Catch()
 	if c.Method() == "POST" {
 		log.Println("正在生成预览数据。。。")
-		// rep := false
+		rep := false
 		id := c.GetString("id")
 		tag, ok := Mgo.FindById("entniche_rule", id, `{}`)
 		if !ok {
@@ -204,13 +204,13 @@ func (c *CustomerRule) ProductData() {
 		// 其他的分隔
 		// 1000<=总个数<4000,将时间(publishtime)按照每3个月进行分割,然后查询到的数据量进行求和。
 		// 4000<=总个数<8000,将时间(publishtime)按照每1个月进行分割,然后查询到的数据量进行求和
-		// var err error
-		// var count int64
+		var err error
+		var count int64
 		// var n int
 		// 小于1000的直接查
 		// if totalCount < 1000 {
-		// err, count = UtilEsFind1(*tag)
-		go UtilEsFind1(*tag)
+		err, count = UtilEsFind1(*tag)
+		// UtilEsFind1(*tag)
 		// } else {
 		// 	if totalCount >= 1000 && totalCount < 4000 {
 		// 		n = 3
@@ -220,19 +220,22 @@ func (c *CustomerRule) ProductData() {
 		// 	}
 		// 	err, count = UtilEsFind2(*tag, n)
 		// }
-		// var msg string
-		// if err == nil {
-		// 	rep = true
-		// 	msg = "数据生成成功"
-		// } else {
-		// 	rep = false
-		// 	msg = "数据生成失败"
-		// }
-		// c.ServeJson(map[string]interface{}{
-		// "rep": rep,
-		// "count": count,
-		// "msg":   msg,
-		// })
+		if err == nil {
+			rep = true
+			// msg = "数据生成成功"
+			c.ServeJson(map[string]interface{}{
+				"rep":   rep,
+				"count": count,
+			})
+		} else {
+			rep = false
+			msg := "数据生成失败"
+			c.ServeJson(map[string]interface{}{
+				"rep":   rep,
+				"count": count,
+				"msg":   msg,
+			})
+		}
 	}
 }
 

+ 16 - 16
src/web/templates/client/cuser_rule_edit.html

@@ -1699,23 +1699,23 @@
     function produceData() {
         com.maskShow("正在生成数据...");
         var isOk = true
-        
-        $.ajax({
-            url: "/customerRule/cuser/produce",
-            type: "post",
-            data: {"id": dataMap.id},
-            success: function (r) {
-                if (r.rep===false){
+        setTimeout(function(){
+            $.ajax({
+                url: "/customerRule/cuser/produce",
+                type: "post",
+                data: {"id": dataMap.id},
+                async: false,
+                success: function (r) {
+                    if (r.msg){
+                        com.maskHide();
+                        isOk = false
+                        showTip(r.msg, 30000);
+                    }
+                },
+                error: function (r) {
                     com.maskHide();
-                    isOk = false
-                    showTip(r.msg, 30000);
                 }
-            },
-            // error: function (r) {
-            //     com.maskHide();
-            // }
-        })
-        setTimeout(function(){
+            })
             if (isOk) {
                 com.maskShow("倒计时3s");
                 setTimeout(function(){
@@ -1731,7 +1731,7 @@
                     },1000)
                 },1000)
             }
-        },3000)
+        },1000)
     }
     
     //预览数据