remsum.js 16.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
var datanum=$('#toll-toptab').attr('data-value');
var fun= {
    init: function () {
        fun.dateInit();
        fun.createTabledata();
        fun.createpayTabledata();
        fun.queryEmployeeStatisRequest();
        $('#payType').selectpicker('refresh');
    },
    dateInit:function () {
        $("#sum_daterange_sta").val(moment().subtract('days', 0).format('YYYY-MM-DD 00:00:00'));
        $("#sum_daterange_end").val(moment().subtract('days', -1).format('YYYY-MM-DD 00:00:00'));

        $("#sum_daterange_sta").datetimepicker({
            weekStart: 1,
            autoclose: true,
            startView: 2,
            minView:1,
            forceParse: false,
            // minView: 0,
            // minuteStep:60,//分钟间隔1分钟
            // showMeridian: 1,
            format: 'yyyy-mm-dd hh:00:00',
            endDate: moment().subtract('days', 0).format('YYYY-MM-DD 23:59:59'),
            language:  'zh-CN',
            clearBtn: true, //添加清除按钮,可选值:true/false
            pickerPosition: "bottom-right"
        });
        $("#sum_daterange_end").datetimepicker({
            weekStart: 1,
            autoclose: true,
            startView: 2,
            forceParse: false,
            minView: 1,
            // showMeridian: 1,
            format: 'yyyy-mm-dd hh:00:00',
            endDate: moment().subtract('days', -1).format('YYYY-MM-DD 00:00:00'),
            language:  'zh-CN',
            clearBtn: true, //添加清除按钮,可选值:true/false
            pickerPosition: "bottom-right"
        });
    },
    createTabledata:function () {
        $('#recharge_table').bootstrapTable('destroy').bootstrapTable({
            striped: true, //表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            // showColumns: true,
            pageSize: 10, //每页显示的记录数
            pageList: [10, 15, 20], //记录数可选列表
            sidePagination: 'server', //表示服务端分页
            queryParamsType: 'limit',
            method: 'POST', //请求方法
            // fixedColumns: true,
            // fixedNumber: 1,
            // leftFixedColumns: true,
            // leftFixedNumber: 3,
            //rightFixedColumns: true,
            //rightFixedNumber: 1,
            // selectItemName: 'personCustName',
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: sumtableLoadRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                {
                    field: 'userPhone',
                    title: '<span class="mobile-icon"> </span>手机号',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'acctType',
                    title: '<span class="status-icon"> </span>账户类型',
                    width: '15%',
                    align: "left",
                    formatter: fun.acctTypeFormatter
                },
                {
                    field: 'rechargeType',
                    title: '<span class="status-icon"> </span>充值类型',
                    width: '15%',
                    align: "left",
                    formatter: fun.chargeTypeFormatter
                },
                {
                    field: 'rechargeFee',
                    title: '<span class="money-icon"> </span>充值金额',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.moneyFormatter

                },

                {
                    field: 'rechargeBalance',
                    title: '<span class="money-icon"> </span>充值后金额',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.moneyFormatter
                },
                {
                    field: 'rechargeTime',
                    title: '<span class="time-icon"> </span>充值时间',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.timeFormatter
                }

            ]
        });
    },
    createpayTabledata:function () {
        $('#apppay_table').bootstrapTable('destroy').bootstrapTable({
            striped: true, //表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            // showColumns: true,
            pageSize: 10, //每页显示的记录数
            pageList: [10, 15, 20], //记录数可选列表
            sidePagination: 'server', //表示服务端分页
            queryParamsType: 'limit',
            method: 'POST', //请求方法
            // fixedColumns: true,
            // fixedNumber: 1,
            // leftFixedColumns: true,
            // leftFixedNumber: 3,
            //rightFixedColumns: true,
            //rightFixedNumber: 1,
            // selectItemName: 'personCustName',
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: sumtableLoadRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                {
                    field: 'plName',
                    title: '<span class="parking-icon"> </span>车场名称',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'userPhone',
                    title: '<span class="mobile-icon"> </span>手机号',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'acctType',
                    title: '<span class="status-icon"> </span>账户类型',
                    width: '15%',
                    align: "left",
                    formatter: fun.acctTypeFormatter
                },
                {
                    field: 'carNumber',
                    title: '<span class="carnum-icon"> </span>车牌',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'tradeFee',
                    title: '<span class="money-icon"> </span>支出费用',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.moneyFormatter

                },
                {
                    field: 'tradeBalance',
                    title: '<span class="money-icon"> </span>支出后余额',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.moneyFormatter

                },

                {
                    field: 'berthNo',
                    title: '<span class="money-icon"> </span>泊位编号',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'tradeTime',
                    title: '<span class="time-icon"> </span>支出时间',
                    width: '15%',
                    align: "left",
                    formatter:commonObj.timeFormatter
                }

            ]
        });
    },
    /*获取查询参数*/
    sumGetQueryParam: function () {

        beginTime = $("#sum_daterange_sta").val();
        //beginTime = beginTime + " 00:00:00";
        beginTime = beginTime == null || beginTime.length == 0 ? null : new Date((beginTime).replace(/-/g, "/"));
        endTime = $("#sum_daterange_end").val();
        // endTime = endTime + " 23:59:59";
        endTime = endTime == null || endTime.length == 0 ? null : new Date((endTime).replace(/-/g, "/"));
        // console.log(beginTime+','+endTime)
        userPhone = $("#phone_Number").val();
        var payType = $("#payType").val();
        payTypeList = payType.split(",");

        var req = {
            userPhone:userPhone,
            startTime: beginTime,
            beginTime: beginTime,
            endTime:endTime,
            payTypeList:payTypeList
        };
        //console.log(req);
        return req;
    },

    //账户类型
    acctTypeFormatter: function (value) {
        // console.log(typeof value)
        if (value == 1) {
            return "账户余额";
        } else if(value == 7){
            return "充值赠送";
        }else {
            return '-';
        }
    },
    //支付类型
    chargeTypeFormatter: function (value) {
        // console.log(typeof value)
        if (value == 1) {
            return "支付宝";
        } else if(value == 2){
            return "微信";
        }else if(value == 6){
            return "线下充值";
        }else if(value == 11){
            return "充值卡";
        }else {
            return '-';
        }
    },

    queryEmployeeStatisRequest: function () {
        var req = fun.sumGetQueryParam();
        //条件查询
        req.baseRequest = {
            pageNum: 1,
            pageSize: 0
        };
        req.sysCode = sysComm.sysCode;
        var opt = {
            method: 'post',
            url: dataUrl.util.queryCustRechargeFeeStatic(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {
                console.log(res);
                if (res.code == '8888') {
                    console.log(res.data);
                    var zfb = 0;
                    var wx = 0;
                    var other = 0;
                    //多条累加
                    $.each(res.data.rows,function(index,item){
                        zfb += item.zfb;
                        wx += item.wx;
                        other += item.other;
                    });
                    /*if(res.data.total == 1){
                     zfb = res.data.rows[0].zfb;
                     wx = res.data.rows[0].wx;
                     }*/
                    $('#all_totalFee').text(commonObj.moneyFormatter(zfb+wx+other));
                    $('#all_zfbFee').text(commonObj.moneyFormatter(zfb));
                    $('#all_wxFee').text(commonObj.moneyFormatter(wx));
                    $('#all_otherFee').text(commonObj.moneyFormatter(other));
                }
            }
        };
        sysAjax(opt);
    },
};

