xuzhiheng 4 years ago
parent
commit
0c7e82e46a

+ 11 - 1
src/history/historytask.go

@@ -250,7 +250,17 @@ func (this *HistoryData) DataTest(id string) {
 	if len(*customer) == 1 {
 		c := (*customer)[0]
 		tmps := Es.GetByIdField(Index, Itype, dataId, "")
-		tmp := *tmps
+		tmp := map[string]interface{}{}
+		if tmps != nil {
+			tmp = *tmps
+		}
+		if len(tmp) == 0 {
+			this.ServeJson(map[string]interface{}{
+				"result": false,
+				"info":   "没有查到此数据",
+			})
+			return
+		}
 		s_globaladdkey := qu.ObjToString(c["s_globaladdkey"])
 		s_globaladdkeymatch := qu.ObjToString(c["s_globaladdkeymatch"])
 		s_globalnotkey := qu.ObjToString(c["s_globalnotkey"])

+ 22 - 0
src/web/templates/com/modal.html

@@ -255,6 +255,28 @@
     </div><!-- /.modal -->
 </div>
 
+<div class="modal fade" id="modal-dataTest" tabindex="-1" role="dialog" aria-hidden="true">
+    <div class="modal-dialog" style="width: 30%">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">数据ID</label>
+                        <div class="col-sm-10">
+                            <input class="form-control" style="max-width: 100%" placeholder="请输入数据ID"
+                                      id="dataTest-txt"></div>
+                        
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <input type="button" onclick="dataTests()" class="btn btn-primary saveBtn" value="确定">
+                </div>
+            </div>
+        </div>
+    </div><!-- /.modal -->
+</div>
+
 <script>
     //通用标签列表
     function importcomrule() {

+ 33 - 0
src/web/templates/private/cuser_rule_create.html

@@ -28,6 +28,8 @@
                 </button>
                 <button class="btn btn-danger btn-sm" onclick="archive()"><i class="fa fa-fw fa-save fa-lg"></i>存档
                 </button>
+                <button class="btn tn-info btn-sm" onclick="dataTest()"><i class="fa fa-fw fa-save fa-lg"></i>测试数据
+                </button>
             </small>
         </h1>
         <ol class="breadcrumb">
@@ -1873,4 +1875,35 @@
         }
         return {flag: flag, v1: v1, v2: v2}
     }
+    
+    function dataTest() {
+        $("#modal-dataTest").modal('show');
+    }
+    function dataTests() {
+        var val = $("#dataTest-txt").val()
+        $.ajax({
+            url: "/service/dataTest/"+ dataMap["id"],
+            type: "post",
+            data: {"id": val},
+            success: function (r) {
+                if (r.result) {
+                    showTip("匹配成功,匹配词 " + r.matchKey, 6000);
+                } else {
+                    var str = "";
+                    if (r.info != ""){
+                        str = r.info
+                        showTip(str, 6000);
+                        return
+                    }
+                    if (r.allexcluedKey != "") {
+                        str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
+                    }
+                    if (r.excluedKey != "") {
+                        str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
+                    }
+                    showTip(str, 6000);
+                }
+            }
+        })
+    }
 </script>

+ 33 - 0
src/web/templates/private/cuser_rule_edit.html

@@ -24,6 +24,8 @@
                 </button>
                 <button class="btn btn-danger btn-sm" onclick="archive()"><i class="fa fa-fw fa-save fa-lg"></i>存档
                 </button>
+                <button class="btn tn-info btn-sm" onclick="dataTest()"><i class="fa fa-fw fa-save fa-lg"></i>测试数据
+                </button>
             </small>
         </h1>
         <ol class="breadcrumb">
@@ -1936,4 +1938,35 @@
         }
         return {flag: flag, v1: v1, v2: v2}
     }
+    
+    function dataTest() {
+        $("#modal-dataTest").modal('show');
+    }
+    function dataTests() {
+        var val = $("#dataTest-txt").val()
+        $.ajax({
+            url: "/service/dataTest/"+ dataMap["id"],
+            type: "post",
+            data: {"id": val},
+            success: function (r) {
+                if (r.result) {
+                    showTip("匹配成功,匹配词 " + r.matchKey, 6000);
+                } else {
+                    var str = "";
+                    if (r.info != ""){
+                        str = r.info
+                        showTip(str, 6000);
+                        return
+                    }
+                    if (r.allexcluedKey != "") {
+                        str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
+                    }
+                    if (r.excluedKey != "") {
+                        str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
+                    }
+                    showTip(str, 6000);
+                }
+            }
+        })
+    }
 </script>