con_contract_content_confirm.lview 44.4 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ZLF  
    $Date: 2014-11-20 下午8:50:38  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <s:server-script import="con_print_path.js"><![CDATA[
            set_parameter_file_path();
        ]]></s:server-script>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_content_asset_detail_link_id" url="${/request/@context_path}/modules/cont/CON505/con_contract_content_asset_detail.lview"/>
        <!--         <a:link id="con_contract_update_print_fin_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update_print_word.lview"/> -->
        <a:link id="con_contract_create_content_link_id" model="cont.CON505.con_contract_create_content" modelaction="update"/>
        <a:link id="con_contract_save_print_information_link_id" model="cont.CON505.con_contract_save_print_information" modelaction="update"/>
        <a:link id="con_contract_uploadfile" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="con_contract_content_confirm_link" url="${/request/@context_path}/modules/cont/CON504/con_contract_content_print.lview"/>
        <a:link id="con_contract_content_delete_link" model="cont.CON505.con_contract_content_delete" modelaction="batch_update"/>
        <a:link id="con_contract_dowload_uploadfile" url="${/request/@context_path}/modules/cont/CON500/con_atm_batch_dl.lsc"/>
        <a:link id="con504_change_confirm_status_link" model="cont.CON504.con_change_content_confirm_status" modelaction="execute"/>
        <a:link id="con_contract_update_print_fin_link_id" url="${/request/@context_path}/modules/cont/CON504/con_contract_update_print_word.lsc"/>
        <a:link id="file_copy_from_template_link_id" url="${/request/@context_path}/office_edit_online/file_copy_from_template.lsc"/>
        <a:link id="con_contract_content_edit_office_online_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_content_edit_office_online.lview"/>
        <a:link id="con_doc_batch_create_link_id" url="${/request/@context_path}/modules/cont/CON500/con_doc_batch_create.lsc"/>
        <!-- 汽车融资租赁合同 FIN -->
        <!--  获取合同打印路径的js -->
        <script src="${/request/@context_path}/modules/cont/CON504/javascripts/contract_print_path.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
            function set_print_detail_btn_disable() {
                $('con_print_detail_print_id').disable();
            }
            
            function set_print_detail_btn_enable() {
                $('con_print_detail_print_id').enable();
            }
            
            function con_print_detail_query() {
                $('con_contract_update_print_detail_line_ds').query();
                $('con_print_detail_print_id').enable();
            }
            
            function con_print_detail_clear() {
                $('con_contract_update_print_detail_grid_id').clear();
            }
            
            function line_refresh() {
                $('con_contract_update_print_detail_line_ds').query();
            }
            
            
            function con_print_detail_print() {
                var result_ds = $('con_contract_update_print_detail_line_ds');
                var records = result_ds.getAll();
                var total_count = 0;
                for (var m = 0;m < records.length;m++) {
                    if (records[m].get('file_exists_flag') != 'Y') {
                        total_count = total_count + 1;
                    }
                }
                if (total_count === 0) {
                    Leaf.showMessage('${l:PROMPT}', '文本都已生成');
                    return;
                }
                var rd = result_ds.getSelected();
                var content_id = rd[0].get('content_id');
                Leaf.request({
                    url: $('file_copy_from_template_link_id').getUrl(),
                    para: {
                        contract_id: '${/parameter/@contract_id}',
                        content_id: content_id,
                        file_path: '${/parameter/@file_path}',
                        batch_flag: 'Y'
                    },
                    success: function(res) {
                        var global_i = 0;
                        var execute_i = 0;
            
                        function open_batch_window(i) {
                            var record = records[i];
                            if (record.get('content_id') && record.get('file_exists_flag') != 'Y') {
                                execute_i++;
                                Leaf.Masker.mask($('${/parameter/@winid}').wrap, '正在执行第' + execute_i + '条,' + record.get('content_number') + ',请等待,' + '总计' + total_count + '条');
                                var win = new Leaf.Window({
                                    id: 'edit_office_online_link_winid' + i,
                                    url: $('con_contract_content_edit_office_online_link_id').getUrl(),
                                    params: {
                                        content_id: record.get('content_id'),
                                        winid: 'edit_office_online_link_winid' + i,
                                        first_copy_flag: 'Y',
                                        contract_id: '${/parameter/@contract_id}',
                                        batch_flag: 'Y'
                                    },
                                    width: 1000,
                                    height: 1000,
                                    x: -10000,
                                    y: -10000,
                                    draggable: true,
                                    modal: false
                                });
                                win.on('close', function() {
                                    Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
                                    if (global_i == records.length - 1) {
                                        result_ds.query(result_ds.currentPage);
                                    } else {
                                        global_i++;
                                        open_batch_window(global_i);
                                    }
                                });
                            } else {
                                global_i++;
                                open_batch_window(global_i);
                            }
                        }
                        open_batch_window(global_i);
                    },
                    error: function() {
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            
            }
            
            
            
            //保留历史版本
            // function con_print_rec(record) {
            // Leaf.request({
            // url: $('con_contract_save_print_information_link_id').getUrl(),
            // para: {
            // contract_id: '${/parameter/@contract_id}',
            // content_id: record.get('content_id')
            // },
            // sync: true,
            // // 同步请求,保证批量打印顺序进行
            // success: function() {
            // var ds1 = $('con_contract_update_print_detail_header_ds');
            // var rec = ds1.getCurrentRecord();
            // var contract_number = rec.get('contract_number');
            // var templt_name, clause_usage = record.get('clause_usage'),
            // business_type = '${/parameter/@business_type}',
            // templet_id = record.get('templet_id'),
            // templet_code = record.get('templet_code'),
            // bp_id = record.get('bp_id'),
            // bp_class = record.get('bp_class'),
            // mortgage_id = record.get('mortgage_id') || '',
            // couple_guarantee_flag = record.get('couple_guarantee_flag'),
            // content_number = record.get('content_number'),
            // content_id = record.get('content_id'),
            // spv_company_code = rec.get('spv_company_code');
            // var link;
            // var pdf_key_path = 'D:/projects/HLS/web/WEB-INF/leaf.plugin.export.word/';
            // var doc_name = 'D:/projects/HLS/excel/' + clause_usage + '/'; // server path
            // if (clause_usage == 'FIN') {
            // templt_name = 'yonda_fin_contract.xml';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // con_name = '零售业租赁合同';
            // } else if (clause_usage == 'MOR') {
            // templt_name = 'yonda_mor_contract.xml';
            // con_name = '抵押合同(上海)';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'FIN_ADMIN') {
            // templt_name = 'yonda_fin_contract.xml';
            // con_name = '管理人员租赁合同';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'FIN_TEST_DRIVE') {
            // templt_name = 'yonda_fin_contract.xml';
            // con_name = '试乘试驾租赁合同';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'PAY_AGR') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '付款承诺书';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'MOR_OUT_SH') {
            // templt_name = 'yonda_mor_contract.xml';
            // con_name = '抵押合同(外地)';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'LOAN_AGR') {
            // templt_name = 'yonda_loan_agr_contract.xml';
            // con_name = '借款协议书';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'MOR_CONFIROM') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '抵押确认书';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'RISK_CONFIROM') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '风险确认书';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'CAR_TRANS') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '汽车转让协议';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'SUP_TRANS') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '补充协议';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'COMMON_TENANT_ADMIN') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '共同承租人确认书(管理人员)';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'COMMON_TENANT_RETAIL') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '共同承租人确认书(零售)';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'PRINCIPAL_PROD') {
            // templt_name = 'yonda_prod_contract.xml';
            // con_name = '委托采购合同';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'FINISH') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '结清用表单';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // } else if (clause_usage == 'ABNORMAL_FINISH') {
            // templt_name = 'yonda_other_contract.xml';
            // con_name = '非正常结清用表单';
            // link = $('con_contract_update_print_fin_link_id').getUrl();
            // }
            // //templet_id租赁物件验收证明    上牌过户确认书不存在签章字段的,
            // var sign_flag;
            // if (templet_id == 1363 || templet_id == 1283) {
            // sign_flag = 'N';
            // } else {
            // sign_flag = 'Y';
            // }
            // var url = link + '?templt_name=' + templt_name + '&contract_id=' + '${/parameter/@contract_id}' + '&document_category=' + '${/parameter/@document_category}' + '&clause_usage=' + clause_usage + '&templet_id=' + templet_id + '&bp_id=' + bp_id + '&mortgage_id=' + mortgage_id + '&content_number=' + content_number + '&contract_number=' + contract_number + '&couple_guarantee_flag=' + couple_guarantee_flag + '&content_id=' + content_id + '&doc_name=' + doc_name + '&company_id=' + '${/parameter/@company_id}' + '&business_type=' + business_type + '&templet_code=' + templet_code + '&con_name=' + con_name + '&pdf_key_path=' + pdf_key_path + '&spv_company_code=' + spv_company_code + '&sign_flag=' + sign_flag;
            // var form = document.createElement("form");
            // form.target = "word_export_window";
            // form.method = "post";
            // form.action = url;
            // var iframe = Ext.get('word_export_window') || new Ext.Template('<iframe id ="word_export_window" name="word_export_window" style="position:absolute;left:-10000px;top:-10000px;width:1px;height:1px;display:none"></iframe>').insertFirst(document.body, {}, true);
            // document.body.appendChild(form);
            // form.submit();
            // Ext.fly(form).remove();
            // //unlock_current_window();
            // set_print_detail_btn_enable();
            // },
            // failure: function() {
            // //unlock_current_window();
            // set_print_detail_btn_enable();
            // },
            // error: function() {
            // //unlock_current_window();
            // set_print_detail_btn_enable();
            // },
            // scope: this
            // });
            
            // }
            
            function con_print_rec(record) {
                Leaf.request({
                    url: $('con_contract_save_print_information_link_id').getUrl(),
                    para: {
                        contract_id: '${/parameter/@contract_id}',
                        content_id: record.get('content_id')
                    },
                    sync: true,
                    // 同步请求,保证批量打印顺序进行
                    success: function() {
                        var ds1 = $('con_contract_update_print_detail_header_ds');
                        var rec = ds1.getCurrentRecord();
                        var contract_number = rec.get('contract_number');
                        var templt_name, clause_usage = record.get('clause_usage'),
                            business_type = '${/parameter/@business_type}',
                            templet_id = record.get('templet_id'),
                            templet_code = record.get('templet_code'),
                            bp_id = record.get('bp_id'),
                            bp_class = record.get('bp_class'),
                            mortgage_id = record.get('mortgage_id') || '',
                            couple_guarantee_flag = record.get('couple_guarantee_flag'),
                            content_number = record.get('content_number'),
                            content_id = record.get('content_id'),
                            spv_company_code = rec.get('spv_company_code');
                        var link;
                        var pdf_key_path = get_pdf_key_path();
                        var doc_name = get_doc_path() + clause_usage + '/'; // server path
                        if (clause_usage == 'FIN') {
                            templt_name = 'yonda_fin_contract.xml';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                            con_name = '零售业租赁合同';
                        } else if (clause_usage == 'MOR') {
                            templt_name = 'yonda_mor_contract.xml';
                            con_name = '抵押合同(上海)';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'FIN_ADMIN') {
                            templt_name = 'yonda_fin_contract.xml';
                            con_name = '管理人员租赁合同';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'FIN_TEST_DRIVE') {
                            templt_name = 'yonda_fin_contract.xml';
                            con_name = '试乘试驾租赁合同';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'PAY_AGR') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '付款承诺书';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'MOR_OUT_SH') {
                            templt_name = 'yonda_mor_contract.xml';
                            con_name = '抵押合同(外地)';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'LOAN_AGR') {
                            templt_name = 'yonda_loan_agr_contract.xml';
                            con_name = '借款协议书';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'MOR_CONFIROM') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '抵押确认书';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'RISK_CONFIROM') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '风险确认书';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'CAR_TRANS') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '汽车转让协议';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'SUP_TRANS') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '补充协议';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'COMMON_TENANT_ADMIN') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '共同承租人确认书(管理人员)';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'COMMON_TENANT_RETAIL') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '共同承租人确认书(零售)';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'PRINCIPAL_PROD') {
                            templt_name = 'yonda_prod_contract.xml';
                            con_name = '委托采购合同';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'FINISH') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '结清用表单';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'ABNORMAL_FINISH') {
                            templt_name = 'yonda_other_contract.xml';
                            con_name = '非正常结清用表单';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        } else if (clause_usage == 'PRJ') {
                            templt_name = 'yonda_fin_contract.xml';
                            con_name = '项目类合同';
                            link = $('con_contract_update_print_fin_link_id').getUrl();
                        }
                        //templet_id租赁物件验收证明    上牌过户确认书不存在签章字段的,
                        var sign_flag;
                        if (templet_id == 1363 || templet_id == 1283) {
                            sign_flag = 'N';
                        } else {
                            sign_flag = 'Y';
                        }
                        var url = link + '?templt_name=' + templt_name + '&contract_id=' + '${/parameter/@contract_id}' + '&document_category=' + '${/parameter/@document_category}' + '&clause_usage=' + clause_usage + '&templet_id=' + templet_id + '&bp_id=' + bp_id + '&mortgage_id=' + mortgage_id + '&content_number=' + content_number + '&contract_number=' + contract_number + '&couple_guarantee_flag=' + couple_guarantee_flag + '&content_id=' + content_id + '&doc_name=' + doc_name + '&company_id=' + '${/parameter/@company_id}' + '&business_type=' + business_type + '&templet_code=' + templet_code + '&con_name=' + con_name + '&pdf_key_path=' + pdf_key_path + '&spv_company_code=' + spv_company_code + '&sign_flag=' + sign_flag;
                        Leaf.request({
                            url: url,
                            para: null,
                            success: function(obj) {
                                var status = obj.result.sign_status;
                                if (status == true) {
                                    Leaf.showMessage('${l:PROMPT}', content_number + '打印合同成功!');
                                    $('con_contract_update_print_detail_line_ds').query();
                                    // 修改合同打印字段信息
                                } else {
                                    Leaf.showMessage('${l:PROMPT}', content_number + '合同打印失败,请重新打印!');
                                }
                                unlock_current_window();
                            },
                            failure: function() {
                                Leaf.showMessage('${l:PROMPT}', content_number + '合同打印失败,请重新打印!');
                                unlock_current_window();
                            },
                            error: function() {
                                Leaf.showMessage('${l:PROMPT}', content_number + '合同打印错误,请重新打印!');
                                unlock_current_window();
                            },
                            scope: this
                        });
                    },
                    failure: function() {
                        unlock_current_window();
            
                    },
                    error: function() {
                        unlock_current_window();
            
                    },
                    scope: this
                });
            
            }
            
            function on_print_detail_lov(record, name) {
                if (record.isNew) {
                    return 'print_detail_grid_lov_id';
                } else {
                    return '';
                }
            }
            
            function on_print_detail_combobox(record, name) {
                if (record.isNew) {
                    return 'print_detail_grid_combobox_id';
                } else {
                    return '';
                }
            }
            
            function con_print_detail_add() {
                $('con_contract_update_print_detail_grid_id').showEditorByRecord($('con_contract_update_print_detail_line_ds').create());
            }
            
            function lock_current_window() {
                Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
            }
            
            function con_print_detail_create() {
                lock_current_window();
                Leaf.request({
                    url: $('con_contract_create_content_link_id').getUrl(),
                    para: {
                        contract_id: '${/parameter/@contract_id}'
                    },
                    success: function(res) {
                        var result_ds = $('con_contract_update_print_detail_line_ds');
                        result_ds.query(result_ds.currentPage);
                        unlock_current_window();
                    },
                    error: function() {
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            }
            
            function con_print_detail_save() {
                lock_current_window();
                if ($('con_contract_update_print_detail_line_ds').validate(true)) {
                    //$('con_contract_update_print_detail_line_ds').submitSelected();
                    $('con_contract_update_print_detail_line_ds').submit();
                } else {
                    unlock_current_window();
                }
            }
            
            function on_result_submitsuccess() {
                unlock_current_window();
                line_refresh();
            }
            
            function on_result_submitfailed() {
                unlock_current_window();
                line_refresh();
            }
            
            function on_result_add(ds, record, index) {
                record.set('contract_id', '${/parameter/@contract_id}');
            }
            
            function see_asset_detail_renderer(value, record, name) {
                if (name == 'asset_detail' && record.get('content_id')) {
                    return '<a href="javascript:con505_asset_detail(' + record.get('content_id') + ',' + record.get('con_contract_bp_id') + ',\'' + record.get('bp_category') + '\');">' + '资产明细' + '</a>';
                }
            }
            
            function con505_asset_detail(content_id, con_contract_bp_id, bp_category) {
                new Leaf.Window({
                    id: 'con_contract_content_asset_detail_winid',
                    url: $('con_contract_content_asset_detail_link_id').getUrl(),
                    params: {
                        contract_id: '${/parameter/@contract_id}',
                        content_id: content_id,
                        con_contract_bp_id: con_contract_bp_id,
                        bp_category: bp_category,
                        winid: 'con_contract_content_asset_detail_winid'
                    },
                    title: '${l:CON505.CON_CONTENT_ASSET_DETAIL}',
                    width: 500,
                    height: 460
                });
            }
            
            function on_print_detail_lov_focus(lov) {
                var record = lov.record,
                    display_name = lov.binder.name;
                record.getField(display_name).setLovPara('templet_usage', record.get('clause_usage'));
            }
            
            function set_required_field(record, set_name, value) {
                var set_field = record.getField(set_name);
                if (value == 'N') {
                    set_field.setRequired(false);
                } else {
                    set_field.setRequired(true);
                }
            }
            
            function on_result_update(ds, record, name, value, old_value) {
                if (name == 'available_flag') {
                    //set_required_field(record, 'content_number', value);
                    set_required_field(record, 'templet_name', value);
                } else if (name == 'templet_name') {
                    var ds1 = $('con_contract_update_print_detail_header_ds');
                    var rec = ds1.getCurrentRecord();
                    var contract_number = rec.get('contract_number');
            
                    record.set('content_number', contract_number + '-' + record.get('clause_usage') + '-' + record.get('templet_id'), false);
                }
            }
            
            function on_result_load(ds) {
                var records = ds.getAll();
                for (var i = 0;i < records.length;i++) {
                    var record = records[i];
                    //set_required_field(record, 'content_number', record.get('available_flag'));
                    set_required_field(record, 'templet_name', record.get('available_flag'));
                }
            }
            
            function update_attachment_renderer(value, record, name) {
                var content_id = record.get('content_id');
                return '<a href="javascript:open_uploadfile_win(' + content_id + ')">附件</a>';
            }
            
            function open_uploadfile_win(content_id) {
                new Leaf.Window({
                    url: $('con_contract_uploadfile').getUrl(),
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    params: {
                        'table_name': 'CON_CONTRACT_CONTENT',
                        'header_id': content_id
                    },
                    width: 850,
                    height: 400
                });
            }
            
            function download_renderer(value, record, name) {
                var content_id = record.get('content_id');
                var content_print_flag = record.get('content_print_flag');
                if (content_print_flag == 'Y') {
            
                    return '<input id="button_i" type="button" value="下载" style="border:none;color:blue;cursor:pointer;" onmouseover="this.style.color=\'red\'" onmouseout="this.style.color=\'blue\'"   onclick = "download_uploadfile_win(\'' + content_id + '\')"/>';
                    // return '<a href="javascript:download_uploadfile_win(\'' + content_id + '\')">下载</a>';
                } else {
                    return '';
                }
            }
            
            function download_uploadfile_win(content_id) {
                //var content_id = record.get('content_id');
                var doc_code = '合同文本附件';
                var url_l = $('con_contract_dowload_uploadfile').getUrl() + '?content_id=' + content_id + '&doc_code=' + encodeURI(doc_code) + '&type=SIN&fnd_atm_flag=Y';
                window.open(href = url_l, target = "_self");
            }
            
            function con_content_delete() {
                Leaf.showConfirm('确认', '确认删除合同文本?', function() {
                    records = $('con_contract_update_print_detail_line_ds').getAll();
                    if (records.length < 1) {
                        Leaf.showMessage('${l:PROMPT}', '请选择记录!');
                        return;
                    }
                    var datas = [];
                    for (var i = 0;i < records.length;i++) {
                        var obj = {};
                        obj['content_id'] = records[i].get('content_id');
                        obj['_status'] = 'delete';
                        datas[i] = obj;
                    }
                    Leaf.request({
                        url: $('con_contract_content_delete_link').getUrl(),
                        para: datas,
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            $('con_contract_update_print_detail_line_ds').query();
                        },
                        scope: this
                    });
                });
            }
            
            function con_atm_download() {
            
                var contract_id = $('con_contract_update_print_detail_line_ds').getAt(0).get('contract_id');
                var doc_code = '合同文本附件';
                var url_l = $('con_contract_dowload_uploadfile').getUrl() + '?contract_id=' + contract_id + '&doc_code=' + encodeURI(doc_code) + '&type=ZIP';
            
                window.open(href = url_l, target = "_self");
            }
            
            function con_contract_content_confirm() {
                if ($('con_contract_update_print_detail_line_ds').getAll().length <= 0) {
                    Leaf.showMessage('提示', '请先生成合同文本!');
                    return;
                }
                records = $('con_contract_update_print_detail_line_ds').getAll();
                var confirm_flag = true;
                for (i = 0;i < records.length;i++) {
                    if (records[i].get('content_print_flag') != 'Y') {
                        confirm_flag = false;
                        break;
                    }
                }
                if (confirm_flag) {
                    Leaf.showConfirm('提示', '您确定该合同信息无误?', function() {
                        Leaf.request({
                            url: $('con504_change_confirm_status_link').getUrl(),
                            para: {
                                contract_id: ${/parameter/@contract_id}
                            },
                            success: function() {
                                Leaf.SideBar.show({
                                    msg: '已确认',
                                    duration: 2000
                                });
                                Leaf.go($('con_contract_content_confirm_link').getUrl());
                                $('con505_contract_result_ds').query();
                            },
                            scope: this
                        });
                    });
                } else {
                    Leaf.showMessage('提示', '请先确认所有合同已经确认打印!');
                    return;
                }
            
            }
            
            function edit_office_attachment_renderer(value, record, name) {
                return '<a href="javascript:open_office_link(' + record.id + ')">在线编辑</a>';
            }
            
            function open_office_link(record_id) {
                doc_plugin_template_copy(record_id);
            }
            
            function doc_plugin_template_copy(record_id) {
                var result_ds = $('con_contract_update_print_detail_line_ds');
                var record = result_ds.findById(record_id);
                var content_id = record.get('content_id');
                Leaf.request({
                    url: $('file_copy_from_template_link_id').getUrl(),
                    para: {
                        content_id: record.get('content_id'),
                        file_path: '${/parameter/@file_path}'
                    },
                    success: function(res) {
                        var win = new Leaf.Window({
                            id: 'edit_office_online_link_winid',
                            url: $('con_contract_content_edit_office_online_link_id').getUrl(),
                            params: {
                                content_id: content_id,
                                winid: 'edit_office_online_link_winid',
                                first_copy_flag: res.result.first_copy_flag,
                                contract_id: record.get('contract_id'),
                                bar_code: record.get('bar_code')
                            },
                            fullScreen: true,
                            draggable: true
                        });
                        win.on('close', function() {
                            result_ds.query(result_ds.currentPage);
                        });
                        unlock_current_window();
                    },
                    error: function() {
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            }
            
            function con_print_detail_print_new() {

                var result_ds = $('con_contract_update_print_detail_line_ds');
                var records = result_ds.getAll();
                var total_count = 0;
                for (var m = 0;m < records.length;m++) {
                    if (records[m].get('file_exists_flag') != 'Y') {
                        total_count = total_count + 1;
                    }
                }
                if (total_count === 0 && records.length) {
                    Leaf.showMessage('${l:PROMPT}', '文本都已生成');
                    return;
                }
                var c_record = result_ds.getSelected()[0];
                Leaf.request({
                    url: $('con_doc_batch_create_link_id').getUrl(),
                    para: {
                        content_id: c_record.get('content_id'),
                        file_path: 'D:\租赁项目\润东',
                        batch_flag: 'N'
                    },
                    success: function(res) {
            
                       },
                    error: function() {
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="basic_clause_tmplet_usage_ds" lookupCode="CON_TMPLET_USAGE"/>
            <a:dataSet id="con_contract_update_print_detail_header_ds" loadData="true" model="cont.CON500.con_contract_v_for_print">
                <a:fields>
                    <a:field name="contract_number" readOnly="true"/>
                    <a:field name="contract_name" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_update_print_detail_line_ds" autoQuery="true" fetchAll="true" pageSize="100" queryUrl="${/request/@context_path}/autocrud/cont.CON500.con_contract_content_v/query?contract_id=${/parameter/@contract_id}" selectable="true" submitUrl="${/request/@context_path}/modules/cont/CON505/con_contract_content_save.lsc">
                <a:fields>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="cont.CON505.con_contract_content_bp_for_lov?contract_id=${/parameter/@contract_id}" lovWidth="550" required="true" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="record_id" to="con_contract_bp_id"/>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_category" to="bp_category"/>
                            <a:map from="bp_category_desc" to="bp_category_desc"/>
                            <a:map from="bp_class" to="bp_class"/>
                            <a:map from="bp_class_desc" to="bp_class_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="clause_usage_name" displayField="code_value_name" options="basic_clause_tmplet_usage_ds" required="true" returnField="clause_usage" valueField="code_value"/>
                    <a:field name="clause_usage"/>
                    <a:field name="templet_name" lovGridHeight="350" lovHeight="500" lovService="basic.con_clause_templet_for_lov" lovWidth="500" required="true" title="CON505.CON_CONTENT_TEMPLET_NAME">
                        <a:mapping>
                            <a:map from="templet_id" to="templet_id"/>
                            <a:map from="description" to="templet_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_id"/>
                    <a:field name="content_number"/>
                    <a:field name="available_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="on_result_update"/>
                    <a:event name="load" handler="on_result_load"/>
                    <a:event name="submitsuccess" handler="on_result_submitsuccess"/>
                    <a:event name="submitfailed" handler="on_result_submitfailed"/>
                    <a:event name="add" handler="on_result_add"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar style="width:1100px">
                <a:gridButton click="con_print_detail_create" text="CON505.CON_CONTENT_CREATE"/>
                <!-- <a:gridButton click="con_print_detail_add" text="HLS.NEW"/>
                <a:gridButton click="con_print_detail_clear" text="HLS.CLEAR"/> -->
                <a:gridButton click="con_print_detail_save" text="HLS.SAVE"/>
                <a:gridButton click="con_content_delete" text="删除"/>
                <!-- <a:gridButton id="con_print_detail_print_id" click="con_print_detail_print" text="HLS.PRINT_CONFIRM"/> -->
                <a:gridButton id="con_print_detail_print_id" click="con_print_detail_print_new" text="HLS.PRINT_CONFIRM"/>
                <!-- <a:gridButton id="con_atm_download_id" click="con_atm_download" text="打包下载"/> -->
                <!-- <a:gridButton click="con_contract_content_confirm" text="合同审核通过"/> -->
            </a:screenTopToolbar>
            <a:form column="2" title="CON505.CON_CONTENT_PRINT" width="1100">
                <a:textField name="contract_number" bindTarget="con_contract_update_print_detail_header_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="contract_name" bindTarget="con_contract_update_print_detail_header_ds" prompt="HLS.CONTRACT_NAME" width="330"/>
            </a:form>
            <a:grid id="con_contract_update_print_detail_grid_id" bindTarget="con_contract_update_print_detail_line_ds" height="400" navBar="true" width="1280">
                <a:columns>
                    <a:column name="clause_usage_name" editorFunction="on_print_detail_combobox" prompt="HLS.CONTRACT_USAGE" width="220"/>
                    <a:column name="bp_name" editorFunction="on_print_detail_lov" prompt="HLS.BP_NAME" width="155"/>
                    <a:column name="bp_category_desc" prompt="HLS.BP_CATEGORY"/>
                    <a:column name="bp_class_desc" prompt="HLS.BP_CLASS"/>
                    <a:column name="templet_name" editor="print_detail_grid_lov_id" prompt="CON505.CON_CONTENT_TEMPLET_NAME" width="260"/>
                    <a:column name="content_number" editor="print_detail_grid_textfield_id" prompt="CON505.CON_CONTENT_NUMBER" width="180"/>
                    <!-- <a:column name="content_print_flag_name" align="center" prompt="CON505.CON_CONTENT_STATUS" width="80"/> -->
                    <!-- <a:column name="available_flag" editor="print_detail_grid_checkbox_id" prompt="CON505.AVAILABLE_FLAG" width="60"/> -->
                    <a:column name="edit_office" align="center" prompt="在线编辑" renderer="edit_office_attachment_renderer" width="80"/>
                    <a:column name="download" align="center" prompt="下载" renderer="download_renderer" width="50"/>
                </a:columns>
                <a:editors>
                    <a:lov id="print_detail_grid_lov_id">
                        <a:events>
                            <a:event name="focus" handler="on_print_detail_lov_focus"/>
                        </a:events>
                    </a:lov>
                    <a:comboBox id="print_detail_grid_combobox_id"/>
                    <a:textField id="print_detail_grid_textfield_id"/>
                    <!-- <a:checkBox id="print_detail_grid_checkbox_id"/> -->
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>