/**
 * Created by Administrator on 2017/12/5 0005.
 */
/**
 * Created by Administrator on 2017/12/4 0004.
 */
$(function () {

    //查询
    //jquery data table 初始化
    var goodsTable = $("#goodsTable").DataTable({
        "paging": false,
        "select": true,
        "processing": true,
        "serverSide": true,
        "language": {
            'lengthMenu': '每页显示 _MENU_ 记录',
            'zeroRecords': '没有数据',
            'info': ' 第_PAGE_ 页/ _PAGES_页，共 _TOTAL_ 条',
            'infoEmpty': '没有符合条件的记录',
            'search': '查找',
            'infoFiltered': '(从  _MAX_ 条记录中过滤)',
            'paginate': { "first":  "首页 ", "last": "末页", "next": "下一页","previous": "上一页"}
        },
        "ajax": {
            url: rootPath + "payment/totalData",
            type:"post",
            //增加参数查询参数
            data:function(data){
                data.payment_stime = $('input[name="payment_stime"]').val();
                data.payment_etime = $('input[name="payment_etime"]').val();
            }
        },
        "lengthChange": false,
        "searching": false,
        "ordering": false,
        "info": false,
        "autoWidth": false,
        "columns": [
            {"data": "index"},
            {"data": "gid"},
            {"data": "gname"},
            {"data": "num"},
            {"data": "gprice", render:function (data) {
                return "$"+data;
            }},
            {"data": "channel"}
        ]
    });

    //当点击search按钮时按条件重新加载数据
    $("#searchBtn").click(function(){
        if($("#totalForm").valid()) {
            goodsTable.ajax.reload();
        }
    });


});