Bladeren bron

wip:匹配方式铺数据

fuwencai 1 jaar geleden
bovenliggende
commit
d8bb172480
2 gewijzigde bestanden met toevoegingen van 55 en 18 verwijderingen
  1. 12 12
      CMPlatform/web/templates/com/modal.html
  2. 43 6
      CMPlatform/web/templates/private/cuser_rule_edit.html

+ 12 - 12
CMPlatform/web/templates/com/modal.html

@@ -84,7 +84,7 @@
         <div class="modal-content">
             <div class="modal-header">
                 <div class="modal-header">
-                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="closeaaa()">&times;</button>
+                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button>
                     <div class="edit-form">
                         <div class="edit-info" style="text-align: center">
                             <span >新增精准筛选规则</span>
@@ -110,8 +110,8 @@
                                     <label class="col-sm-4 control-label"><span style="color:red;">* </span>匹配方式</label>
                                     <div class="col-sm-8">
                                         <select class="form-control selectpicker" multiple name="matchWay">
-                                            <option value="title" selected>标题</option>
-                                            <option value="content">正文</option>
+<!--                                            <option value="title" selected>标题</option>-->
+<!--                                            <option value="content">正文</option>-->
                                         </select>
                                     </div>
                                 </div>
@@ -136,8 +136,8 @@
                                 <label class="col-sm-4 control-label"><span style="color:red;">* </span>匹配方式</label>
                                 <div class="col-sm-8">
                                     <select class="form-control selectpicker" multiple name="matchWay">
-                                        <option value="title" selected>标题</option>
-                                        <option value="content">正文</option>
+<!--                                        <option value="title" selected>标题</option>-->
+<!--                                        <option value="content">正文</option>-->
                                     </select>
                                 </div>
                             </div>
@@ -150,7 +150,7 @@
 
                 </div>
                <div class="modal-footer">
-                   <button type="button" class="btn btn-default" data-dismiss="modal" onclick="formReset()">取消</button>
+                   <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
                    <button type="button" class="btn btn-primary" onclick="add_exactRule_save()">确定</button>
                </div>
             </div>
@@ -162,7 +162,7 @@
         <div class="modal-content">
             <div class="modal-header">
                 <div class="modal-header">
-                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="closeaaa()">&times;</button>
+                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button>
                     <div class="edit-form">
                         <div class="edit-info" style="text-align: center">
                             <span >编辑精准筛选规则</span>
@@ -188,8 +188,8 @@
                                     <label class="col-sm-4 control-label"><span style="color:red;">* </span>匹配方式</label>
                                     <div class="col-sm-8">
                                         <select class="form-control selectpicker" multiple name="matchWay">
-                                            <option value="title" selected>标题</option>
-                                            <option value="content">正文</option>
+<!--                                            <option value="title" selected>标题</option>-->
+<!--                                            <option value="content">正文</option>-->
                                         </select>
                                     </div>
                                 </div>
@@ -214,8 +214,8 @@
                                 <label class="col-sm-4 control-label"><span style="color:red;">* </span>匹配方式</label>
                                 <div class="col-sm-8">
                                     <select class="form-control selectpicker" multiple name="matchWay">
-                                        <option value="title" selected>标题</option>
-                                        <option value="content">正文</option>
+<!--                                        <option value="title" selected>标题</option>-->
+<!--                                        <option value="content">正文</option>-->
                                     </select>
                                 </div>
                             </div>
@@ -228,7 +228,7 @@
 
                 </div>
                <div class="modal-footer">
-                   <button type="button" class="btn btn-default" data-dismiss="modal" onclick="formReset1()">取消</button>
+                   <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
                    <button id="edit_exactRule_save" type="button" class="btn btn-primary" onclick="edit_exactRule_save()">确定</button>
                </div>
             </div>

+ 43 - 6
CMPlatform/web/templates/private/cuser_rule_edit.html

@@ -2800,13 +2800,20 @@
     //分组管理
     // 精准筛选规则-新增按钮点击方法
     function addExactRuleShow(){
-        // todo 判断是否设置关键词
-
-        // todo 判断是否设置关键词匹配方式
-        //
+        //  判断是否设置关键词
+        if (o_rules.length===0) {
+            showTip("请先设置关键词")
+            return
+        }
+        //  判断是否设置关键词匹配方式
+        if (!hasMatchWay()){
+            showTip("请先设置关键词匹配方式")
+            return
+        }
         // 清空数据
         $("#modal-add-exactRule select[name='groupSelect']").empty()
         $("#modal-add-exactRule input[name='count']").val('')
+        matchWayShow("#insertexactRule")
         $("#insertexactRule  select[name=matchWay]").val("").trigger("change")
         $("#insertexactRule  select[name=matchWay]").selectpicker('val', 'title');
         // 新增精准筛选规则弹框
@@ -3001,6 +3008,7 @@
     // 编辑点击事件
     function editExacRuleClick(index){
         showGroupListData("#modal-edit-exactRule") // 铺分组下拉列表数据
+        matchWayShow("#editexactRule")
         $("#editexactRuleId").text(index) // 隐藏选中的数组行号
         // 铺数据
         let contentArr = exactRuleTableArr[index]
@@ -3080,8 +3088,37 @@
         $("#editExactRuleButton").hide() // 隐藏新增按钮
         // $(".insertexactRule-form").selectpicker("refresh");
     }
-    // 判断是否设置关键词
-
     //  判断是否设置匹配方式
+    function hasMatchWay() {
+        for (let i = 0; i < o_rules.length; i++) {
+            if (o_rules[i]["s_keymatch"]!=""&&o_rules[i]["s_keymatch"]!=undefined){
+                return true
+            }
+        }
+        return false
+    }
+    // 获取已经设置的匹配方式  但是目前仅支持 标题和正文
+    const ruleMatchMruleStr = {
+        "1":"title",
+        "2":"content"
+    }
+    function matchWayShow(mId) {
+        let arr  = new Set();
+        for (let i = 0; i < o_rules.length; i++) {
+            if (o_rules[i]["s_keymatch"] != "" && o_rules[i]["s_keymatch"] != undefined) {
+                if (ruleMatchMruleStr.hasOwnProperty(o_rules[i]["s_keymatch"])){
+                    let matchWay = ruleMatchMruleStr[o_rules[i]["s_keymatch"]]
+                    arr.add({ value: matchWay, text: matchWayMap[matchWay] })
+                }
+            }
+        }
+        let  arr2 = Array.from(arr)
+        for (let i = 0; i <arr2.length; i++) {
+            let  option = arr2[i]
+            let s = `<option value="`+option.value+`">`+option.text+`</option>`
+            $(mId+'  select[name=matchWay]').append(`<option value="`+option.value+`">`+option.text+`</option>`)
+        }
+        $(mId+'  select[name=matchWay]').selectpicker('refresh');
 
+    }
 </script>