Преглед на файлове

Merge branch 'dev1.3' of http://192.168.3.207:10080/qmx/datatag into dev1.3

jiaojiao7 преди 4 години
родител
ревизия
d5463572ea
променени са 4 файла, в които са добавени 630 реда и са изтрити 115 реда
  1. 248 43
      src/history/historytask.go
  2. 78 25
      src/web/templates/com/modal.html
  3. 155 26
      src/web/templates/private/cuser_rule_create.html
  4. 149 21
      src/web/templates/private/cuser_rule_edit.html

+ 248 - 43
src/history/historytask.go

@@ -2,6 +2,8 @@ package history
 
 import (
 	"encoding/json"
+	"fmt"
+
 	"log"
 	mongoutil "qfw/mongodb"
 	qu "qfw/util"
@@ -239,27 +241,158 @@ func (this *HistoryData) ProductData() {
 	}
 }
 
+//func (this *HistoryData) DataTest(id string) {
+//	log.Println("测试数据是否匹配开始...")
+//	dataId := this.GetString("id")
+//	log.Println("id", id)
+//	log.Println("dataId", dataId)
+//	//加载一个客户
+//	customer, _ := Mgo.Find("cuserdepartrule", map[string]interface{}{"_id": mongoutil.StringTOBsonId(id)}, nil, nil, false, -1, -1)
+//	if len(*customer) == 1 {
+//		c := (*customer)[0]
+//		tmps := Es.GetByIdField(Index, Itype, dataId, "")
+//		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"])
+//		s_globalnotkeymatch := qu.ObjToString(c["s_globalnotkeymatch"])
+//		// s_globalclearkey := qu.ObjToString(c["s_globalclearkey"])
+//		// s_globalclearkeymatch := qu.ObjToString(c["s_globalclearkeymatch"])
+//		o_rule, ok := c["o_rules"].([]interface{})
+//		if !ok {
+//			o_rule = []interface{}{}
+//		}
+//		o_rules := qu.ObjArrToMapArr(o_rule)
+//		matchKey := ""
+//		//
+//		if s_globaladdkey != "" {
+//			gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, tmp)
+//			if gKey == "" {
+//				this.ServeJson(map[string]interface{}{
+//					"result": false,
+//					"info":   "全局附加词没有匹配成功",
+//				})
+//				return
+//			} else {
+//				matchKey = gKey
+//			}
+//		}
+//		if s_globalnotkey != "" {
+//			gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, tmp)
+//			if gNKey != "" {
+//				this.ServeJson(map[string]interface{}{
+//					"result":        false,
+//					"allexcluedKey": gNKey,
+//				})
+//				return
+//			}
+//		}
+//		for _, v := range o_rules {
+//			key := qu.ObjToString(v["s_matchkey"])
+//			keymatch := qu.ObjToString(v["s_keymatch"])
+//			addkey := qu.ObjToString(v["s_addkey"])
+//			addkeymatch := qu.ObjToString(v["s_addkeymatch"])
+//			notkey := qu.ObjToString(v["s_notkey"])
+//			notkeymatch := qu.ObjToString(v["s_notkeymatch"])
+//			if notkey != "" {
+//				nKey := TestMactchKeys(notkeymatch, notkey, tmp)
+//				if nKey != "" {
+//					this.ServeJson(map[string]interface{}{
+//						"result":     false,
+//						"excluedKey": nKey,
+//					})
+//					return
+//				}
+//			}
+//			if key != "" {
+//				sKey := TestMactchKeys(keymatch, key, tmp)
+//				aKey := ""
+//				if addkey != "" {
+//					aKey = TestMactchKeys(addkeymatch, addkey, tmp)
+//					if aKey != "" && sKey != "" {
+//						if matchKey != "" {
+//							matchKey += ","
+//						}
+//						matchKey = aKey + "," + sKey
+//						break
+//					}
+//				} else {
+//					if sKey != "" {
+//						if matchKey != "" {
+//							matchKey += ","
+//						}
+//						matchKey = sKey
+//						break
+//					}
+//				}
+//			}
+//		}
+//		if matchKey == "" {
+//			this.ServeJson(map[string]interface{}{
+//				"result": false,
+//				"info":   "没有匹配成功",
+//			})
+//		} else {
+//			this.ServeJson(map[string]interface{}{
+//				"result":   true,
+//				"matchKey": matchKey,
+//			})
+//		}
+//		return
+//	} else {
+//		log.Println("初始化客户信息失败")
+//	}
+//	log.Println("测试数据是否匹配结束...")
+//}
 func (this *HistoryData) DataTest(id string) {
+	//获取数据
+	title := this.GetString("title")
+	detail := this.GetString("detail")
+	fmt.Println(title,detail)
+	if title == "" && detail == "" {
+		this.ServeJson(map[string]interface{}{
+			"status":false,
+			"data":"",
+			"message":"标题和正文至少要有一个",
+		})
+		return
+	}
+	article :=map[string]interface{}{
+		"title":title,
+		"detail":detail,
+	}
+
 	log.Println("测试数据是否匹配开始...")
-	dataId := this.GetString("id")
+
+	//
 	log.Println("id", id)
-	log.Println("dataId", dataId)
 	//加载一个客户
 	customer, _ := Mgo.Find("cuserdepartrule", map[string]interface{}{"_id": mongoutil.StringTOBsonId(id)}, nil, nil, false, -1, -1)
 	if len(*customer) == 1 {
 		c := (*customer)[0]
-		tmps := Es.GetByIdField(Index, Itype, dataId, "")
-		tmp := map[string]interface{}{}
-		if tmps != nil {
-			tmp = *tmps
-		}
-		if len(tmp) == 0 {
-			this.ServeJson(map[string]interface{}{
-				"result": false,
-				"info":   "没有查到此数据",
-			})
-			return
-		}
+		//tmps := Es.GetByIdField(Index, Itype, dataId, "")
+		//
+		//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"])
@@ -272,13 +405,19 @@ func (this *HistoryData) DataTest(id string) {
 		}
 		o_rules := qu.ObjArrToMapArr(o_rule)
 		matchKey := ""
-		//
+
 		if s_globaladdkey != "" {
-			gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, tmp)
+			gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, article)
 			if gKey == "" {
 				this.ServeJson(map[string]interface{}{
-					"result": false,
-					"info":   "全局附加词没有匹配成功",
+					"status":true,
+					"data":map[string]interface{}{
+						"result":  false,
+						"info":   "全局附加词没有匹配成功",
+						"data":   s_globaladdkey,
+					},
+					"message":"测试成功",
+
 				})
 				return
 			} else {
@@ -286,69 +425,135 @@ func (this *HistoryData) DataTest(id string) {
 			}
 		}
 		if s_globalnotkey != "" {
-			gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, tmp)
+			gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, article)
 			if gNKey != "" {
 				this.ServeJson(map[string]interface{}{
-					"result":        false,
-					"allexcluedKey": gNKey,
+					"status":true,
+					"data":map[string]interface{}{
+						"result":        false,
+						"info":"被全局排除词排除",
+						"data": gNKey,
+					},
+					"message":"测试成功",
 				})
 				return
 			}
 		}
