<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Think  
    $Date: 2016-8-31 上午10:01:29  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="${/parameter/@layout_code}_con632_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}_car_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain.lview"/>
        <a:link id="${/parameter/@layout_code}_prj_project_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_create_tree_n.lview"/>
        <a:link id="${/parameter/@layout_code}_car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create_special.lview"/>
        <a:link id="${/parameter/@layout_code}_con_contract_cashflow_id" url="${/request/@context_path}/modules/cont/CON632/con_contract_cashflow.lview"/>
        <a:link id="${/parameter/@layout_code}_prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_prj500_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            //超链接渲染
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'project_number') {
                    return '<a href="javascript:openWindow(\'' + record.id + '\',\'' + record.ds.id + '\');">' + value + '</a>';
                } else if (name == 'attachment') {
                    link_function = '${/parameter/@layout_code}_prj500_cdd_attachtment_upload';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name == 'attach_file_name') {
                    //附件名称
                    if (value != null) {
                        var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                        var str = value.split(';;');
                        var url = '';
                        for (var i = 0;i < str.length;i++) {
                            var temp = str[i].split('--');
                            if (!Leaf.isEmpty(temp[0])) {
            
                                var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                                if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                    url = url + '<a ref="img" href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                } else {
                                    url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                }
                            }
                        }
                        return url;
                    }
                    //逾期信息
                } else if (name == 'due_times') {
                    link_function = '${/parameter/@layout_code}_overdue_cashflow';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + record.ds.id + '\');">' + value + '</a>';
                }
            };
            //打开现金流逾期信息
            window['${/parameter/@layout_code}_overdue_cashflow'] = function(record_id, ds_id) {
                var win = new Leaf.Window({
                    url: $('${/parameter/@layout_code}_con_contract_cashflow_id').getUrl(),
                    title: '逾期状态',
                    params: {
                        contract_id: '${/parameter/@contract_id}',
                        winid: '${/parameter/@layout_code}_con_contract_cashflow_winid'
                    },
                    id: '${/parameter/@layout_code}_con_contract_cashflow_winid',
                    width: 1100,
                    height: 400
                });
            };
            
            function openWindow(record_id, ds_id) {
                //var record = $(ds_id).findById(record_id);
                var contract_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var contract_record = $(contract_ds).getAt(0);
                var maintain_type = 'QUERY';
                var param = {};

                param['company_id'] = contract_record.get('company_id');
                param['project_id'] = contract_record.get('project_id');
                param['function_code'] = 'PRJ502D';
                param['function_usage'] = 'QUERY';
                param['bp_class'] = contract_record.get('bp_class');
                param['maintain_type'] = maintain_type;
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('${/parameter/@layout_code}_con632_get_layout_code_link_id', param, '${/parameter/@layout_code}_car_modify_special_link', ds_id, '${/parameter/@layout_code}');
            };
             if ('${/parameter/@function_code}') {
             zjwfl5110_ApproveChecker_add('zjwfl5110_submit', function(type) {
             if (type == 'agree') {
             window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
             return true;
             } else {
             return true;
             }
             });
             } 
            
            //附件上传
            window['${/parameter/@layout_code}_prj500_cdd_attachtment_upload'] = function(ds_id, id, name, query_only) {
                var record = $(ds_id).findById(id);

                if (record.get('check_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('${/parameter/@layout_code}_prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}${/parameter/@tree_code}_prj500_cdd_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
                    win.on('close', function() {
                        record.ds.query();
                    });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
