incomeparking.js 46.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 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 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
// 搜索日期切换


//日 周 月 切换
var reportDateTag=1;
var srzbechartsPie;
$('#parkincome-toptab li').on('click',function () {
    var _index = $(this).index();
    switch (_index){
        case 0:
            $('.parkincome-choosedatemonth').addClass('display-none');
            $('.parkincome-choosedateweek').addClass('display-none');
            $('.parkincome-choosedateday').removeClass('display-none');
            $('#parkincome-toptab li').eq(0).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');
            // incomeparkFun.dayDate();
            reportDateTag=1;
            tabFunction(reportDateTag);
            break;
        case 1:
            $('.parkincome-choosedateday').addClass('display-none');
            $('.parkincome-choosedatemonth').addClass('display-none');
            $('.parkincome-choosedateweek').removeClass('display-none');
            $('#parkincome-toptab li').eq(1).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');
            // incomeparkFun.weekDate();
            reportDateTag=2;
            tabFunction(reportDateTag);
            break;
        case 2:
            $('.parkincome-choosedateday').addClass('display-none');
            $('.parkincome-choosedateweek').addClass('display-none');
            $('.parkincome-choosedatemonth').removeClass('display-none');
            $('#parkincome-toptab li').eq(2).addClass('ITD-graynav-topbaractive').siblings().removeClass('ITD-graynav-topbaractive');
            // incomeparkFun.monthDate();
            reportDateTag=3;
            tabFunction(reportDateTag);
            break;

    }
})
//切换tcb事件
function tabFunction(reportDateTag){
    incomeparkFun.incomeparkTotal(reportDateTag);
    incomeparkFun.queryIncomeParkForPayType();
    var index = $("#srzb-tabbar .srzb-active").index();
    if(index==0){
        //临停数据
        incomeparkFun.ltsrcreateTableData();
        $("#reportLi").css({display:"block"});
    }else{
        //会员卡数据
        incomeparkFun.vipcreateTableData();
        $("#reportLi").css({display:"none"});
    }
}
//支付方式占比
var incomeparkFun={
    init:function(){

        //incomeparkFun.srzbChartsFun();
        incomeparkFun.dayDate();
        incomeparkFun.weekDate();
        incomeparkFun.monthDate();
        //汇总查询
        incomeparkFun.incomeparkTotal(1);
        incomeparkFun.queryIncomeParkForPayType();
        //临停数据
        incomeparkFun.ltsrcreateTableData();
    },
    //汇总查询
    incomeparkTotal:function(reportTabTag){
        //获取停车场信息
        //获取停车场信息
        var data = fn.getParkLot();
        var plNos = [];
        for (var i = 0; i < data.length; i++) {
            plNos.push(data[i].code);
        }
        var reportDate="";
        var reportTabTag=reportDateTag;
        if(reportTabTag==1){
            reportDate=$("#incomepark-daydaterange-btnsta").val();
        }else if(reportTabTag==2){
            var reportDateStr=$("#incomepark-weekdaterange-btnsta").attr('data-text');
            reportDate=reportDateStr.substring(11,21);
        }else if(reportTabTag==3){
            reportDate=$("#incomepark-monthdaterange-btnsta").val();
        }
        var reportTabTagName = "";
        if("1" ==reportTabTag){
            reportTabTagName="日";
            $("#reportDateTitle").text(reportDate);
        }else if("2" ==reportTabTag){
            reportTabTagName="周";
        }else{
            reportTabTagName="月";
        }
        //条件查询
        var req = {
            reportDate:reportDate,
            plNos:plNos,
            reportTabTag:reportTabTag,
            sysCode:sysComm.sysCode
        };

        var opt = {
            method: 'post',
            url: dataUrl.util.queryIncomeParkAndVipForTotal(),
            data: JSON.stringify(req),
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (res) {
                if("8888" == res.code){
                    var data = res.data;
                    console.log(data)
                    if(data.orgName==null || data.orgName==undefined || data.orgName ==''){
                        data.orgName=" ";
                    }
                    $("#orgName").val(data.orgName);
                    $("#orgNameTitle").text(data.orgName+" 停车场统计"+reportTabTagName+"报");
                    if(reportTabTagName=='周'){
                        console.log(reportTabTagName);
                        $("#reportDateTitle").text($("#incomepark-weekdaterange-btnsta").html())
                    }else{
                        $("#reportDateTitle").text(reportDate);
                    }

                    $("#parkTotalNum").text(data.parkTotalNum);    //停车场总个数
                    $("#pBerthTotalNum").text(data.pBerthTotalNum);    //泊位总个数
                    $("#orderActFeeTotal").text(moneyFormatter(data.orderActFeeTotal));    //总收入
                    $("#orderActFeeParkTotal").text(moneyFormatter(data.orderActFeeParkTotal));    //临时停车总收入
                    $("#orderActFeeVipCardTotal").text(moneyFormatter(data.orderActFeeVipCardTotal));    //会员卡总收入
                    //明细
                    var incomeParkAndVipDetailList = data.incomeParkAndVipDetailList;
                    $.each(incomeParkAndVipDetailList,function(index,row){
                        if("1" ==row.plType){//路侧停车场
                            $("#OutparkNum").text(row.parkNum); //路测停车场个数
                            $("#OutpBerthNum").text(row.pBerthNum); //路测泊位个数
                            $("#OutorderActFeeToal").text(moneyFormatter(row.orderActFeeToal)); //路测总收入
                            $("#OutorderActFeePark").text(moneyFormatter(row.orderActFeePark)); //路测临停车收入
                            $("#OutorderActFeeVipCard").text(moneyFormatter(row.orderActFeeVipCard)); //路测会员卡收入

                        }else{
                            $("#InparkNum").text(row.parkNum); //封闭停车场个数
                            $("#InpBerthNum").text(row.pBerthNum); //封闭泊位个数
                            $("#InorderActFeeToal").text(moneyFormatter(row.orderActFeeToal)); //封闭总收入
                            $("#InorderActFeePark").text(moneyFormatter(row.orderActFeePark)); //封闭临停车收入
                            $("#InorderActFeeVipCard").text(moneyFormatter(row.orderActFeeVipCard)); //封闭会员卡收入
                        }
                    });

                }
            }
        };
        sysAjax(opt);



    },
    dayDate:function() {
        $('#incomepark-daydaterange-btnsta').val(moment().subtract('days', 1).format('YYYY-MM-DD'));
        $('#incomepark-daydaterange-btnsta').datetimepicker({
            endDate: moment().subtract('days', 1).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"
        })
    },
    weekDate:function() {
        $('#incomepark-weekdaterange-btnsta').attr('data-text',moment().subtract('days', 7).format('YYYY-MM-DD')+'-'+moment().subtract('days', 1).format('YYYY-MM-DD'))
        $('#incomepark-weekdaterange-btnsta').html(moment().subtract('days', 7).format('YYYY-MM-DD')+' 至 '+moment().subtract('days', 1).format('YYYY-MM-DD'));

    },

    monthDate:function() {
        $('#incomepark-monthdaterange-btnsta').val(moment().subtract('months', 1).format('YYYY-MM'));
        $('#incomepark-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"
        })
    },
    //默认生成表格数据-临停收入
    ltsrcreateTableData: function () {
        $('#incomepark-billtable').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: incomeparktableLoadRequest,//自定义ajax加载数据
            // uniqueId:'id',
            columns: [
                {
                    field: 'number',
                    title: '排名',
                    width: '2%',
                    align: "left",
                    formatter:function(value,row,index){
                        //return index+1; //序号正序排序从1开始
                        var pageSize=$('#incomepark-billtable').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber=$('#incomepark-billtable').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        var operStr='';
                        var topNo=pageSize * (pageNumber - 1) + index + 1;
                        if(topNo==1){
                            operStr ='<span class="ITD-popNo-one">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==2){
                            operStr ='<span class="ITD-popNo-two">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==3){
                            operStr ='<span class="ITD-popNo-three">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else {
                            operStr ='<span class="ITD-popNo-origin">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }

                    }

                },
                {
                    field: 'plName',
                    title: '车场名称',
                    width: '10%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'plType',
                    title: '车场类型',
                    width: '3%',
                    align: "left",
                    formatter: incomeparkFun.plTypeFormatter
                },
                {
                    field: 'berthNum',
                    title: '泊位数',
                    width: '2%',
                    align: "left",
                    formatter: incomeparkFun.numberFormatter
                },
                {
                    field: 'chargerNum',
                    title: '收费员人数',
                    width: '2%',
                    align: "left",
                    formatter: incomeparkFun.numberFormatter
                },

                {
                    field: 'wxFee',
                    title: '微信',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'aliFee',
                    title: '支付宝',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'balanceFee',
                    title: '余额',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'cashFee',
                    title: '现金',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'actFee',
                    title: '总收入',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'totalFee',
                    title: '应收金额',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'actFee',
                    title: '泊位平均收益',
                    width: '2%',
                    align: "left",
                    formatter: incomeparkFun.avgFeeFormatter
                },
                {
                    field: 'totalFee',
                    title: '泊位平均应收收益',
                    width: '2%',
                    align: "left",
                    formatter: incomeparkFun.avgFeeFormatter
                },
            ]
        });
    },
    //表格数据-会员卡收入
    vipcreateTableData: function () {
        $('#incomepark-billtable').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: incomeviptableLoadRequest,//自定义ajax加载数据
            // uniqueId:'id',
            columns: [
                {
                    field: 'number',
                    title: '排名',
                    width: '2%',
                    align: "left",
                    formatter:function(value,row,index){
                        //return index+1; //序号正序排序从1开始
                        var pageSize=$('#incomepark-billtable').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber=$('#incomepark-billtable').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        var operStr='';
                        var topNo=pageSize * (pageNumber - 1) + index + 1;
                        if(topNo==1){
                            operStr ='<span class="income-popNo-1">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==2){
                            operStr ='<span class="income-popNo-2">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else if(topNo==3){
                            operStr ='<span class="income-popNo-3">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }else {
                            operStr ='<span class="income-popNo">'+topNo+'</span>';
                            return operStr;    //返回每条的序号: 每页条数 * (当前页 - 1 )+ 序号
                        }
                    }

                },
                {
                    field: 'plName',
                    title: '车场名称',
                    width: '10%',
                    align: "left",
                    formatter:commonObj.replacenull
                },
                {
                    field: 'plType',
                    title: '车场类型',
                    width: '5%',
                    align: "left",
                    formatter: incomeparkFun.plTypeFormatter
                },
                {
                    field: 'berthNum',
                    title: '泊位数',
                    width: '2%',
                    align: "left",
                    formatter: incomeparkFun.numberFormatter
                },
                {
                    field: 'actFee',
                    title: '总收入',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'wxFee',
                    title: '微信',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'aliFee',
                    title: '支付宝',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'balanceFee',
                    title: '余额',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
                {
                    field: 'cashFee',
                    title: '现金',
                    width: '2%',
                    align: "left",
                    formatter: commonObj.moneyFormatter
                },
//              {
//                  field: 'actFee',
//                  title: '泊位平均收益',
//                  width: '2%',
//                  align: "left",
//                  formatter: incomeparkFun.avgFeeFormatter
//              },
            ]
        });
    },

    //数量处理
    numberFormatter: function (value) {
        // console.log(typeof value)
        if (value == 0 || value == undefined || value == null||value =='') {
            return 0;
        } else {
            return value;
        }
    },
    //停车场类型
    plTypeFormatter: function (value) {
        if (value == undefined || value == null||value =='') {
            return '';
        } else if(value==1){
            return "路侧";
        }else if(value==2){
            return "封闭";
        }
    },
    //泊位平均收益
    avgFeeFormatter: function (value,row,index) {
        var days = incomeparkFun.incomeparkgetQueryParam().days;
        if (value == undefined || value == null ||value =='') {
            return commonObj.moneyFormatter(0);
        }
        if(row.berthNum == undefined || row.berthNum == null || row.berthNum == 0){
            return commonObj.moneyFormatter(value);
        }
        else {
            var avgFee = (value/row.berthNum/days).toFixed(2);
            return commonObj.moneyFormatter(avgFee);
        }
    },
    /*获取查询参数*/
    incomeparkgetQueryParam: function () {
        var days = 1;//查询间隔天数
        var dayArray = [1,31,28,31,30,31,30,31,31,30,31,30,31]//每月的天数
        //0,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10,11,12
        var data = fn.getParkLot();
        var plNos = [];
        for (var i = 0; i < data.length; i++) {
            plNos.push(data[i].code);

        }
        if (plNos.length < 1) {
            plNos.push("-1X");
        }

        var reportTabTag=reportDateTag;
        if(reportTabTag==1){
            var reportDate=$("#incomepark-daydaterange-btnsta").val();
            days = 1;
        }else if(reportTabTag==2){
            var reportDate=$("#incomepark-weekdaterange-btnsta").attr('data-text');
            reportDate=reportDate.substring(11,21);
            days = 7;
        }else if(reportTabTag==3){
            var reportDate=$("#incomepark-monthdaterange-btnsta").val();
            var i = reportDate.substring(5,7);
            i=Number(i);
            days = dayArray[i];
        }
        var req = {
            sysCode: sysComm.sysCode,
            plNos: plNos,
            reportDate: reportDate,
            reportTabTag:reportTabTag,
            days:days
        };
        return req;

    },

    //查询支付方式收费饼图
    queryIncomeParkForPayType: function () {

        $("#outwxfee").text("0.00");
        $("#outalifee").text("0.00");
        $("#outcashfee").text("0.00");
        $("#outbalancefee").text("0.00");
        $("#inwxfee").text("0.00");
        $("#inalifee").text("0.00");
        $("#incashfee").text("0.00");
        $("#inbalancefee").text("0.00");
        $("#allwxfee").text("0.00");
        $("#allalifee").text("0.00");
        $("#allcashfee").text("0.00");
        $("#allbalancefee").text("0.00");
        var req = incomeparkFun.incomeparkgetQueryParam();
        req.baseRequest = {
            pageNum: 1,
            pageSize: 0
        };
        var index = $("#disPrint").val();
        console.log(index);
        var url = dataUrl.util.queryIncomeParkForPayType();
        if (1 == parseInt(index)) {
            url = dataUrl.util.queryIncomeParkForPayType();
        } else {
            url = dataUrl.util.queryIncomeVipForPayType();
        }
        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") {
                    var data = res.data;
                    if (data != null && data.length > 0) {
                        for(var index in data){
                            if(1==parseInt(data[index].plType)){
                                $("#outwxfee").text(commonObj.moneyFormatter(data[index].wxFee));
                                $("#outalifee").text(commonObj.moneyFormatter(data[index].aliFee));
                                $("#outcashfee").text(commonObj.moneyFormatter(data[index].cashFee));
                                $("#outbalancefee").text(commonObj.moneyFormatter(data[index].balanceFee));
                            }else if(2==parseInt(data[index].plType)){
                                $("#inwxfee").text(commonObj.moneyFormatter(data[index].wxFee));
                                $("#inalifee").text(commonObj.moneyFormatter(data[index].aliFee));
                                $("#incashfee").text(commonObj.moneyFormatter(data[index].cashFee));
                                $("#inbalancefee").text(commonObj.moneyFormatter(data[index].balanceFee));
                            }else{
                                $("#allwxfee").text(commonObj.moneyFormatter(data[index].wxFee));
                                $("#allalifee").text(commonObj.moneyFormatter(data[index].aliFee));
                                $("#allcashfee").text(commonObj.moneyFormatter(data[index].cashFee));
                                $("#allbalancefee").text(commonObj.moneyFormatter(data[index].balanceFee));
                                dataValue=[
                                    {value:commonObj.moneyFormatter(data[index].aliFee), name:'支付宝'},
                                    {value:commonObj.moneyFormatter(data[index].wxFee), name:'微信'},
                                    {value:commonObj.moneyFormatter(data[index].balanceFee), name:'余额'},
                                    {value:commonObj.moneyFormatter(data[index].cashFee), name:'现金'},
                                ]

                                incomeparkFun.srzbChartsFun(dataValue);
                                // srzbChartsFun(dataValue);

                            }
                        }



                    }else{
                        dataValue=[
                            {value:0, name:'支付宝'},
                            {value:0, name:'微信'},
                            {value:0, name:'余额'},
                            {value:0, name:'现金'}
                        ];
                        //console.log(dataValue);
                        incomeparkFun.srzbChartsFun(dataValue);
                    }


                } else {
                    dataValue=[
                        {value:0, name:'支付宝'},
                        {value:0, name:'微信'},
                        {value:0, name:'余额'},
                        {value:0, name:'现金'}
                    ];
                    //console.log(dataValue);
                    incomeparkFun.srzbChartsFun(dataValue);
                    // srzbChartsFun(dataValue);

                }
            }
        };
        sysAjax(opt);
    },

    srzbChartsFun:function (dataValue) {
        console.log(dataValue);
        srzbechartsPie = echarts.init(document.getElementById('srzb-echarts'));
        srzboption = {
            color:['#1E95CD','#5fe98f','#fdc94d','#50c0f5'],
            title: {
                // subtext: "" + totalFee,
                // text: '总计',
                textStyle: {
                    color: '#c2c2c2',
                    fontSize: '14',
                    align: 'middle',
                    verticalAlign: 'middle',
                },
                subtextStyle: {
                    color: '#000',
                    fontSize: '24',
                    align: 'middle',
                    verticalAlign: 'middle',
                },
                left: 'center',
                top: '60',

            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                selectedMode:false,
                orient: 'horizontal',
                bottom: '0',
                icon:'circle',
                data:['支付宝','微信','余额','现金']
            },

            series: [
                {
                    name:'支付方式占比',
                    type:'pie',
                    radius: ['55%', '65%'],
                    center: ['50%', '40%'],
                    hoverAnimation: false,
                    avoidLabelOverlap: false,
                    legendHoverLink: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                fontSize: '14',
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:dataValue
                }
            ]
        }
        srzbechartsPie.setOption(srzboption, true);
        window.srzbechartsPie=srzbechartsPie;
        //自适应
        window.onresize = function(){
            srzbechartsPie.resize();
        };
    }

};
incomeparkFun.init();



//临停 会员卡收入 切换
documentBindFunc.on('click', "#srzb-tabbar div", function () {
    var index = $(this).index();
    //console.log(index);
    $(this).addClass('srzb-active').siblings('div').removeClass('srzb-active');
    //加载临停数据 index=0
    if(index==0){
        incomeparkFun.ltsrcreateTableData();
        $('#disPrint').attr('data-size','1');
        $('#disPrint').val(1);
        $("#reportLi").css({display:"block"});
    }else{
        incomeparkFun.vipcreateTableData();
        $('#disPrint').val(2);
        $("#reportLi").css({display:"none"});

    }
    incomeparkFun.queryIncomeParkForPayType();

});

// 收入明细

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

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

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;

    var opt = {
        method: 'post',
        url: dataUrl.util.queryParkIncomeForPage(),
        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 函数
 * 自定义table AJAX请求
 * @param {Object} params
 */
function incomeviptableLoadRequest(params) {
    var req = incomeparkFun.incomeparkgetQueryParam();

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

    //条件查询
    req.baseRequest = {
        pageNum: pageNum,
        pageSize: params.data.limit
    };
    req.sysCode = sysComm.sysCode;

    var opt = {
        method: 'post',
        url: dataUrl.util.queryVipCardIncomeForPage(),
        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);
}

/**
 * 金额处理
 * @param value
 * @returns {*}
 */
function moneyFormatter (value) {
    // console.log(typeof value)
    if (value == 0 || value == undefined || value == null) {
        return "0.00";
    } else {
        return (value / 100).toFixed(2);
    }
}

//打印
//打印功能
documentBindFunc.on('click','#incomeParkPrint',function () {
    //printTarget();网页打印

    //;
    var data = fn.getParkLot();
    var plNos = [];
    for (var i = 0; i < data.length; i++) {
        plNos.push(data[i].code);
    }
    var userName = fn.getUserName();
    var reportDate="";
    var reportTabTag = $("#parkincome-toptab").find("li.ITD-graynav-topbaractive").attr('reportdatetabtag');
    if(reportTabTag==1){
        reportDate=$("#incomepark-daydaterange-btnsta").val();
    }else if(reportTabTag==2){
        var reportDateStr=$("#incomepark-weekdaterange-btnsta").attr('data-text');
        reportDate=reportDateStr.substring(11,21);
    }else if(reportTabTag==3){
        reportDate=$("#incomepark-monthdaterange-btnsta").val();
    }
    var indexparkAndVipTag = $("#srzb-tabbar .srzb-active").index();  //明细切换 0:临时停车 1:会员卡
    var orgName = $("#orgName").val();
    var orgId = fn.getOrgId();
    //begin调用打印
    var url = dataUrl.util.incomeParkAndVipPrint();
    var openUrl = "";//弹出窗口的url
    var iWidth=800; //弹出窗口的宽度;
    var iHeight=800; //弹出窗口的高度;
    var iTop = (window.screen.availHeight-80-iHeight)/2; //获得窗口的垂直位置;
    var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
    var win= window.open('','_blank',"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+",location=no,resizable=no");

    var html="<!DOCTYPE html><html><head><title>收入报表</title><meta charset=\"utf-8\" /></head><body><form action='"+url+"' method='get'  id='incomeParkAndVipPrint' accept-charset='UTF-8'>";
    html+="<input type='hidden' name='reportDate' value='"+reportDate+"'/>";
    html+="<input type='hidden' name='orgId' value='"+orgId+"'/>";
    html+="<input type='hidden' name='orgName' value='"+orgName+"'/>";
    html+="<input type='hidden' name='reportTabTag' value='"+reportTabTag+"'/>";
    html+="<input type='hidden' name='plNos' value='"+plNos+"'/>";
    html+="<input type='hidden' name='indexparkAndVipTag' value='"+indexparkAndVipTag+"'/>";
    html+="<input type='hidden' name='userName' value='"+userName+"'/>";
   html+="<input type='hidden' name='days' value='"+incomeparkFun.incomeparkgetQueryParam().days+"'/>";
    html+="</form>";
    html += "</form><script type='text/javascript'>document.getElementById('incomeParkAndVipPrint').submit();";
    html += "<\/script></body></html>".toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, "");
    win.document.write(html);

});
//查询按钮
documentBindFunc.on('click','#incomepark-billQueryBnt',function(){
    //汇总查询
    incomeparkFun.incomeparkTotal(reportDateTag);
    incomeparkFun.queryIncomeParkForPayType();
    var index = $("#srzb-tabbar .srzb-active").index();
    if(index==0){
        //临停数据
        incomeparkFun.ltsrcreateTableData();
    }else{
        //会员卡数据
        incomeparkFun.vipcreateTableData();
    }
});

function printTarget() {
    //@chartsObj
    //@chartClass echarts样式名
    //@tabOption(@panelClass、panelContent)
    var disSize =$('#disPrint').attr('data-size');
    var rows="";
    if(disSize=='1'){
        rows = disltsrcreateTableData()
    }else{
        rows =disvipcreateTableData()
    }
    var tableStr ='<table id="incomepark-billtable" class="incomepark-billtable table table-hover table-striped">'+
        '<thead>'+
        '<tr>'+
        '<th style="text-align: left; width: 5%; " data-field="number" tabindex="0"><div class="th-inner ">收入排名</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 10%; " data-field="plName" tabindex="0"><div class="th-inner ">车场名称</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="plType" tabindex="0"><div class="th-inner ">车场类型</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="berthNum" tabindex="0"><div class="th-inner ">泊位数</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="actFee" tabindex="0"><div class="th-inner ">总收入</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="wxFee" tabindex="0"><div class="th-inner ">微信收入</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="aliFee" tabindex="0"><div class="th-inner ">支付宝收入</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="balanceFee" tabindex="0"><div class="th-inner ">余额收入</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="cashFee" tabindex="0"><div class="th-inner ">现金收入</div><div class="fht-cell"></div></th>'+
        '<th style="text-align: left; width: 5%; " data-field="actFee" tabindex="0"><div class="th-inner ">泊位平均收益</div><div class="fht-cell"></div></th>'+
        '</tr>'+
        '</thead>'+
        '<tbody>'+rows+'</tbody>'+
        '</table>';
    var tabOption = {
        panelClass: "billtableBox",//容器class
        panelContent: tableStr//动态内容
    }
    // 
    jQuery('#print_Msg').print(window.srzbechartsPie, 'srzb-echarts', tabOption);
}

//默认生成表格数据-临停收入
function disltsrcreateTableData() {
    var dataRows ="";

    var req = incomeparkFun.incomeparkgetQueryParam();
    //条件查询
    req.baseRequest = {
        pageNum: 1,
        pageSize: 0
    };

    var opt = {
        method: 'post',
        url: dataUrl.util.queryParkIncomeForPage(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: false,
        success: function (res) {

            console.log(res);
            if (res.code == '8888') {
                var data = res.data.rows;
                $.each(data,function(index,row){
                    dataRows+= '<tr data-index="0">';
                    if(index==0){
                        dataRows+= '<td style="text-align: left; width: 5%; "><span class="income-popNo-1">'+(index+1)+'</span></td>';
                    }else if (index==1){
                        dataRows+= '<td style="text-align: left; width: 5%; "><span class="income-popNo-2">'+(index+1)+'</span></td>';
                    }else if(index==2){
                        dataRows+= '<td style="text-align: left; width: 5%; "><span class="income-popNo-3">'+(index+1)+'</span></td>';
                    }else {
                        dataRows+= '<td style="text-align: left; width: 5%; "><span class="income-popNo">'+(index+1)+'</span></td>';
                    }
                    dataRows+= '<td style="text-align: left; width: 10%; ">'+row.plName+'</td>' ;
                    if(row.plType==1){
                        dataRows+='<td style="text-align: left; width: 5%; ">路侧</td>';
                    }else if(row.plType==2){
                        dataRows+='<td style="text-align: left; width: 5%; ">封闭</td>';
                    }else{
                        dataRows+='<td style="text-align: left; width: 5%; ">-</td>';
                    }
                    dataRows+='<td style="text-align: left; width: 5%; ">'+row.berthNum+'</td>'
                        +'<td style="text-align: left; width: 5%; ">'+commonObj.moneyFormatter(row.actFee)+'</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.wxFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.aliFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.balanceFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.cashFee) + '</td>';
                    if(row.berthNum == undefined || row.berthNum == null || row.berthNum == 0){
                        dataRows+='<td style="text-align: left; width: 5%; ">'+commonObj.moneyFormatter(row.actFee)+'</td>' ;
                    }else if(row.actFee == undefined || row.actFee == null){
                        dataRows+='<td style="text-align: left; width: 5%; ">'+commonObj.moneyFormatter(row.actFee)+'</td>' ;
                    }else{
                        var avgFee = (row.actFee/row.berthNum).toFixed(2);
                        dataRows+='<td style="text-align: left; width: 5%; ">'+commonObj.moneyFormatter(avgFee)+'</td>' ;
                    }

                    dataRows+='</tr>';



                });

            }

        }

    };
    sysAjax(opt);
    return dataRows;
}
//表格数据-会员卡收入
function disvipcreateTableData() {
    var dataRows = "";
    var req = incomeparkFun.incomeparkgetQueryParam();
    //条件查询
    req.baseRequest = {
        pageNum: 1,
        pageSize: 0
    };

    var opt = {
        method: 'post',
        url: dataUrl.util.queryVipCardIncomeForPage(),
        data: JSON.stringify(req),
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: false,
        success: function (res) {
            console.log(res);
            if (res.code == '8888') {
                var data = res.data.rows;
                $.each(data, function (index, row) {
                    dataRows += '<tr data-index="0">';
                    if (index == 0) {
                        dataRows += '<td style="text-align: left; width: 5%; "><span class="income-popNo-1">' + (index + 1) + '</span></td>';
                    } else if (index == 1) {
                        dataRows += '<td style="text-align: left; width: 5%; "><span class="income-popNo-2">' + (index + 1) + '</span></td>';
                    } else if (index == 2) {
                        dataRows += '<td style="text-align: left; width: 5%; "><span class="income-popNo-3">' + (index + 1) + '</span></td>';
                    } else {
                        dataRows += '<td style="text-align: left; width: 5%; "><span class="income-popNo">' + (index + 1) + '</span></td>';
                    }
                    dataRows += '<td style="text-align: left; width: 10%; ">' + row.plName + '</td>';
                    if (row.plType == 1) {
                        dataRows += '<td style="text-align: left; width: 5%; ">路侧</td>';
                    } else if (row.plType == 2) {
                        dataRows += '<td style="text-align: left; width: 5%; ">封闭</td>';
                    } else {
                        dataRows += '<td style="text-align: left; width: 5%; ">-</td>';
                    }
                    dataRows += '<td style="text-align: left; width: 5%; ">' + row.berthNum + '</td>'+
                        '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.actFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.wxFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.aliFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.balanceFee) + '</td>';
                    dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.cashFee) + '</td>';
                    if (row.berthNum == undefined || row.berthNum == null || row.berthNum == 0) {
                        dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.actFee) + '</td>';
                    } else if (row.actFee == undefined || row.actFee == null) {
                        dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(row.actFee) + '</td>';
                    } else {
                        var avgFee = (row.actFee / row.berthNum).toFixed(2);
                        dataRows += '<td style="text-align: left; width: 5%; ">' + commonObj.moneyFormatter(avgFee) + '</td>';
                    }
                    dataRows += '</tr>';
                });

            }

        }

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

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

//timer处理函数
function SetRemainTime() {
    if (curCount == 0) {
        window.clearInterval(InterValObj);//停止计时器
        $("#reportBtn").removeAttr("disabled");//启用按钮
        $(".ITD-export-btn").css("width", "72px");
        $("#reportBtn").val("导出");
    }
    else {
        curCount--;
        $("#reportBtn").val(curCount + "秒后可再次导出");
    }
}
//导出excle
documentBindFunc.on('click','#reportBtn',function (){
    //获取table所有行数据
    var parkLot = $("#incomepark-billtable").bootstrapTable('getData');
    //获取table总条数
    var numTotal = $("#incomepark-billtable").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 data = fn.getParkLot();
    var plNos = [];
    for (var i = 0; i < data.length; i++) {
        plNos.push(data[i].code);
    }
    var userName = fn.getUserName();
    var reportDate="";
    var reportTabTag = $("#parkincome-toptab").find("li.ITD-graynav-topbaractive").attr('reportdatetabtag');
    if(reportTabTag==1){
        reportDate=$("#incomepark-daydaterange-btnsta").val();
    }else if(reportTabTag==2){
        var reportDateStr=$("#incomepark-weekdaterange-btnsta").attr('data-text');
        reportDate=reportDateStr.substring(11,21);
    }else if(reportTabTag==3){
        reportDate=$("#incomepark-monthdaterange-btnsta").val();
    }
    var indexparkAndVipTag = $("#srzb-tabbar .srzb-active").index();  //明细切换 0:临时停车 1:会员卡
    var orgName = $("#orgName").val();
    var orgId = fn.getOrgId();

    var url = dataUrl.util.exportIncomePark();
    var days = incomeparkFun.incomeparkgetQueryParam().days;
    var forms = exportIncomeDetailFormforbill(url, reportDate, orgId, orgName,
        reportTabTag,plNos,indexparkAndVipTag,userName,days);
    forms.submit();
});




function exportIncomeDetailFormforbill(url, reportDate, orgId, orgName,reportTabTag,plNos,indexparkAndVipTag,userName,days
) {

    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.name = "reportDate";
    input.value = reportDate;
    form.appendChild(input);

    var input1 = document.createElement("input");
    input1.name = "orgName";
    input1.value = orgName;
    form.appendChild(input1);

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

    var input3 = document.createElement("input");
    input3.name = "plNos";
    input3.value = plNos;
    form.appendChild(input3);

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

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


    var input16 = document.createElement("input");
    input16.name = "reportTabTag";
    input16.value = reportTabTag;
    form.appendChild(input16);

    var input17 = document.createElement("input");
    input17.name = "days";
    input17.value = days;
    form.appendChild(input17);

    return form;

};