tollincomeandexp.js 21.6 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
var datanum = $('#toll-toptab').attr('data-value');
var inexpfun = {
    init: function () {
        //收费员初始化
        inexpfun.tollperInit();
        /**时间初始化*/
        $('#tollinexp-daydaterange-btnsta').val(moment().subtract('days', 0).format('YYYY-MM-DD'));
        $('#tollinexp-daydaterange-btnend').val(moment().subtract('days', 0).format('YYYY-MM-DD'));
        //开始日期
        $("#tollinexp-daydaterange-btnsta").datetimepicker({
            endDate: moment().subtract('days', 0).format('YYYY-MM-DD'),
            format: 'yyyy-mm-dd',
            autoclose: true,
            startView: 2,
            //maxDate:moment().subtract('months', 3),
            minView: 2,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
        //结束日期
        $("#tollinexp-daydaterange-btnend").datetimepicker({
            endDate: moment().subtract('days', 0).format('YYYY-MM-DD'),
            format: 'yyyy-mm-dd',
            autoclose: true,
            startView: 2,
            //maxDate:moment().subtract('months', 3),
            minView: 2,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
        //充值记录
        inexpfun.inexpcreateTableData();
        //支出记录
        inexpfun.expcreateTableData();

        //统计汇总
        inexpfun.chargerAcctRecordStatistic();

    },
    //获取接口收费员信息
    getChargerMsg: function () {
        var plNo = "";
        var chargers = "";
        var req = {
            baseRequest: {pageNum: 1, pageSize: 0},
            plNo: plNo,
            parkAreaCode: "",
            groupCode: "",
            onduty: "",
            status: "",
            nameOrNo: "",
            orgId: fn.getOrgId(),
            sysCode: sysComm.sysCode
        };
        var opt = {
            async: false,
            data: JSON.stringify(req),
            method: "POST",
            url: dataUrl.util.queryCashierListInfo(),
            success: function (res) {
                if (res.code == '8888') {
                    chargers = JSON.stringify(res.data.rows);
                }
            }
        }
        sysAjax(opt);
        return JSON.parse(chargers);
    },
    //收费员下拉框
    tollperInit: function () {
        var data = inexpfun.getChargerMsg();
        var htmls = '';
        var html = '';
        var chargerCodes = [];
        for (var i = 0; i < data.length; i++) {
            chargerCodes.push(data[i].chargerCode);
            html += "<option value='[\"" + data[i].chargerCode + "\"]'>" + data[i].chargerCode + "-" + data[i].chargerName + "</option>";
        }
        var chargerCodesStr = JSON.stringify(chargerCodes);
        htmls = '<option value=' + chargerCodesStr + ' selected>所有收费员</option>' + html;

        $("#tollinexp-tollper").empty();
        $("#tollinexp-tollper").append(htmls);
        $('#tollinexp-tollper').selectpicker('render');
    },
    //默认生成表格数据-充值记录
    inexpcreateTableData: function () {
        $('#tollinexp-billtable-pay').bootstrapTable('destroy').bootstrapTable({
            striped: true,//表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            pageSize: 10,  //每页显示的记录数
            pageList: [10, 15, 20],  //记录数可选列表
            sidePagination: 'server',//表示服务端分页
            queryParamsType: 'limit',
            sortable: true,                     //是否启用排序
            sortOrder: "asc",
            method: 'POST',//请求方法
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: inexptableLoadRequest,//自定义ajax加载数据
            // uniqueId:'id',
            columns: [
                {
                    field: 'custId',
                    title: '<span class="type-icon"> </span>收费员编号',
                    width: '15%',
                    align: "left",
                    formatter: commonObj.replacenull
                },
                {
                    field: 'custName',
                    title: '<span class="information-icon"> </span>收费员名称',
                    width: '15%',
                    align: "left",
                    formatter: commonObj.replacenull
                },
                {
                    field: 'rechargeFee',
                    title: '<span class="money-icon"> </span>充值费用',
                    width: '15%',
                    align: "center",
                    formatter: commonObj.moneyFormatter
                },

                {
                    field: 'rechargeType',
                    title: '<span class="money-icon"> </span>充值渠道',
                    width: '15%',
                    align: "center",
                    formatter: function (value) {
                        var rechargeTypeStr = '未知';
                        //充值类型  1-支付宝;2-微信;3-银联;4-微信公众号;6-现金;7-IC卡;2-微信; 5-账户余额;-5-个人账户余额退款
                        switch (value) {
                            case 1:
                                rechargeTypeStr = '支付宝';
                                break;
                            case 2:
                                rechargeTypeStr = '微信';
                                break;
                            case 5:
                                rechargeTypeStr = '余额';
                                break;
                            case 6:
                                rechargeTypeStr = '现金';
                                break;
                            default:
                                rechargeTypeStr = '未知';
                                break;

                        }
                        return rechargeTypeStr;

                    }
                },

                {
                    field: 'rechargeBalance',
                    title: '<span class="tkmoneynum-icon"> </span>充值后余额',
                    width: '15%',
                    align: "center",
                    formatter: commonObj.moneyFormatter
                },

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

                {
                    field: 'rechargeRemark',
                    title: '<span class="information-icon"> </span>备注',
                    width: '15%',
                    align: "left",
                    formatter: function (value, row, index) {
                        return '<div style="margin-right: 3px;max-width: 200px;" class="ITD-hidden-nowrap" data-toggle="tooltip" title="' + commonObj.replacenull(value) + '">' + commonObj.replacenull(value) + '</div>';
                    }
                },
                {
                    field: 'rechargeName',
                    title: '<span class="information-icon"> </span>操作人',
                    width: '15%',
                    align: "left",
                    formatter: commonObj.replacenull
                },


            ]
        });
    },
    //收费员账户记录汇总
    chargerAcctRecordStatistic: function () {
        var req = inexpfun.inexpgetQueryParam();
        var index = $('#toll-toptab div.ITD-graynav-topbaractive').index();

        req.sysCode = sysComm.sysCode;
        var url;
        if (index == 0) {
            url = dataUrl.util.statisticAcctRecharge();
        } else {
            url = dataUrl.util.statisticAcctPayOut();
        }
        var opt = {
            method: 'post',
            url: url,
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {

                if (res.code == '8888') {

                    var data = res.data;

                    if (index == 0) {
                        $('#all_totalFee').text(commonObj.moneyFormatter(data.positiveFee));
                        $('#all_wxFee').text(commonObj.numberFormatter(data.positiveNum));
                        $('#all_zfbFee').text(commonObj.moneyFormatter(data.negativeFee));
                        $('#all_otherFee').text(commonObj.numberFormatter(data.negativeNum));
                    } else {
                        $('#outall_totalFee').text(commonObj.moneyFormatter(data.positiveFee));
                        $('#outall_wxFee').text(commonObj.numberFormatter(data.positiveNum));

                    }


                }
            }
        };
        sysAjax(opt);


    },

    //生成表格数据-支出记录
    expcreateTableData: function () {
        $('#tollinexp-billtable-exp').bootstrapTable('destroy').bootstrapTable({
            striped: true,//表格显示条纹
            pagination: true, //启动分页
            pageNumber: 1, //当前第几页
            pageSize: 10,  //每页显示的记录数
            pageList: [10, 15, 20],  //记录数可选列表
            sidePagination: 'server',//表示服务端分页
            queryParamsType: 'limit',
            sortable: true,                     //是否启用排序
            sortOrder: "asc",
            method: 'POST',//请求方法
            paginationPreText: '<',
            paginationNextText: '>',
            ajax: inexptableLoadRequest,//自定义ajax加载数据
            // uniqueId:'id',
            columns: [
                {
                    field: 'custId',
                    title: '<span class="type-icon"> </span>收费员编号',
                    width: '15%',
                    align: "left",
                    formatter: commonObj.replacenull
                },
                {
                    field: 'custName',
                    title: '<span class="information-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: 'carNumber',
                    title: '<span class="information-icon"> </span>车牌号',
                    width: '15%',
                    align: "left",
                    formatter: commonObj.replacenull
                },

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


            ]
        });
    },
    /*获取查询参数*/
    inexpgetQueryParam: function () {
        var tollPer = JSON.parse($("#tollinexp-tollper").val());

        var rechargeTypeIndex = $('#tab-btn-wrap li.tabAction').index();
        var rechargeType = null;
        if (rechargeTypeIndex == 0) {
            rechargeType = 10;
        }
        if (rechargeTypeIndex == 1) {
            rechargeType = 20;
        }
        if (rechargeTypeIndex == 2) {
            rechargeType = 30;
        }

        if (tollPer.length < 1) {
            tollPer.push("-1X");
        }
        var beginTime = null;
        var endTime = null;
        var dateValue1 = $("#tollinexp-daydaterange-btnsta").val();
        var dateValue2 = $("#tollinexp-daydaterange-btnend").val();
        beginTime = dateValue1 + " 00:00:00";
        endTime = dateValue2 + " 23:59:59";

        beginTime = beginTime == null || beginTime.length == 0 ? null : new Date((beginTime).replace(/-/g, "/"));
        endTime = endTime == null || endTime.length == 0 ? null : new Date((endTime).replace(/-/g, "/"));
        var req = {
            rechargeType: rechargeType,
            sysCode: sysComm.sysCode,
            beginTime: beginTime,
            custIds: tollPer,
            endTime: endTime
        };
        return req;
    },

};
//默认页面初始执行函数
inexpfun.init();

//查询事件
documentBindFunc.on('click', "#tollinexp-Btn", function () {
    var index = datanum;
    //console.log(index);
    if (0 == index) {
        // console.log(index);
        //充值记录
        inexpfun.inexpcreateTableData();

    } else {
        //支出记录
        inexpfun.expcreateTableData();
    }

    //统计汇总
    inexpfun.chargerAcctRecordStatistic();

})

/**
 * 默认table 函数
 * 自定义table AJAX请求
 * @param {Object} params
 */
function inexptableLoadRequest(params) {
    var req = inexpfun.inexpgetQueryParam();

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

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;
    var index = datanum;
    console.log(index);
    var url;
    if (index == 0) {
        url = dataUrl.util.queryAcctRechargeForPage();
    } else {
        url = dataUrl.util.queryAcctPayOutForPage();
    }
    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);
                $("[data-toggle='tooltip']").tooltip({
                    delay: {show: 500, hide: 100},
                });
            }
        }
    };
    sysAjax(opt);
};

