jiaojiao7 4 роки тому
батько
коміт
5df0e7648b

+ 1 - 1
src/service/second_push.go

@@ -619,7 +619,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
 					row.AddCell().SetValue(v["company_email"])      //中标企业邮箱
 					ids := SE.EncodeString(qu.ObjToString(v["id"])) //唯一标识
 					row.AddCell().SetValue(ids)
-					row.AddCell().SetValue(v["projectId"]) //项目标识
+					row.AddCell().SetValue(SE.EncodeString(qu.ObjToString(v["projectId"]))) //项目标识
 
 					//row.AddCell().SetValue(v["jybxhref"])
 					//row.AddCell().SetValue(v["projectcode"])

+ 89 - 78
src/web/templates/client/index.html

@@ -34,76 +34,80 @@
                                             <h3 class="box-title">企业客户信息</h3>
                                             <a class="btn btn-primary btn-sm syncUpdate"
                                                style="float: right;margin-top: 7px;margin-right: 10px;background-color: #f39c12;border-color: #f39c12;"
-                                               onclick="SynEnt(dataMap._id)"><span class="glyphicon glyphicon-refresh"></span> 同步</a>
+                                               onclick="SynEnt(dataMap._id)"><span
+                                                        class="glyphicon glyphicon-refresh"></span> 同步</a>
                                             <a class="btn btn-primary btn-sm"
                                                style="float: right;margin-top: 7px;margin-right: 10px"
                                                onclick="saveCuser()"><i class="fa fa-fw fa-file-text fa-lg"></i>保存</a>
                                         </div>
                                         <div class="box-body">
                                             <div class="row">
-                                             
 
-                                                    <label class="col-sm-2 control-label">客户名称</label>
-                                                    <div>
 
-                                                        <label id="S_name" class="control-label"
-                                                               style="margin-left: 15px;font-weight:normal;"></label>
-                                                        <!--<input id="pushSwitch" type="checkbox" checked/>-->
-                                                 
+                                                <label class="col-sm-2 control-label">客户名称</label>
+                                                <div>
+
+                                                    <label id="S_name" class="control-label"
+                                                           style="margin-left: 15px;font-weight:normal;"></label>
+                                                    <!--<input id="pushSwitch" type="checkbox" checked/>-->
+
                                                 </div>
 
                                             </div>
                                             <div>
-                                      <div class="form-group" style="margin-top:20px;">
-                                                <label class="col-sm-2 control-label">推送设置</label>
-                                                <div class="col-sm-3">
-                                                    <input id="pushSwitch" type="checkbox" checked   />
+                                                <div class="form-group" style="margin-top:20px;">
+                                                    <label class="col-sm-2 control-label">推送设置</label>
+                                                    <div class="col-sm-3">
+                                                        <input id="pushSwitch" type="checkbox" checked/>
+                                                    </div>
+                                                    <script>
+                                                        $('#pushSwitch').on('switchChange.bootstrapSwitch', function (event, state) {
+
+
+                                                            if (state) {
+                                                                dataMap["i_push"] = 1
+                                                            } else {
+                                                                dataMap["i_push"] = 0
+                                                            }
+
+                                                        })
+                                                    </script>
                                                 </div>
-                                                <script>
-                                                    $('#pushSwitch').on('switchChange.bootstrapSwitch', function (event, state) {
-                                                   
-                                                      
-                                                        if (state) {
-                                                            dataMap["i_push"] = 1
-                                                        }else {
-                                                            dataMap["i_push"] = 0
-                                                        }
-                                                    
-                                                    })
-                                                </script>
-                                            </div>
-                                            <div class="form-group" style="margin-top:20px;">
-                                                <label class="col-sm-2 control-label"><span style="color:red;">* </span>推送模式</label>
-                                                <div class="col-sm-3">
-                                                    <select class="form-control" id="pushModelSelect" disabled>
-                                                        <option value=0>全局模式</option>
-                                                        <option value=1>部门模式</option>
-                                                        <option value=2>标签模式</option>
-                                                        <option value=3>部门+标签模式</option>
-                                                        <option value=4>规则模式(不去重)</option>
-                                                    </select>
+                                                <div class="form-group" style="margin-top:20px;">
+                                                    <label class="col-sm-2 control-label"><span
+                                                                style="color:red;">* </span>推送模式</label>
+                                                    <div class="col-sm-3">
+                                                        <select class="form-control" id="pushModelSelect" disabled>
+                                                            <option value=0>全局模式</option>
+                                                            <option value=1>部门模式</option>
+                                                            <option value=2>标签模式</option>
+                                                            <option value=3>部门+标签模式</option>
+                                                            <option value=4>规则模式(不去重)</option>
+                                                        </select>
+                                                    </div>
                                                 </div>
-                                            </div>
-                                            <div class="form-group" style="margin-top:20px;">
-                                                <label class="col-sm-2 control-label"><span style="color:red;">* </span>推送方式</label>
-                                                <div class="col-sm-3">
-                                                    <select class="form-control" id="pushTypeSelect" disabled>
-                                                        <option value=0 code="email">邮箱</option>
-                                                        <option value=1 code="interface">接口</option>
-                                                    </select>
+                                                <div class="form-group" style="margin-top:20px;">
+                                                    <label class="col-sm-2 control-label"><span
+                                                                style="color:red;">* </span>推送方式</label>
+                                                    <div class="col-sm-3">
+                                                        <select class="form-control" id="pushTypeSelect" disabled>
+                                                            <option value=0 code="email">邮箱</option>
+                                                            <option value=1 code="interface">接口</option>
+                                                        </select>
+                                                    </div>
                                                 </div>
                                             </div>
-                                            </div>
-                                            
+
                                             <div>
                                                 <div class="row">
-                                                 
-                                                        <label class="col-sm-2 control-label" style="margin-top:20px;">邮箱设置</label>
-                                                        <button type="button" class="btn btn-primary addMail"
-                                                                style="margin-left: 15px;padding: 2px 12px;margin-top:24px;">
-                                                            添加邮箱
-                                                        </button>
-                                              
+
+                                                    <label class="col-sm-2 control-label"
+                                                           style="margin-top:20px;">邮箱设置</label>
+                                                    <button type="button" class="btn btn-primary addMail"
+                                                            style="margin-left: 15px;padding: 2px 12px;margin-top:24px;">
+                                                        添加邮箱
+                                                    </button>
+
                                                 </div>
                                                 <div class="row" style="margin-top: 5px; margin-left: 97px">
                                                     <div class="col-lg-7 col-md-offset-1" id="mails">