+
+		var resultList []interface{}
 		for _, v := range o_rules {
+			matchKey=""
 			key := qu.ObjToString(v["s_matchkey"])
 			keymatch := qu.ObjToString(v["s_keymatch"])
 			addkey := qu.ObjToString(v["s_addkey"])
 			addkeymatch := qu.ObjToString(v["s_addkeymatch"])
 			notkey := qu.ObjToString(v["s_notkey"])
 			notkeymatch := qu.ObjToString(v["s_notkeymatch"])
+			var tempData = map[string]interface{}{
+				"key":key,
+				"keymatch":keymatch,
+				"addkey":addkey,
+				"addkeymatch":addkeymatch,
+				"notkey":notkey,
+				"notkeymatch":notkeymatch,
+			}
 			if notkey != "" {
-				nKey := TestMactchKeys(notkeymatch, notkey, tmp)
+				nKey := TestMactchKeys(notkeymatch, notkey, article)
 				if nKey != "" {
-					this.ServeJson(map[string]interface{}{
-						"result":     false,
-						"excluedKey": nKey,
-					})
-					return
+					tempData["status"] = false
+					tempData["info"] = "排除词排除"
+					tempData["data"] = nKey
+					resultList = append(resultList,tempData)
+					continue
+					//this.ServeJson(map[string]interface{}{
+					//	"status":true,
+					//	"data":map[string]interface{}{
+					//		"result":     false,
+					//		"data": nKey,
+					//		"info":"被排除词排除",
+					//	},
+					//	"message":"测试成功",
+					//})
+					//return
 				}
 			}
 			if key != "" {
-				sKey := TestMactchKeys(keymatch, key, tmp)
+				sKey := TestMactchKeys(keymatch, key, article)
 				aKey := ""
 				if addkey != "" {
-					aKey = TestMactchKeys(addkeymatch, addkey, tmp)
+					aKey = TestMactchKeys(addkeymatch, addkey, article)
 					if aKey != "" && sKey != "" {
-						if matchKey != "" {
-							matchKey += ","
-						}
 						matchKey = aKey + "," + sKey
-						break
+						tempData["status"] = true
+						tempData["info"] = "匹配成功"
+						tempData["data"] = matchKey
+						resultList = append(resultList,tempData)
+
+
+					}else if aKey == "" {
+						tempData["status"] = false
+						tempData["info"] = "附加词匹配失败"
+						tempData["data"] = ""
+						resultList = append(resultList,tempData)
+
+					}else if sKey == "" {
+						tempData["status"] = false
+						tempData["info"] = "关键词匹配失败"
+						tempData["data"] = ""
+						resultList = append(resultList,tempData)
+
 					}
 				} else {
 					if sKey != "" {
-						if matchKey != "" {
-							matchKey += ","
-						}
 						matchKey = sKey
-						break
+						tempData["status"] = true
+						tempData["info"] = "匹配成功"
+						tempData["data"] = matchKey
+						resultList = append(resultList,tempData)
+
+					}else {
+
+							matchKey = sKey
+							tempData["status"] = false
+							tempData["info"] = "关键词匹配失败"
+							tempData["data"] = matchKey
+							resultList = append(resultList,tempData)
+
+
 					}
 				}
 			}
 		}
