billmanage.js 38.7 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 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
var fun = {
    init: function () {
        commSelect.area_Pl_LinkedSelect("#bill-parkArea", "#bill-parkIds");
        fun.dateInit();
        fun.monthdateInit();
        fun.createTableData();
        fun.initSummaryFeeData();
        //弹窗
        documentBindFunc.on('click', '[lookOper]', function() {
            fun.lookOper(this);
        });
    },
    //时间初始化
    dateInit: function () {
        $('#bill-daterange-btnsta').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
        $('#bill-daterange-btnend').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
        //开始日期
        $("#bill-daterange-btnsta").datetimepicker({
            endDate: moment().subtract('days', 1).format('YYYY-MM-DD'),
            format: 'yyyy-mm-dd',
            autoclose: true,
            startView: 2,
            minView: 2,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
        $("#bill-daterange-btnend").datetimepicker({
            endDate: moment().subtract('days', 1).format('YYYY-MM-DD'),
            //startDate:startVal,
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            startView: 2,
            minView: 2,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
    },
    monthdateInit: function () {
        /** 月 时间初始化 **/
        $('#bill-monthdaterange-btnsta').val(moment().subtract('months', 1).format('YYYY-MM'));
        $('#bill-monthdaterange-btnend').val(moment().subtract('months', 1).format('YYYY-MM'));
        //开始日期
        $("#bill-monthdaterange-btnsta").datetimepicker({
            endDate: moment().subtract('months', 1).format('YYYY-MM'),
            format: 'yyyy-mm',
            autoclose: true,
            startView: 3,
            //maxDate:moment().subtract('months', 3),
            minView: 3,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
        //结束日期
        $("#bill-monthdaterange-btnend").datetimepicker({
            endDate: moment().subtract('months', 1).format('YYYY-MM'),
            //startDate:startVal,
            format: 'yyyy-mm',
            weekStart: 1,
            autoclose: true,
            startView: 3,
            minView: 3,
            forceParse: false,
            locale: "zh-CN",
            language: 'zh-CN',
            pickerPosition: "bottom-right"
        })
    },

    /*获取查询参数*/
    queryParamForBillManage: function () {
        var plNos = JSON.parse($("#bill-parkIds").val());
        if (plNos.length < 0 || plNos == null || plNos == undefined) {
            plNos.push(-1);
        }
        /**统计分类 1、日 2、 月**/
        var timeType = 1;
        /*开始时间*/
        var beginTime;
        /*结束时间*/
        var endTime;
        timeType = $("#queryType").val();
        if (1 == parseInt(timeType)) {
            //日
            beginTime = $("#bill-daterange-btnsta").val();
            endTime = $("#bill-daterange-btnend").val();
            beginTime = beginTime + " 00:00:00";
            endTime = endTime + " 23:59:59";
        } else {
            timeType = 2;
            beginTime = $("#bill-monthdaterange-btnsta").val() + "-01 00:00:00";
            endTime = $("#bill-monthdaterange-btnend").val();

            var dates = endTime.split("-");
            if (dates[1] == '02') {
                endTime = endTime + "-28 23:59:59";
            } else if (dates[1] == '01' || dates[1] == '03' || dates[1] == '05' || dates[1] == '07'
                || dates[1] == '08' || dates[1] == '10' || dates[1] == '12') {
                endTime = endTime + "-31 23:59:59";
            } else {
                endTime = endTime + "-30 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 detailType =$("#tab-btn-wrap").find(".tabAction").val();///**1.停车场;2:办事处.*/
        //alert(detailType)
        var req = {
            plNos: plNos,
            beginTime: beginTime,
            endTime: endTime,
            timeType: timeType,
            detailType:detailType
        };
        //console.log(req);
        return req;
    },

    initSummaryFeeData:function(){
        $("#park_actFeeForRefund").text("0.00");


        $("#park_actFee").text("0.00");
        $("#vip_actFee").text("0.00");
        $("#back_actFee").text("0.00");


        $("#park_dicountFee").text("0.00");
        $("#back_dicountFee").text("0.00");
        $("#vip_dicountFee").text("0.00");

        $("#park_totalFee").text("0.00");
        $("#vip_totalFee").text("0.00");
        $("#back_totalFee").text("0.00");
        $("#all_totalFee").text("0.00");
        $("#all_actFee").text("0.00");
        $("#all_dicountFee").text("0.00");
        $("#all_otherFee").text("0.00");

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

                         /********************begin实收*****************************/
                         //临停实收
                         var parkActFee=data.actFee==null?0:data.actFee;
                         //会员卡实收
                         var vipActFee=data.actFeeForVIP==null?0:data.actFeeForVIP;
                         //补缴实收
                         var backActFee=data.actFeeForBack==null?0:data.actFeeForBack;
                        /*****************************begin折扣*****************************/
                        //临停折扣
                        var parkDicountFee=data.dicountFee==null?0:data.dicountFee;
                        //补缴折扣
                        var backDicountFee=data.dicountFeeForBack==null?0:data.dicountFeeForBack;
                        //会员卡折扣
                        var vipDicountFee=data.dicountFeeForVIP==null?0:data.dicountFeeForVIP;
                        /********************begin退费*****************************/
                         debugger;
                        //临停退费
                         var orderRefund = data.orderRefund==null?0:data.orderRefund;
                         //会员卡退费
                         var vipRefund = data.vipRefund==null?0:data.vipRefund;
                        //充值退费
                        var rechargeRefund  = data.rechargeRefund==null?0:data.rechargeRefund;
                        /********************begin欠费*****************************/
                        //临停欠费
                        var orderArrearageFee=data.arrearageFee==null?0:data.arrearageFee;
                        //会员卡欠费
                        var vipArrearageFee=data.arrearageFeeForVIP==null?0:data.arrearageFeeForVIP;
                        //补缴卡欠费
                        var arrearageFeeForBack=data.arrearageFeeForBack==null?0:data.arrearageFeeForBack;


                        /******************************begin赋值操作******************************************/
                         //实收
                          var allactFee=parkActFee+vipActFee+backActFee;
                          $("#all_actFee").text(fun.money(allactFee));//实收汇总
                          $("#park_actFee").text(fun.money(parkActFee)); //临停实收
                          $("#vip_actFee").text(fun.money(vipActFee));   //会员卡实收
                          $("#back_actFee").text(fun.money(backActFee)); //补缴实收
                          //折扣
                          var alldicountFee=parkDicountFee+backDicountFee+vipDicountFee;
                          $("#all_dicountFee").text(fun.money(alldicountFee)); //汇总折扣
                          $("#park_dicountFee").text(fun.money(parkDicountFee));//临停折扣
                          $("#vip_dicountFee").text(fun.money(vipDicountFee));//会员卡折扣
                          $("#back_dicountFee").text(fun.money(backDicountFee));//补缴折扣
                          //退费
                           var allotherFee =orderRefund+vipRefund+rechargeRefund;
                           $("#all_otherFee").text(fun.money(allotherFee));//汇总退费
                           $("#orderRefund").text(fun.money(orderRefund));//临停退费
                           $("#vipRefund").text(fun.money(vipRefund));//会员卡退费
                           $("#rechargeRefund").text(fun.money(rechargeRefund));////补缴退费
                           //应收
                           $("#park_totalFee").text(fun.money(parkActFee+parkDicountFee+orderArrearageFee));//临停应收=临停实收+临停折扣+临停欠费
                           $("#vip_totalFee").text(fun.money(vipActFee+vipDicountFee+vipDicountFee+vipArrearageFee));//会员卡应收=会员卡实收+会员卡折扣+会员卡欠费
                           //欠费arrearageFee
                           //$("#back_totalFee").text(fun.money(backActFee+backDicountFee+arrearageFeeForBack));//补缴卡应收=补缴卡实收+补缴折扣+补缴欠费
                           //$("#back_totalFee").text(fun.money(data.arrearageFee == null ? 0.00:data.arrearageFee));//补缴卡应收=补缴卡实收+补缴折扣+补缴欠费
                           $("#all_totalFee").text(fun.money(parkActFee+parkDicountFee+orderArrearageFee+vipActFee+vipDicountFee+vipDicountFee+vipArrearageFee+backActFee+backDicountFee+arrearageFeeForBack));
                           
                    }


                }
            }
        };
        sysAjax(opt);

    },
    //停车场 table 默认
    createTableData: function () {
        $('#recordtable').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: tableLoadRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                [{
                    field: 'checkDate',
                    title: '<span class="time-icon"></span>日期',
                    valign: "middle",
                    align: 'left',
                    rowspan: 2,
                    valign: "middle",
                    formatter: commonObj.replacenull
                    //width: '20%'
                },
                    {
                        field: 'areaName',
                        title: '<span class="office-icon"></span>办事处',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        //formatter: commonObj.replacenull
                        formatter: fun.operFormatter
                    },

                    {
                        field: 'totalFee',
                        title: '<span class="money-icon"></span>应收',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: '',
                        title:'<span class="money-icon"></span>实收',
                        valign: "middle",
                        align: "center",
                        colspan: 5,
                        rowspan: 1,
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'arrearageFee',
                        title: '<span class="money-icon"></span>欠费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: commonObj.moneyFormatter
                    },
                    { field: 'actFeeForRefund',
                        title: '<span class="money-icon"></span>退费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'dicountFee',
                        title: '<span class="discount-icon"></span>折扣',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: commonObj.moneyFormatter
                    },


                ],
                [

                    {
                        field: 'wxFee',
                        title: '<span class="weixin-icon"></span>微信',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'aliFee',
                        title: '<span class="zhifubao-icon"></span>支付宝',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'cashFee',
                        title: '<span class="xianjin-icon"></span>现金',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'balanceFee',
                        title: '<span class="information-icon"></span>余额',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'orderPayedFee',
                        title: '<span class="information-icon"></span>合计',
                        width: '10%',
                        align: "left",
                        formatter: allActFeeFormatter
                    },

                ],


            ]
        });
        function allActFeeFormatter(value, row, index){
            var allFee=0;
            if(row.wxFee!=null){
                allFee=allFee+row.wxFee;
            }
            if(row.aliFee!=null){
                allFee=allFee+row.aliFee;
            }
            if(row.cashFee!=null){
                allFee=allFee+row.cashFee;
            }
            if(row.balanceFee!=null){
                allFee=allFee+row.balanceFee;
            }
            /** 退费**/
            //var allRefundFee=row.actFeeForRefund==null?0:row.actFeeForRefund;
            if(allFee=="0.00"){
                return 0.00;
            }else{
                return (allFee/100).toFixed(2);
            }

        }


        function totalFeemoneyFormatter(value, row, index){
            // var allFee=0;
            // if(row.arrearageFee!=null){
            //     allFee+=row.arrearageFee;
            // }
            // return ((value+allFee)/100).toFixed(2);
            return ((value)/100).toFixed(2);
        };

    },
    //办事处 table 维度
    createbscTableData: function () {
        $('#recordtable').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: tableLoadRequest, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                [{
                    field: 'checkDate',
                    title: '<span class="time-icon"></span>日期',
                    valign: "middle",
                    align: 'left',
                    rowspan: 2,
                    valign: "middle",
                    formatter: commonObj.replacenull
                    //width: '20%'
                },
                    {
                        field: 'areaName',
                        title: '<span class="office-icon"></span>办事处',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        //formatter: fun.operFormatter
                        formatter: commonObj.replacenull
                    },
                    {
                        field: 'plName',
                        title: '<span class="park-icon"></span>停车场',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2

                    },
                    {
                        field: 'totalFee',
                        title: '<span class="money-icon"></span>应收',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: '',
                        title:'<span class="money-icon"></span>实收',
                        valign: "middle",
                        align: "center",
                        colspan: 5,
                        rowspan: 1,
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'arrearageFee',
                        title: '<span class="money-icon"></span>欠费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: commonObj.moneyFormatter
                    },
                    { field: 'actFeeForRefund',
                        title: '<span class="money-icon"></span>退费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'dicountFee',
                        title: '<span class="discount-icon"></span>折扣',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: commonObj.moneyFormatter
                    },


                ],
                [

                    {
                        field: 'wxFee',
                        title: '<span class="weixin-icon"></span>微信',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'aliFee',
                        title: '<span class="zhifubao-icon"></span>支付宝',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'cashFee',
                        title: '<span class="xianjin-icon"></span>现金',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'balanceFee',
                        title: '<span class="information-icon"></span>余额',
                        width: '10%',
                        align: "left",
                        formatter: commonObj.moneyFormatter
                    },
                    {
                        field: 'orderPayedFee',
                        title: '<span class="information-icon"></span>合计',
                        width: '10%',
                        align: "left",
                        formatter: allActFeeFormatter
                    },

                ],


            ]
        });
        function allActFeeFormatter(value, row, index){
            var allFee=0;
            if(row.wxFee!=null){
                allFee=allFee+row.wxFee;
            }
            if(row.aliFee!=null){
                allFee=allFee+row.aliFee;
            }
            if(row.cashFee!=null){
                allFee=allFee+row.cashFee;
            }
            if(row.balanceFee!=null){
                allFee=allFee+row.balanceFee;
            }


            if(allFee=="0.00"){
                return "0.00";
            }else{
                return (allFee/100).toFixed(2);
            }

        }


        function totalFeemoneyFormatter(value, row, index){
            // var allFee=0;
            // if(row.arrearageFee!=null){
            //     allFee+=row.arrearageFee;
            // }
            // return ((value+allFee)/100).toFixed(2);
            return ((value)/100).toFixed(2);
        };

    },
    //操作显示
    operFormatter: function(value, row, index) {
        var areaName="-";
        if(row.areaName!=null){
            areaName=row.areaName;
        }
        var areaId="-";
        if(row.areaId!=null){
            areaId=row.areaId;
        }
        var operStr = '<a href="javascript:;" lookOper areaid="' + areaId + '" areaname="' + areaName + '"  plNo="' + row.plNo + '" datatime="' + row.checkDate + '" >'+ areaName +'</a>';
        return operStr;
    },

    money:function (value) {
        if(value==null || value==undefined || value =="0.00"){
            return "0.00";
        }else{
            return (value/100).toFixed(2);
        }
    },

    lookOper: function(element) {
        $('#popAreaname').text('');
        var areaName = $(element).attr('areaname');
        areaId = $(element).attr('areaid');
        var areadate = $(element).attr('datatime');
        $('#popAreaname').text(areaName+'('+areadate+')');
        if(areaName!=null && areaName !=undefined && areaName !="全部" && areaName!="-"){
            var beginTime= $(element).attr('datatime');
            if(beginTime.length>7){
                beginTimeNew =new Date((beginTime + " 00:00:00").replace(/-/g, "/"));
                endTimeNew =new Date((beginTime + " 23:59:59").replace(/-/g, "/"));
            }else{
                beginTimeNew =new Date((beginTime + "-01 00:00:00").replace(/-/g, "/"));
                //console.log(beginTime);
                var dates = beginTime.split("-");
                //console.log(dates[1]);
                if (dates[1] == '02') {
                    beginTime = beginTime + "-28 23:59:59";
                } else if (dates[1] == '01' || dates[1] == '03' || dates[1] == '05' || dates[1] == '07'
                    || dates[1] == '08' || dates[1] == '10' || dates[1] == '12') {
                    beginTime = beginTime + "-31 23:59:59";
                } else {
                    beginTime = beginTime + "-30 23:59:59";
                }
                endTimeNew =new Date((beginTime).replace(/-/g, "/"));
            }
            var plNos = JSON.parse($("#bill-parkIds").val());
            //console.log(plNos.length);
            parkIdList = [];
            if(parseInt(plNos.length)>=2){
                parkIdList=fun.getPlNosByAreaName(areaName);
            }else{
                parkIdList=plNos;
            }

            //console.log(parkIdList);

           fun.popCreateTableData();

            $('#billmana-myModal').modal('show');
        }

    },
    getPlNosByAreaName: function (areaName) {
        //停车场
        var data = fn.getParkLot();
        var areaPlNos = {};
        var areaNameList = [];
        for (var i = 0; i < data.length; i++) {
            var areaNameNew = data[i].areaName;
            if (areaNameList.indexOf(areaNameNew) == -1) {
                areaNameList.push(areaNameNew);
                var plNos = [];
                plNos.push(data[i].code);
                areaPlNos[areaNameNew] = plNos;
            } else {
                var plNos = areaPlNos[areaNameNew];
                if (plNos.indexOf(data[i].code) == -1) {
                    plNos.push(data[i].code);
                    areaPlNos[areaNameNew] = plNos;
                }
            }
        }
        return areaPlNos[areaName];
    },
    popCreateTableData: function () {
        $('#billincometable').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: tableLoadRequestpop, //自定义ajax加载数据
            uniqueId: 'id',
            columns: [
                [
                //     {
                //     field: 'checkDate',
                //     title: '<span class="information-icon"></span>日期',
                //     valign: "middle",
                //     align: 'left',
                //     rowspan: 2,
                //     valign: "middle",
                //     //width: '20%'
                // },
                    {
                        field: 'plName',
                        title: '<span class="information-icon"></span>车场名称',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle"
                    },
                    {
                        field: 'totalFee',
                        title: '<span class="money-icon"></span>应收',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: totalFeemoneyFormatter
                    },
                    {field: '', title:'<span class="money-icon"></span>实收', valign: "middle", align: "center", colspan: 5, rowspan: 1},
                    {
                        field: 'arrearageFee',
                        title: '<span class="money-icon"></span>欠费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        valign: "middle",
                        width: '10%',
                        formatter: fun.money
                    },
                    { field: 'actFeeForRefund',
                        title: '<span class="money-icon"></span>退费',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: fun.money
                    },
                    {
                        field: 'dicountFee',
                        title: '<span class="discount-icon"></span>折扣',
                        valign: "middle",
                        align: 'left',
                        rowspan: 2,
                        width: '10%',
                        valign: "middle",
                        formatter: fun.money
                    },


                ],
                [

                    {
                        field: 'wxFee',
                        title: '<span class="weixin-icon"></span>微信',
                        width: '10%',
                        align: "left",
                        formatter: fun.money
                    },
                    {
                        field: 'aliFee',
                        title: '<span class="zhifubao-icon"></span>支付宝',
                        width: '10%',
                        align: "left",
                        formatter: fun.money
                    },
                    {
                        field: 'cashFee',
                        title: '<span class="xianjin-icon"></span>现金',
                        width: '10%',
                        align: "left",
                        formatter: fun.money
                    },
                    {
                        field: 'balanceFee',
                        title: '<span class="information-icon"></span>余额',
                        width: '10%',
                        align: "left",
                        formatter: fun.money
                    },
                    {
                        field: 'orderPayedFee',
                        title: '<span class="information-icon"></span>合计',
                        width: '10%',
                        align: "left",
                        formatter: allActFeeFormatter
                    },

                ],


            ]
        });
        function allActFeeFormatter(value, row, index){
            var allFee=0;
            if(row.wxFee!=null){
                allFee+=row.wxFee;
            }
            if(row.aliFee!=null){
                allFee+=row.aliFee;
            }
            if(row.cashFee!=null){
                allFee+=row.cashFee;
            }
            if(row.balanceFee!=null){
                allFee+=row.balanceFee;
            }

            if(allFee=="0.00"){
                return "0.00";
            }else{
                return (allFee/100).toFixed(2);
            }

        }


        function totalFeemoneyFormatter(value, row, index){
            // var allFee=0;
            // if(row.arrearageFee!=null){
            //     allFee+=row.arrearageFee;
            // }
            // return ((value+allFee)/100).toFixed(2);
            return ((value)/100).toFixed(2);
        };
    },
};
fun.init();
//查询
documentBindFunc.on('click', '#bill-queryBtn', function () {
    fun.createTableData();
    fun.initSummaryFeeData();
});
//切换 搜索部分 是否生效
documentBindFunc.on('click', "#bill-toptab div.ITD-graynav-topbar", function () {
    var index = $(this).index();
    $(this).addClass('ITD-graynav-topbaractive').siblings('div').removeClass('ITD-graynav-topbaractive');
    //console.log(index);
    //切换完后,调用查询表格
    // fun.createTableData();

});
//日月切换 点击事件
//日 点击
documentBindFunc.on('click', '#billdayType', function () {
    $('.bill-choosedateday').removeClass('display-none');
    $('.bill-choosedatemonth').addClass('display-none');
    $('#queryType').attr('data-value', '1');
    $("#queryType").val(1);
    fun.createTableData();
    fun.initSummaryFeeData();
});
//月 点击
documentBindFunc.on('click', '#billmonthType', function () {
    $('.bill-choosedatemonth').removeClass('display-none');
    $('.bill-choosedateday').addClass('display-none');
    $('#queryType').attr('data-value', '2');
    $("#queryType").val(2);
    fun.createTableData();
    fun.initSummaryFeeData();
});