fun.init();

//查询事件
documentBindFunc.on('click', "#sum_queryBtn", function () {
    //console.log(index);
    if (0 == datanum) {
        // console.log(index);
        //充值记录
        fun.createTabledata();
        fun.queryEmployeeStatisRequest();
    } else {
        //支出记录
        fun.createpayTabledata();
    }
});

//切换头部收入topbar
documentBindFunc.on('click', "#toll-toptab div", function () {
    var index = $(this).index();
    $(this).addClass('ITD-graynav-topbaractive').siblings('div').removeClass('ITD-graynav-topbaractive');
    datanum=$("#toll-toptab").attr('data-value');
    datanum=index;
    if(index==0){
        fun.queryEmployeeStatisRequest();
        /** 函数 表格数据 **/
        fun.createTabledata();
        $('#apprecharge_Cont').removeClass('display-none');
        $('#appmsg_card').removeClass('display-none');
        $('#apppay_Cont').addClass('display-none');
        window.clearInterval(InterValObj);//停止计时器
        $("#sum_reportBtn").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#sum_reportBtn").val("导出");

    }else{
        /** 函数 表格数据 **/
        fun.createpayTabledata();
        window.clearInterval(InterValObj);//停止计时器
        $('#apprecharge_Cont').addClass('display-none');
        $('#apppay_Cont').removeClass('display-none');
        $('#appmsg_card').addClass('display-none');
        $("#sum_reportBtn").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#sum_reportBtn").val("导出");

    }

});