-		if matchKey == "" {
+		if resultList == nil{
 			this.ServeJson(map[string]interface{}{
-				"result": false,
-				"info":   "没有匹配成功",
+				"status":true,
+				"data":map[string]interface{}{
+					"result":        true,
+					"info":"全局附加词匹配成功"+matchKey,
+					"data": "",
+				},
+				"message":"测试成功",
 			})
+			return
+
 		} else {
 			this.ServeJson(map[string]interface{}{
-				"result":   true,
-				"matchKey": matchKey,
+				"status":  true,
+				"data":    resultList,
+				"message": "测试成功",
 			})
 		}
 		return
 	} else {
+
+
 		log.Println("初始化客户信息失败")
+		this.ServeJson(map[string]interface{}{
+			"status":true,
+			"data":"",
+			"message":"初始化客户信息失败",
+		})
+		return
 	}
 	log.Println("测试数据是否匹配结束...")
-}
+}

+ 78 - 25
src/web/templates/com/modal.html

@@ -39,11 +39,10 @@
                         </div>
                         <div id="btnGroupMatch"></div>
                         <div id="btnGroupMatch2" style="margin-top: 15px"></div>
-                        
-                        
-                 
-                   </div>
-                  <span style="display: block; color: red;font-size: 12px;margin-left: 25px;">提示:第一行和第二行不能同时选择,第一行可多选,第二行不可多选</span>
+
+
+                    </div>
+                    <span style="display: block; color: red;font-size: 12px;margin-left: 25px;">提示:第一行和第二行不能同时选择,第一行可多选,第二行不可多选</span>
 
                 </div>
                 <div class="modal-footer">
