• easyUI demo2


    图片:

                 

    代码:

    jsp

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <html>
    <head>
        <base href="<%=basePath%>">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>报警邮件管理</title>
        <link href="css/default.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="easyui/easyui/themes/default/easyui.css" />
        <link rel="stylesheet" type="text/css" href="easyui/easyui/themes/icon.css" />
        <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="easyui/js/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="easyui/js/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript" src="config_js/cfgEmail.js?v=1.9"></script>
        <style type="text/css">
                .a{text-align:right;padding-top: 10px;}
                .b{padding-top: 10px;}
                .fast_search{margin-bottom: 6px;height:auto;width:100%}
                .fast_textbox{width: 300px;float:left;}
                .fast_button{width: 500px;float:left;}
                .advanced_search{margin-bottom:6px;height:auto;width:100%;float:right;margin-top:6px;display:none;}
                .advanced_parent{float:left;margin-bottom: 6px;}
                .explain{width:40px;text-align:right;float:left;margin-top: 3px;}
                .explain60{width:70px;text-align:right;float:left;margin-top: 3px;}
                .content{width: 150px;float:left;}
                .content select {width:140px}
                .floatsort{float:left;width: 130px;}
                .batchServer{width: 100%;float: left;margin-top: 10px;}
                .textbox{width: 140px;}
        </style>
    </head>
    <body style="overflow-y: hidden;">
        <div id="tb" style="background:white">
            <div style="padding-top:10px;margin-left:5px;margin-bottom:8px">
                <a href="javascript:void(0)" class="easyui-linkbutton" style="margin-right:3px;" id="addButton" iconCls="icon-add" >添加</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" style="margin-right:3px;" id="batchOpenEmail" iconCls="icon-edit">批量开启邮件</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" style="margin-right:3px;" id="batchStopEmail" iconCls="icon-edit">批量暂停邮件</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" style="margin-right:3px;" id="batchEdit" iconCls="icon-edit">批量修改</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" style="margin-right:3px;" id="ipConfig" iconCls="icon-add" onclick="ipConfig()">例外邮件暂停</a>
            </div>
        </div>
        <table id="roleList">
               <thead>
              <tr>
                  <th data-options="field:'ck',checkbox:true"></th>
                  <th data-options="field:'p_type',70,align:'center',formatter:p_type">产品类型</th>
                  <th data-options="field:'email_title',100,align:'center'">邮件标题</th>
                  <th data-options="field:'email_description',100,align:'center'">邮件描述</th>
                  <th data-options="field:'email_interval',40,align:'center'">发送间隔(分)</th>
                  <th data-options="field:'email_addr',120,align:'center'">收件人</th>
                  <th data-options="field:'next_email_time',100,align:'center'">下次发送时间</th>
                  <th data-options="field:'is_email',55,align:'center',formatter:is_email,formatter:emailFlag,styler:emailColor">状态</th>
                  <th data-options="field:'operate',90,align:'center',formatter:formatOper">操作</th>
              </tr>
            </thead>
        </table>
        <div id="titledialogs" class="easyui-dialog" style="550px;height:520px;pxpadding:10px;">
            <form id="addForm" method="post" style="text-align:-webkit-center;">
                <table class="servertable" style="padding-top:5px">
                    <tr>
                        <td></td>
                        <td style="font-size: 8px;">&nbsp;例:CPU预警(KVM_CPU_WARNING),CPU报警(KVM_CPU_ALARM)</td>
                    </tr>
                    <tr>
                        <td class="a">邮件类型:</td>
                        <td class="b">&nbsp;<input class="easyui-textbox" id="emailType" name="cfgEmail.emailType" style="240px" data-options="prompt:'例:预警(XXX_CPU_WARNING),报警(XXX_CPU_ALARM)'"></input></td>
                    </tr>
                    <tr>
                        <td class="a">邮件描述:</td>
                        <td class="b">&nbsp;<input class="easyui-textbox" id="emailDescription" name="cfgEmail.emailDescription" style="240px" data-options=""></input></td>
                    </tr>
                    <tr>
                        <td class="a">邮件标题:</td>
                        <td class="b">&nbsp;<input class="easyui-textbox" id="emailTitle" name="cfgEmail.emailTitle" style="240px" data-options=""></input></td>
                    </tr>
                    <tr>
                        <td class="a">监控类型:</td>
                        <td class="b">&nbsp;<select class="easyui-combotree" id="alarmChar" name="cfgEmail.alarmChar" style=" 240px; height: 24px;">
                             </select></td>
                    </tr>
                    <tr>
                        <td class="a">发送时间间隔:</td>
                        <td class="b">&nbsp;<input class="easyui-textbox" id="emailInterval" name="cfgEmail.emailInterval" style="240px" data-options=""></input>(分)</td>
                    </tr>
                    <tr>
                        <td class="a">下次执行时间:</td>
                        <td class="b">&nbsp;<input class="easyui-datetimebox" id="nextEmailTime" name="cfgEmail.nextEmailTime" style="240px" editable="false" data-options=""></input></td>
                    </tr>
                    <tr>
                        <td class="a">发送邮件:</td>
                        <td class="b"><input id="yj1" type="radio" name="cfgEmail.isEmail" value="1" checked="checked"/>发送
                                       <input id="yj2" type="radio" name="cfgEmail.isEmail" value="0"/>不发送</td>
                    </tr>
                    <tr>
                        <td class="a">发送恢复邮件:</td>
                        <td class="b"><input id="hfyj1" type="radio" name="cfgEmail.isRegainEmail" value="1"/>发送
                                       <input id="hfyj2" type="radio" name="cfgEmail.isRegainEmail" value="0" checked="checked"/>不发送</td>
                    </tr>
                    <tr>
                        <td class="a">收件人邮箱:</td>
                        <td class="b">&nbsp;<input class="easyui-textbox" id="emailAddr" name="cfgEmail.emailAddr" style="300px;height:100px;" data-options="prompt:'多个邮件用英文逗号隔开',multiline:true"></input></td>
                    </tr>
                    <input type="hidden" name="id"/>
                </table>
            </form>
        </div>
        <div id="cfgEmailAddDialogs" class="easyui-dialog" style="1100px;height:550px;padding:10px;">
            <div id="tbb" style="background:white">
                <form id="cfgEmailAddForm" method="post" style="text-align:-webkit-center;">
                    <div style="font-size: 16px;margin-top: 10px;">
                        时间类型:<select class="easyui-combobox" id="controlType" style="180px"  name="cfgEmail.controlType" editable="false" required="required" data-options="panelHeight:'auto'">
                                <option value="ONLYONE">时间段</option>
                                <option value="EVERYDAY">每天</option>
                            </select>
                        &nbsp;开始时间:<input class="easyui-datetimebox" style=" 180px;" name='cfgEmail.beginTime' editable="false" id="stime"/>
                        &nbsp;结束时间:<input class="easyui-datetimebox" style=" 180px;" name='cfgEmail.endTime' editable="false" id="etime"/>
                        <input type="hidden" id="addEmailType" name="cfgEmail.emailType">
                        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="addCfgEmailAdd()">保存</a>
                    </div>
                </form>
            </div>
            <table id="cfgEmailAddList">
                   <thead>
                  <tr>
    <!--                   <th data-options="field:'ck',checkbox:true"></th>   -->
                      <th data-options="field:'email_type',70,align:'center'">邮件类型</th>
                      <th data-options="field:'control_type',40,align:'center',formatter:control_type">时间类型</th>
                      <th data-options="field:'begin_time',70,align:'center'">开始时间</th>
                      <th data-options="field:'end_time',70,align:'center'">结束时间</th>
                      <th data-options="field:'is_use',40,align:'center',formatter:is_use,formatter:useFlag,styler:useColor">状态</th>
                      <th data-options="field:'operate',35,align:'center',formatter:formatOperAdd">操作</th>
                  </tr>    
                </thead>    
            </table>
        </div>
        <div id="emaildialos" class="easyui-dialog" title="批量修改" 
            data-options="closed:true,iconCls: 'icon-save',buttons: [
        {
            text: '保存',
            iconCls:'icon-ok',
            handler: function(){
                 $.messager.confirm('系统提示', '您确定要修改吗?', function(r){
                        if (r) {
                $('#emailForm').form('submit', {
                    url: 'config/batchUpdateCfgEmail.action',
                    onSubmit: function(){
                        var isValid = $(this).form('validate');
                        if (!isValid){
                            $.messager.progress('close');    
                        }
                        return isValid;    
                    },
                    success: function(data){
                        $.messager.progress('close');
                        $.messager.alert('系统提示', data, 'info');
                        $('#emaildialos').dialog('close');
                        loaddata();
                    }
                });
                }
                });
                }
        },
        {
            text: '取消',
            iconCls:'icon-cancel',
            handler: function(){
                $('#emaildialos').dialog('close');
            }
        }
    ]" 
                style="500px;height:310px;padding:30px;">
            <form id="emailForm">
                    <input name="id" type="hidden" id="ids">
                <table>
                    <tr>
                         <td style="text-align: right;font-size: 15px" ><input id="zt" type="checkbox" onclick="fszt()">发送状态:</td>
                         
                         <td style="font-size: 15px" ><input disabled="disabled" id="f1" type="radio" name="flag" value="1">开启
                         <input disabled="disabled" id="f2" type="radio" name="flag" value="0">关闭</td>
                    </tr>
                    <tr>
                         <td style="text-align: right;font-size: 15px" ><input id="yj" type="checkbox" onclick="yjjg()">邮件间隔:</td>
                         <td style="font-size: 15px" >&nbsp;<input disabled="disabled" id="jg" type="text" name="interval">(分)</td>
                    </tr>
                    <tr>
                         <td style="text-align: right;font-size: 15px" ><input id="sj" type="checkbox" onclick="sjr()">收件人:</td>
                         <td>&nbsp;<input id="yx" name="sjryx" readonly="readonly" class="easyui-textbox" type="text" style="300px;height:100px" data-options="prompt:'多个邮件用英文逗号隔开',multiline:true"></input></td>
                    </tr>
                </table>
            </form>
            </div>
    </body>
    </html>

    js:

    $(function(){
        // 关闭弹窗
        $('#titledialogs').dialog('close');
        $('#cfgEmailAddDialogs').dialog('close');
        //加载数据
        loaddata(); 
        //监控类型下拉框
        getMonitorItemChar();
        // 添加按钮
        $("#addButton").click(function() {
            addInfo();
        });
        //批量开启关闭邮件状态
        $("#batchOpenEmail").click(function () {
            batchChangeEmailFlag(1);
        });
        $("#batchStopEmail").click(function () {
            batchChangeEmailFlag(0);
        });
        //批量修改弹窗关闭清除表单
        $("#emaildialos").dialog({
            onClose : function() {
                $("#zt").attr("checked", false);
                $("#yj").attr("checked", false);
                $("#sj").attr("checked", false);
    //            $("input[type='radio']").removeAttr('checked');
                $("#f1").removeAttr("checked");
                $("#f2").removeAttr("checked");
                $("#f1").attr("disabled", "disabled");
                $("#f2").attr("disabled", "disabled");
                $("#jg").val("");
                $("#jg").attr("disabled", "disabled");
                $("#yx").textbox('setValue', '');
                $('#yx').textbox('readonly', true);
            }
        });
        //批量修改
        $("#batchEdit").click(function() {
            var ss = '';
            var rows = $('#roleList').datagrid('getSelections');
            if (rows == null || rows.length == 0) {
                $.messager.progress('close');
                $.messager.alert('系统提示', '请选择要批量修改的行', 'info');
                return;
            }
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                if (i == rows.length - 1) {
                    ss += row.id;
                } else {
                    ss += row.id + ',';
                }
            }
            $("#ids").val(ss);
            $('#emaildialos').dialog('open');
        });
    })
    function loaddata() {
        $('#roleList').datagrid({
            //title: '邮件配置1',
            iconCls : 'icon-ok',
    //        height:($(window).height()),
            width : '100%',
            pageSize : 15,//默认选择的分页是每页5行数据
            pageList : [ 15, 50, 100, 150 ],//可以选择的分页集合
            nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取
            striped : true,//设置为true将交替显示行背景。
            collapsible : true,//显示可折叠按钮
            toolbar : "#tb",//在添加 增添、删除、修改操作的按钮要用到这个
            url : 'config/getCfgEmailList.action',//url调用Action方法
            loadMsg : '数据装载中......',
            fit : true,
            //singleSelect:true,//为true时只能选择单行
            fitColumns : true,//允许表格自动缩放,以适应父容器
            //sortName : 'xh',//当数据表格初始化时以哪一列来排序
            //sortOrder : 'desc',//定义排序顺序,可以是'asc'或者'desc'(正序或者倒序)。
            remoteSort : false,
            pagination : true,//分页
            rownumbers : true,//行数
            onLoadSuccess : function(data) {
                $('#roleList').datagrid('fixRowHeight');
                $(".datagrid-btable tr td div").each(function() {
                    $(this).attr("title", $(this).text());
                });
                $(".addCfgEmailAddCabinet").linkbutton({
                    text : '特殊',
                    plain : true,
                    iconCls : 'icon-add'
                });
                $(".editCabinet").linkbutton({
                    text : '修改',
                    plain : true,
                    iconCls : 'icon-edit'
                });
                $(".delCabinet").linkbutton({
                    text : '删除',
                    plain : true,
                    iconCls : 'icon-remove'
                });
            },
        });
    }
    function is_email(val, row, index) {
        if (val == 0) {
            return "暂停";
        } else if (val == 1) {
            return "发送";
        }
    }
    function emailColor(val, row, index) {
        if (val == 1) {
            return 'background:#B9F3B9';
        } else if (val == 0) {
            return 'background:#FFCCCC';
        }
    }
    function emailFlag(val, row, index) {
        if (val == 1) {
            var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
            return '<a href="javascript:void(0)" style = "color:green;text-decoration:underline;" onclick="changeEmailFlag('+$row+',0)">已启用</a>';
        } else if (val == 0) {
            var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
            return '<a href="javascript:void(0)" style = "color:red;text-decoration:underline;" onclick="changeEmailFlag('+$row+',1)">已停止</a>';
        }
    }
    function changeEmailFlag(row, flag) {
        $.ajax({
            url : "config/updateCfgEmailFlag.action",
            type : "POST",
            data : {
                "id" : row.id,
                "cfgEmail.isEmail" : flag,
            },
            timeout : 180000,
            success : function(data) {
                loaddata();
            }
        });
    }
    function batchChangeEmailFlag(flag) {
        var id = '';
        var rows = $('#roleList').datagrid('getSelections');
        if (rows == null || rows.length == 0) {
            $.messager.progress('close');
            $.messager.alert('系统提示', '请选择要批量修改的行', 'info');
            return;
        }
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            if (i == rows.length - 1) {
                id += row.id;
            } else {
                id += row.id + ',';
            }
        }
        $.messager.confirm('系统提示', "您确定要修改邮件状态吗?", function (r) {
            if (r) {
                $.ajax({
                    url : "config/updateCfgEmailFlag.action",
                    type : "POST",
                    data : {
                        "id" : id,
                        "cfgEmail.isEmail" : flag,
                    },
                    timeout : 180000,
                    async: true,
                    success: function (data) {
                        loaddata("");
                        $.messager.progress('close');
                        $.messager.alert('系统提示', data, 'info');
                    }
                });
            }
        });
    }
    function p_type(val, row, index) {
        if (row.p_type == 1) {
            return "快云服务器";
        } else if (row.p_type == 3) {
            return "快云VPS";
        } else if (row.p_type == 4) {
            return "快云存储";
        } else if (row.p_type == 5) {
            return "虚拟主机";
        } else if (row.p_type == 6) {
            return "快云数据库";
        }
    }
    function formatOper(val, row, index) {
        var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
        return '<a href="javascript:void(0)"  class="addCfgEmailAddCabinet"  onclick="cfgEmailAddDialogs('+ $row +')"></a>'+
               '<a href="javascript:void(0)"  class="editCabinet"  onclick="editInfo('+ $row +')"></a>'+
               '<a href="javascript:void(0)"  class="delCabinet"  onclick="delInfo('+ $row +')"></a>';
    }
    //监控类型下拉框
    function getMonitorItemChar() {
        var tid = $("#tid").val();
        var ip = $("#ip").val();
        $.ajax({
            url:"config/getMonitorItemChar.action",
            type:"POST",
            timeout:180000,
            async:false, 
            success:function(data){
                var data = eval(data);
                $('#alarmChar').combotree({ 
                    valueField: "id", //Value字段 
                    textField: "text", //Text字段 
                    multiple: true, 
                    data: data,
                    panelHeight: 180,
                }); 
            }
        });
        //清空combotree下拉框图标
        $(".tree-icon,.tree-file").removeClass("tree-icon tree-file");
        $(".tree-icon,.tree-folder").removeClass("tree-icon tree-folder tree-folder-open tree-folder-closed");
    }
    //当前时间
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1
                + strDate + " " + date.getHours() + seperator2
                + date.getMinutes() + seperator2 + date.getSeconds();
        return currentdate;
    }
    //判断字符是否为空的方法
    function isEmpty(obj){
        if(typeof obj == "undefined" || obj == null || obj == ""){
            return true;
        }else{
            return false;
        }
    }
    //例外邮件暂停
    function ipConfig() {
        parent.$('.easyui-accordion li div').removeClass("selected");
        parent.$('.easyui-accordion li a').eq(1).parent().addClass("selected");
        parent.addTab('例外邮件暂停', 'config/ipConfig.action', 'icon-add');
    }
    //清除弹框数据
    function clearInfo() {
        $('#emailType').textbox('setValue','');
        $('#emailDescription').textbox('setValue','');
        $('#emailTitle').textbox('setValue','');
        $('#alarmChar').combotree('setValue','');
        $('#emailInterval').textbox('setValue','');
        $('#nextEmailTime').datetimebox('setValue','');
        $("#yj1").attr("checked","checked");
        $("#hfyj2").attr("checked","checked");
        $('#emailAddr').textbox('setValue','');
    }
    //添加
    function addInfo() {
        //清空表单记录
        clearInfo();
        //下次执行时间赋值
        $("#nextEmailTime").datetimebox('setValue', getNowFormatDate());
        $('#titledialogs').dialog('open').dialog({
            title : '添加报警邮件',
            iconCls : 'icon-save',
            buttons : [ {
                text : '保存',
                iconCls : 'icon-ok',
                handler : function() {
                    $.messager.confirm('系统提示', '您确定要添加吗?', function(r) {
                        if (r) {
                            if(isEmpty($("#emailType").val().trim())){
                                $.messager.alert('系统提示', '邮件类型不能为空', 'info');
                                return
                            }
                            if(isEmpty($("#emailDescription").val().trim())){
                                $.messager.alert('系统提示', '邮件描述不能为空', 'info');
                                return
                            }
                            if(isEmpty($("#emailTitle").val().trim())){
                                $.messager.alert('系统提示', '邮件标题不能为空', 'info');
                                return
                            }
                            if(isEmpty($("#alarmChar").combotree('getValue'))){
                                $.messager.alert('系统提示', '监控类型不能为空', 'info');
                                return
                            }
                            var emailInterval = $("#emailInterval").val().trim();
                            if(isEmpty(emailInterval)){
                                $.messager.alert('系统提示', '发送时间间隔不能为空', 'info');
                                return
                            }
                            if (!emailInterval.match(/[0-9]+/)) {
                                $.messager.alert('系统提示', '发送时间间隔必须为数字', 'info');
                                return;
                            }
                            if(isEmpty($("#emailAddr").val().trim())){
                                $.messager.alert('系统提示', '收件人邮箱不能为空', 'info');
                                return
                            }
                            $('#addForm').form('submit', {
                                url : 'config/addCfgEmail.action',
                                onSubmit : function() {
                                    var isValid = $(this).form('validate');
                                    if (!isValid) {
                                        $.messager.progress('close');
                                    }
                                    return isValid;
                                },
                                success : function(data) {
                                    $.messager.progress('close');
                                    $.messager.alert('系统提示', data, 'info');
                                    if (data.indexOf('成功') >= 0) {
                                        $('#titledialogs').dialog('close');
                                        loaddata();
                                    }
                                }
                            });
                        }
                    });
                }
            }, {
                text : '取消',
                iconCls : 'icon-cancel',
                handler : function() {
                    $('#titledialogs').dialog('close');
                }
            } ]
        });
    }
    //修改
    function editInfo(row) {
        $('#addForm').form('load',{'cfgEmail.emailType':row.email_type,
                                    "cfgEmail.emailDescription":row.email_description,
                                    "cfgEmail.emailTitle":row.email_title,
    //                                "cfgEmail.alarmChar":row.alarm_char,
                                    "cfgEmail.emailInterval":row.email_interval,
                                    "cfgEmail.nextEmailTime":row.next_email_time,
                                    "cfgEmail.isEmail":row.is_email,
                                    "cfgEmail.isRegainEmail":row.is_regain_email,
                                    "cfgEmail.emailAddr":row.email_addr,
                                    "id":row.id});
    //    $("#alarmChar").combotree('setValues', row.alarm_char);
        //下拉框加载数据
        var arr = [];
        if (row.alarm_char.indexOf(",") == -1) {
            var alarmChar = row.alarm_char + ',';
        }
        var alarmChar = row.alarm_char.split(',');
        for (var i = 0; i < alarmChar.length; i++) {
            arr.push(alarmChar[i]);
        }
        $("#alarmChar").combotree('setValues', arr);
        //弹出弹框
        $('#titledialogs').dialog('open').dialog({
            title:'修改报警邮件',
            iconCls: 'icon-save',
            buttons: [
                      {
                          text: '保存',
                          iconCls:'icon-ok',
                          handler: function(){
                        $.messager.confirm('系统提示', '您确定要修改吗?', function(r){
                            if (r) {
                              $('#addForm').form('submit', {
                                  url: 'config/updateCfgEmail.action',
                                  onSubmit: function(){
                                      var isValid = $(this).form('validate');
                                      if (!isValid){
                                          $.messager.progress('close');    
                                      }
                                      return isValid;    
                                  },
                                  success: function(data){
                                      $.messager.progress('close');
                                      $.messager.alert('系统提示', data, 'info');
                                      if(data.indexOf('成功') >= 0){
                                          $('#titledialogs').dialog('close');
                                          loaddata();
                                      }
                                  }
                              });
                            }
                        });
                              }
                      },
                      {
                          text: '取消',
                          iconCls:'icon-cancel',
                          handler: function(){
                              $('#titledialogs').dialog('close');
                          }
                      }
                  ]
        });
    }
    //删除
    function delInfo(row){
        if (row){  
            $.messager.confirm('系统提示', "您确定要删除该条信息吗?", function(r){
                if (r) {
                     $.ajax({
                        url:"config/delCfgEmail.action",
                        type:"POST",
                        data:{"id":row.id},
                        timeout:180000,
                        success:function(data){
                            if(data.indexOf('失败') >= 0){
                                $.messager.alert('系统提示', data, 'info');
                            }
                            loaddata();
                        }
                    });
                }
            });  
        } 
    }
    /**
     * 
     * 特殊(特殊时间内不发邮件)
     */
    //添加特殊时间内不发邮件
    function cfgEmailAddDialogs(row) {
        //获取展示数据
        cfgEmailAddList(row.email_type);
        $("#addEmailType").val(row.email_type);
        //打开弹框
        $('#cfgEmailAddDialogs').dialog('open').dialog({
            title : '添加特殊时间内不发邮件',
            iconCls : 'icon-save',
            buttons : [ 
    //                    {
    //            text : '保存',
    //            iconCls : 'icon-ok',
    //            handler : function() {
    //                $.messager.confirm('系统提示', '您确定要添加吗?', function(r) {
    //                    if (r) {
    //                    }
    //                });
    //            }
    //        }, 
            {
                text : '取消',
                iconCls : 'icon-cancel',
                handler : function() {
                    $('#cfgEmailAddDialogs').dialog('close');
                }
            } ]
        });
    }
    function cfgEmailAddList(emailType) {
        $('#cfgEmailAddList').datagrid({
            iconCls : 'icon-ok',
             '100%',
            height: '100%',
            pageSize : 15, //默认选择的分页是每页5行数据
            pageList : [ 15, 50, 100, 150 ], //可以选择的分页集合
            nowrap : true, //设置为true,当数据长度超出列宽时将会自动截取
            striped : true, //设置为true将交替显示行背景。
            collapsible : true, //显示可折叠按钮
            toolbar : "#tbb", //在添加 增添、删除、修改操作的按钮要用到这个
            url : 'config/getcfgEmailAddList.action', //url调用Action方法
            loadMsg : '数据装载中......',
    //        fit : true, //页面自适应
            singleSelect : true, //为true时只能选择单行
            fitColumns : true, //允许表格自动缩放,以适应父容器
            //sortName : 'xh',//当数据表格初始化时以哪一列来排序
            //sortOrder : 'desc',//定义排序顺序,可以是'asc'或者'desc'(正序或者倒序)。
            remoteSort : false,
            pagination : false, //分页
            rownumbers : true, //行数
            queryParams : {"cfgEmail.emailType" : emailType},
            onLoadSuccess : function(index, row) {
                //单元格超出部分隐藏并鼠标移动到单元格时弹框显示
                $(".datagrid-row td div").each(function() {
                    $(this).attr("title", $(this).text());
                });
                $('#roleList').datagrid('fixRowHeight');
                $(".delCabinetAdd").linkbutton({
                    text : '删除',
                    plain : true,
                    iconCls : 'icon-remove'
                });
            },
        })
        //去除遮罩
        $(".datagrid-mask").remove();
        $(".datagrid-mask-msg").remove();
    }
    function control_type(val, row, index) {
        if (val == "ONLYONE") {
            return "时间段";
        } else if (val == "EVERYDAY") {
            return "每天";
        }
    }
    function is_use(val, row, index) {
        if (val == 0) {
            return "关闭";
        } else if (val == 1) {
            return "开启";
        }
    }
    function useColor(val, row, index) {
        if (val == 1) {
            return 'background:#B9F3B9';
        } else if (val == 0) {
            return 'background:#FFCCCC';
        }
    }
    function useFlag(val, row, index) {
        if (val == 1) {
            var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
            return '<a href="javascript:void(0)" style = "color:green;text-decoration:underline;" onclick="changeUseFlag('+$row+',0)">已启用</a>';
        } else if (val == 0) {
            var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
            return '<a href="javascript:void(0)" style = "color:red;text-decoration:underline;" onclick="changeUseFlag('+$row+',1)">已停止</a>';
        }
    }
    function changeUseFlag(row, flag) {
        var templateId = $("#templateId").val();
        $.ajax({
            url : "config/updateCfgEmailAddFlag.action",
            type : "POST",
            data : {
                "cfgEmail.id" : row.id,
                "cfgEmail.isUse" : flag,
            },
            timeout : 180000,
            success : function(data) {
                var emailType = $("#addEmailType").val();
                cfgEmailAddList(emailType);
            }
        });
    }
    function formatOperAdd(val, row, index) {
        var $row = JSON.stringify(row).replace(/"/g,"'");//row的是一个对象
        return '<a href="javascript:void(0)" class="delCabinetAdd" onclick="delCfgEmailAdd('+$row+')"></a>';
    };
    function clearCfgEmailAddInfo() {
        $('#stime').datetimebox('setValue','');
        $('#etime').datetimebox('setValue','');
    }
    //添加
    function addCfgEmailAdd() {
        $('#cfgEmailAddForm').form('submit', {
              url: 'config/addCfgEmailAdd.action',
                onSubmit: function(){
                    var isValid = $(this).form('validate');
                    if (!isValid){
                        $.messager.progress('close');    
                    }
                    return isValid;    
                },
                success: function(data){
                    if(data.indexOf('失败') >= 0){
                        $.messager.alert('系统提示', data, 'info');
                    }
                    var emailType = $("#addEmailType").val();
                    cfgEmailAddList(emailType);
                    //清空添加数据
                    clearCfgEmailAddInfo();
                }
          });
    }
    //删除
    function delCfgEmailAdd(row){
        if (row){  
            $.messager.confirm('系统提示', "您确定要删除该条信息吗?", function(r){
                if (r) {
                     $.ajax({
                        url:"config/delCfgEmailAdd.action",
                        type:"POST",
                        data:{"id":row.id},
                        timeout:180000,
                        success:function(data){
                            if(data.indexOf('失败') >= 0){
                                $.messager.alert('系统提示', data, 'info');
                            }
                            var emailType = $("#addEmailType").val();
                            cfgEmailAddList(emailType);
                        }
                    });
                }
            });  
        } 
    }
    /**
     * 批量修改
     */
    function fszt() {
        if ($('#zt').prop("checked")) {//判断checkbox是否选中
            //选中状态
            $("#f1").removeAttr("disabled");
            $("#f2").removeAttr("disabled");
            $("#f1").attr("checked", "checked");
        } else {
            //未选中状态
            $("#f1").attr("disabled", "disabled");
            $("#f2").attr("disabled", "disabled");
            $("#f1").removeAttr("checked");
            $("#f2").removeAttr("checked");
        }
    }
    function yjjg() {
        if ($('#yj').prop("checked")) {//判断checkbox是否选中
            //选中状态
            $("#jg").removeAttr("disabled");
        } else {
            //未选中状态
            $("#jg").attr("disabled", "disabled");
        }
    }
    function sjr() {
        if ($('#sj').prop("checked")) {//判断checkbox是否选中
            //选中状态
            $('#yx').textbox('readonly', false);
        } else {
            //未选中状态
            $('#yx').textbox('readonly', true);
        }
    }
  • 相关阅读:
    golang中的GOPATH使用和简单项目配置
    无法go get,Golang手动安装依赖包【package】
    Golang入门注意事项
    C语言创建单向链表
    Linuxlinux上安装git 测试
    剖析虚幻渲染体系(14) 延展篇:现代渲染引擎演变史Part 4(结果期)
    翻译器
    [Tips] Mac Terminal配置Git使用ClashX
    [Tips] Linux ssh 基于密钥文件免密登陆
    【Notes】Mac从零开始按照oh my zsh
  • 原文地址:https://www.cnblogs.com/raitorei/p/10870015.html
Copyright © 2020-2023  润新知