Jianghan %!s(int64=5) %!d(string=hai) anos
pai
achega
20f4b8a247

+ 1 - 1
src/service/feedback_service.go

@@ -34,7 +34,7 @@ func (f *Feedback) FeedbackList() {
 			}
 		}
 
-		data, _ := Mgo.Find("feedback", query, nil, nil, false, start, limit)
+		data, _ := Mgo.Find("feedback", query, `{"_id":-1}`, nil, false, start, limit)
 		count := Mgo.Count("feedback", query)
 		f.ServeJson(map[string]interface{}{
 			"draw":            draw,

+ 3 - 2
src/service/rule_service.go

@@ -57,7 +57,7 @@ func (r *Rule) RuleList() {
 			}
 		}
 
-		data, _ := Mgo.Find("tags", query, nil, nil, false, start, limit)
+		data, _ := Mgo.Find("tags", query, `{"i_createtime":-1}`, nil, false, start, limit)
 		count := Mgo.Count("tags", query)
 		r.ServeJson(map[string]interface{}{
 			"draw":            draw,
@@ -346,12 +346,13 @@ func (r *Rule) ProductData() {
 		id := r.GetString("id")
 		fmt.Println(id)
 		tag, _ := Mgo.FindById("tags", id, `{}`)
-		err := UtilEsFind(*tag)
+		err, count := UtilEsFind(*tag)
 		if err == nil {
 			rep = true
 		}
 		r.ServeJson(map[string]interface{}{
 			"rep": rep,
+			"count": count,
 		})
 	}
 }

+ 7 - 6
src/util/utiltag.go

@@ -57,12 +57,12 @@ func UtilEsSaveData(sdataid string, datas *[]map[string]interface{}) error {
 
 }
 
-func UtilEsFind(tags map[string]interface{}) error {
+func UtilEsFind(tags map[string]interface{}) (error, int64) {
 	defer util.Catch()
 	sdataid := util.ObjToString(tags["s_dataid"])
 	esquery := util.ObjToString(tags["s_esquery"])
 	if len(esquery) < 1 || len(sdataid) < 1 {
-		return errors.New("s_esquery or s_dataid no found")
+		return errors.New("s_esquery or s_dataid no found"), 0
 	}
 	i_maxnum := util.Int64All(tags["i_maxnum"])
 	if i_maxnum > 100 || i_maxnum <= 0 {
@@ -76,7 +76,7 @@ func UtilEsFind(tags map[string]interface{}) error {
 		isStandardFields = false
 	default:
 		log.Println("字段定义错误")
-		return errors.New("i_extfieldstype no found")
+		return errors.New("i_extfieldstype no found"), 0
 	}
 	maths := make([]map[string]string, 0)
 	if orules, ok := tags["o_rules"].([]interface{}); ok {
@@ -95,7 +95,7 @@ func UtilEsFind(tags map[string]interface{}) error {
 			})
 		}
 	} else {
-		return errors.New("o_rules no found")
+		return errors.New("o_rules no found"), 0
 	}
 	client := elastic.GetEsConn()
 	defer elastic.DestoryEsConn(client)
@@ -167,10 +167,11 @@ func UtilEsFind(tags map[string]interface{}) error {
 			"$set": bson.M{
 				"i_estotal": searchResult.Hits.TotalHits,
 			}}, false, false)
-		return UtilEsSaveData(sdataid, &datas)
+		count := searchResult.Hits.TotalHits
+		return UtilEsSaveData(sdataid, &datas), count
 	} else {
 		log.Println("es:", err)
-		return err
+		return err, 0
 	}
 }
 

+ 17 - 17
src/web/res/js/com.js

@@ -123,23 +123,6 @@ com.maskHide=function(){
 	$(".mask").addClass("hide");
 	$(window).unbind("resize");
 }