@@ -94,10 +93,10 @@
                             <span>公告行业</span>
                         </div>
                         <div class="btn_content">
-                        <div ><label class="control-label">一级行业</label></div>
-                       
+                            <div><label class="control-label">一级行业</label></div>
+
                             <div id="btnGroupTop" class="btn-group-top" style="margin-top: 5px"></div>
-                        <div ><label class="control-label" style="margin-top: 20px">二级行业</label></div>
+                            <div><label class="control-label" style="margin-top: 20px">二级行业</label></div>
                             <div id="btnGroupSub" style="display: flex; margin-top: 5px"></div>
                         </div>
                     </div>
@@ -255,22 +254,70 @@
     </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 fade" id="modal-dataTest" tabindex="-1" role="dialog" aria-hidden="true" style="height:100%">
+    <div class="modal-dialog" style="width: 60%; ">
         <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="row">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+
+                    </div>
+                    <div class="row">
+                        <label class="col-sm-2 control-label">数据标题</label>
                         <div class="col-sm-10">
-                            <input class="form-control" style="max-width: 100%" placeholder="请输入数据ID"
-                                      id="dataTest-txt"></div>
-                        
+                            <textarea placeholder="请输入数据标题" id="dataTest-title"
+                                      style="overflow-y: visible; margin: 0px;resize: none; width: 100%; height: 40px;"></textarea>
+
+                        </div>
                     </div>
+                    <div class="row">
+                        <label class="col-sm-2 control-label">数据正文</label>
+                        <div class="col-sm-10">
+
+                            <textarea placeholder="请输入数据正文" id="dataTest-detail"
+                                      style="overflow-y:visible;margin: 0px;resize: none; width:100%; height: 40px;"></textarea>
+                        </div>
+                    </div>
+                    <div style="text-align: right">
+                        <input type="button" onclick="dataTests()" class="btn btn-primary saveBtn" value="确定">
+
+                    </div>
+
+
                 </div>
-                <div class="modal-footer">
-                    <input type="button" onclick="dataTests()" class="btn btn-primary saveBtn" value="确定">
+
+
+                <div id="testResult" class="modal-header" style=" border-top-color: #f4f4f4;border-top: 1px;display: none ">
+
+                    <div class="row" id="testGlobal" style="display: none">
+                        <label class="col-sm-2 control-label">匹配结果</label>
+                        <div class="col-sm-10">
+                            <p id="result_message"></p>
+
+
+                        </div>
+                    </div>
+                    <div id="testKeyDiv" style="display: none">
+                        <table id="testKey" class="table table-bordered" >
+                            <thead>
+
+                            <tr>
+
+
+                                <th>编号</th>
+                                <th>关键词</th>
+                                <th>附加词</th>
+                                <th>排除词</th>
+                                <th>是否通过</th>
+                                <th>结果说明</th>
+                                <th>匹配值</th>
+                            </tr>
+                            </thead>
+                        </table>
+
+                    </div>
+
                 </div>
             </div>
         </div>