//切换  全部 有差异 无差异
$('#tab-btn-wrap li').on('click',function () {
    var that=$(this).index();
    //因后面逻辑需要,一定要线切换 tabAction 样式, 然后在调用 对应的函数
    $(this).addClass('tabAction').siblings().removeClass('tabAction');
    if(that==1){
        //停车场 维度
        fun.createbscTableData();

    }else{
        //办事处 维度
        fun.createTableData();
    }

});

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

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

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;
    req.checkFeeTypes=[100,103,300,301,302];
    var opt = {
        method: 'post',
        url: dataUrl.util.queryDetailForAreaByType(),
        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);
}


/**
 * 区域弹窗
 * 自定义table AJAX请求
 * @param {Object} params
 */
var parkIdList=[];
var areaId;
var beginTimeNew;
var endTimeNew;
function tableLoadRequestpop(params) {
    var req = fun.queryParamForBillManage();

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

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.beginTime=beginTimeNew;
    req.endTime=endTimeNew;
    req.plNos = null;
    req.areaId = areaId;
    req.sysCode = sysComm.sysCode;
    req.checkFeeTypes=[100,103,300,301,302];
    var cehicleFlowTableAjax = {
        method: params.type,
        url: dataUrl.util.queryDetailForParkByType(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function(res) {
            console.log(res.data);
            if(res.code == '8888') {
                //alert(res.data);
                params.success(res.data);
            } else {

            }
        }
    };
    sysAjax(cehicleFlowTableAjax);
}


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

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

//timer处理函数
function SetRemainTime() {
    if (curCount == 0) {
        window.clearInterval(InterValObj);//停止计时器
        $("#billmanageReport").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#billmanageReport").val("导出");
    }
    else {
        curCount--;
        $("#billmanageReport").val(curCount + "秒后可再次导出");
    }
}
//导出excle
documentBindFunc.on('click','#billmanageReport',function (){
    //获取table所有行数据
    var parkLot = $("#recordtable").bootstrapTable('getData');
    //获取table总条数
    var numTotal = $("#recordtable").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 = fun.queryParamForBillManage();
    var beginTime = DateUtils.long2String(req.beginTime, 7);
    var endTime = DateUtils.long2String(req.endTime, 7);

    var url = dataUrl.util.exportBillExcleforNewAll();
    var forms = exportIncomeDetailFormforbill(url, beginTime, endTime, req.plNos, req.timeType
    );
    forms.submit();
});




function exportIncomeDetailFormforbill(url, beginTime, endTime, plNos, timeType
) {

    var form = document.createElement("form");
    form.style.display = 'none';
    form.action = url;
    form.method = "post";
    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 = "plNos";
    input3.value = plNos;
    form.appendChild(input3);


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

    return form;

};