<?xml version="1.0" encoding="UTF-8"?>
<!--
  create by nyl  2014-12-3 
  for contract context create
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.specify_code=${/parameter/@specify_code}" model="cont.CON543.lsh_hls_specify_define" rootPath="hls_specify_define_info"/>
    </a:init-procedure>
    <a:view>
        <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_update_link_id" url="${/request/@context_path}/modules/cont/CON501N/con_contract_modify.lview"/>
        <a:link id="legal_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_wfl_dyn_prj_secify_approver_link" url="${/request/@context_path}/modules/prj/PRJ501N/lsh_hls_specify_approver.lview"/>
        <a:link id="con_update_print_detail_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update_print_detail.lview"/>
        <a:link id="con301n_con_contract_info_link" url="${/request/@context_path}/modules/prj/PRJ506/virtual_contract_query.lview"/>
        <a:link id="${/parameter/@layout_code}_con560_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_con560_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_con560_change_detail_link" url="${/request/@context_path}/modules/cont/CON561/sdic_con_contract_change_detail_wfl.lview"/>
        <script type="text/javascript"><![CDATA[
            function zjwfl_before_approve_procedure(out_type) {
                var document_id = '${/parameter/@contract_id}';
                var appoint_check = '${/parameter/@appoint_check}';
                var specify_code = '${/parameter/@specify_code}';
                var params;
                out_type = 'no_win';
                var out_object = 'out_object';
                if (appoint_check && specify_code) {
                    var document_table = 'CON_CONTRACT';
                    var title = '${/model/hls_specify_define_info/record/@description}';
                    var win = new Leaf.Window({
                        id: 'lsh_prj_secify_approver_screen',
                        url: $('con_wfl_dyn_prj_secify_approver_link').getUrl(),
                        params: {
                            document_id: document_id,
                            specify_code: specify_code
                        },
                        closeable: false,
                        title: title,
                        width: 550,
                        heigh: 650
                    });
                    out_type = 'win';
                    out_object = win;
                }
            
                params = {
                    out_type: out_type,
                    out_object: out_object
                };
                return params;
            }
            //结清文件
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_terminate');
                if (ds_id) {
                    var record = $(ds_id).getCurrentRecord();
                    new Leaf.Window({
                        id: 'con_contract_update_print_detail_winid',
                        params: {
                            contract_id: record.get('contract_id'),
                            terminate_id: record.get('terminate_id'),
                            document_category: record.get('document_category'),
                            business_type: record.get('business_type'),
                            winid: 'con_contract_update_print_detail_winid',
                            content_type: 'TERMINATE'
                        },
                        url: $('con_update_print_detail_link_id').getUrl(),
                        title: '${l:CON505.CON_CONTENT_PRINT}',
                        width: 900,
                        height: 450
                    });
                }
            };
            
            function param_set_value(record_id, name, query_only) {

                var record = window['${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
                var param = {};
                param['project_id'] = record.get('project_id');
                param['function_code'] = 'C0N301D_CON';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con301n_con_contract_info_link');
            }
            
            function con_termilate_acc_link(record_id, name, query_only) {
                 var record = window['${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
                  if (record.get('contract_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_con560_downloadFile_id').getUrl() + '?table_name=CON_CONTRACT&header_id=' + record.get('contract_id');
                    } else {
                        url = $('${/parameter/@layout_code}_con560_uploadFile_id').getUrl() + '?table_name=CON_CONTRACT&header_id=' + record.get('contract_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}_con560_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
            
                    win.on('close', function() {
                        record.ds.query();
                    });
                }
            }
            
            function contract_change_detail_link(record_id, name, query_only){
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
                if (record.get('contract_id')) {
                    var url = $('${/parameter/@layout_code}_con560_change_detail_link').getUrl();
                    var win = new Leaf.Window({
                        url: url,
                        title: '变更明细',
                        params:{
                            contract_id:record.get('contract_id')
                        },
                        id: '${/parameter/@layout_code}_con560_change_detail_screen_id',
                        width: 850,
                        height: 400
                    });
            
                    win.on('close', function() {
                        record.ds.query();
                    });
                }
            }
            
            //超链接渲染
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {

                var link_function = '';
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'contract_details' && !record.isNew) {
                    link_function = 'param_set_value';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + '合同明细' + '</a>';
                }else if(name == 'con_termilate_acc' && !record.isNew){
                    link_function = 'con_termilate_acc_link';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + '合同结束附件' + '</a>';
                }else if(name == 'contract_change_detail' && !record.isNew){
                    link_function = 'contract_change_detail_link';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>