//切换头部收入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) {
        // tableByexp
        /** 函数 表格数据 **/
        inexpfun.inexpcreateTableData();
        $('#tableByexp,#expout_card').addClass('display-none');
        $('#tableByin,#expuse_card').removeClass('display-none');
        window.clearInterval(InterValObj);//停止计时器
        $("#expReport").removeAttr("disabled");//启用按钮
        $("#inexpReport").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#expReport").val("导出");
        $("#inexpReport").val("导出");

    } else {
        /** 函数 表格数据 **/
        inexpfun.expcreateTableData();
        window.clearInterval(InterValObj);//停止计时器
        $('#tableByin,#expuse_card').addClass('display-none');
        $('#tableByexp,#expout_card').removeClass('display-none');
        $("#expReport").removeAttr("disabled");//启用按钮
        $("#inexpReport").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#expReport").val("导出");
        $("#inexpReport").val("导出");
    }
    //统计汇总
    inexpfun.chargerAcctRecordStatistic();

});
//切换  全部 有差异 无差异
$('#tab-btn-wrap li').on('click', function () {
    //因后面逻辑需要,一定要线切换 tabAction 样式, 然后在调用 对应的函数
    $(this).addClass('tabAction').siblings().removeClass('tabAction');
    inexpfun.inexpcreateTableData();
});

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

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

}

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