@@ -312,21 +359,25 @@
             },
             "columns": [
                 {"data": null},
-                {"data": "_id", width: "1%", render: function (val, a, row) {
+                {
+                    "data": "_id", width: "1%", render: function (val, a, row) {
                         return "<input type='checkbox' value='" + val + "' addkeytype='" + row.i_globaladdkeytype + "' notkeytype='" + row.i_globalnotkeytype + "' style='text-align: center'/>"
                     }
                 },
                 {"data": "s_name"},
                 {"data": "i_globaladdkeytype"},
                 {"data": "i_globalnotkeytype"},
-                {"data": "s_globalbuyerclass", render: function (val) {
+                {
+                    "data": "s_globalbuyerclass", render: function (val) {
                         if (val && val != "") {
                             return val
                         } else {
                             return ""
                         }
-                    }, width: "18%"},
-                {"data": function (row) {
+                    }, width: "18%"
+                },
+                {
+                    "data": function (row) {
                         if (row.s_globaltopscopeclass && row.s_globaltopscopeclass != "") {
                             return row.s_globaltopscopeclass
                         } else if (row.s_globalsubscopeclass && row.s_globalsubscopeclass != "") {
@@ -334,8 +385,10 @@
                         } else {
                             return ""
                         }
-                    }, width: "18%"},
-                {"data": "i_createtime", render: function (val) {
+                    }, width: "18%"
+                },
+                {
+                    "data": "i_createtime", render: function (val) {
                         var dt = new Date();
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd")
@@ -409,7 +462,7 @@
                 alert("公告行业不一致");
                 return
             }
-        }else if (subScopeArr.length > 0) {
+        } else if (subScopeArr.length > 0) {
             if (subScopeArr.some(function (value, index) {
                 return value !== subScopeArr[0];
             })) {

+ 155 - 26
src/web/templates/private/cuser_rule_create.html

@@ -1169,33 +1169,33 @@
     function addkeyWord(rdata) {
         o_rules = rdata["o_rules"];
         // 如果所上传文件中全局附加词为空  附加词置空 匹配方式置空
-        if (rdata["s_globaladdkey"]===undefined) {
+        if (rdata["s_globaladdkey"] === undefined) {
             $('#g_addkey').val("");
             dataMap["s_globaladdkey"] = "";
             $('#s_addkeymatch').val("");
             dataMap["s_globaladdkeymatch"] = "";
-        }else {
+        } else {
             $('#g_addkey').val(rdata["s_globaladdkey"]);
             dataMap["s_globaladdkey"] = rdata["s_globaladdkey"];
         }
         //如果上传文件中全局排除词为空 排除词置空 匹配方式置空
-        if (rdata["s_globalnotkey"]===undefined){
+        if (rdata["s_globalnotkey"] === undefined) {
             $('#g_notkey').val("");
             dataMap["s_globalnotkey"] = "";
             $('#s_notkeymatch').val("");
             dataMap["s_globalnotkeymatch"] = "";
-        }else {
+        } else {
             $('#g_notkey').val(rdata["s_globalnotkey"]);
             dataMap["s_globalnotkey"] = rdata["s_globalnotkey"];
         }
 
         //如果上传文件中全局清理词为空 则清理词置空 匹配方式置空
-        if(rdata["s_globalclearkey"]===undefined){
+        if (rdata["s_globalclearkey"] === undefined) {
             $('#s_globalclearkey').val("");
             dataMap["s_globalclearkey"] = "";
             $('#s_globalclearkeymatch').val("");
             dataMap["s_globalclearkeymatch"] = "";
-        }else {
+        } else {
             $('#s_globalclearkey').val(rdata["s_globalclearkey"]);
             dataMap["s_globalclearkey"] = rdata["s_globalclearkey"];
         }
@@ -1875,38 +1875,167 @@
         }
         return {flag: flag, v1: v1, v2: v2}
     }
-    
+
+    $('#testKey').DataTable({
+        "paging": false,
+        "lengthChange": false,
+        "searching": false,
+        "ordering": false,
+        "info": true,
+        "autoWidth": false,
+        "language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+        "fnDrawCallback": function () {
+            this.api().column(0).nodes().each(function (cell, i) {
+                cell.innerHTML = i + 1;
+            });
+        },
+        "data": [],
+        "columns": [
+            {"data": null, width: "5%"},
+            {"data": function (row) {
+                    var str = row.keymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.key+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+
+            // {"data": "addkey", width: "10%"},
+            {"data": function (row) {
+                    var str = row.addkeymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.addkey+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+            // {"data": "notkey", width: "10%"},
+            {"data": function (row) {
+                    var str = row.notkeymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.notkey+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+            {"data": "status", width: "10%"},
+            {"data": "info", width: "10%"},
+            {"data": "data", width: "10%"},
+
+        ]
+    });
     function dataTest() {
+        $("#dataTest-title").val("")
+        $("#dataTest-detail").val("")
+        $("#testResult").hide()
         $("#modal-dataTest").modal('show');
     }
     function dataTests() {
-        var val = $("#dataTest-txt").val()
+        // var val = $("#dataTest-txt").val()
+        var title = ""
+        var detail = ""
+        if ($("#dataTest-title").val()){
+            title = $("#dataTest-title").val()
+        }
+        if ($("#dataTest-detail").val()){
+            detail = $("#dataTest-detail").val()
+        }
         $.ajax({
             url: "/service/dataTest/"+ dataMap["id"],
             type: "post",
-            data: {"id": val},
+            data: {"title": title,"detail":detail},
             success: function (r) {
-                if (r.result) {
-                    showTip("匹配成功,匹配词 " + r.matchKey, 6000);
-                } else {
-                    var str = "";
-                    if (r.info != "" && r.info != null && r.info != undefined){
-                        str = r.info
-                        showTip(str, 6000);
-                        return
-                    }
-                    if (r.allexcluedKey != "") {
-                        str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
-                        showTip(str, 6000);
-                        return 
+
+
+                if (r.status){
+
+                    //全局附加词未匹配成功或者 排除词排除
+                    if(r.data.result === false){
+                        // $("#result_status").html("匹配失败")
+                        $("#result_message").html("匹配失败 "+r.data.info+"["+r.data.data+"]")
+                        $("#testGlobal").show()
+                        $("#testKeyDiv").hide()
+                    }else if (r.data.result === true && r.data.data===""){
+                        //没有关键词时 全局附加词匹配成功时
+                        $("#result_message").html("匹配成功 "+r.data.info)
+
+                        $("#testKeyDiv").hide()
+                        $("#testGlobal").show()
                     }
-                    if (r.excluedKey != "") {
-                        str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
-                        showTip(str, 6000);
-                        return
+                    else {
+
+                        $("#result_message").html("")
+                        $('#testKey').dataTable().fnClearTable();
+                        $('#testKey').dataTable().fnAddData(r.data);
+                        $("#testKeyDiv").show()
+
+
+
                     }
+                    $("#testResult").show()
+
+
+                }else {
+
+                    showTip(r.message, 500);
+
                 }
+
+                // if (r.result) {
+                //     showTip("匹配成功,匹配词 " + r.matchKey, 6000);
+                // } else {
+                //     var str = "";
+                //     if (r.info !== "" && r.info != null){
+                //         str = r.info
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                //     if (r.allexcluedKey !== "" && r.allexcluedKey != null) {
+                //
+                //         str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                //     if (r.excluedKey !== "" && r.excluedKey != null) {
+                //
+                //         str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                // }
             }
+
+
         })
     }
 </script>

+ 149 - 21
src/web/templates/private/cuser_rule_edit.html

@@ -1938,38 +1938,166 @@
         }
         return {flag: flag, v1: v1, v2: v2}
     }
-    
+    $('#testKey').DataTable({
+        "paging": false,
+        "lengthChange": false,
+        "searching": false,
+        "ordering": false,
+        "info": true,
+        "autoWidth": false,
+        "language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+        "fnDrawCallback": function () {
+            this.api().column(0).nodes().each(function (cell, i) {
+                cell.innerHTML = i + 1;
+            });
+        },
+        "data": [],
+        "columns": [
+            {"data": null, width: "5%"},
+            {"data": function (row) {
+                    var str = row.keymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.key+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+
+            // {"data": "addkey", width: "10%"},
+            {"data": function (row) {
+                    var str = row.addkeymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.addkey+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+            // {"data": "notkey", width: "10%"},
+            {"data": function (row) {
+                    var str = row.notkeymatch;
+                    if (str && str != "") {
+                        var s = "";
+                        for (var i in matchTypeMap) {
+                            if (str.indexOf(matchTypeMap[i]["code"]) != -1) {
+                                if (s == "") {
+                                    s = matchTypeMap[i]["name"]
+                                } else {
+                                    s = s + "," + matchTypeMap[i]["name"]
+                                }
+                            }
+                        }
+                        return row.notkey+"("+s+")"
+                    }
+                    return ""
+                }, width: "10%"},
+            {"data": "status", width: "10%"},
+            {"data": "info", width: "10%"},
+            {"data": "data", width: "10%"},
+
+        ]
+    });
     function dataTest() {
+        $("#dataTest-title").val("")
+        $("#dataTest-detail").val("")
+        $("#testResult").hide()
         $("#modal-dataTest").modal('show');
     }
     function dataTests() {
-        var val = $("#dataTest-txt").val()
+        // var val = $("#dataTest-txt").val()
+        var title = ""
+        var detail = ""
+        if ($("#dataTest-title").val()){
+            title = $("#dataTest-title").val()
+        }
+        if ($("#dataTest-detail").val()){
+            detail = $("#dataTest-detail").val()
+        }
         $.ajax({
             url: "/service/dataTest/"+ dataMap["id"],
             type: "post",
-            data: {"id": val},
+            data: {"title": title,"detail":detail},
             success: function (r) {
-                if (r.result) {
-                    showTip("匹配成功,匹配词 " + r.matchKey, 6000);
-                } else {
-                    var str = "";
-                    if (r.info != "" && r.info != null && r.info != undefined){
-                        str = r.info
-                        showTip(str, 6000);
-                        return
-                    }
-                    if (r.allexcluedKey != "") {
-                        str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
-                        showTip(str, 6000);
-                        return 
-                    }
-                    if (r.excluedKey != "") {
-                        str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
-                        showTip(str, 6000);
-                        return
+
+
+                if (r.status){
+
+                    //全局附加词未匹配成功或者 排除词排除
+                    if(r.data.result === false){
+                        // $("#result_status").html("匹配失败")
+                        $("#result_message").html("匹配失败 "+r.data.info+"["+r.data.data+"]")
+                        $("#testGlobal").show()
+                        $("#testKeyDiv").hide()
+                    }else if (r.data.result === true && r.data.data===""){
+                        //没有关键词时 全局附加词匹配成功时
+                        $("#result_message").html("匹配成功 "+r.data.info)
+
+                        $("#testKeyDiv").hide()
+                        $("#testGlobal").show()
                     }
+                    else {
+
+                        $("#result_message").html("")
+                        $('#testKey').dataTable().fnClearTable();
+                        $('#testKey').dataTable().fnAddData(r.data);
+                        $("#testKeyDiv").show()
+
+
+
+        }
+                    $("#testResult").show()
+
+
+                }else {
+
+                    showTip(r.message, 500);
+
                 }
+
+                // if (r.result) {
+                //     showTip("匹配成功,匹配词 " + r.matchKey, 6000);
+                // } else {
+                //     var str = "";
+                //     if (r.info !== "" && r.info != null){
+                //         str = r.info
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                //     if (r.allexcluedKey !== "" && r.allexcluedKey != null) {
+                //         debugger
+                //         str = "匹配失败,被全局排除词 "+ r.allexcluedKey + " 排除";
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                //     if (r.excluedKey !== "" && r.excluedKey != null) {
+                //         debugger
+                //         str = "匹配失败,被排除词 "+ r.excluedKey + " 排除";
+                //         showTip(str, 6000);
+                //         return
+                //     }
+                // }
             }
+
+
         })
     }
 </script>