<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="prj_project_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_create_tree_n.lview"/>
        <a:link id="car_modify_special_link2" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create_special.lview"/>
        <a:link id="car_modify_mananger_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain_manager.lview"/>
        <a:link id="car_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain_readonly.lview"/>
        <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_modify_link" url="${/request/@context_path}/modules/cont/CON301N/con_contract_query.lview"/> -->
        <a:link id="con_contract_modify_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/PRJ500N/prj_project_create.lview"/> -->
        <a:link id="${/parameter/@layout_code}_contract_print_link_id" url="${/request/@context_path}/modules/cont/CON302N/con_contract_print.lview"/>
        <a:link id="get_atch_download_link" url="${/request/@context_path}/modules/cont/CON309/lease_atm_batch_dl.lsc"/>
        <!-- <a:link id="get_atch_download_link" url="${/request/@context_path}/modules/batch_download/lease_atm_batch_dl.lsc"/> -->
        <!-- <a:link id="con_atm_batch_download_pdf_link_id" url="${/request/@context_path}/modules/cont/CON500/con_atm_batch_download_pdf.lsc"/> -->
        <a:link id="import_save_data_link" url="${/request/@context_path}/modules/cont/CON309/con_batch_download_temp.lsc"/>
        <script type="text/javascript"><![CDATA[
            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', null);
            }
            
            function open_project_Window(record_id, ds_id) {             
                 var record = $(ds_id).findById(record_id);
                //项目类layout_code
                if (record.get('prj_document_type') == 'PRJ') {
                    var maintain_type = 'QUERY';
                    var param = record.data;
                    param['document_id'] = record.get('project_id');
                    param['function_code'] = 'PRJ502D';
                    param['function_usage'] = 'QUERY';
                    param['bp_class'] = 'NP';
                    param['maintain_type'] = maintain_type;
                    param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                    hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'prj_project_modify_link', ds_id);
                } else if (record.get('prj_document_type') == 'CARLS') {
                    if (record.get('special_permit_flag') == 'Y') {
                        //零售特批
                        maintain_type = 'QUERY';
                        param = record.data;
                        param['document_id'] = record.get('project_id');
                        param['function_code'] = 'PRJ502D_SPECIAL';
                        param['function_usage'] = 'MODIFY';
                        param['maintain_type'] = maintain_type;
                        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);
                    } else if (record.get('prj_lease_channel') == '02') {
                        //管理人员
                        maintain_type = 'QUERY';
                        param = record.data;
                        param['document_id'] = record.get('project_id');
                        param['function_code'] = 'PRJ502D';
                        param['function_usage'] = 'MODIFY';
                        param['maintain_type'] = maintain_type;
                        param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_mananger_link', ds_id);
                    } else {
                        maintain_type = 'QUERY';
                        param = record.data;
                        param['document_id'] = record.get('project_id');
                        param['function_code'] = 'PRJ501Q';
                        param['function_usage'] = 'QUERY';
                        param['maintain_type'] = maintain_type;
                        param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_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>';
                }
            };
            
            
            // //打包下载
            // window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            //
            // var con_contract_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            // var con_contract_record = $(con_contract_id).getSelected();
            // // var datas = [];
            // // for (var i = 0;i < con_contract_record.length;i++) {
            // // var obj = {};
            // // obj['table_pk_value'] = con_contract_record[i].get('contract_id');
            // // obj['table_name'] = 'CON_CONTRACT';
            // // obj['doc_code'] = '附件打包下载';
            // // obj['all_flag'] = 'Y';
            // // obj['contract_number'] = con_contract_record[i].get('contract_number');
            // // obj['_status'] = 'update';
            // // datas[i] = obj;
            // // }
            // var jason = datas.toString();
            // var url_l = $('get_atch_download_link').getUrl() + '?jason=' + escape(jason);
            // for (var i = 0;i < con_contract_record.length;i++) {
            // var contract_id = con_contract_record[i].get('contract_id');
            // var contract_number = con_contract_record[i].get('contract_number');
            // var doc_code = '附件下载';
            // var url_l = $('get_atch_download_link').getUrl() + '?table_pk_value=' + contract_id + '&table_name=CON_CONTRACT' + '&doc_code=' + doc_code + '&contract_number=' + contract_number + '&all_flag=Y';
            // window.open(href = url_l, target = "_self");
            // }
            // Leaf.request({
            // url: $('get_atch_download_link').getUrl(),
            // para: datas,
            // success: function(res) {
            // },
            // scope: this
            // });
            //多个合同附件打包下载  modify by lpc
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var con_contract_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var con_contract_record = $(con_contract_id).getSelected();
                var datas = [];
                for (var i = 0;i < con_contract_record.length;i++) {
                    var obj = {};
                    obj['contract_id'] = con_contract_record[i].get('contract_id');
                    // obj['table_name'] = 'CON_CONTRACT';
                    obj['doc_code'] = '附件打包下载';
                    // obj['all_flag'] = 'Y';
                    obj['contract_number'] = con_contract_record[i].get('contract_number');
                    // obj['_status'] = 'update';
                    datas[i] = obj;
                }
                Leaf.request({
                    url: $('import_save_data_link').getUrl(),
                    para: datas,
                    success: function() {
                        var doc_code = '附件下载';
                        var url_l = $('get_atch_download_link').getUrl() + '?session_id=' + ${/session/@session_id} + '&doc_code=' + doc_code;
                        window.open(href = url_l, target = "_self");
                    },
                    scope: this
                });
            
            };
            
            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'], 'prj_project');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
        ]]></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>