//导出excle
documentBindFunc.on('click', '#inexpReport', function () {
    //获取table所有行数据
    var parkLot = $("#tollinexp-billtable-pay").bootstrapTable('getData');
    //获取table总条数
    var numTotal = $("#tollinexp-billtable-pay").bootstrapTable('getOptions').totalRows;
    //提示 无数据不导出
    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;
    }

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

    var req = inexpfun.inexpgetQueryParam();
    var beginTime = DateUtils.long2String(req.beginTime, 7);
    var endTime = DateUtils.long2String(req.endTime, 7);
    var url = dataUrl.util.exportAcctRechargeList();
    var forms = exportIncomeDetailFormforbill(url, beginTime, endTime, req.custIds, req.rechargeType);
    forms.submit();
});
//导出excle
documentBindFunc.on('click', '#expReport', function () {
    //获取table所有行数据
    var parkLot = $("#tollinexp-billtable-exp").bootstrapTable('getData');
    //获取table总条数
    var numTotal = $("#tollinexp-billtable-exp").bootstrapTable('getOptions').totalRows;
    //提示 无数据不导出
    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;
    }

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

    var req = inexpfun.inexpgetQueryParam();
    var beginTime = DateUtils.long2String(req.beginTime, 7);
    var endTime = DateUtils.long2String(req.endTime, 7);

    var url = dataUrl.util.exportAcctPayOutList();
    console.log(beginTime + ',' + endTime)
    var forms = exportIncomeDetailFormforbill(url, beginTime, endTime, req.custIds);
    forms.submit();
});

function exportIncomeDetailFormforbill(url, beginTime, endTime, custIds, rechargeType) {

    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 = "custIds";
    input3.value = custIds;
    form.appendChild(input3);

    if (rechargeType != undefined && null != rechargeType) {
        var input4 = document.createElement("input");
        //input2.type = "hidden";
        input4.name = "rechargeType";
        input4.value = rechargeType;
        form.appendChild(input4);
    }


    return form;

};