<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xuls  
    $Date: 2017-4-21 下午01:54:29  
    $Revision: 1.0  
    $Purpose: 合同维护入口界面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query model="cont.CON620.get_sys_role" rootPath="role_info"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con311_create_entrusts_link" model="cont.CON311.create_entrusts" modelaction="execute"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}zj_wfl_approve_history_check" url="${/request/@context_path}/modules/zjwfl/zj_wfl_approve_history_check.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_get_identify_link" model="hls.HLS214N.hls_bp_master_modify_user" modelaction="query"/>
        <a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON311/con_re_print_modify.lview"/>
        <a:link id="${/parameter/@layout_code}con_contract_query_link"
                url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <a:link id="car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain.lview"/>
        <a:link id="con_contract_update_print_detail_link_id" url="${/request/@context_path}/modules/cont/CON311/con_contract_update_print_word_detail.lview"/>
        <a:link id="con_lease_org_print_link"
                url="${/request/@context_path}/modules/cont/CON620/create_content_for_collection.lsc"/>
        <script type="text/javascript"><![CDATA[



        Leaf.onReady(function() {

            if("${/model/role_info/record/@role_code}"!="0018"&&"${/model/role_info/record/@role_code}"!="0019") {
                // document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_AGENT_EXTRA_NAM_prompt").style.display = "";
                // document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_AGENT_EXTRA_NAM").style.display = "";
                document.getElementById("CONTRACT_PRINT_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1_prompt").style.display = "";
                document.getElementById("CONTRACT_PRINT_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1").style.display = "";

            } else {
                $('CONTRACT_PRINT_ENTRANCE_user_button2').hide();

                // document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_AGENT_EXTRA_NAM_prompt").style.display = "none";
                // document.getElementById("CONTRACT_QUERY_ENTRANCE_F_QUERY_NULL_AGENT_EXTRA_NAM").style.display = "none";
                document.getElementById("CONTRACT_PRINT_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1_prompt").style.display = "none";
                document.getElementById("CONTRACT_PRINT_ENTRANCE_F_QUERY_NULL_BP_ID_AGENT_LEVEL1").style.display = "none";

            }

        });


            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                if(record.get('sign_contract_status')=='NEW' || record.get('sign_contract_status')=='SIGN_RETURN'){
                    param['function_code'] = 'CON301MM';
                    param['function_usage'] = 'MODIFY';
                }
                else{
                    param['function_code'] = 'CON301';
                    param['function_usage'] = 'QUERY';
                    //add by 24976
                    param['sign_contract_status'] = record.get('sign_contract_status');
                    param['contract_status'] = record.get('contract_status');
                }
                param['winid'] = 'con_contract_modify_win_id';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}con_contract_query_link', ds_id);
            }
            
            function open_project_Window(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['hide_flag'] = 'Y';
                param['company_id'] = record.get('company_id');
                param['project_id'] = record.get('project_id');
                param['function_usage'] = 'QUERY';
                param['function_code'] = 'PRJ501_WFL';
                param['bp_class'] = record.get('bp_class');
                param['maintain_type'] = 'QUERY';
                /*  param['window_open_flag'] = 'Y';
                 param['show_history_flag'] = 'Y'; */
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_special_link', ds_id, '${/parameter/@layout_code}');
            }

            function open_bs_Window(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301BS';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
                param['contract_id'] = record.get('contract_id');
                param['url_title'] = 'BS明细';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', ds_id);
            }

            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'contract_number' && value) {
                    return '<a href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                }
                if (name == 'project_id_c' && value) {
                    return '<a href="javascript:open_project_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
                if (name == 'bs_link') {
                    return '<a href="javascript:open_bs_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">明细</a>';
                }

                return value;
            };
            window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
            
            
            //单据跟踪
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
                // var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                // var records = $('prj_project_ds_id').getSelected();
                var ds = $('CONTRACT_QUERY_ENTRANCE_G_CONTRACT_RESULT_con_contract_ds');
                var records = ds.getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择一条数据！');
                    return;
                }
                var instance_id = records[0].get('wfl_instance_id');
                var win = new Leaf.Window({
                    id: 'history_check',
                    url: $('${/parameter/@layout_code}${/parameter/@pre_layout}zj_wfl_approve_history_check').getUrl(),
                    params: {
                        instance_id: instance_id
                    },
                    title: '单据历史查看',
                    height: 500,
                    width: 860,
                    fullScreen: true
                });
            };
            //合同文本打印
         /*   window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var records = $(ds_id).getSelected();
                for (var i = 0;i < records.length;i++) {
                    var param = records[i].data;
                    param['function_code'] = 'CON311D';
                    if(records[i].data.contract_status=='NEW'){
                         param['maintain_type'] = 'UPDATE';
                         param['function_usage'] = 'UPDATE';
                         param['query_only'] = 'N';
                         }
                    else{
                         param['maintain_type'] = 'QUERY';
                         param['function_usage'] = 'QUERY';
                         param['query_only'] = 'Y';
                         }
                    param['winid'] = 'con_contract_modify_link_winid';
                    param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                    hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', ds_id);
                }
            };*/
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            var records = $(ds_id).getSelected();
            if (records.length != 1) {
                Leaf.showMessage('${l:PROMPT}','${l:HLS.SELECT_RECORD}');
                return;
            }
            var record=records[0];
            new Leaf.Window({
                id: 'con_contract_update_print_detail_winid',
                params: {
                    contract_id: record.get('contract_id'),
                    document_category:record.get('document_category'),
                    business_type :record.get('business_type'),
                    winid: 'con_contract_update_print_detail_winid',
                    content_type : 'NORMAL'
                },
                url: $('con_contract_update_print_detail_link_id').getUrl(),
                title: '${l:CON505.CON_CONTENT_PRINT}',
                width:1000,
                height:450
            });
        }

        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            var records = $(ds_id).getSelected();
            if (records.length != 1) {
                Leaf.showMessage('${l:PROMPT}','${l:HLS.SELECT_RECORD}');
                return;
            }
            var record=records[0];
            if(record.get('sign_contract_status')=='SIGN'){
                var contract_id = record.get('contract_id');
                var templet_code = 'SIGN_SUGGESTION';
                var  url=$('con_lease_org_print_link').getUrl() + '?contract_id=' + contract_id + '&templet_code=' + templet_code;
                window.open(url, '_self');
            }else{
                Leaf.showMessage('${l:PROMPT}','签约未完成，不可打印！');
                return;
            }
        };

        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