-function setCookie(name,value){ 
-    var expdate = new Date();   //初始化时间
-    expdate.setTime(expdate.getTime() + 30 * 60 * 1000);   //时间
-    document.cookie = name+"="+value+";expires="+expdate.toGMTString()+";path=/";
-}
-function getCookie(c_name){
-	if (document.cookie.length>0){
-	  c_start=document.cookie.indexOf(c_name + "=")
-	  if (c_start!=-1){ 
-	    c_start=c_start + c_name.length+1 
-	    c_end=document.cookie.indexOf(";",c_start)
-	    if (c_end==-1) c_end=document.cookie.length
-	   	 return unescape(document.cookie.substring(c_start,c_end))
-	    } 
-	  }
-	return ""
-}
 com.trimStr = function (str) {
 	str = str.replace(/^(\s|\u00A0)+/,'');
 	str = str.replace(/\s/g,'');
@@ -150,4 +133,21 @@ com.trimStr = function (str) {
 		}
 	}
 	return str;
+}
+com.setCookie = function(name,value){
+	var expdate = new Date();   //初始化时间
+	expdate.setTime(expdate.getTime() + 30 * 60 * 1000);   //时间
+	document.cookie = name+"="+value+";expires="+expdate.toGMTString()+";path=/";
+}
+com.getCookie = function (c_name){
+	if (document.cookie.length>0){
+		c_start=document.cookie.indexOf(c_name + "=")
+		if (c_start!=-1){
+			c_start=c_start + c_name.length+1
+			c_end=document.cookie.indexOf(";",c_start)
+			if (c_end==-1) c_end=document.cookie.length
+			return unescape(document.cookie.substring(c_start,c_end))
+		}
+	}
+	return ""
 }

+ 2 - 2
src/web/templates/private/rule_create.html

@@ -275,8 +275,8 @@
                                         <label class="col-sm-2 control-label ">高级字段包</label>
                                         <div class="col-sm-3">
                                             <select class="form-control" id="extfiledselect" style="border-radius:3px">
-                                                <option value="1">否</option>
                                                 <option value="2">是</option>