@@ -293,32 +297,32 @@
         if (dataMap.i_state == 0) {
             $('.tab_2').hide()
             $('.syncUpdate').hide()
-        
+
             $('#pushDiv').hide()
         }
         tagruleArr = {{.T.tagrule}}
-        $('#pushSwitch').bootstrapSwitch({
+            $('#pushSwitch').bootstrapSwitch({
                 onText: "开启",
                 offText: "关闭",
             })
 
-            if (dataMap.i_push && dataMap.i_push == 1) {
-                $('#pushSwitch').bootstrapSwitch('state', true);
-            }else {
-                $('#pushSwitch').bootstrapSwitch('state', false);
+        if (dataMap.i_push && dataMap.i_push == 1) {
+            $('#pushSwitch').bootstrapSwitch('state', true);
+        } else {
+            $('#pushSwitch').bootstrapSwitch('state', false);
+        }
+        $('#pushSwitch').bootstrapSwitch('disabled', true)
+        $("#pushModelSelect option").each(function () {
+            if ($(this).val() == dataMap.i_pushmodel) {
+                $(this).attr("selected", 'selected');
             }
-             $('#pushSwitch').bootstrapSwitch('disabled', true)
-            $("#pushModelSelect option").each(function (){
-                if($(this).val()==dataMap.i_pushmodel){
-                    $(this).attr("selected",'selected');
-                }
-            });
-            $('#pushModelSelect').val(dataMap.i_pushmodel)
-            $("#pushTypeSelect option").each(function (){
-                if($(this).val()==dataMap.i_pushtype){
-                    $(this).attr("selected",'selected');
-                }
-            });
+        });
+        $('#pushModelSelect').val(dataMap.i_pushmodel)
+        $("#pushTypeSelect option").each(function () {
+            if ($(this).val() == dataMap.i_pushtype) {
+                $(this).attr("selected", 'selected');
+            }
+        });
 
         $('#S_name').html(dataMap.s_name);
         $('#departTable').DataTable({
@@ -434,7 +438,7 @@
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
                         var s = [val, row.s_userid]
                         tmp = '<div>' +
-                            '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\')">关联数据范围</a>&nbsp&nbsp' +
+                            '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
                         return tmp
                     }
@@ -766,8 +770,10 @@
     var tagid = ""
 
     //关联规则
-    function associated(val) {
+    function associated(val, o_departruleids) {
         tagid = val.split(",")[0]
+        console.log(o_departruleids)
+        var departRuleIds = o_departruleids.split(",")
         $('#cuserRule').DataTable({
             "destroy": true,
             "paging": true,
@@ -793,8 +799,12 @@
             "columns": [
                 {"data": null, width: "1%"},
                 {
-                    "data": "", width: "1%", render: function () {
-                        return `<input type="checkbox" name="ckb-rule" onclick="singleSelect(this)" style="text-align: center">`
+                    "data": "_id", width: "1%", render: function (val) {
+                        if (departRuleIds.indexOf(val) !== -1) {
+                            return `<input type="checkbox" checked name="ckb-rule" onclick="singleSelect(this)" style="text-align: center">`
+                        } else {
+                            return `<input type="checkbox" name="ckb-rule" onclick="singleSelect(this)" style="text-align: center">`
+                        }
                     }
                 },
                 {"data": "s_name", width: "20%"},
@@ -835,18 +845,19 @@
             }
         })
     }
+
     //同步信息
     function SynEnt(val) {
-        showConfirm("确认同步企业信息吗?", function() {
+        showConfirm("确认同步企业信息吗?", function () {
             $.ajax({
                 url: "/client/cuser/synchronous",
                 type: "post",
                 data: {"_id": val},
-                success: function(r){
-                    if(r.rep){
+                success: function (r) {
+                    if (r.rep) {
                         showTip("同步成功", 1000);
                         ttable.ajax.reload()
-                    }else{
+                    } else {
                         showTip("同步失败", 1000);
                     }
                 }

+ 144 - 92
src/web/templates/private/customer_edit.html

@@ -18,8 +18,10 @@
         <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 data-mode="guide" class="tab_2"><a href="#tab_2" data-toggle="tab" aria-expanded="false">私有标签</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="tab_2"><a href="#tab_2" data-toggle="tab"
+                                                           aria-expanded="false">私有标签</a></li>
                 </ul>
                 <div class="tab-content">
 
@@ -29,18 +31,22 @@
                                 <div class="box-header with-border">
                                     <i class="fa fa-tag"></i>
                                     <h3 class="box-title">基本信息</h3>
-                                    <a class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" onclick="saveCuser()"><i class="fa fa-fw fa-file-text fa-lg"></i>保存</a>
+                                    <a class="btn btn-primary btn-sm"
+                                       style="float: right;margin-top: 7px;margin-right: 10px" onclick="saveCuser()"><i
+                                                class="fa fa-fw fa-file-text fa-lg"></i>保存</a>
                                 </div>
                                 <div class="box-body">
                                     <div class="form-group">
-                                        <label class="col-sm-2 control-label"><span style="color:red;">* </span>客户名称</label>
+                                        <label class="col-sm-2 control-label"><span
+                                                    style="color:red;">* </span>客户名称</label>
                                         <div class="col-sm-3">
                                             <input type="text" class="form-control" id="customername" placeholder="公司名称"
                                                    value="{{.T.data.s_name}}" required>
                                         </div>
                                     </div>
                                     <div class="form-group">
-                                        <label class="col-sm-2 control-label"><span style="color:red;">* </span>销售人员</label>
+                                        <label class="col-sm-2 control-label"><span
+                                                    style="color:red;">* </span>销售人员</label>
                                         <div class="col-sm-3">
                                             <input type="text" class="form-control" id="seller" placeholder="销售人员名称"
                                                    value="{{.T.data.s_salesperson}}" required>
@@ -49,7 +55,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="skills" placeholder="技术支持" value="{{.T.data.skills}}" required>
+                                            <input type="text" class="form-control" id="skills" placeholder="技术支持"
+                                                   value="{{.T.data.skills}}" required>
                                         </div>
                                     </div>
                                     <div class="form-group">
@@ -74,7 +81,7 @@
                                                     $('#pushSwitch').on('switchChange.bootstrapSwitch', function (event, state) {
                                                         if (state) {
                                                             dataMap["i_push"] = 1
-                                                        }else {
+                                                        } else {
                                                             dataMap["i_push"] = 0
                                                         }
                                                     })
@@ -104,9 +111,10 @@
                                             <div class="form-group">
                                                 <label class="col-sm-2 control-label">数据扩展</label>
                                                 <div class="col-sm-3">
-                                                    <select class="form-control selectpicker" multiple id="expandSelect">
-                                                        <option value="hospitalgrade" >医院等级</option>
-                                                        <option value="enterpise" >企业信息</option>
+                                                    <select class="form-control selectpicker" multiple
+                                                            id="expandSelect">
+                                                        <option value="hospitalgrade">医院等级</option>
+                                                        <option value="enterpise">企业信息</option>
                                                     </select>
                                                     <script>
                                                         $('#expandSelect').on('hide.bs.select', function () {
@@ -157,7 +165,10 @@
                             <div class="box-header with-border">
                                 <i class="fa fa-bookmark"></i>
                                 <h3 class="box-title">私有标签</h3>
-                                <a class="btn btn-primary btn-sm" style="float: right;margin-top: 7px;margin-right: 10px" href="/service/euser/tag/edit?cid={{.T.data._id}}"><i class="fa fa-fw fa-file-code-o fa-lg"></i>新建标签</a>
+                                <a class="btn btn-primary btn-sm"
+                                   style="float: right;margin-top: 7px;margin-right: 10px"
+                                   href="/service/euser/tag/edit?cid={{.T.data._id}}"><i
+                                            class="fa fa-fw fa-file-code-o fa-lg"></i>新建标签</a>
                             </div>
                             <table id="tagrule" class="table table-bordered">
                                 <thead>
@@ -274,26 +285,27 @@
         if (dataMap.i_state == 0) {
             $('.tab_2').hide()
             $('#pushDiv').hide()
-        }else {
+        } else {
             tagruleArr = {{.T.tagrule}}
+                console.log("私有标签", tagruleArr)
             $('#pushSwitch').bootstrapSwitch({
                 onText: "开启",
                 offText: "关闭",
             })
             if (dataMap.i_push && dataMap.i_push == 1) {
                 $('#pushSwitch').bootstrapSwitch('state', true);
-            }else {
+            } else {
                 $('#pushSwitch').bootstrapSwitch('state', false);
             }
-            $("#pushModelSelect option").each(function (){
-                if($(this).val()==dataMap.i_pushmodel){
-                    $(this).attr("selected",'selected');
+            $("#pushModelSelect option").each(function () {
+                if ($(this).val() == dataMap.i_pushmodel) {
+                    $(this).attr("selected", 'selected');
                 }
             });
             $('#pushModelSelect').val(dataMap.i_pushmodel)
-            $("#pushTypeSelect option").each(function (){
-                if($(this).val()==dataMap.i_pushtype){
-                    $(this).attr("selected",'selected');
+            $("#pushTypeSelect option").each(function () {
+                if ($(this).val() == dataMap.i_pushtype) {
+                    $(this).attr("selected", 'selected');
                 }
             });
             // if (dataMap.i_pushtype == 0) {
@@ -302,12 +314,12 @@
             //     $('#pushTypeSelect').val(1)
             // }
             if (dataMap.s_extends && dataMap.s_extends.indexOf("hospitalgrade") >= 0 && dataMap.s_extends.indexOf("enterpise") >= 0) {
-                $('#expandSelect').find("option[value = hospitalgrade]").attr("selected","selected");
-                $('#expandSelect').find("option[value = enterpise]").attr("selected","selected");
-            }else if (dataMap.s_extends && dataMap.s_extends.indexOf("hospitalgrade") >= 0){
-                $('#expandSelect').find("option[value = hospitalgrade]").attr("selected","selected");
-            }else if (dataMap.s_extends && dataMap.s_extends.indexOf("enterpise") >= 0) {
-                $('#expandSelect').find("option[value = enterpise]").attr("selected","selected");
+                $('#expandSelect').find("option[value = hospitalgrade]").attr("selected", "selected");
+                $('#expandSelect').find("option[value = enterpise]").attr("selected", "selected");
+            } else if (dataMap.s_extends && dataMap.s_extends.indexOf("hospitalgrade") >= 0) {
+                $('#expandSelect').find("option[value = hospitalgrade]").attr("selected", "selected");
+            } else if (dataMap.s_extends && dataMap.s_extends.indexOf("enterpise") >= 0) {
+                $('#expandSelect').find("option[value = enterpise]").attr("selected", "selected");
             }
         }
         $('#departTable').DataTable({
@@ -327,37 +339,46 @@
                 });
             },
             "columns": [
-                {"data":function() {
+                {
+                    "data": function () {
                         return `<input type="checkbox" name="ckb-depart" onclick="singleSelect1(this)" style="text-align: center">`
-                    }, width: "3%"},
+                    }, width: "3%"
+                },
                 {"data": null, width: "3%"},
                 {"data": "s_name", width: "10%"},
-                {"data": function (row) {
+                {
+                    "data": function (row) {
                         if (row.s_contract == "") {
                             return ""
-                        }else {
+                        } else {
                             return row.s_contract
                         }
-                    }, width: "10%"},
-                {"data": "i_updatetime", render: function (val) {
+                    }, width: "10%"
+                },
+                {
+                    "data": "i_updatetime", render: function (val) {
                         var dt = new Date();
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd hh:mm:ss")
-                    }, width: "20%"},
-                {"data": "i_isuse", render: function (val, a, row) {
+                    }, width: "20%"
+                },
+                {
+                    "data": "i_isuse", render: function (val, a, row) {
                         tmp = ""
-                        if(val == 1){
-                            tmp="<a href='#' title='停用' onclick='setup(\""+row._id+"\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
-                        }else{
-                            tmp="<a href='#' title='启用' onclick='setup(\""+row._id+"\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
+                        if (val == 1) {
+                            tmp = "<a href='#' title='停用' onclick='setup(\"" + row._id + "\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
+                        } else {
+                            tmp = "<a href='#' title='启用' onclick='setup(\"" + row._id + "\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
                         }
                         return tmp
-                    }, width: "10%" },
-                {"data": "_id", width: "20%", render: function (val, a, row, pos) {
+                    }, width: "10%"
+                },
+                {
+                    "data": "_id", width: "20%", render: function (val, a, row, pos) {
                         var s = [val, row.s_userid];
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" href="/service/cuser/rule/list?ids=' + s + '">规则列表</a>&nbsp&nbsp'
-                            '</div>';
+                        '</div>';
                         return tmp
                     }
                 }
@@ -382,41 +403,51 @@
             "columns": [
                 {"data": null, width: "1%"},
                 {"data": "s_name", width: "10%"},
-                {"data": "i_updatetime", width:"9%", render: function (val) {
+                {
+                    "data": "i_updatetime", width: "9%", render: function (val) {
                         var dt = new Date()
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd hh:mm:ss")
-                    }},
-                {"data": "i_isuse", render: function (val, a, row) {
+                    }
+                },
+                {
+                    "data": "i_isuse", render: function (val, a, row) {
                         tmp = ""
-                        if(val == 1){
-                            tmp="<a href='#' title='停用' onclick='setupTag(\""+row._id+"\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
-                        }else{
-                            tmp="<a href='#' title='启用' onclick='setupTag(\""+row._id+"\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
+                        if (val == 1) {
+                            tmp = "<a href='#' title='停用' onclick='setupTag(\"" + row._id + "\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
+                        } else {
+                            tmp = "<a href='#' title='启用' onclick='setupTag(\"" + row._id + "\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
                         }
                         return tmp
-                    }, width: "10%" },
-                {"data": "_id", width:"11%",render: function (val, a, row, pos) {
+                    }, width: "10%"
+                },
+                {
+                    "data": "_id", width: "11%", render: function (val, a, row, pos) {
                         tmp = '<div>' +
-                            '<a class="btn btn-sm btn-primary" href="/service/euser/tag/edit?id='+val+'&cid='+row.s_userid+'">编辑</a>&nbsp&nbsp'+
-                            '<a class="btn btn-sm btn-danger" onclick="delTag(\''+val+'\')">删除</a>'+
+                            '<a class="btn btn-sm btn-primary" href="/service/euser/tag/edit?id=' + val + '&cid=' + row.s_userid + '">编辑</a>&nbsp&nbsp' +
+                            '<a class="btn btn-sm btn-danger" onclick="delTag(\'' + val + '\')">删除</a>' +
                             '</div>';
                         return tmp
-                    }},
-                {"data": "_id", width:"11%",render: function (val, a, row, pos) {
+                    }
+                },
+                {
+                    "data": "_id", width: "11%", render: function (val, a, row, pos) {
                         var s = [val, row.s_userid]
                         tmp = '<div>' +
-                            '<a class="btn btn-sm btn-primary" onclick="associated(\''+s+'\')">关联数据范围</a>&nbsp&nbsp'+
+                            '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
                         return tmp
-                    }},
+                    }
+                },
             ],
         });
     })
+
     function cancelModel() {
         $('#modal-add-depart').modal("hide")
         $('#modal-associated').modal("hide")
     }
+
     //表格全选
     function allSelect(obj) {
         if ($(obj).is(':checked')) {
@@ -435,6 +466,7 @@
             })
         }
     }
+
     function singleSelect(obj) {
         var tag = true;
         selectIndex.length = 0;
@@ -442,18 +474,19 @@
             if (this.checked) {
                 keyTableChecked = true;
                 selectIndex.push($(this).parents("tr").index());
-            }else {
+            } else {
                 tag = false
             }
         });
         if (tag) {
             keyTableAllChecked = true;
             $('#allCheckbox').prop("checked", true);
-        }else {
+        } else {
             keyTableAllChecked = false;
             $('#allCheckbox').prop("checked", false);
         }
     }
+
     function singleSelect1(obj) {
         var tag = true;
         selectIndex.length = 0;
@@ -461,14 +494,14 @@
             if (this.checked) {
                 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);
         }
@@ -514,6 +547,7 @@
         $('#s_depart_name').val("");
         $('#modal-add-depart').modal("show")
     }
+
     //修改部门
     function modify_Depart() {
         depart_flag = 1
@@ -524,9 +558,10 @@
         $("#isuseSelect").val(departArr[index].i_isuse)
         $('#modal-add-depart').modal("show");
     }
+
     function del_Depart() {
         if (keyTableChecked && selectIndex.length > 0) {
-            showConfirm("确定删除?", function() {
+            showConfirm("确定删除?", function () {
                 var tmp = []
                 for (var i in selectIndex) {
                     var j = selectIndex[i] - 1;
@@ -540,10 +575,10 @@
                     data: {"id": did},
                     success: function (r) {
                         bol = r.rep
-                        if(r.rep){
+                        if (r.rep) {
                             // showTip("删除成功", 1000)
                             window.location.reload()
-                        }else{
+                        } else {
                             showTip("删除失败", 1000);
                         }
                     }
@@ -557,15 +592,16 @@
                 if (departArr.length == 0) {
                     $('#allCheckbox').prop("checked", false);
                     $('#departTable').dataTable().fnClearTable();
-                }else {
+                } else {
                     $('#departTable').dataTable().fnClearTable();
                     $('#departTable').dataTable().fnAddData(departArr);
                 }
             })
-        }else {
+        } else {
             showTip("请选中需要删除的关键词", 1000)
         }
     }
+
     function saveDepart() {
         var name = $('#depart_name').val();
         if (name != "") {
@@ -573,18 +609,18 @@
                 var index = selectIndex[0] - 1;
                 var depart = departArr[index]
                 depart["id"] = depart["_id"]
-            }else {
+            } else {
                 var depart = {}
                 depart["s_userid"] = dataMap._id
             }
             depart["s_name"] = name;
             depart["s_contract"] = $('#depart_contract').val();
             depart["s_subname"] = $('#s_depart_name').val()
-            depart["i_isuse"] =  $('#isuseSelect').val()
+            depart["i_isuse"] = $('#isuseSelect').val()
             if (depart_flag == 1) {
                 var index = selectIndex[0] - 1;
                 departArr.splice(index, 1, depart)
-            }else {
+            } else {
                 departArr.push(depart)
             }
             $('#departTable').dataTable().fnClearTable();
@@ -596,70 +632,73 @@
                 type: "post",
                 data: depart,
                 success: function (r) {
-                    if(r.rep){
+                    if (r.rep) {
                         // showTip("保存成功", 1000)
                         window.location.reload()
-                    }else{
+                    } else {
                         showTip("保存失败", 1000);
                     }
                 }
             })
-        }else {
+        } else {
             showTip("部门名称不能为空", 500)
         }
     }
+
     function setup(val, bol) {
         var msg = ""
         var i_isuse = 0
         if (bol) {
             msg = "确定启用?"
             i_isuse = 1
-        }else {
+        } else {
             msg = "确定停用?"
             i_isuse = 0
         }
-        showConfirm(msg, function() {
+        showConfirm(msg, function () {
             $.ajax({
-                url:"/service/customer/setup",
-                type:"post",
-                data:{"_id": val, "i_isuse": i_isuse},
-                success:function(r){
-                    if(r.rep){
+                url: "/service/customer/setup",
+                type: "post",
+                data: {"_id": val, "i_isuse": i_isuse},
+                success: function (r) {
+                    if (r.rep) {
                         // showTip("设置成功", 1000);
                         window.location.reload()
-                    }else{
+                    } else {
                         showTip("设置失败", 1000);
                     }
                 }
             })
         });
     }
+
     function setupTag(val, bol) {
         var msg = ""
         var i_isuse = 0
         if (bol) {
             msg = "确定启用?"
             i_isuse = 1
-        }else {
+        } else {
             msg = "确定停用?"
             i_isuse = 0
         }
-        showConfirm(msg, function() {
+        showConfirm(msg, function () {
             $.ajax({
-                url:"/service/euser/tag/setup",
-                type:"post",
-                data:{"_id": val, "i_isuse": i_isuse},
-                success:function(r){
-                    if(r.rep){
+                url: "/service/euser/tag/setup",
+                type: "post",
+                data: {"_id": val, "i_isuse": i_isuse},
+                success: function (r) {
+                    if (r.rep) {
                         // showTip("设置成功", 1000);
                         window.location.reload()
-                    }else{
+                    } else {
                         showTip("设置失败", 1000);
                     }
                 }
             })
         });
     }
+
     function delTag(val) {
         showConfirm("确定删除?", function () {
             $.ajax({
@@ -676,10 +715,14 @@
             })
         });
     }
+
     var tagid = ""
+
     //关联规则
-    function associated(val) {
+    function associated(val, o_departruleids) {
         tagid = val.split(",")[0]
+        var departRuleIds = o_departruleids.split(",")
+        // console.log(departRuleIds)
         $('#cuserRule').DataTable({
             "destroy": true,
             "paging": true,
@@ -704,20 +747,29 @@
             },
             "columns": [
                 {"data": null, width: "1%"},
-                {"data": "", width: "1%", render: function() {
-                        return `<input type="checkbox" name="ckb-rule" onclick="singleSelect(this)" style="text-align: center">`
-                    }},
+                {
+                    "data": "_id", width: "1%", render: function (val) {
+                        if (departRuleIds.indexOf(val) !== -1) {
+                            return `<input type="checkbox" name="ckb-rule" checked="checked" onclick="singleSelect(this)" style="text-align: center">`
+                        } else {
+                            return `<input type="checkbox" name="ckb-rule" onclick="singleSelect(this)" style="text-align: center">`
+                        }
+                    }
+                },
                 {"data": "s_name", width: "20%"},
                 {"data": "s_depart", width: "10%"},
-                {"data": "i_updatetime", width:"10%", render: function (val) {
+                {
+                    "data": "i_updatetime", width: "10%", render: function (val) {
                         var dt = new Date()
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd hh:mm:ss")
-                    }},
+                    }
+                },
             ],
         });
         $('#modal-associated').modal("show")
     }
+
     function saveTagrule() {
         var ids = [];
         var table = $('#cuserRule').dataTable();

+ 119 - 96
src/web/templates/private/second_push_create.html

@@ -20,7 +20,8 @@
         <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>
                 </ul>
                 <div class="tab-content">
                     <div class="tab-pane active" id="tab_1">
@@ -29,16 +30,20 @@
                                 <div class="box-header with-border">
                                     <i class="fa fa-tag"></i>
                                     <h3 class="box-title">用户基本信息</h3>
-                                    <a class="btn btn-primary btn-sm saveuser" style="float: right;margin-top: 7px;margin-right: 10px" onclick="saveCuser()"><i class="fa fa-fw fa-file-text fa-lg"></i>保存</a>
+                                    <a class="btn btn-primary btn-sm saveuser"
+                                       style="float: right;margin-top: 7px;margin-right: 10px" onclick="saveCuser()"><i
+                                                class="fa fa-fw fa-file-text fa-lg"></i>保存</a>
                                 </div>
                                 <div class="box-body">
                                     <div class="form-group">
-                                        <label class="col-sm-2 control-label"><span style="color:red;">* </span>客户名称</label>
+                                        <label class="col-sm-2 control-label"><span
+                                                    style="color:red;">* </span>客户名称</label>
                                         <div class="col-sm-2">
                                             <input type="text" class="form-control" id="customername" placeholder="公司名称"
                                                    value="{{.T.data.s_name}}" required disabled>
                                         </div>
-                                        <label class="col-sm-2 control-label"><span style="color:red;">* </span>销售人员</label>
+                                        <label class="col-sm-2 control-label"><span
+                                                    style="color:red;">* </span>销售人员</label>
                                         <div class="col-sm-2">
                                             <input type="text" class="form-control" id="seller" placeholder="销售人员名称"
                                                    value="{{.T.data.s_salesperson}}" required disabled>
@@ -58,10 +63,11 @@
                                             <div class="form-group">
                                                 <label class="col-sm-2 control-label">发送邮箱</label>
                                                 <div class="col-sm-2">
-                                                    <input type="text" class="form-control" id="sendMail" placeholder="发送邮箱"
+                                                    <input type="text" class="form-control" id="sendMail"
+                                                           placeholder="发送邮箱"
                                                            value="{{.T.data.sendMail}}">
                                                 </div>
-                                               <label class="col-sm-2 control-label ">字段包</label>
+                                                <label class="col-sm-2 control-label ">字段包</label>
                                                 <div class="col-sm-2">
                                                     <select class="form-control selectpicker" id="extfiledselect">
                                                         <option value="2">高级字段包</option>
@@ -90,7 +96,7 @@
                                                 <label class="col-sm-2 control-label ">结束时间</label>
                                                 <div class="col-sm-2">
                                                     <div class="wui-content">
-                                                        <div class="wui-area" id="endtime" >
+                                                        <div class="wui-area" id="endtime">
                                                             <wui-date
                                                                     format="yyyy-mm-dd hh:mm:ss"
                                                                     placeholder="请选择或输入结束日期"
@@ -160,7 +166,7 @@
                                 <th>修改时间</th>
                                 <th>部门状态</th>
                                 <th>规则状态</th>
-                                <th class="hidden">规则id  </th>
+                                <th class="hidden">规则id</th>
 
                             </tr>
                             </thead>
@@ -192,11 +198,11 @@
     var c_id = getParam("id");
     var s_pushid = getParam("s_pushid");
     var iscomplete = getParam("complete");
-    if (history_rule !== null){
-        if (history_rule.length>0){
+    if (history_rule !== null) {
+        if (history_rule.length > 0) {
             html = "";
             var num = 1;
-            for (var i=0;i<history_rule.length;i++){
+            for (var i = 0; i < history_rule.length; i++) {
                 var selected_rule = {};
                 selected_rule.department_name = history_rule[i].s_depart_name;
                 selected_rule.rule_name = history_rule[i].s_name;
@@ -209,12 +215,12 @@
                 rules_id.push(history_rule[i]._id);
                 selected_rules.push(selected_rule);
             }
-            if (selected_rules.length>0){
+            if (selected_rules.length > 0) {
                 $(".selected-rules").html(html);
-                for (var i=0;i<selected_rules.length;i++){
-                    html += '<tr><td>'+num+'</td><td>'+selected_rules[i].department_name+'</td><td>'+selected_rules[i].rule_name+'</td><td>'+selected_rules[i].update_time+'</td>'+'<td>'+selected_rules[i].department_status+'</td>'+'<td>'+selected_rules[i].rule_status+'</td>';
+                for (var i = 0; i < selected_rules.length; i++) {
+                    html += '<tr><td>' + num + '</td><td>' + selected_rules[i].department_name + '</td><td>' + selected_rules[i].rule_name + '</td><td>' + selected_rules[i].update_time + '</td>' + '<td>' + selected_rules[i].department_status + '</td>' + '<td>' + selected_rules[i].rule_status + '</td>';
                     // if (selected_rules[i].isinc == "true"){
-                    html += '<td><a style="margin-left:10px" class="btn btn-danger delete-button" eid="'+selected_rules[i].rule_id+'" onclick="del_selected_rule(this)">删除</a></td>'
+                    html += '<td><a style="margin-left:10px" class="btn btn-danger delete-button" eid="' + selected_rules[i].rule_id + '" onclick="del_selected_rule(this)">删除</a></td>'
                     // html += '<td></td>'
                     // html += '<td></td>'
                     num++
@@ -226,23 +232,23 @@
 
     $(document).ready(function () {
         //起始时间
-        if (dataMap.starttime != 0&&typeof (dataMap.starttime)!="undefined") {
+        if (dataMap.starttime != 0 && typeof (dataMap.starttime) != "undefined") {
             var dt = new Date();
             dt.setTime(parseInt(dataMap.starttime) * 1000);
             $('#starttime').find("input").val(dt.format("yyyy-MM-dd hh:mm:ss"));
         }
         //结束时间
-        if (dataMap.endtime != 0 &&typeof (dataMap.endtime)!="undefined") {
+        if (dataMap.endtime != 0 && typeof (dataMap.endtime) != "undefined") {
             var dt = new Date();
             dt.setTime(parseInt(dataMap.endtime) * 1000);
             $('#endtime').find("input").val(dt.format("yyyy-MM-dd hh:mm:ss"));
         }
         $('#extfiledselect').val(dataMap.i_extfieldstype);
-        if (iscomplete == "1"){
-            $('#starttime').css("pointer-events","none");
-            $('#endtime').css("pointer-events","none");
-            $("#sendMail").attr("disabled",true);
-            $("#extfiledselect").attr("disabled",true);
+        if (iscomplete == "1") {
+            $('#starttime').css("pointer-events", "none");
+            $('#endtime').css("pointer-events", "none");
+            $("#sendMail").attr("disabled", true);
+            $("#extfiledselect").attr("disabled", true);
             $(".saveuser").hide();
             $(".delete-button").hide();
             $(".select-button").hide();
@@ -251,21 +257,21 @@
         if (dataMap.i_state == 0) {
             $('.tab_2').hide()
             $('#pushDiv').hide()
-        }else {
+        } else {
             tagruleArr = {{.T.tagrule}}
-            $('#pushSwitch').bootstrapSwitch({
-                onText: "开启",
-                offText: "关闭",
-            })
+                $('#pushSwitch').bootstrapSwitch({
+                    onText: "开启",
+                    offText: "关闭",
+                })
             if (dataMap.i_push && dataMap.i_push == 1) {
                 $('#pushSwitch').bootstrapSwitch('state', true);
-            }else {
+            } else {
                 $('#pushSwitch').bootstrapSwitch('state', false);
             }
             $('#pushModelSelect').val(dataMap.i_pushmodel)
             if (dataMap.i_pushtype == 0) {
                 $('#pushTypeSelect').val(0)
-            }else {
+            } else {
                 $('#pushTypeSelect').val(1)
             }
             $("#sendMail").val(dataMap.sendMail);
@@ -289,42 +295,52 @@
             "columns": [
                 {"data": null, width: "1%"},
                 {"data": "s_name", width: "10%"},
-                {"data": "i_updatetime", width:"9%", render: function (val) {
+                {
+                    "data": "i_updatetime", width: "9%", render: function (val) {
                         var dt = new Date()
                         dt.setTime(parseInt(val) * 1000);
                         return dt.format("yyyy-MM-dd hh:mm:ss")
-                    }},
-                {"data": "i_isuse", render: function (val, a, row) {
+                    }
+                },
+                {
+                    "data": "i_isuse", render: function (val, a, row) {
                         tmp = ""
-                        if(val == 1){
-                            tmp="<a href='#' title='停用' onclick='setupTag(\""+row._id+"\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
-                        }else{
-                            tmp="<a href='#' title='启用' onclick='setupTag(\""+row._id+"\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
+                        if (val == 1) {
+                            tmp = "<a href='#' title='停用' onclick='setupTag(\"" + row._id + "\",false)'><i class='fa fa-fw fa-circle text-green'></i></a>已启用"
+                        } else {
+                            tmp = "<a href='#' title='启用' onclick='setupTag(\"" + row._id + "\",true)'><i class='fa fa-fw fa-circle text-red'></i></a>未启用"
                         }
                         return tmp
-                    }, width: "10%" },
-                {"data": "_id", width:"11%",render: function (val, a, row, pos) {
+                    }, width: "10%"
+                },
+                {
+                    "data": "_id", width: "11%", render: function (val, a, row, pos) {
                         tmp = '<div>' +
                             // '<a class="btn btn-sm btn-primary" href="/service/euser/tag/edit?id='+val+'&cid='+row.s_userid+'">编辑</a>&nbsp&nbsp'+
-                            '<a class="btn btn-sm btn-danger" onclick="delTag(\''+val+'\')">删除</a>'+
+                            '<a class="btn btn-sm btn-danger" onclick="delTag(\'' + val + '\')">删除</a>' +
                             '</div>';
                         return tmp
-                    }},
-                {"data": "_id", width:"11%",render: function (val, a, row, pos) {
+                    }
+                },
+                {
+                    "data": "_id", width: "11%", render: function (val, a, row, pos) {
                         var s = [val, row.hid]
                         tmp = '<div>' +
-                            '<a class="btn btn-sm btn-primary" onclick="associated(\''+s+'\')">关联数据范围</a>&nbsp&nbsp'+
+                            '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
                         return tmp
-                    }},
+                    }
+                },
             ],
         });
     })
+
     function cancelModel() {
         $('#modal-add-depart').modal("hide")
         $('#modal-associated').modal("hide")
         $('#modal-history').modal("hide")
     }
+
     //表格全选
     function allSelect(obj) {
         if ($(obj).is(':checked')) {
@@ -332,7 +348,7 @@
             $(".history_rules tr").each(function () {
                 $(".history_rules tr").find('td').eq(0).find('input').addClass("");
                 var tag_ruleid = $(this).find('td').eq(7).text();
-                console.log("tag_ruleid",tag_ruleid)
+                console.log("tag_ruleid", tag_ruleid)
             })
 
         } else {
@@ -343,6 +359,7 @@
 
         }
     }
+
     function singleSelect(obj) {
         var tag = true;
         selectIndex.length = 0;
@@ -350,18 +367,19 @@
             if (this.checked) {
                 keyTableChecked = true;
                 selectIndex.push($(this).parents("tr").index());
-            }else {
+            } else {
                 tag = false
             }
         });
         if (tag) {
             keyTableAllChecked = true;
             $('#allCheckbox').prop("checked", true);
-        }else {
+        } else {
             keyTableAllChecked = false;
             $('#allCheckbox').prop("checked", false);
         }
     }
+
     function singleSelect1(obj) {
         var tag = true;
         selectIndex.length = 0;
@@ -369,14 +387,14 @@
             if (this.checked) {
                 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);
         }
@@ -413,43 +431,45 @@
             }
         })
     }
+
     var tagid = ""
-    
+
     function select_Depart() {
         //获取用户自定义规则
         $.ajax({
-           url:"/service/secondpush/getrules",
-           type:"POST",
-           data:{"c_id":c_id},
-           success:function (r) {
-                if (r.status=="success"){
+            url: "/service/secondpush/getrules",
+            type: "POST",
+            data: {"c_id": c_id},
+            success: function (r) {
+                if (r.status == "success") {
                     var html = ""
                     var number = 1
-                    for (var i=0;i<r.data.length;i++){
-                        if (r.data[i].department_rule.length!=0){
-                            for (var l=0;l<r.data[i].department_rule.length;l++){
-                                html += '<tr><td><input type="checkbox" id="rule_id" onclick="getcheck(this)"/></td><td>'+number+'</td><td>'+r.data[i].depart_name+'</td><td>'+r.data[i].department_rule[l].s_name+'</td><td>'+formattime(r.data[i].department_rule[l].i_updatetime)+'</td>';
-                                if (r.data[i].department_isuse ==1){
-                                    html += "<td>"+"已启用"
-                                }else{
-                                    html += "</td><td>"+"未启用"
+                    for (var i = 0; i < r.data.length; i++) {
+                        if (r.data[i].department_rule.length != 0) {
+                            for (var l = 0; l < r.data[i].department_rule.length; l++) {
+                                html += '<tr><td><input type="checkbox" id="rule_id" onclick="getcheck(this)"/></td><td>' + number + '</td><td>' + r.data[i].depart_name + '</td><td>' + r.data[i].department_rule[l].s_name + '</td><td>' + formattime(r.data[i].department_rule[l].i_updatetime) + '</td>';
+                                if (r.data[i].department_isuse == 1) {
+                                    html += "<td>" + "已启用"
+                                } else {
+                                    html += "</td><td>" + "未启用"
                                 }
-                                if (r.data[i].department_rule[l].i_isuse ==1){
-                                    html += "</td><td>"+"已启用"+"</td>"
-                                }else{
-                                    html += "</td><td>"+"未启用"+"</td>"
+                                if (r.data[i].department_rule[l].i_isuse == 1) {
+                                    html += "</td><td>" + "已启用" + "</td>"
+                                } else {
+                                    html += "</td><td>" + "未启用" + "</td>"
                                 }
-                                html += "<td hidden>"+r.data[i].department_rule[l]._id+"</td><td hidden class='is_inc'>false</td>";
+                                html += "<td hidden>" + r.data[i].department_rule[l]._id + "</td><td hidden class='is_inc'>false</td>";
                                 number++
                             }
                         }
                     }
                     $(".history_rules").html(html)
                 }
-           }
+            }
         });
         $("#modal-history").modal("show");
     }
+
     function getParam(name) {
         var search = document.location.search;
         // alert(search);
@@ -469,8 +489,9 @@
         }
         return items;
     };
+
     function formattime(date) {
-        let _date = new Date(parseInt(date)*1000);
+        let _date = new Date(parseInt(date) * 1000);
         let y = _date.getFullYear();
         let m = _date.getMonth() + 1;
         m = m < 10 ? ('0' + m) : m;
@@ -481,24 +502,24 @@
 
         return dates;
     }
-    
+
     function saveHistoryRule(e) {
         var nowDate = new Date();
         $(".history_rules tr").each(function () {
             var chk = $(this).find('td').eq(0).find("#rule_id");
-            if (chk.hasClass('checked')){
+            if (chk.hasClass('checked')) {
                 var selected_rule = new Object()
                 var rule_id = $(this).find('td').eq(7).text();
-                if(rules_id.indexOf(rule_id)>-1){
+                if (rules_id.indexOf(rule_id) > -1) {
                     console.log("元素存在")
-                }else{
+                } else {
                     selected_rule.department_name = $(this).find('td').eq(2).text();
                     selected_rule.rule_name = $(this).find('td').eq(3).text();
                     selected_rule.update_time = $(this).find('td').eq(4).text();
                     selected_rule.department_status = $(this).find('td').eq(5).text();
                     selected_rule.rule_status = $(this).find('td').eq(6).text();
                     // selected_rule.isinc = $(this).find('td').eq(8).text();
-                    selected_rule.create_time = nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+":"+nowDate.getSeconds();
+                    selected_rule.create_time = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate() + " " + nowDate.getHours() + ":" + nowDate.getMinutes() + ":" + nowDate.getSeconds();
                     selected_rule.rule_id = rule_id
                     rules_id.push(rule_id);
                     selected_rules.push(selected_rule)
@@ -508,12 +529,12 @@
         })
         var num = 1
         var html = ""
-        if (selected_rules.length>0){
+        if (selected_rules.length > 0) {
             $(".selected-rules").html(html);
-            for (var i=0;i<selected_rules.length;i++){
-                html += '<tr><td>'+num+'</td><td>'+selected_rules[i].department_name+'</td><td>'+selected_rules[i].rule_name+'</td><td>'+selected_rules[i].update_time+'</td>'+'<td>'+selected_rules[i].department_status+'</td>'+'<td>'+selected_rules[i].rule_status+'</td>';
+            for (var i = 0; i < selected_rules.length; i++) {
+                html += '<tr><td>' + num + '</td><td>' + selected_rules[i].department_name + '</td><td>' + selected_rules[i].rule_name + '</td><td>' + selected_rules[i].update_time + '</td>' + '<td>' + selected_rules[i].department_status + '</td>' + '<td>' + selected_rules[i].rule_status + '</td>';
                 // if (selected_rules[i].isinc == "true"){
-                html += '<td><a style="margin-left:10px" class="btn btn-danger delete-button" eid="'+selected_rules[i].rule_id+'" onclick="del_selected_rule(this)">删除</a></td>'
+                html += '<td><a style="margin-left:10px" class="btn btn-danger delete-button" eid="' + selected_rules[i].rule_id + '" onclick="del_selected_rule(this)">删除</a></td>'
                 // html += '<td><button class="btn btn-danger" onclick="del_selected_rule('+selected_rules[i].rule_id+')">删除</button></td>'
                 // }else{
                 // html += "<td></td>"
@@ -525,36 +546,38 @@
         $(".selected-rules").append(html);
         $("#modal-history").modal("hide");
         $.ajax({
-            url:"/service/secondpush/saverule",
-            type:"POST",
-            data:{'rulesid':rules_id.join(','),'userid':c_id,"s_pushid":s_pushid},
-            traditional:true,
+            url: "/service/secondpush/saverule",
+            type: "POST",
+            data: {'rulesid': rules_id.join(','), 'userid': c_id, "s_pushid": s_pushid},
+            traditional: true,
         })
     }
+
     function getcheck(e) {
         $(e).toggleClass("checked")
     }
-    $("#pushTypeSelect").on("change",function(){
-            selectid = $("option:selected",this).val();//需求主键
-            if (selectid == 0){
-                $(".sendmail").show()
-            }else{
-                $(".sendmail").hide()
-            }
 
-        });
+    $("#pushTypeSelect").on("change", function () {
+        selectid = $("option:selected", this).val();//需求主键
+        if (selectid == 0) {
+            $(".sendmail").show()
+        } else {
+            $(".sendmail").hide()
+        }
+
+    });
 
     //删除选中规则
     function del_selected_rule(obj) {
         var res = confirm("确定删除?")
-        if(res){
+        if (res) {
             var val = $(obj).attr("eid");
             $.ajax({
-                url:"/service/customer/secondpush/delrule",
-                type:"POST",
-                data:{'id':val,"s_pushid":s_pushid},
-                success:function (r) {
-                    if(r.success){
+                url: "/service/customer/secondpush/delrule",
+                type: "POST",
+                data: {'id': val, "s_pushid": s_pushid},
+                success: function (r) {
+                    if (r.success) {
                         window.location.reload();
                     }
                 }