Jquery右键菜单(jqueryeasyui)

相高谊
2023-12-01

Jquery右键菜单(jqueryeasyui)

直接贴出页面html,部分敏感内容去掉,只是示例,不能运行

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Reply.aspx.cs" Inherits="Admin.Reply" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>评论的回复</title>
    <script src="/Js/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="/Js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

    <link href="/Style/defaults.css" rel="stylesheet" type="text/css" />
    <link href="/Js/jqueryeasyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="/Js/jqueryeasyui/themes/icon.css" rel="stylesheet" />
    <script src="Js/jqueryeasyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <form id="form1" runat="server">
        
            <div>
                请输入搜索关键字:
            <input id="tbusername" type="text" size="20" style="margin-left: 5px;" />
                时间:<input id="tbBeginTime" value="<%=GetCurMonthDay() %>" style="width: 150px; height: 15px;" class="Wdate" οnfοcus="WdatePicker({el:'tbBeginTime',dateFmt:'yyyy-MM-dd HH:mm:ss', maxDate:'%y-%M-%d 00:00:00',minDate:'%y-#{%M-2}-%d 00:00:00'})" /> <span runat="server" id="endtime">至</span>
                <input id="tbEndTime" value="<%=DateTime.Now.ToString("yyyy-MM-dd 23:59:59") %>" style="width: 150px; height: 15px;" class="Wdate" οnfοcus="WdatePicker({el:'tbEndTime',dateFmt:'yyyy-MM-dd HH:mm:ss', maxDate:'%y-%M-%d 23:59:59',minDate:'%y-#{%M-2}-%d 23:59:59'})" />

                <input id="bntSearch" value="搜索" type="button" style="margin-left: 5px;" />
            </div>
        <div id="divData">
            <table id="tabdata" class="hover">
                <thead>
                    <tr>
                        <td style="width: 5%">
                            <input type="checkbox" id="chkall" name="chkall" value="0" />
                        </td>
                        <td style="width: 5%">用户Id
                        </td>
                        <td style="width: 12%">用户名
                        </td>
                        <td style="width: 12%">回复时间
                        </td>
                        <td style="width: 20%">评论内容
                        </td>
                        <td>回复内容
                        </td>
                        
                        <td style="width: 5%">是否显示
                        </td>
                        <td style="width: 5%">操作
                        </td>
                    </tr>
                </thead>
                <tbody id="datadetails">
                </tbody>
            </table>
        </div>
        <div id="tb_page" class="hm_tb_page" style="display: block;">
        </div>
        <div id="rightmenu" class="easyui-menu">
            <div data-options="iconCls:'icon-ok'" οnclick="checkPass(10)">选中审核</div>
            <div data-options="iconCls:'icon-ok'" οnclick="checkPass(11)">全部审核</div>
            <div data-options="iconCls:'icon-bforbid'" οnclick="checkPass(20)">选中禁止</div>
            <div data-options="iconCls:'icon-bforbid'" οnclick="checkPass(21)">全部禁止</div>
        </div>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            rightHandEvent();
            BindData(pageIndex, pageSize);
            $("#bntSearch").click(function () {
                BindUsersLog(pageIndex, pageSize);
            });
        });
        function BindData(idx, size) {
            var data = {};
            data.method = "GetData";
            data.name = $("#tbusername").val();
            data.startTime = $("#tbBeginTime").val();
            data.endTime = $("#tbEndTime").val();
            data.pageIndex = idx;
            data.pageSize = size;
            ajaxProcess("/Reply.aspx?", data, callSuccess, callError);
            function callSuccess(oRet) {
                var result = oRet.Result;
                if (result != null) {
                    console.log(result);
                    var html = [];
                    var tr = "<tr><td><input type='checkbox' name='chkId' value='{Id}' /></td><td>{UserId}</td><td>{Name}</td><td>{CreateTime}</td><td>{CContents}</td><td>{Contents}</td><td>{IsShow}</td><td>{Oper}</td></tr>";
                    $(result.Rows).each(function () {
                        this.Oper = "";
                        this.IsShow = this.IsShow ? "是" : "否";
                        html.push(tr.format(this));
                    });
                    $("#datadetails").html(html);
                }

                Pagebars($("#tb_page").show(), result.PageCount, pageSize, result.PageIndex, function (idx, size) { BindUsersLog(idx, size); }); //分页
            }
            function callError(e) {
                alert(e);
            }
        }
    </script>
    <script type="text/javascript">
        $("#chkall").click(function () {
            if (this.checked) {
                $("input[name='chkId']").each(function () {
                    this.checked = true;
                });
            } else {
                $("input[name='chkId']").each(function () {
                    this.checked = false;
                });
            }
        });
    </script>
    <script type="text/javascript">
        function checkPass(val) {
            var isShow = 0;
            if (val == 10 || val == 11) {
                isShow = 1;
            }
            var listId = "";

            if (val == 10 || val == 20) {
                $("input[name='chkId']").each(function () {
                    if (this.checked) {
                        listId += this.value + ",";
                    }
                });
            }
            if (val == 11 || val == 21) {
                $("input[name='chkId']").each(function () {
                    listId += this.value + ",";
                });
            }
            
            if (listId.length < 1) {
                showDialog("请选择要操作的行");
                return;
            }

            var data = {};
            data.method = "Audit";
            data.ids = listId;
            data.isShow = isShow;
            data.operType = val;

            ajaxProcess("?", data, function (oRet) {
                if (oRet.Error || oRet.Result < 0) {
                    showDialog(oRet.Error || "操作失败");
                    return;
                }
                showDialog("操作成功", 1, 0, "提示", function () {
                    window.location.href = "Reply.aspx";
                });
            }, function (ex) { alert(ex); });
        }

        function rightHandEvent() {
            $("#divData").bind('contextmenu', function (e) {
                $('#rightmenu').menu('show', {
                    left: e.pageX,
                    top: e.pageY
                });

                return false;
            });

        }
    </script>

</body>
</html>
后台部分代码

        /// <summary>
        /// 评论回复
        /// </summary>
        public object GetData(string name, string startTime, string endTime, int pageIndex, int pageSize = 25)
        {
            try
            {
                if (!string.IsNullOrEmpty(name))
                {
                    name = name.Trim().SqlFilter();
                }

                ...........
                return new PagedResult(dv, pageSize, pageIndex);
            }
            catch (Exception e)
            {
                Log.Error(e.Message + e.StackTrace);
            }
            return null;
        }


        public object Audit(string ids, int isShow,int operType)
        {
            ids = ids.SqlFilter();
            if (!string.IsNullOrEmpty(ids))
            {
                var sql = "UPDATE [dbo].[T_CircleReply] set IsShow='{0}' where Id in({1})".Formats(isShow, ids.TrimEnd(','));
                return Db.ExecuteNonQuery(sql);
            }
            else
            {
                return true;
            }
        }


 类似资料: