monthBill.jsp 50 KB
Newer Older
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 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>

<%@include file="/WEB-INF/page/header.jsp" %>
<script>changeMenu(7, 1);//左边菜单active</script>
<div class="row white-bg border-bottom white-bg page-heading">
    <div class="col-lg-12">
        <h2>保单信息</h2>
        <ol class="breadcrumb">
            <li>主页</li>
            <li><a>对账模块</a></li>
            <li class="active"><strong>每月账单</strong></li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins" id="report-container">
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-1">
                            <select class="form-control" id="yearBill">
                                <option value="2019">2019年</option>
                                <option selected value="2018">2018年</option>
                                <option value="2017">2017年</option>
                                <option value="2016">2016年</option>
                                <option value="2015">2015年</option>
                            </select>
                        </div>
                        <div class="col-sm-1">
                            <select class="form-control" id="monthBill">
                                <option selected value="12">12月</option>
                                <option value="11">11月</option>
                                <option value="10">10月</option>
                                <option value="9">9月</option>
                                <option value="8">8月</option>
                                <option value="7">7月</option>
                                <option value="6">6月</option>
                                <option value="5">5月</option>
                                <option value="4">4月</option>
                                <option value="3">3月</option>
                                <option value="2">2月</option>
                                <option value="1">1月</option>
                            </select>
                        </div>
                        <div class="col-sm-3">
                            <div class="input-group"><input type="text" id="keyword" placeholder="搜索关键字"
                                                            class="input-sm form-control"><span class="input-group-btn">
                                <button type="button" class="btn btn-sm btn-primary"
                                        onclick="search()"> 查询</button> </span></div>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 10px">
                        <div class="col-md-6">
                            <div style="float: left; width: 25%">
                                <p>当月服务费</p>
                                <p><span id="addServiceCost">0.00</span>元</p>
                            </div>
                            <div style="float: left; width: 25%">
                                <p>退保扣减服务费</p>
                                <p><span id="reduceServiceCost">0.00</span>元</p>
                            </div>
                            <div style="float: left; width: 25%">
                                <p>当月应付服务费</p>
                                <p><span id="sumServiceCost">0.00</span>元</p>
                            </div>
                            <div style="float: left; width: 25%">
                                <p>当月成交保费</p>
                                <p><span id="dealBf">0.00</span>元</p>
                            </div>
                        </div>
                        <div class="col-sm-1">

                        </div>
                        <div class="col-sm-6" style="margin-top: 10px;text-align: right">
                            <button type="button" class="btn btn-large btn-info" onclick="confirmBills()"
                                    id="confirmBill">对账单确认无误
                            </button>
                            <span id="conformBillsText" style="color:red;">&nbsp;&nbsp;&nbsp;&nbsp;请在每月的第三个工作日确认对账单,过期将自动确认</span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div style="float: left;">
                                付款方:<span id="company-name"></span>&nbsp;&nbsp;&nbsp;&nbsp;对账时间:<span
                                    id="reconciliation-time-desc"></span>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 10px">
                        <div class="col-md-12 jqGrid_wrapper">
                            <table id="gridTable2"></table>
                            <div id="gridPager2"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-1" style="margin-top: 10px">
                            <a href="javaScript:void(0)" onclick="downloadBillOrder()">下载对账单</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-order-Remark1" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog" style="min-width: 650px;">
        <div class="modal-content">
            <div class="modal-header">
                <div class="table-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        <span class="white">&times;</span>
                    </button>
                    修改备注
                </div>
            </div>
            <div class="modal-body" id="modal-orderRemark-body">
                <div class="modal-body" >
                    <div id="mod-edit-tip" class="red clearfix"></div>
                    <input type="hidden" id="modal-remark-orderid" value="">
                    <input type="hidden" id="modal-remark-tableid" value="">
                    <div class="form-group" style="margin-left: 30px;">
                        <label class="control-label">请输入备注:</label>
                    </div>
                    <div class="form-group" style="margin-left: 30px;">
						     <textarea id="modal-orderRemark-text" rows="6" cols="70"
                                       placeholder="请输入备注"></textarea>
                    </div>
                </div>
                <div class="modal-footer no-margin-top">
                    <div class="text-center">
                        <button id="mod-check-success" type="button" class="btn btn-sm btn-primary" onclick="savaRemark1();">
                            保存
                        </button>
                        <button class="btn btn-sm" data-dismiss="modal">
                            取消
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div id="modal-reviewPay" class="modal fade" tabindex="-1">
    <div class="modal-dialog" style="max-width: 600px;">
        <div class="modal-content">
            <div class="modal-header">
                <div class="table-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        <span class="white">&times;</span>
                    </button>
                    确认支付
                </div>
            </div>
            <div class="modal-body">
                <form id="viewForm" class="form-horizontal">
                    <div class="form-group">
                        <input type="hidden" name="orderId" id="modal-reviewPay-orderId"/>
                        <input type="hidden" name="attachType" id="mod-file-bf"/>
                        <label class="col-sm-3 control-label">投保单</label>
                        <div class="col-sm-6 text-left" id="modal-reviewPay-1"></div>
                        <input class="col-sm-3" type="button" onclick="downloadOrderAttactByType(52)" value="一键下载">
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">转账证明</label>
                        <div class="col-sm-6 text-left" id="modal-reviewPay-2"></div>
                        <input class="col-sm-3" type="button" onclick="downloadOrderAttactByType(41)" value="一键下载">
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label text-left">备注</label>
                        <div class="col-sm-9 text-left"></div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12 control-label text-left" style="text-align: left">
                            <div id="remarkText" style="padding-left: 100px;"></div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">输入付款保费:</label>
                        <input type="text" class="col-sm-8 text-left " id="input-bf"> </input>
                        <label class="col-sm-1 control-label">元</label>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">反馈问题说明</label>
                        <textarea cols="45" rows="2" id="reviewPayFailReason" placeholder="投保单或转账证明有问题时填写!"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn " data-dismiss="modal"><i class="fa fa-share bigger-160"></i>取消</button>
                <button class="btn btn-warning" type="button" id="mod-reviewPay-fail-submit"><strong>反馈问题给律师</strong>
                </button>
                <button class="btn btn-primary" type="button" id="mod-reviewPay-submit"><strong>确认收款</strong></button>
            </div>
        </div>
    </div>