+                                                <option value="1">否</option>
                                             </select>
                                             <script>
                                                 $('#extfiledselect').on("change", function () {
@@ -385,7 +385,7 @@
         "i_maxnum": 100,
         "i_starttime": 0,
         "i_endtime": 0,
-        "i_extfieldstype": 1,
+        "i_extfieldstype": 2,
         "i_esquerytype": 1,
     };
 

+ 261 - 169
src/web/templates/private/rule_edit.html

@@ -9,15 +9,21 @@
     <section class="content-header">
         <h1>编辑规则
             <small>
-                <button class="btn btn-primary btn-sm" onclick="importRule()"><i class="fa fa-fw fa-cloud-upload fa-lg"></i>导入规则</button>
+                <button class="btn btn-primary btn-sm" onclick="importRule()"><i
+                            class="fa fa-fw fa-cloud-upload fa-lg"></i>导入规则
+                </button>
                 <form style="display:none" id='uploadform' method='post' action='/service/importfile'>
                     <input type='file' name='xlsx' id='file'/>
                 </form>
-                <button class="btn btn-info btn-sm" onclick="importEs()"><i class="fa fa-fw fa-cloud-upload fa-lg"></i>导入查询语句</button>
-                <a class="btn btn-sm btn-success" id="download" onclick="downloades()"><i class="fa fa-fw fa-cloud-download fa-lg"></i>下载查询语句</a>
+                <button class="btn btn-info btn-sm" onclick="importEs()"><i class="fa fa-fw fa-cloud-upload fa-lg"></i>导入查询语句
+                </button>
+                <a class="btn btn-sm btn-success" id="download" onclick="downloades()"><i
+                            class="fa fa-fw fa-cloud-download fa-lg"></i>下载查询语句</a>
                 <a class="btn btn-sm btn-instagram" onclick="produceData()"><i class="fa fa-fw fa-database fa-lg"></i>生成数据</a>
-                <button class="btn btn-warning btn-sm" onclick="previewData()"><i class="fa fa-fw fa-eye fa-lg"></i>预览数据</button>
-                <button class="btn btn-danger btn-sm" onclick="archive()"><i class="fa fa-fw fa-save fa-lg"></i>存档</button>
+                <button class="btn btn-warning btn-sm" onclick="previewData()"><i class="fa fa-fw fa-eye fa-lg"></i>预览数据
+                </button>
+                <button class="btn btn-danger btn-sm" onclick="archive()"><i class="fa fa-fw fa-save fa-lg"></i>存档
+                </button>
             </small>
         </h1>
         <ol class="breadcrumb">
@@ -31,9 +37,12 @@
         <div class="tab-content">
             <div class="nav-tabs-custom">
                 <ul class="nav nav-tabs edit-step">
-                    <li class="active" data-mode="guide"><a href="#tab_1" data-toggle="tab" aria-expanded="true">通用条件</a></li>
+                    <li class="active" data-mode="guide"><a href="#tab_1" data-toggle="tab"
+                                                            aria-expanded="true">通用条件</a></li>
                     <li data-mode="guide" class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">关键词</a></li>
-                    <button class="btn btn-primary btn-sm" style="float: right;margin-top: 4px;margin-right: 10px" onclick="saveTag()"><i class="fa fa-fw fa-file-text fa-lg"></i>保存规则</button>
+                    <button class="btn btn-primary btn-sm" style="float: right;margin-top: 4px;margin-right: 10px"
+                            onclick="saveTag()"><i class="fa fa-fw fa-file-text fa-lg"></i>保存规则
+                    </button>
                 </ul>
                 <div class="tab-content">
                     <div class="tab-pane active" id="tab_1">
@@ -128,7 +137,8 @@
                                     <div class="form-group">
                                         <label class="col-sm-2 control-label">一级公告类别</label>
                                         <div class="col-sm-3">
-                                            <select class="form-control selectpicker" multiple id="topTypeSelect"></select>
+                                            <select class="form-control selectpicker" multiple
+                                                    id="topTypeSelect"></select>
                                             <script>
                                                 $('#topTypeSelect').on('hide.bs.select', function () {
                                                     var arr = $(this).val();
@@ -146,7 +156,8 @@
                                         </div>
                                         <label class="col-sm-2 control-label">二级公告类别</label>
                                         <div class="col-sm-3">
-                                            <select class="form-control selectpicker" multiple id="subTypeSelect"></select>
+                                            <select class="form-control selectpicker" multiple
+                                                    id="subTypeSelect"></select>
                                             <script>
                                                 $('#subTypeSelect').on('hide.bs.select', function () {
                                                     var arr = $(this).val();
@@ -219,7 +230,8 @@
                                     <div class="form-group">
                                         <label class="col-sm-2 control-label">全局附加词</label>
                                         <div class="col-sm-3">
-                                            <input type="text" class="form-control" id="g_addkey" value="{{.T.data.s_globaladdkey}}">
+                                            <input type="text" class="form-control" id="g_addkey"
+                                                   value="{{.T.data.s_globaladdkey}}">
                                         </div>
                                         <label class="col-sm-2 control-label">匹配方式</label>
                                         <div class="col-sm-3">
@@ -243,7 +255,8 @@
                                     <div class="form-group">
                                         <label for="spiderChannel" class="col-sm-2 control-label">全局排除词</label>
                                         <div class="col-sm-3">
-                                            <input type="text" class="form-control" id="g_notkey" value="{{.T.data.s_globalnotkey}}">
+                                            <input type="text" class="form-control" id="g_notkey"
+                                                   value="{{.T.data.s_globalnotkey}}">
                                         </div>
                                         <label class="col-sm-2 control-label">匹配方式</label>
                                         <div class="col-sm-3">
@@ -268,7 +281,8 @@
                                     <div class="form-group">
                                         <label class="col-sm-2 control-label">预览数据量</label>
                                         <div class="col-sm-3">
-                                            <input type="text" class="form-control" id="maxnum" value="{{.T.data.i_maxnum}}">
+                                            <input type="text" class="form-control" id="maxnum"
+                                                   value="{{.T.data.i_maxnum}}">
                                         </div>
                                         <label class="col-sm-2 control-label ">高级字段包</label>
                                         <div class="col-sm-3">
@@ -363,7 +377,6 @@
     var setValue = 5;                   // 赋值表格,5: 关键词/附加词匹配方式,7:排除词匹配方式,8:采购行业,9:公告行业
     var state = 1;
     $(document).ready(function () {
-
         $('#extfiledselect').val(dataMap.i_extfieldstype);
         $('#estxt').val(dataMap.s_esquery);
         if (dataMap.i_starttime != 0) {
@@ -400,7 +413,7 @@
             for (var j in districtMap[i]) {
                 if (dataMap.s_district.indexOf(districtMap[i][j]) != -1) {
                     optGroup += '<option selected value="' + i + "," + districtMap[i][j] + '">' + districtMap[i][j] + '</option>';
-                }else {
+                } else {
                     optGroup += '<option value="' + i + "," + districtMap[i][j] + '">' + districtMap[i][j] + '</option>';
                 }
             }
@@ -509,17 +522,22 @@
             "data": o_rules,
             "columns": [
                 {"data": null, width: "1.5%"},
-                {"data": function() {
+                {
+                    "data": function () {
                         return `<input type="checkbox" name="ckb-keyid" onclick="singleSelect(this)" style="text-align: center">`
-                    }, width: "1%"},
+                    }, width: "1%"
+                },
                 {"data": "s_matchkey", width: "17%"},
-                {"data": "s_addkey", width: "5%", render: function (val) {
+                {
+                    "data": "s_addkey", width: "5%", render: function (val) {
                         if (val == undefined) {
                             val = ""
                         }
                         return val
-                    }},
-                {"data": function (row) {
+                    }
+                },
+                {
+                    "data": function (row) {
                         var str = row.s_keymatch;
                         if (str != undefined && str != "") {
                             var s = "";
@@ -527,7 +545,7 @@
                                 if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
                                     if (s == "") {
                                         s = matchTypeMap[i]["name"]
-                                    }else {
+                                    } else {
                                         s = s + "," + matchTypeMap[i]["name"]
                                     }
                                 }
@@ -535,15 +553,19 @@
                             return s
                         }
                         return ""
-                    }, width: "5%"},
-                {"data": function (row) {
-                       if (row.s_notkey != undefined) {
-                           return row.s_notkey
-                       }else {
-                           return ""
-                       }
-                    }, width: "5%"},
-                {"data": function (row) {
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
+                        if (row.s_notkey != undefined) {
+                            return row.s_notkey
+                        } else {
+                            return ""
+                        }
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
                         var str = row.s_notkeymatch;
                         if (str != undefined && str != "") {
                             var s = "";
@@ -551,7 +573,7 @@
                                 if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
                                     if (s == "") {
                                         s = matchTypeMap[i]["name"]
-                                    }else {
+                                    } else {
                                         s = s + "," + matchTypeMap[i]["name"]
                                     }
                                 }
@@ -559,15 +581,19 @@
                             return s
                         }
                         return ""
-                    }, width: "5%"},
-                {"data": function (row) {
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
                         if (row.s_buyerclass != undefined) {
                             return row.s_buyerclass
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "5%"},
-                {"data": function (row) {
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
                         var top = row.s_topscopeclass;
                         var sub = row.s_subscopeclass;
                         var str = "";
@@ -577,12 +603,13 @@
                         if (sub != undefined && sub != "") {
                             if (str == "") {
                                 str = sub
-                            }else {
+                            } else {
                                 str = str + "," + sub
                             }
                         }
                         return str
-                    }, width: "5%"},
+                    }, width: "5%"
+                },
             ]
         });
     });
@@ -596,6 +623,7 @@
     $('#district').selectpicker({
         liveSearch: true,
     });
+
     //全局modal取消按钮
     function cancelModel() {
         $('#modal-imp-es').modal("hide");
@@ -603,10 +631,12 @@
         $('#modal-select-buyer').modal("hide");
         $('#modal-select-scope').modal("hide");
     }
+
     //导入es语句modal
     function importEs() {
         $("#modal-imp-es").modal("show");
     }
+
     //保存es语句
     function saveEs() {
         var esStr = $("#es_json").val();
@@ -622,6 +652,7 @@
             showMsg("json格式有误")
         }
     }
+
     //选择公告类别
     function selectType(obj) {
         var val = obj.options[obj.selectedIndex].value;
@@ -644,24 +675,27 @@
         $('#infoType').selectpicker("deselectAll")
         $('#infoType').selectpicker("refresh");
     }
+
     //关键词匹配方式modal
     function selectKeyMatch() {
         if (keyTableChecked) {
             setValue = 5;
             $('#modal-select-match').modal("show");
-        }else {
+        } else {
             alert("请选中关键词")
         }
     }
+
     //排除词匹配方式modal
     function selectNotMatch() {
         if (keyTableChecked) {
             setValue = 7;
             $('#modal-select-match').modal("show");
-        }else {
+        } else {
             alert("请选中关键词")
         }
     }
+
     //匹配方式按钮点击事件
     function clickMatchBtn(obj) {
         if ($(obj).hasClass("active-btn-match")) {
@@ -669,7 +703,7 @@
             if (setValue == 5) {
                 matchCode1.splice($.inArray($(obj).attr("code"), matchCode), 1);
                 matchName1.splice($.inArray($(obj).val(), matchName), 1)
-            }else {
+            } else {
                 matchCode2.splice($.inArray($(obj).attr("code"), matchCode), 1);
                 matchName2.splice($.inArray($(obj).val(), matchName), 1)
             }
@@ -678,12 +712,13 @@
             if (setValue == 5) {
                 matchCode1.push($(obj).attr("code"));
                 matchName1.push($(obj).val())
-            }else {
+            } else {
                 matchCode2.push($(obj).attr("code"));
                 matchName2.push($(obj).val())
             }
         }
     }
+
     //匹配方式保存
     function saveMatch() {
         $('#btnGroupMatch').find("input").each(function () {
@@ -696,25 +731,25 @@
             for (var i in matchName1) {
                 if (matchNameStr == "") {
                     matchNameStr = matchName1[i];
-                }else {
+                } else {
                     matchNameStr += "," + matchName1[i]
                 }
                 if (codeStr == "") {
                     codeStr = matchCode1[i]
-                }else {
+                } else {
                     codeStr = codeStr + "," + matchCode1[i]
                 }
             }
-        }else if (setValue == 7) {
+        } else if (setValue == 7) {
             for (var i in matchName2) {
                 if (matchNameStr == "") {
                     matchNameStr = matchName2[i];
-                }else {
+                } else {
                     matchNameStr += "," + matchName2[i]
                 }
                 if (codeStr == "") {
                     codeStr = matchCode2[i]
-                }else {
+                } else {
                     codeStr = codeStr + "," + matchCode2[i]
                 }
             }
@@ -722,14 +757,14 @@
         for (var i in selectIndex) {
             var j = selectIndex[i] - 1;
             if (setValue == 5) {
-                if ($("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child(3)").text() != "" ||
-                    $("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child(4)").text() != "") {
-                    $("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child("+setValue+")").html(matchNameStr);
+                if ($("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(3)").text() != "" ||
+                    $("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(4)").text() != "") {
+                    $("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(" + setValue + ")").html(matchNameStr);
                     o_rules[j]["s_keymatch"] = codeStr;
                 }
-            }else if (setValue == 7) {
-                if ($("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child(6)").text() != "") {
-                    $("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child("+setValue+")").html(matchNameStr);
+            } else if (setValue == 7) {
+                if ($("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(6)").text() != "") {
+                    $("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(" + setValue + ")").html(matchNameStr);
                     o_rules[j]["s_notkeymatch"] = codeStr;
                 }
             }
@@ -740,15 +775,17 @@
         matchName2.length = 0;
         matchCode2.length = 0;
     }
+
     //采购单位modal
     function selectBuyer() {
         if (keyTableChecked) {
             $('#modal-select-buyer').modal("show");
             setValue = 8
-        }else {
+        } else {
             alert("请选中关键词")
         }
     }
+
     //采购单位点击
     function clickBuyerBtn(obj) {
         if ($(obj).hasClass("active-btn-match")) {
@@ -759,6 +796,7 @@
             buyerArr.push($(obj).val())
         }
     }
+
     function saveBuyer() {
         $('#btnGroupBuyer').find("input").each(function () {
             $(this).removeClass("active-btn-match");
@@ -768,28 +806,30 @@
         for (var i in buyerArr) {
             if ("" === buyerStr) {
                 buyerStr = buyerArr[i];
-            }else {
+            } else {
                 buyerStr += "," + buyerArr[i]
             }
         }
         for (var i in selectIndex) {
             var j = selectIndex[i] - 1;
             //采购单位
-            $("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child("+setValue+")").html(buyerStr);
+            $("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(" + setValue + ")").html(buyerStr);
             o_rules[j]["s_buyerclass"] = buyerStr;
         }
         $('#modal-select-buyer').modal("hide");
         buyerArr.length = 0;
     }
+
     //公告行业modal
     function selectScope() {
         if (keyTableChecked) {
             $('#modal-select-scope').modal("show");
             setValue = 9
-        }else {
+        } else {
             alert("请选中关键词")
         }
     }
+
     //公告行业一级点击
     function btnTopScopeClick(obj) {
         if ($(obj).hasClass("active-btn-match")) {
@@ -800,6 +840,7 @@
             scopeTopArr.push($(obj).val())
         }
     }
+
     //公告行业二级点击
     function btnSubScopeClick(obj) {
         if ($(obj).hasClass("active-btn-match")) {
@@ -813,6 +854,7 @@
             scopeSubArr.push($(obj).attr("code"))
         }
     }
+
     function saveScope() {
         $('#btnGroupTop').find("input").each(function () {
             $(this).removeClass("active-btn-match");
@@ -826,7 +868,7 @@
         for (var i in scopeTopArr) {
             if ("" == scopeStr) {
                 scopeStr = scopeTopArr[i];
-            }else {
+            } else {
                 scopeStr += "," + scopeTopArr[i]
             }
             if (topStr == "") {
@@ -838,7 +880,7 @@
         for (var i in scopeSubArr) {
             if ("" == scopeStr) {
                 scopeStr = scopeSubArr[i];
-            }else {
+            } else {
                 scopeStr += "," + scopeSubArr[i]
             }
             if (subStr == "") {
@@ -849,7 +891,7 @@
         }
         for (var i in selectIndex) {
             var j = selectIndex[i] - 1;
-            $("#keywords tbody tr:nth-child("+selectIndex[i]+") td:nth-child(9)").html(scopeStr);
+            $("#keywords tbody tr:nth-child(" + selectIndex[i] + ") td:nth-child(9)").html(scopeStr);
             o_rules[j]["s_topscopeclass"] = topStr;
             o_rules[j]["s_subscopeclass"] = subStr;
         }
@@ -857,6 +899,7 @@
         scopeTopArr.length = 0;
         scopeSubArr.length = 0;
     }
+
     //页面添加附加词、排除词
     function addkeyWord(rdata) {
         o_rules = rdata["o_rules"];
@@ -869,6 +912,7 @@
         $('#keywords').dataTable().fnAddData(rdata["o_rules"]);
 
     }
+
     //表格全选
     function allSelect(obj) {
         if ($(obj).is(':checked')) {
@@ -878,7 +922,7 @@
                 this.checked = true;
                 selectIndex.push($(this).parents("tr").index() + 1);
             })
-        }else {
+        } else {
             selectIndex.length = 0;
             keyTableChecked = false;
             keyTableAllChecked = false;
@@ -887,6 +931,7 @@
             })
         }
     }
+
     //表格单个选中
     function singleSelect(obj) {
         var tag = true;
@@ -895,14 +940,14 @@
             if (this.checked == true) {
                 keyTableChecked = true;
                 selectIndex.push($(this).parents("tr").index() + 1);
-            }else {
+            } else {
                 tag = false;
             }
         });
         if (tag) {
             keyTableAllChecked = true;
             $('#allCheckbox').prop("checked", true);
-        }else {
+        } else {
             keyTableAllChecked = false;
             $('#allCheckbox').prop("checked", false);
         }
@@ -917,7 +962,6 @@
             alert("请填写必须字段!")
             return
         }
-
         // if (o_rules == undefined || o_rules.length == 0) {
         //     alert("请导入关键词!");
         //     return
@@ -942,32 +986,34 @@
             data: dataMap,
             success: function (r) {
                 if (r.rep && r.id) {
-                    state = 2;
                     alert("保存成功");
-                    window.location.reload();
+                    state = 2
+                    // window.location.reload();
                 } else {
                     alert("保存失败")
                 }
             }
         })
     }
+
     //生成数据
     function produceData() {
         com.maskShow("正在生成数据...");
         $.ajax({
-            url:"/service/rule/produce",
-            type:"post",
+            url: "/service/rule/produce",
+            type: "post",
             data: {"id": dataMap.id},
-            success:function(r){
+            success: function (r) {
                 com.maskHide();
-                if(r.rep){
-
-                }else{
-                    showTip("生成失败",1000);
+                if (r.rep) {
+                    dataMap.i_estotal = r.count
+                } else {
+                    showTip("生成失败", 1000);
                 }
             }
         })
     }
+
     //预览数据
     function previewData() {
         $('#previewData').DataTable({
@@ -1002,186 +1048,232 @@
             },
             "columns": [
                 {"data": null, width: "2%"},
-                {"data": function(row) {
+                {
+                    "data": function (row) {
                         if (row.s_matchkey != undefined) {
                             return row.s_matchkey
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "8%"},
-                {"data": function(row) {
+                    }, width: "8%"
+                },
+                {
+                    "data": function (row) {
                         if (row.area != undefined) {
                             return row.area
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function(row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.city != undefined) {
                             return row.city
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.s_jyhref != undefined) {
                             if (row.title.length > 36) {
                                 var str = row.title.substring(0, 36) + "..."
-                            }else {
+                            } else {
                                 var str = row.title
                             }
-                            tmp = '<a class="" target="_blank" href='+row.s_jyhref+'>'+str+'</a>';
+                            tmp = '<a class="" target="_blank" href=' + row.s_jyhref + '>' + str + '</a>';
                             return tmp
-                        }else {
+                        } else {
                             return row.title
                         }
-                    }, width: "5%"},
-                {"data": function(row) {
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
                         if (row.subtype != undefined) {
                             return row.subtype
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         var str = com.trimStr(row.detail);
                         if (str.length > 14) {
                             return str.substring(0, 14) + "..."
-                        }else {
+                        } else {
                             return str
                         }
-                    }, width: "5%"},
-                {"data": function(row) {
+                    }, width: "5%"
+                },
+                {
+                    "data": function (row) {
                         var dt = new Date();
-                        dt.setTime(parseInt(row.publishtime)*1000);
+                        dt.setTime(parseInt(row.publishtime) * 1000);
                         return dt.format("yyyy-MM-dd")
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.href != undefined) {
                             var shref = row.href;
-                            tmp = '<a class="" target="_blank" href='+shref+'>公告地址</a>';
+                            tmp = '<a class="" target="_blank" href=' + shref + '>公告地址</a>';
                             return tmp
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "5%"},
+                    }, width: "5%"
+                },
                 {"data": "projectname", width: "5%"},
-                {"data": function (row) {
+                {
+                    "data": function (row) {
                         if (row.projectscope != undefined) {
                             if (row.projectscope.length > 14) {
                                 return row.projectscope.substring(0, 14) + "..."
-                            }else {
+                            } else {
                                 return row.projectscope
                             }
                         }
                         return ""
-                    }, width: "3%"},
-                {"data": function (row) {
+                    }, width: "3%"
+                },
+                {
+                    "data": function (row) {
                         if (row.budget == undefined) {
                             return ""
-                        }else {
+                        } else {
                             return row.budget
                         }
-                    }, width: "3%"},
-                {"data": function (row) {
+                    }, width: "3%"
+                },
+                {
+                    "data": function (row) {
                         if (row.bidamount == undefined) {
                             return ""
-                        }else {
+                        } else {
                             return row.bidamount
                         }
-                    }, width: "3%"},
-                {"data": "bidopentime", width: "3%", render: function (val) {
+                    }, width: "3%"
+                },
+                {
+                    "data": "bidopentime", width: "3%", render: function (val) {
                         if (val != undefined) {
                             var dt = new Date();
-                            dt.setTime(parseInt(val)*1000);
+                            dt.setTime(parseInt(val) * 1000);
                             return dt.format("yyyy-MM-dd")
-                        }else {
+                        } else {
                             return ""
                         }
-                    }},
-                {"data": "buyer", width: "3%", render: function (val) {
+                    }
+                },
+                {
+                    "data": "buyer", width: "3%", render: function (val) {
                         if (val == undefined) {
                             val = ""
                         }
                         return val
-                    }},
-                {"data": function (row) {
-                       if (row.buyerperson != undefined) {
-                           return row.buyerperson
-                       }else {
-                           return ""
-                       }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }
+                },
+                {
+                    "data": function (row) {
+                        if (row.buyerperson != undefined) {
+                            return row.buyerperson
+                        } else {
+                            return ""
+                        }
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.buyertel != undefined) {
                             return row.buyertel
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": "agency", width: "5%", render: function (val) {
+                    }, width: "4%"
+                },
+                {
+                    "data": "agency", width: "5%", render: function (val) {
                         if (val == undefined) {
                             val = ""
                         }
                         return val
-                    }},
-                {"data": "winner", width: "3%", render: function (val) {
+                    }
+                },
+                {
+                    "data": "winner", width: "3%", render: function (val) {
                         if (val == undefined) {
                             val = ""
                         }
                         return val
-                    }},
-                {"data": function (row) {
+                    }
+                },
+                {
+                    "data": function (row) {
                         if (row.winnerperson != undefined) {
                             return row.winnerperson
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.winnertel != undefined) {
                             return row.winnertel
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.legal_person != undefined) {
                             return row.legal_person
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.company_phone != undefined) {
                             return row.company_phone
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
-                {"data": function (row) {
+                    }, width: "4%"
+                },
+                {
+                    "data": function (row) {
                         if (row.company_email != undefined) {
                             return row.company_email
-                        }else {
+                        } else {
                             return ""
                         }
-                    }, width: "4%"},
+                    }, width: "4%"
+                },
             ]
         });
         $('#modal-preview').modal("show");
         if (dataMap.i_extfieldstype == 1) {
             var str = "标准字段包 " + dataMap.i_maxnum + "/" + dataMap.i_estotal;
             $('#dataCount').html(str)
-        }else {
+        } else {
             var str = "高级字段包 " + dataMap.i_maxnum + "/" + dataMap.i_estotal;
             $('#dataCount').html(str)
         }
     }
+
     //导入规则
     function importRule() {
         $("#file").click();
     }
-    $(function() {
+
+    $(function () {
         $("#uploadform").find("input").change(function () {
             var val = $(this).val() ? $(this).val() : "";
             if (val.indexOf(".xlsx") < 0) {
@@ -1210,32 +1302,32 @@
             }
         })
     })
-    
+
     //下载es
-    function downloades(){
-      if(state==1){
-        alert("请先保存规则")
-      }else{
-        $("#download").attr("href","/service/rule/exportes?id={{.T.data.id}}")
-      }
+    function downloades() {
+        if (state == 1) {
+            alert("请先保存规则")
+        } else {
+            $("#download").attr("href", "/service/rule/exportes?id={{.T.data.id}}")
+        }
     }
-    
+
     //存档
-    function archive(){
-      showConfirm("是否存档?", function() {
-        $.ajax({
-            url:"/service/rule/archive",
-            type:"post",
-            data:{"_id":dataMap["id"]},
-            success:function(r){
-              if(r.rep){
-                showTip("存档成功",1000);
-                //ttable.ajax.reload();
-              }else{
-                showTip("存档失败",1000);
-              }
-            }
-        })
-      });
+    function archive() {
+        showConfirm("是否存档?", function () {
+            $.ajax({
+                url: "/service/rule/archive",
+                type: "post",
+                data: {"_id": dataMap["id"]},
+                success: function (r) {
+                    if (r.rep) {
+                        showTip("存档成功", 1000);
+                        //ttable.ajax.reload();
+                    } else {
+                        showTip("存档失败", 1000);
+                    }
+                }
+            })
+        });
     }
 </script>