소스 검색

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

jiaojiao7 4 년 전
부모
커밋
35db6cf2c1
2개의 변경된 파일93개의 추가작업 그리고 111개의 파일을 삭제
  1. 58 61
      src/client/customerRule.go
  2. 35 50
      src/web/templates/client/cuser_rule_edit.html

+ 58 - 61
src/client/customerRule.go

@@ -18,11 +18,11 @@ import (
 
 type CustomerRule struct {
 	*xweb.Action
-	cuserRuleCreate xweb.Mapper `xweb:"/customerRule/cuser/rule/create"`  //新建规则
-	ruleImport      xweb.Mapper `xweb:"/customerRule/rule/import"`        //导入关键词  导入文件excel
-	productData     xweb.Mapper `xweb:"/customerRule/cuser/produce"`      //生成预览数据
-	demoData        xweb.Mapper `xweb:"/customerRule/rule/preview"`       //预览数据
-	dataTest        xweb.Mapper `xweb:"/customerRule/rule/dataTest/(.*)"` //规则测试
+	cuserRuleCreate xweb.Mapper `xweb:"/customerRule/cuser/rule/create"` //新建规则
+	ruleImport      xweb.Mapper `xweb:"/customerRule/rule/import"`       //导入关键词  导入文件excel
+	productData     xweb.Mapper `xweb:"/customerRule/cuser/produce"`     //生成预览数据
+	demoData        xweb.Mapper `xweb:"/customerRule/rule/preview"`      //预览数据
+	dataTest        xweb.Mapper `xweb:"/customerRule/rule/dataTest/(.*)"`     //规则测试
 }
 
 func (c *CustomerRule) CuserRuleCreate() {
@@ -151,7 +151,7 @@ func (c *CustomerRule) ProductData() {
 		// 限制multi_match 个数小于1000个
 		s_esquery := qu.ObjToString((*tag)["s_esquery"])
 		multi_match_count := strings.Count(s_esquery, "multi_match")
-		//fmt.Println("multi_match", multi_match_count, s_esquery)
+		fmt.Println("multi_match",multi_match_count,s_esquery)
 		if multi_match_count > 1000 {
 			c.ServeJson(map[string]interface{}{
 				"rep": false,
@@ -193,7 +193,7 @@ func (c *CustomerRule) ProductData() {
 				}
 			}
 			// 判断总数是否大于4000
-			//fmt.Println(keyTotal, addKeyTotal)
+			fmt.Println(keyTotal,addKeyTotal)
 			if keyTotal > 4000 || addKeyTotal > 4000 {
 				c.ServeJson(map[string]interface{}{
 					"rep": false,
@@ -215,7 +215,7 @@ func (c *CustomerRule) ProductData() {
 		c.ServeJson(map[string]interface{}{
 			"rep":   rep,
 			"count": count,
-			"msg":   msg,
+			"msg":msg,
 		})
 	}
 }
@@ -252,18 +252,18 @@ func (this *CustomerRule) DataTest(id string) {
 	//获取数据
 	title := this.GetString("title")
 	detail := this.GetString("detail")
-	//fmt.Println(title, detail)
+	fmt.Println(title,detail)
 	if title == "" && detail == "" {
 		this.ServeJson(map[string]interface{}{
-			"status":  false,
-			"data":    "",
-			"message": "标题和正文至少要有一个",
+			"status":false,
+			"data":"",
+			"message":"标题和正文至少要有一个",
 		})
 		return
 	}
-	article := map[string]interface{}{
-		"title":  title,
-		"detail": detail,
+	article :=map[string]interface{}{
+		"title":title,
+		"detail":detail,
 	}
 
 	log.Println("测试数据是否匹配开始...")
@@ -301,13 +301,14 @@ func (this *CustomerRule) DataTest(id string) {
 		//清理清理词
 		for _, cwm := range cwmArr {
 			if text := qu.ObjToString(article[cwm]); text != "" {
-				for _, gcw_reg := range cwkArr {
+				for _, gcw_reg := range cwkArr{
 					text = gcw_reg.ReplaceAllString(text, "")
 				}
 				article[cwm] = text
 			}
 		}
 
+
 		o_rule, ok := c["o_rules"].([]interface{})
 		if !ok {
 			o_rule = []interface{}{}
@@ -319,13 +320,14 @@ func (this *CustomerRule) DataTest(id string) {
 			gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, article)
 			if gKey == "" {
 				this.ServeJson(map[string]interface{}{
-					"status": true,
-					"data": map[string]interface{}{
-						"result": false,
+					"status":true,
+					"data":map[string]interface{}{
+						"result":  false,
 						"info":   "全局附加词没有匹配成功",
 						"data":   s_globaladdkey,
 					},
-					"message": "测试成功",
+					"message":"测试成功",
+
 				})
 				return
 			} else {
@@ -336,13 +338,13 @@ func (this *CustomerRule) DataTest(id string) {
 			gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, article)
 			if gNKey != "" {
 				this.ServeJson(map[string]interface{}{
-					"status": true,
-					"data": map[string]interface{}{
-						"result": false,
-						"info":   "被全局排除词排除",
-						"data":   gNKey,
+					"status":true,
+					"data":map[string]interface{}{
+						"result":        false,
+						"info":"被全局排除词排除",
+						"data": gNKey,
 					},
-					"message": "测试成功",
+					"message":"测试成功",
 				})
 				return
 			}
@@ -350,7 +352,7 @@ func (this *CustomerRule) DataTest(id string) {
 
 		var resultList []interface{}
 		for _, v := range o_rules {
-			matchKey = ""
+			matchKey=""
 			key := qu.ObjToString(v["s_matchkey"])
 			keymatch := qu.ObjToString(v["s_keymatch"])
 			addkey := qu.ObjToString(v["s_addkey"])
@@ -358,12 +360,12 @@ func (this *CustomerRule) DataTest(id string) {
 			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,
+				"key":key,
+				"keymatch":keymatch,
+				"addkey":addkey,
+				"addkeymatch":addkeymatch,
+				"notkey":notkey,
+				"notkeymatch":notkeymatch,
 			}
 			if notkey != "" {
 				nKey := TestMactchKeys(notkeymatch, notkey, article)
@@ -371,42 +373,34 @@ func (this *CustomerRule) DataTest(id string) {
 					tempData["status"] = false
 					tempData["info"] = "排除词排除"
 					tempData["data"] = nKey
-					tempData["marknotkey"] = nKey
-					resultList = append(resultList, tempData)
-					if key != "" {
-						tempData["markkey"] = TestMactchKeys(keymatch, key, article)
-					}
-					if addkey != "" {
-						tempData["markaddkey"] = TestMactchKeys(addkeymatch, addkey, article)
-					}
+					resultList = append(resultList,tempData)
 					continue
 				}
 			}
 			if key != "" {
 				sKey := TestMactchKeys(keymatch, key, article)
-				tempData["markkey"] = sKey
 				aKey := ""
 				if addkey != "" {
 					aKey = TestMactchKeys(addkeymatch, addkey, article)
-					tempData["markaddkey"] = aKey
 					if aKey != "" && sKey != "" {
 						matchKey = aKey + "," + sKey
 						tempData["status"] = true
 						tempData["info"] = "匹配成功"
 						tempData["data"] = matchKey
-						resultList = append(resultList, tempData)
+						resultList = append(resultList,tempData)
+
 
-					} else if aKey == "" {
+					}else if aKey == "" {
 						tempData["status"] = false
 						tempData["info"] = "附加词匹配失败"
 						tempData["data"] = ""
-						resultList = append(resultList, tempData)
+						resultList = append(resultList,tempData)
 
-					} else if sKey == "" {
+					}else if sKey == "" {
 						tempData["status"] = false
 						tempData["info"] = "关键词匹配失败"
 						tempData["data"] = ""
-						resultList = append(resultList, tempData)
+						resultList = append(resultList,tempData)
 
 					}
 				} else {
@@ -415,29 +409,30 @@ func (this *CustomerRule) DataTest(id string) {
 						tempData["status"] = true
 						tempData["info"] = "匹配成功"
 						tempData["data"] = matchKey
-						resultList = append(resultList, tempData)
+						resultList = append(resultList,tempData)
 
-					} else {
+					}else {
 
 						matchKey = sKey
 						tempData["status"] = false
 						tempData["info"] = "关键词匹配失败"
 						tempData["data"] = matchKey
-						resultList = append(resultList, tempData)
+						resultList = append(resultList,tempData)
+
 
 					}
 				}
 			}
 		}
-		if resultList == nil {
+		if resultList == nil{
 			this.ServeJson(map[string]interface{}{
-				"status": true,
-				"data": map[string]interface{}{
-					"result": true,
-					"info":   "全局附加词匹配成功" + matchKey,
-					"data":   "",
+				"status":true,
+				"data":map[string]interface{}{
+					"result":        true,
+					"info":"全局附加词匹配成功"+matchKey,
+					"data": "",
 				},
-				"message": "测试成功",
+				"message":"测试成功",
 			})
 			return
 
@@ -451,13 +446,15 @@ func (this *CustomerRule) DataTest(id string) {
 		return
 	} else {
 
+
 		log.Println("初始化客户信息失败")
 		this.ServeJson(map[string]interface{}{
-			"status":  true,
-			"data":    "",
-			"message": "初始化客户信息失败",
+			"status":true,
+			"data":"",
+			"message":"初始化客户信息失败",
 		})
 		return
 	}
 	log.Println("测试数据是否匹配结束...")
 }
+

+ 35 - 50
src/web/templates/client/cuser_rule_edit.html

@@ -38,15 +38,6 @@
         color: #fff;
         text-align: center;
     }
-    mark {
-        background-color: #00ff90;
-        font-weight: bold;
-    }
-    mark1 {
-        background-color: red;
-        font-weight: bold;
-    }
-
 </style>
 <div class="content-wrapper">
     <section class="content-header">
@@ -2042,7 +2033,7 @@
                     success: function (r) {
                         if (r.rep) {
                             // dataMap["id"] = r.id;
-                            // console.log(r.rdata)
+                            console.log(r.rdata)
                             addkeyWord(r.rdata);
                             alert("导入成功")
                         } else {
@@ -2254,7 +2245,6 @@
             {
                 "data": function (row) {
                     var str = row.keymatch;
-                    let keyStrArray = []
                     if (str && str != "") {
                         var s = "";
                         for (var i in matchTypeMap) {
@@ -2266,20 +2256,20 @@
                                 }
                             }
                         }
+                        return row.key + "(" + s + ")"
+                    }
+                    return ""
+                },
 
-                        let markArr = row.markkey.split(",")
-                        let keyArr = row.key.split(",")
-                        // console.log(keyArr)
-                        for (let i in keyArr) {
-                            // row.key = row.key.replaceAll(keyArr[i], "<mark>" + keyArr[i] + "</mark>")
-                            if(markArr.includes(keyArr[i])){
-                                keyStrArray.push( "<mark>" + keyArr[i] + "</mark>")
-                            }else {
-                                // console.log(keyArr[i])
-                                keyStrArray.push(  keyArr[i] )
-                            }
+                render: function (data) {
+                    if (data) {
+                        if (data.length > 60) {
+                            return '<span title="' + data + '">' + data.substr(0, 60) + '...</span>';
+
+
+                        } else {
+                            return '<span title="' + data + '">' + data + '</span>';
                         }
-                        return keyStrArray.join(",") + "(" + s + ")"
                     }
                     return ""
                 },
@@ -2302,25 +2292,22 @@
                                 }
                             }
                         }
-                        if (row.markaddkey != undefined && row.markaddkey!=""){
-                            let keyStrArray= []
-                            let markArr = row.markaddkey.split(",")
-                            let keyArr = row.addkey.split(",")
-                            for (let i in keyArr) {
-                                if(markArr.includes(keyArr[i])){
-                                    keyStrArray.push( "<mark>" + keyArr[i] + "</mark>")
-                                }else {
-                                    // console.log(keyArr[i])
-                                    keyStrArray.push(  keyArr[i] )
-                                }
-                            }
-                        return keyStrArray.join(",") + "(" + s + ")"
-                        }
                         return row.addkey + "(" + s + ")"
                     }
                     return ""
                 },
+                render: function (data) {
+                    if (data) {
+                        if (data.length > 40) {
+                            return '<span title="' + data + '">' + data.substr(0, 40) + '...</span>';
+
 
+                        } else {
+                            return '<span title="' + data + '">' + data + '</span>';
+                        }
+                    }
+                    return ""
+                },
                 width: "18%"
             },
             // {"data": "notkey", width: "10%"},
@@ -2338,24 +2325,22 @@
                                 }
                             }
                         }
-                        if (row.marknotkey != undefined){
-                            let keyStrArray = []
-                            let markArr = row.marknotkey.split(",")
-                            let keyArr = row.notkey.split(",")
-                            for (let i in keyArr) {
-                                if(markArr.includes(keyArr[i])){
-                                    keyStrArray.push( "<mark1>" + keyArr[i] + "</mark1>")
-                                }else {
-                                    keyStrArray.push(  keyArr[i] )
-                                }
-                            }
-                            return keyStrArray.join(",") + "(" + s + ")"
-                        }
                         return row.notkey + "(" + s + ")"
                     }
                     return ""
                 },
+                render: function (data) {
+                    if (data) {
+                        if (data.length > 40) {
+                            return '<span title="' + data + '">' + data.substr(0, 40) + '...</span>';
+
 
+                        } else {
+                            return '<span title="' + data + '">' + data + '</span>';
+                        }
+                    }
+                    return ""
+                },
                 width: "18%"
             },
             {"data": "status", width: "7%"},