</div>

<div id="mod-file" class="modal fade" tabindex="-1">
    <div class="modal-dialog" style="max-width: 500px;">
        <div class="modal-content">
            <div class="modal-header no-padding">
                <div class="table-header" style="height: 26px;margin-top: 11px;">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                            style="margin-right: 10px;">
                        <span class="white">&times;</span>
                    </button>
                    上传投保单和保函模板
                </div>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form id="fileform">
                            <div class="col-xs-12">
                                <input type="hidden" name="attachType" id="mod-file-accountSel"/>
                                <input type="hidden" name="attachType" id="mod-file-attachType"/>
                                <input type="hidden" name="attachType" id="mod-file-attachTemplateType"/>
                                <input type="hidden" name="orderId" id="mod-file-orderId"/>
                                <div class="col-sm-6 ">
                                    <label for="fileId">投保单</label>
                                    <input type="file" id="fileId" name="avatar" multiple>
                                </div>
                                <div class="col-sm-6 ">
                                    <label for="templateId">保函模板</label>
                                    <div style="display: none" id="div_templateId">
                                        <input type="file" id="templateId" name="avatar" multiple>
                                    </div>
                                    <div style="text-align: center ;display:none" id="templateId_pic">
                                        <input type="hidden" id="templateId_pic_hidden_id" value="">
                                        <img src="" style="width: 119px;height: 111px" id="templateId_pic_img">
                                    </div>
                                    <div style="text-align: center ;display:none" id="templateId_del">
                                        <a href="javascript:void(0)" onclick="deletePic()">删除</a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <label class="col-sm-3 no-padding">输入收款账号</label>
                                <div class="col-sm-9 text-left no-padding">
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <label class="col-sm-2 no-padding" style="margin-top: 10px;">地区:</label>
                                <div class="col-sm-4 text-left" style="padding-bottom: 10px;">
                                    <select class="form-control" id="address-province">
                                        <option selected value="0">省</option>
                                    </select>
                                </div>
                                <label class="col-sm-2 no-padding"></label>
                                <div class="col-sm-4 text-left">
                                    <select class="form-control" id="address-city">
                                        <option selected value="0">市</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <label class="col-sm-2 no-padding" style="margin-top: 10px;">账户名:</label>
                                <div class="col-sm-10 text-left no-padding">
                                    <input type="text" id="mod-file-accountName" class="form-control"
                                           style="margin-bottom: 5px"/>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <label class="col-sm-2 no-padding" style="margin-top: 10px;">账号:</label>
                                <div class="col-sm-10 text-left no-padding">
                                    <input type="text" id="mod-file-accountNum" class="form-control"
                                           style="margin-bottom: 5px"/>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <label class="col-sm-2 no-padding" style="margin-top: 10px;">开户行:</label>
                                <div class="col-sm-10 text-left no-padding">
                                    <input type="text" id="mod-file-accountBank" class="form-control"
                                           style="margin-bottom: 5px"/>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <div class="hr hr-12 dotted"></div>
                            </div>
                            <div class="text-center">
                                <button type="button" class="btn btn-sm btn-primary" onclick="fileUpload();">上传</button>
                                <button type="reset" class="btn btn-sm">清除</button>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div><!-- /.row -->

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>


<%@include file="/WEB-INF/page/order/orderDetail.jsp" %>

<%@include file="/WEB-INF/page/footer.jsp" %>

<link href="${contextPath}/static/css/plugins/jQueryUI/jquery-ui-1.10.4.custom.min.css" rel="stylesheet"/>
<link href="${contextPath}/static/css/plugins/jqGrid/ui.jqgrid.css" rel="stylesheet">
<link rel="stylesheet" href="${contextPath}/static/ssdb/ace.fileinput.css"/>

<script src="${contextPath}/static/js/plugins/jqGrid/jquery.jqGrid.min.js"></script>
<script src="${contextPath}/static/js/plugins/jqGrid/i18n/grid.locale-cn.js"></script>

<!-- Data picker -->
<script src="${contextPath}/static/js/plugins/datapicker/bootstrap-datepicker.js"></script>

<script src="${contextPath}/static/js/plugins/lazyload/jquery.lazyload.js"></script>

<!-- 阿里OSS JSSDK -->
<script type="text/javascript" src="${contextPath}/static/ssdb/promise-6.1.0.js"></script>
<script type="text/javascript" src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js"></script>
<script type="text/javascript" src="${contextPath}/static/ssdb/ace.fileinput.js"></script>
<script type="text/javascript" src="${contextPath}/static/ssdb/uuid.js"></script>
<script type="text/javascript" src="${contextPath}/static/ssdb/fileupload.js?v=2"></script>
<script type="text/javascript">
    var accountsObject = {};

    var currentOrderId = null;
    var gridTable1 = null;
    var grid_selector = "#gridTable2";
    var notSubmitReviewPayFail = true;
    var notSubmitReviewPayPass = true;
    var pager_selector = "#gridPager2";
    jQuery(function ($) {
        $('#startDate').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            autoclose: true,
            format: "yyyy-mm-dd"
        });
        $('#endDate').datepicker({
            todayBtn: "linked",
            keyboardNavigation: false,
            forceParse: false,
            calendarWeeks: true,
            autoclose: true,
            format: "yyyy-mm-dd"
        });

        initGridTable();
        // resize to fit page size
        $(window).on("resize.jqGrid", function () {
            $(grid_selector).jqGrid("setGridWidth", $(".page-content").width());
        });
        // resize on sidebar collapse/expand
        var parent_column = $(grid_selector).closest("[class*='col-']");
        $(document).on("settings.ace.jqGrid", function (ev, event_name, collapsed) {
            if (event_name === "sidebar_collapsed" || event_name === "main_container_fixed") {
                // setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                setTimeout(function () {
                    $(grid_selector).jqGrid("setGridWidth", parent_column.width());
                }, 0);
            }
        });

        $(document).one('ajaxloadstart.page', function (e) {
            $(grid_selector).jqGrid('GridUnload');
            $('.ui-jqdialog').remove();
        });

        $('#mod-reviewPay-fail-submit').on('click', function () {
            reviewPayFailSubmit();
        });

        $('#mod-reviewPay-submit').on('click', function () {
            var sysBf = $("#mod-file-bf").val();
            var inputBf = $("#input-bf").val();
            if (inputBf == "") {
                alert("请输入付款保费");
                return;
            } else {
                var sysBfFoult = parseFloat(sysBf);
                var inputBfFoult = parseFloat(inputBf);
                if (sysBfFoult != inputBfFoult) {
                    alert("付款保费和平台保费不一致,请联系多问客服人员确认!");
                    return;
                }
            }
            reviewPayPassSubmit();
        });

        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            gridTable1.setGridWidth(width);
        });

        $('#mod-file-accountSel').change(function () {
            onchangeAccountSel();
        });
    });


    function errorCallbackDefault(data) {

    }

    function getBlankInfos(id) {
        $("#mod-file-accountName").val("");
        $("#mod-file-accountBank").val("");
        $("#mod-file-accountNum").val("");
        var url = '${contextPath}/order/getAreaBlankInfos';
        var parameters = {"orderId": id};
        postData(url, parameters, getBlankInfosCallback, errorCallbackDefault);
    }

    function loadPic(id, attachType) {
        var url = '${contextPath}/order/getOrderAttachsByType';
        var parameters = {"orderId": id, "attachType": attachType};
        var picUrl = '${oss_bucket_ssdb_url}';
        $.ajax({
            dataType: "json",
            url: url,
            type: "post",
            data: parameters,
            success: function (data) {
                if (data.success) {
                    if (data.attachs.length > 0) {
                        $("#div_templateId").hide();
                        $("#templateId_pic").show();
                        $("#templateId_del").show();
                        $("#templateId_pic_img").attr('src', picUrl + data.attachs[0].path);
                        $("#templateId_pic_hidden_id").val(data.attachs[0].id);
                    } else {
                        $("#div_templateId").show();
                        $("#templateId_pic").hide();
                        $("#templateId_del").hide();
                    }
                } else {
                    $("#div_templateId").show();
                    $("#templateId_pic").hide();
                    $("#templateId_del").hide();
                }
            }
        });
    }

    //删除图片
    function deletePic() {
        var id = '';
        id = $("#templateId_pic_hidden_id").val();

        var url = '${contextPath}/order/deleteAttachById';
        var parameters = {"id": id};
        $.ajax({
            dataType: "json",
            url: url,
            type: "post",
            data: parameters,
            success: function (data) {
                if (data.success) {
                    $("#div_templateId").show();
                    $("#templateId_pic").hide();
                    $("#templateId_del").hide();
                } else {
                    showMsg(data.message);
                }

            }
        });
    }

    function errorCallbackDefault(data) {

    }

    $("#address-province").change(function () {
        var selectval = $("#address-province").val();

        $.ajax({
            dataType: "json",
            url: "${contextPath}/pub/getAreas",
            type: "post",
            data: {
                'parentCode': selectval,
            },
            success: function (ret) {
                if (ret != null) {
                    var optionCity = '';
                    var cityListArray = ret;
                    $("#address-city").html(optionCity);
                    for (var i = 0; i < cityListArray.length; i++) {
                        optionCity += '<option value=' + cityListArray[i].code + '>' + cityListArray[i].name + '</option>';
                    }
                    $("#address-city").append(optionCity);
                    //选中
                    $("#address-city").val(0);
                }
            }
        });
    });

    $("#address-city").change(function () {
        var selectval = $("#address-city").val();
        var orderId = $("#mod-file-orderId").val();
        //根据公司id 和 省市 返回具体地址
        $.ajax({
            dataType: "json",
            url: "${contextPath}/company/getCompanyAccount",
            type: "post",
            data: {
                'cityCode': selectval,
                'orderId': orderId
            },
            success: function (ret) {
                if (ret.success) {
                    var tempRet = ret.ssdbCompanyAccount;
                    $("#mod-file-accountName").val(tempRet.accountName);
                    $("#mod-file-accountBank").val(tempRet.accountBank);
                    $("#mod-file-accountNum").val(tempRet.accountNum);
                } else {
                    $("#mod-file-accountName").val("");
                    $("#mod-file-accountBank").val("");
                    $("#mod-file-accountNum").val("");
                }
            }
        });
    });

    function getBlankInfosCallback(ret) {
        $("#address-province").html("");
        $("#address-city").html("");
        if (ret.success) {
            $("#mod-file").modal("toggle");
            var optionProvince = '';
            var provinceArray = ret.provinceList;
            for (var i = 0; i < provinceArray.length; i++) {
                optionProvince += '<option value=' + provinceArray[i].code + '>' + provinceArray[i].areaName + '</option>';
            }
            $("#address-province").append(optionProvince);
            //选中
            $("#address-province").val(ret.targetProvinceCode);

            var optionCity = '';
            var cityListArray = ret.cityList;
            if (cityListArray != null) {
                for (var i = 0; i < cityListArray.length; i++) {
                    optionCity += '<option value=' + cityListArray[i].code + '>' + cityListArray[i].areaName + '</option>';
                }
            }
            $("#address-city").append(optionCity);
            //选中
            $("#address-city").val(ret.targetCityCode);

            $("#mod-file-accountName").val(ret.accountName);
            $("#mod-file-accountBank").val(ret.accountBank);
            $("#mod-file-accountNum").val(ret.accountNum);

        } else {
            showMsg(ret.message);
        }
    }

    function getOrderAttachsCallback(data) {
        if (data.success) {
            notSubmitReviewPayFail = true;
            notSubmitReviewPayPass = true;
            var html1 = '';
            var es = data.example3s;
            var e = null;
            var url = '${oss_bucket_ssdb_url}';
            var thum = '${oss_bucket_ssdb_url_img}';
            var size = '${oss_bucket_ssdb_url_img_size}';
            var path = null;
            for (var i in es) {
                e = es[i];
                path = e.path;
                if (path.indexOf('/') != 0) {
                    path = '/' + path;
                }
                html1 += '<a href="' + url + path + '" target="_blank">';
                html1 += '<img class="lazy" src="${contextPath}/static/img/loading.gif" data-original="' + thum + path + size + e.suffix.toLowerCase() + '" height="100" width="100"/>';
                html1 += '</a>&nbsp;';
            }
            if (html1 != '') {
                $('#modal-reviewPay-1').html(html1);
            } else
                $('#modal-reviewPay-1').html('无');

            var html2 = '';
            es = data.payed;
            for (var i in es) {
                e = es[i];
                path = e.path;
                if (path.indexOf('/') != 0) {
                    path = '/' + path;
                }
                html2 += '<a href="' + url + path + '" target="_blank">';
                html2 += '<img class="lazy" src="${contextPath}/static/img/loading.gif" data-original="' + thum + path + size + e.suffix.toLowerCase() + '" height="100" width="100"/>';
                html2 += '</a>&nbsp;';
            }
            if (html2 != '') {
                $('#modal-reviewPay-2').html(html2);
            } else
                $('#modal-reviewPay-2').html('无');

            $("#modal-reviewPay").modal('toggle');
            //alert(1);
            setTimeout(function () {
                $("img.lazy").lazyload({
                    threshold: 200
                });
            }, 200);

        } else {
            showMsg(data.message);
        }

    }

    function initGridTable() {
        gridTable1 = jQuery(grid_selector).jqGrid({
            subGrid: false,
            url: "${contextPath}/order/getBillOrders",//
            datatype: "json",
            height: "auto",
            autowidth: true,
            colModel: [{
                name: "createDate",
                index: "createDate",
                label: "订单时间",
                width: 70,
                search: false
            }, {
                name: "payedDate",
                index: "payedDate",
                label: "付款时间",
                width: 90,
                search: false
            }, {
                name: "orderId",
                index: "orderId",
                label: "订单号",
                width: 80,
                search: false
            }, {
                name: "provinceText",
                index: "provinceText",
                label: "省",
                width: 40,
                search: false
            }, {
                name: "cityText",
                index: "cityText",
                label: "市",
                width: 40,
                sortable: false,
                search: false
            }, {
                name: "courtName",
                index: "courtName",
                label: "法院",
                width: 90,
                search: false
            }, {
                name: "plaintiff",
                index: "plaintiff",
                label: "原告",
                width: 50,
                search: false
            }, {
                name: "sqbd",
                index: "sqbd",
                label: "保全金额",
                width: 80,
                search: false
            }, {
                name: "bf",
                index: "bf",
                label: "保费",
                width: 60,
                search: false,
                formatter: changeCostStyle
            }, {
                name: "serviceCostProportion",
                index: "serviceCostProportion",
                label: "服务费比例",
                width: 60,
                search: false
            }, {
                name: "serviceCost",
                index: "serviceCost",
                label: "应付服务费",
                width: 80,
                search: false,
                formatter: changeCostStyle
            }, {
                name: "settlementType",
                index: "settlementType",
                label: "结算情况",
                width: 60,
                search: false,
                formatter: changeCostStyle
            }, {
                name: "remark",
                index: "remark",
                label: "备注",
                width: 50,
                search: false
            }, {
                align: "center",
                label: "操作",
                width: 120,
                viewable: false,
                sortable: false,
                fixed: true,
                formatter: operationLink
            }],
            sortname: "createDate",
            sortorder: "desc",
            viewrecords: true,
            rowNum: 1000,
            rowList: [10, 500, 1000],
            pager: pager_selector,
            altRows: true,
            //toppager : true,
            multiselect: false,
            //multikey : "ctrlKey",
            multiboxonly: true,
            rownumbers: true,
            rownumWidth: 30,

        });
    }

    function optionFormatter(cellvalue, options, cell) {
        var template = cell.lpDate;
        if (cell.receivablesOverTime) {
            template += "  <button type=\"button\" style='background-color: #d30404;'><span style='color:white'>已超时</span></button>";
        }
        return template;
    }

    function isBlank(obj) {
        var result = false;
        if (obj == undefined || obj == null || obj == 'null' || obj.length < 1) {
            result = true;
        }
        return result;
    }

    function onchangeAccountSel() {
        var obj = {
            'accountBank': 'mod-file-accountBank',
            'accountName': 'mod-file-accountName',
            'accountNum': 'mod-file-accountNum'
        };
        var info = {'accountBank': '', 'accountName': '', 'accountNum': ''};
        var v = $('#mod-file-accountSel').val();
        if (!isBlank(v)) {
            info = accountsObject[v];
        }
        for (var o in obj) {
            $('#' + obj[o]).val(info[o]);
        }
    }

    //向后台请求数据
    function postData(url, parameters, successCallback, errorCallback) {
        $.ajax({
            type: "POST",
            url: url,
            data: parameters,
            dataType: "json",
            success: function (data) {
                successCallback(data);
            },
            error: function (data) {
                errorCallback(data);
            }
        });
    }

    //操作链接
    function operationLink(cellvalue, options, rowObject) {
        var result = '<a href="javascript:void(0);" style="color:blue" onclick="showdetail(\'' + rowObject.orderId + '\')">详细</a>';
        result += '&nbsp;|&nbsp;<a href="javascript:void(0);" style="color:blue" onclick="showRemark1(\'' + rowObject.remark + '\',' + rowObject.orderId + ',\'' + grid_selector + '\')">添加备注</a>';
        return result;
    }

    function showRemark1(remark,id,tableId){
        if (remark != 'null') {
            $('#modal-orderRemark-text').val(remark);
        } else {
            $('#modal-orderRemark-text').val("");
        }
        $("#modal-remark-tableid").val(tableId);
        $("#modal-remark-orderid").val(id);
        $("#modal-order-Remark1").modal("toggle");
    }

    function savaRemark1() {
        var id = $("#modal-remark-orderid").val();
        var remark = $("#modal-orderRemark-text").val();
        var tableId = $("#modal-remark-tableid").val();
        $.ajax({
            dataType : "json",
            url : "${contextPath}/order/updateBillRemark",
            type : "post",
            data : {
                'orderId' : id,
                'remark':remark
            },
            complete : function(ret) {
                $("#modal-order-Remark1").modal("toggle");
                jQuery(tableId).trigger("reloadGrid");
            }
        });
    }

    //四舍五入保留2位小数(不够位数,则用0替补)
    function keepTwoDecimalFull(num) {

        if (isNaN(parseFloat(num))) {
            console.log("传递参数错误,请检查!" + num)
            return num;
        }

        var f = Math.round(num * 100) / 100;
        var s = f.toString();
        var rs = s.indexOf('.');
        if (rs < 0) {
            rs = s.length;
            s += '.';
        }
        while (s.length <= rs + 2) {
            s += '0';
        }
        return s;
    }

    //根据是否退保改变样式
    function changeCostStyle(cellvalue, options, rowObject) {
        var result = null;
        cellvalue = keepTwoDecimalFull(cellvalue)
        //退保
        if (rowObject.signB) {
            result = '<span style="color: #DC143C">' + cellvalue + '</span>'
        } else {
            result = cellvalue;
        }
        return result;
    }

    function reloadGrid() {
        gridTable1.trigger('reloadGrid');
    }

    //保存付款未通过成功后回调
    function reviewPayFailCallback(data) {
        notSubmitReviewPayFail = true;
        if (data.success) {
            $("#modal-reviewPay").modal('toggle');
            showMsg('保存成功');
            reloadGrid();
        } else {
            showMsg(data.message);
        }
    }

    //保存付款未通过失败后回调
    function reviewPayFailErrorCallback(data) {
        notSubmitReviewPayFail = true;
    }


    //保存付款未通过
    function reviewPayFailSubmit() {
        if (notSubmitReviewPayFail) {
            var reason = $('#reviewPayFailReason').val();
            if (reason != undefined && reason.length > 0) {
                notSubmitReviewPayFail = false;
                var url = '${contextPath}/order/saveReviewPayFail';
                var parameters = {"reason": reason, "orderId": currentOrderId};
                postData(url, parameters, reviewPayFailCallback, reviewPayFailErrorCallback);
            } else {
                alert('反馈问题说明不能为空');
            }
        } else {
            showMsg('提交中,请稍候');
        }
    }

    function reviewPayOperation(id, remark, bf) {
        $("#input-bf").val("");
        if (remarkText != "null") {
            $("#remarkText").html(remark);
        }
        $("#mod-file-bf").val(bf);
        $("#modal-reviewPay-orderId").val(id);
        currentOrderId = id;
        var url = '${contextPath}/order/getOrderAttachs';
        var parameters = {"orderId": id};
        postData(url, parameters, getOrderAttachsCallback, errorCallbackDefault);
    }

    //保存付款通过成功后回调
    function reviewPayPassCallback(data) {
        notSubmitReviewPayPass = true;
        if (data.success) {
            $("#modal-reviewPay").modal('toggle');
            showMsg('保存成功');
            reloadGrid();
        } else {
            showMsg(data.message);
        }
    }

    function downloadOrderAttactByType(type) {
        var orderId = $("#modal-reviewPay-orderId").val();
        var url = "${contextPath}/order/downloadOrderAttachsByType?id=" + orderId + "&key=" + type;
        window.open(url);
    }

    //保存付款未通过失败后回调
    function reviewPayPassErrorCallback(data) {
        notSubmitReviewPayPass = true;
    }

    //保存付款通过
    function reviewPayPassSubmit() {
        if (notSubmitReviewPayPass) {
            notSubmitReviewPayPass = false;
            var url = '${contextPath}/order/saveReviewPayPass';
            var parameters = {"orderId": currentOrderId};
            postData(url, parameters, reviewPayPassCallback, reviewPayPassErrorCallback);
        } else {
            showMsg('提交中,请稍候');
        }
    }

    function search() {
        var keyword = $("#keyword").val();
        var startDate = $("#yearBill").val();
        var endDate = $("#monthBill").val();
        gridTable1.setGridParam({
            postData: {'keyword': keyword, 'year': startDate, 'month': endDate},
            url: '${contextPath}/order/getBillOrders',
            page: 1
        }).trigger('reloadGrid');
        $(function () {
            var data = {"year": startDate, "month": endDate};
            getTotalCost(data);
        });
    }

    //显示信息
    function showMsg(msg) {
        if (msg != undefined && msg.length > 0) {
            alert(msg);
        }
    }

    function uploadFileShow(attachType, attachTemplateType, orderId) {
        document.getElementById("fileform").reset();

        $("#mod-file-orderId").val(orderId);
        loadPic(orderId, 70);
        getBlankInfos(orderId);
        $("#mod-file-attachType").val(attachType);
        $("#mod-file-attachTemplateType").val(attachTemplateType);
    }


    function uploadFileSuccess() {
        alert("文件上传成功!");
        $("#mod-file").modal("toggle");
        gridTable1.trigger('reloadGrid');
    }

    var appServer = 'http://b.duowenlvshi.com/oss/token?name=ssdb';
    var bucket = '${oss_bucket_ssdb}';
    var region = 'oss-cn-shenzhen';
    var Buffer = OSS.Buffer;
    var OSS = OSS.Wrapper;
    var STS = OSS.STS;
    var applyTokenDo = function (func) {
            var url = appServer;
            $.ajax({
                type: "POST",
                url: url,
                data: "",
                dataType: "jsonp",
                success: function (e) {
                    var client = new OSS({
                        region: region,
                        accessKeyId: e.AccessKeyId,
                        accessKeySecret: e.AccessKeySecret,
                        stsToken: e.SecurityToken,
                        bucket: bucket
                    });
                    return func(client);
                },
                error: function (data) {
                    console.log(data);
                }
            });
        }
    ;
    var uploadFile = function (client) {
            var accountBank = $('#mod-file-accountBank').val();
            var accountName = $('#mod-file-accountName').val();
            var accountNum = $('#mod-file-accountNum').val();

            var orderId = document.getElementById('mod-file-orderId').value;
            var picfilenum = document.getElementById('fileId').files.length;
            var keyArray = "";
            var fileNameArray = "";
            var fileTypeArray = "";
            for (var i = 0; i < picfilenum; i++) {
                var picFile = document.getElementById('fileId').files[i];
                var fileName = UUIDjs.create().hex;
                var fileType = getFileType(picFile.name);
                var oDate = new Date(); //实例一个时间对象;
                var y = oDate.getFullYear();   //获取系统的年;
                var m = oDate.getMonth() + 1;   //获取系统月份,由于月份是从0开始计算,所以要加1
                var d = oDate.getDate(); // 获取系统日
                var key = "ssdb/order/" + y + "/" + m + "/" + d + "/" + fileName + "." + fileType;

                client.multipartUpload(key, picFile, {
                    progress: progress
                }).then(function (res) {

                });
                if (i == picfilenum - 1) {
                    keyArray += key;
                    fileNameArray += fileName;
                    fileTypeArray += fileType;
                } else {
                    keyArray = keyArray + key + ",";
                    fileNameArray = fileNameArray + fileName + ",";
                    fileTypeArray = fileTypeArray + fileType + ",";
                }
            }


            var picfilenumTemplate = document.getElementById('templateId').files.length;
            var keyArrayTemplate = "";
            var fileNameArrayTemplate = "";
            var fileTypeArrayTemplate = "";
            for (var i = 0; i < picfilenumTemplate; i++) {
                var picFile = document.getElementById('templateId').files[i];
                var fileName = UUIDjs.create().hex;
                var fileType = getFileType(picFile.name);
                var oDate = new Date(); //实例一个时间对象;
                var y = oDate.getFullYear();   //获取系统的年;
                var m = oDate.getMonth() + 1;   //获取系统月份,由于月份是从0开始计算,所以要加1
                var d = oDate.getDate(); // 获取系统日
                var key = "ssdb/order/" + y + "/" + m + "/" + d + "/" + fileName + "." + fileType;

                client.multipartUpload(key, picFile, {
                    progress: progress
                }).then(function (res) {

                });
                if (i == picfilenumTemplate - 1) {
                    keyArrayTemplate += key;
                    fileNameArrayTemplate += fileName;
                    fileTypeArrayTemplate += fileType;
                } else {
                    keyArrayTemplate = keyArrayTemplate + key + ",";
                    fileNameArrayTemplate = fileNameArrayTemplate + fileName + ",";
                    fileTypeArrayTemplate = fileTypeArrayTemplate + fileType + ",";
                }
            }

            if (fileTypeArrayTemplate == null || fileTypeArrayTemplate == '') {
                showMsg('保函模板不能为空,请重新上传');
                return;
            }
            var imgeType = fileTypeArrayTemplate.toLowerCase();
            if (imgeType != "bmp" && imgeType != "jpg" && imgeType != "jpeg" && imgeType != "png" && imgeType != "gif" && imgeType != "bmp"
                && imgeType != "pcx" && imgeType != "tiff" && imgeType != "tga" && imgeType != "exif" && imgeType != "fpx" && imgeType != "svg" && imgeType != "psd") {
                showMsg('保函模板必须为图片,请重新上传');
                return;
            }


            saveToDB(orderId, keyArray, keyArrayTemplate, fileNameArray, fileNameArrayTemplate, fileTypeArray, fileTypeArrayTemplate, accountBank, accountName, accountNum);
        }
    ;
    var progress = function (p) {//上传成功的进度条
            return function (done) {
                done();
            };
        }
    ;
    var getFileURL = function (client) {
            var object = data[0].name;
            var filename = object.replace(/^.*[\\\/]/, '');
            console.log(object + ' => ' + filename);
            var result = client.signatureUrl(object, {
                response: {
                    'content-disposition': 'attachment; filename="' + filename + '"'
                }
            });
            // fileRequest(result);
            //  return result;
        }
    ;

    //文件上传处理
    function fileUpload() {
        var obj = {'mod-file-accountBank': '开户行', 'mod-file-accountName': '开户名', 'mod-file-accountNum': '银行账户'};
        for (var o in obj) {
            if (isBlank($('#' + o).val())) {
                showMsg(obj[o] + '不能为空');
                return;
            }
        }
        applyTokenDo(uploadFile);
    }

    function getFileType(fileName) {
        var ldot = fileName.lastIndexOf('.')
        if (ldot >= 0)
            return fileName.substring(ldot + 1);
        else
            return "";
    }

    //保存图片路径到数据库
    function saveToDB(orderId, keyArray, keyArrayTemplate, fileNameArray, fileNameArrayTemplate, fileTypeArray, fileTypeArrayTemplate, accountBank, accountName, accountNum) {
        var attachType = $("#mod-file-attachType").val();
        var attachTemplateType = $("#mod-file-attachTemplateType").val();
        var parameters = {
            "orderId": orderId,
            "attachType": attachType,
            "attachTemplateType": attachTemplateType,
            "path": keyArray,
            "pathTemplate": keyArrayTemplate,
            "fileNameArray": fileNameArray,
            "fileNameArrayTemplate": fileNameArrayTemplate,
            "fileTypeArrayTemplate": fileTypeArrayTemplate,
            "fileTypeArray": fileTypeArray,
            "accountBank": accountBank,
            "accountName": accountName,
            "accountNum": accountNum
        };

        $.ajax({
            dataType: "json",
            url: "${contextPath}/order/bdTempleteUpload",
            type: "post",
            data: parameters,
            success: function (result) {
                if (result.success) {
                    uploadFileSuccess();
                } else
                    alert(result.message);
            }
        });
    }
</script>
<script>
    function downloadBillOrder() {
        var year = $("#yearBill").val();
        var month = $("#monthBill").val();
        var data = {"year": year, "month": month};
        window.open('${contextPath}/order/downloadBillOrder?year=' + year + '&month=' + month);
    }

    function confirmBills() {
        //确认取消按钮
        if(window.confirm('是否确认账单无误,确认后账单将无法修改,请谨慎操作!')){
            var year = $("#yearBill").val();
            var month = $("#monthBill").val();
            var data = {"year": year, "month": month};
            $.ajax({
                dataType: "json",
                url: "${contextPath}/order/confirmBillOrder",
                type: "post",
                data: data,
                success: function (result) {
                    if (result != null) {
                        $("#confirmBill").show();
                        $("#conformBillsText").show();
                        if (result.success) {
                            $("#confirmBill").html("已确认");
                            $("#confirmBill").attr('disabled', true);
                        }
                        alert(result.message);
                    }
                }
            });
            return true;
        }else{
            return false;
        }
    }

    function getTotalCost(data) {
        $.ajax({
            dataType: "json",
            url: "${contextPath}/order/getTotalCost",
            type: "post",
            data: data,
            success: function (result) {
                if (result != null) {
                    $("#addServiceCost").html(keepTwoDecimalFull(result.addServiceCost));
                    $("#reduceServiceCost").html(keepTwoDecimalFull(result.reduceServiceCost));
                    $("#sumServiceCost").html(keepTwoDecimalFull(result.sumServiceCost));
                    $("#dealBf").html(keepTwoDecimalFull(result.dealBf));
                    $("#confirmBill").show();
                    $("#conformBillsText").show();
                    if (result.confirmBill) {
                        $("#confirmBill").html("已确认");
                        $("#confirmBill").attr('disabled', true);
                    } else {
                        $("#confirmBill").html("对账单确认无误");
                        $("#confirmBill").attr('disabled', false);
                    }
                    if (result.orderTime) {
                        var time = result.orderTime;
                        var arr = time.split("-");
                        if (arr.length > 2) {
                            $("#yearBill").val(arr[0]);
                            $("#monthBill").val(arr[1]);
                        }
                    }
                    $("#company-name").html(result.companyName);
                    $("#reconciliation-time-desc").html(result.reconciliationTimeDesc);
                    if (result.currentMon) {
                        $("#conformBillsText").hide();
                        $("#confirmBill").hide();
                        alert("该月账单未生成。。")
                    }
                }
            }
        });
    }

    $(function () {
        var data = {"year": "", "month": ""};
        getTotalCost(data);
        gridTable1.setGridParam({
            postData: {},
            url: '${contextPath}/order/getBillOrders',
            page: 1
        }).trigger('reloadGrid');
    });
</script>