/**
 * 自定义table AJAX请求
 * @param {Object} params
 */
function sumtableLoadRequest(params) {
    var req = fun.sumGetQueryParam();

    //设置请求参数
    var pageNum = (params.data.offset / params.data.limit) + 1;

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;
    var url = dataUrl.util.queryCustRechargeFeeStaticMsg();
    if (datanum==0) {
        url = dataUrl.util.queryCustRechargeFeeStaticMsg();
    } else{
        console.log(1)
        url = dataUrl.util.queryappAcctPayOutForPage();
    }
    var opt = {
        method: 'post',
        url: url,
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (res) {
            console.log(res);
            if (res.code == '8888') {
                params.success(res.data);
            }
        }
    };
    sysAjax(opt);
}

//导出
var InterValObj; //timer变量,控制时间
var count = 8; //间隔函数,1秒执行
var curCount;//当前剩余秒数

function sendMessage() {
    curCount = count;
    //设置button效果,开始计时
    $("#sum_reportBtn").attr("disabled", "true");
    $(".ITD-export-btn").css("width", "138px");
    $("#sum_reportBtn").val(curCount + "秒后可再次导出");
    InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器,1秒执行一次
}

//timer处理函数
function SetRemainTime() {
    if (curCount == 0) {
        window.clearInterval(InterValObj);//停止计时器
        $("#sum_reportBtn").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#sum_reportBtn").val("导出");
    }
    else {
        curCount--;
        $("#sum_reportBtn").val(curCount + "秒后可再次导出");
    }
}

//导出excle
documentBindFunc.on('click','#sum_reportBtn',function (){
    //获取table所有行数据
    var parkLot = $("#recharge_table").bootstrapTable('getData');
    //获取table总条数
    var numTotal = $("#recharge_table").bootstrapTable('getOptions').totalRows;
    //提示 无数据不导出
    console.log(parkLot)
    if(parkLot.length<1){
        $('.ITD-alertmodel-contentmsg').text('无数据可导出!');
        $('#ITD-tipsmodel').modal('show');
        setTimeout(function () {
            $('.ITD-alertmodel-contentmsg').text('');
            $('#ITD-tipsmodel').modal('hide');
        },3000);
        return false;
    }
    //超1万条 缩短查询范围
    if(numTotal>10000){
        $('.ITD-alertmodel-contentmsg').text('数据量过大,请缩小查询范围!');
        $('#ITD-tipsmodel').modal('show');
        setTimeout(function () {
            $('.ITD-alertmodel-contentmsg').text('');
            $('#ITD-tipsmodel').modal('hide');
        },3000);
        return false;
    }

    //执行倒计时函数s
    sendMessage();

    var req = fun.sumGetQueryParam();
    var beginTime = DateUtils.long2String(req.startTime, 7);
    var endTime = DateUtils.long2String(req.endTime, 7);
    var url = dataUrl.util.exportappAcctRechargeList();
    var payTypeList = [];
    payTypeList = $("#payType").val().split(",");
    console.log(beginTime+','+endTime)
    var forms = exportIncomeDetailFormforbill(url,beginTime,endTime,req.userPhone,fn.getOrgId(),payTypeList);
    forms.submit();
});


function exportIncomeDetailFormforbill(url,beginTime, endTime,userPhone,orgId,payTypeList) {

    var form = document.createElement("form");
    form.style.display = 'none';
    form.action = url;
    form.method = "get";
    document.body.appendChild(form);

    var input = document.createElement("input");
    //input.type = "hidden";
    input.name = "beginTime";
    input.value = beginTime;
    form.appendChild(input);

    var input2 = document.createElement("input");
    input2.name = "endTime";
    input2.value = endTime;
    form.appendChild(input2);

    var input3 = document.createElement("input");
    //input2.type = "hidden";
    input3.name = "userPhone";
    input3.value = userPhone;
    form.appendChild(input3);

    var input4 = document.createElement("input");
    input4.name = "orgId";
    input4.value = orgId;
    form.appendChild(input4);

    var input5 = document.createElement("input");
    input5.name = "payTypeList";
    input5.value = payTypeList;
    form.appendChild(input5);

    return form;

};