@{
    ViewBag.Title = "公告信息";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="centerdiv">
        <div class="wrapper wrapper-content">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <table class="table table-bordered table-striped table-hover">
                        <tr>
                            <td width="5%">时间：</td>
                            <td width="10%">
                                <input id="BEGINDATE" onfocus="WdatePicker({ isShowClear: true, readOnly: true })" type="text" class="form-control" style="width:150px" />
                            </td>
                            <td>
                                <input id="ENDDATE" onfocus="WdatePicker({ isShowClear: true, readOnly: true })" type="text" class="form-control" style="width:150px" />
                            </td>
                            <td width="5%">
                                标题：
                            </td>
                            <td width="10%">
                                <input id="title" type="text" class="form-control" style="width:150px" />
                            </td>
                            <td>
                                <button onclick="serach()" class="btn btn-default"><i class="glyphicon glyphicon-search"></i> 查询</button> <button onclick="NewNotice()" class="btn btn-default"><i class="glyphicon glyphicon-plus-sign"></i> 新增</button>
                            </td>
                        </tr>
                    </table>
                    <table id="NoticeTable"  data-mobile-responsive="true"></table>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function today() {//取当前时间
            var today = new Date();
            var h = today.getFullYear();
            var m = today.getMonth() + 1;
            var d = today.getDate();
            if (m < 10) {
                m = "0" + m;
            }
            if (d < 10) {
                d = "0" + d;
            }
            return h + "-" + m + "-" + d;
        }
        function NewNotice() {
            layer.open({
                type: 2,
                title: '<i class="glyphicon glyphicon-plus-sign"></i> 新增公告',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '90%'],
                content: '../DealerEdition/UpdateNotice'
            });
        }
        function See(noticeid, createtime, begindate, enddate, content, image, title) {
            layer.open({
                type: 2,
                title: '<i class="glyphicon glyphicon-plus-sign"></i> 预览公告',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '90%'],
                content: '../DealerEdition/UpdateNotice?noticeid=' + noticeid + '&createtime=' + createtime + '&begindate=' + begindate + '&enddate=' + enddate + '&content=' + content + '&title=' + title + '&see=true&image=' + image
            });
        }
        function Edit(noticeid, createtime, begindate, enddate, content, image, title) {
            layer.open({
                type: 2,
                title: '<i class="glyphicon glyphicon-plus-sign"></i> 编辑公告',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '90%'],
                content: '../DealerEdition/UpdateNotice?noticeid=' + noticeid + '&createtime=' + createtime + '&begindate=' + begindate + '&enddate=' + enddate + '&content=' + content + '&title=' + title + '&edit=true&image=' + image
            });
        }
        function Del(noticeid) {
            layer.confirm("确认删除？", function (enter) {//删除前提示
                if (enter) {
                    $.ajax({
                        url: "../DealerEdition/DelNoticeFunction",
                        dataType: "text",
                        data: { noticeid: noticeid },
                        type: "post",
                        success: function (data) {//
                            $('#NoticeTable').bootstrapTable('refresh');
                            layer.msg(data, { time: 2000 })
                            layer.close(index); //再执行关闭
                        },
                        error: function (data) {
                            layer.msg(data, { time: 2000 })
                            layer.close(index); //再执行关闭
                        }
                    });
                    layer.close(index);
                }
            })
        }
        function serach() {
            $("#NoticeTable").bootstrapTable('refresh', {
                url: '../DealerEdition/GetNoticesList',
                queryParams: function (params) {
                    return {
                        pagesize: params.limit,//页面大小
                        page: params.offset, //页码
                        begindate: $("#BEGINDATE").val(),
                        enddate: $("#ENDDATE").val(),
                        title: $("#title").val()
                    };
                }
            });
            //$('#NoticeTable').bootstrapTable("refresh", { url: '../DealerEdition/GetNoticesList?begindate=' + $("#BEGINDATE").val() + '&enddate=' + $("#ENDDATE").val() + '&title=' + $("#title").val() });
        }
        $(function () {
            $("#BEGINDATE").val(today());
            $("#ENDDATE").val(today());
            $('#NoticeTable').bootstrapTable({//线路信息
                url: '../DealerEdition/GetNoticesList',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                toolbar: '',                //工具按钮用哪个容器
                striped: false,                      //是否显示行间隔色
                pagination: true,                   //是否显示分页（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [15, 30, 50],        //可供选择的每页的行数（*）
                minimumCountColumns: 2,  //最少允许的列数
                //height: "100%",               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "",            //每一行的唯一标识，一般为主键列
                clickToSelect: true,              //是否启用点击选中行
                sortable: false,                     //是否启用排序
                silentSort: false,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                strictSearch: false,
                paginationFirstText: '首页',
                paginationLastText: '末页',
                paginationPreText: '上一页',
                paginationNextText: '下一页',
                showColumns: false,            //是否显示所有的列
                showRefresh: false,              //是否显示刷新按钮
                showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                queryParams: function (params) {
                    return {
                        pagesize: params.limit,//页面大小
                        page: params.offset, //页码
                        begindate: $("#BEGINDATE").val(),
                        enddate: $("#ENDDATE").val(),
                        title: $("#title").val()
                    };
                },//传递参数（*）
                columns:
                [
                    { field: "NOTICEID", title: 'NOTICEID'}, 
                    { field: "BEGINDATE", title: 'BEGINDATE'}, 
                    { field: "ENDDATE", title: 'ENDDATE'}, 
                    { field: "NOTICECONTENT", title: 'NOTICECONTENT'}, 
                    { field: "IMAGE", title: 'NOTICEID'}, 
                    { field: "NUMBER", title: "序号", width: "2%", align: "center", formatter: function (value, row, index) {
                        var pageNumber = $('#NoticeTable').bootstrapTable('getOptions').pageNumber;
                        var pageSize = $('#NoticeTable').bootstrapTable('getOptions').pageSize;
                        return (pageNumber - 1) * pageSize + index + 1;
                    }
                    },
                    { field: "CREATETIME", title: "创建时间",width: "15%", align: "center" },
                    { field: "LOGINID", title: "LOGINID",width: "15%", align: "center" },
                    { field: "NOTICETITLE", title: "公告标题",width: "20%", align: "center" },
                    //{ field: "OPERATION", title: "操作", rowspan: 1, colspan: 3, valign: "middle", align: 'center' }],
                    {
                        field: "SEE", title: "预览", width: "7%", align: 'center', formatter: function (value, row, index) {
                            var strhtml = '<button class="btn btn-default" onClick="See(\'' + row.NOTICEID + '\',\'' + row.CREATETIME + '\',\'' + row.BEGINDATE + '\',\'' + row.ENDDATE + '\',\'' + row.NOTICECONTENT + '\',\'' + row.IMAGE + '\',\'' + row.NOTICETITLE + '\')"><i class="glyphicon glyphicon-edit"></i> 预览</button>';
                            return strhtml;
                        }
                    }, 
                    {
                        field: "EDIT", title: "编辑", width: "7%", align: 'center', formatter: function (value, row, index) {
                            var strhtml = '<button class="btn btn-default" onClick="Edit(\'' + row.NOTICEID + '\',\'' + row.CREATETIME + '\',\'' + row.BEGINDATE + '\',\'' + row.ENDDATE + '\',\'' + row.NOTICECONTENT + '\',\'' + row.IMAGE + '\',\'' + row.NOTICETITLE + '\')"><i class="glyphicon glyphicon-edit"></i> 编辑</button>';
                            return strhtml;
                        }
                    }, 
                    {
                        field: "DELETE", title: "删除", width: "7%", align: 'center', formatter: function (value, row, index) {
                            var strhtml = '<button class="btn btn-default" onClick="Del(\'' + row.NOTICEID + '\')"><i class="glyphicon glyphicon-trash"></i> 删除</button>';
                            return strhtml;
                        }
                    }
                ]
            });
            //隐藏列
            $('#NoticeTable').bootstrapTable('hideColumn', 'NOTICEID');
            $('#NoticeTable').bootstrapTable('hideColumn', 'LOGINID');
            $('#NoticeTable').bootstrapTable('hideColumn', 'BEGINDATE');
            $('#NoticeTable').bootstrapTable('hideColumn', 'ENDDATE');
            $('#NoticeTable').bootstrapTable('hideColumn', 'NOTICECONTENT');
            $('#NoticeTable').bootstrapTable('hideColumn', 'IMAGE');
        })
    </script>
</body>