<?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="con_contract_get_layout_code_link" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <a:link id="con_contract_modify_link"
                url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <a:link id="call_detail_map_link"
                url="${/request/@context_path}/modules/call/call240/call_detail_map.lview"/>
        <a:link id="call_242_list_link" url="${/request/@context_path}/modules/call/call240/call_detail_map.lview"/>
        <a:link id="${/parameter/@layout_code}_con_collection_income_link_id"
                url="${/request/@context_path}/modules/rent/rent300/con_collection_management.lview"/>
        <script type="text/javascript"><![CDATA[

        function open_contract_win(ds_id, record_id) {
            debugger
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'CON301';
            param['function_usage'] = 'QUERY';
            param['maintain_type'] = 'QUERY';
            param['winid'] = 'contract_detail_win';
            param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
            hls_doc_get_layout_code('con_contract_get_layout_code_link', param, 'con_contract_modify_link', null);
        }

        function openWindow_return(url) {
            debugger
            new Leaf.Window({
                id: 'call_242_list_link_winid',
                params: {
                    winId: 'call_242_list_link_winid',
                    windows_flag: 'Y'
                },
                url: url,
                fullScreen: true
            });
        }

        function open_trailer_win(ds_id, record_id) {

            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'RENT200_TRAILER';
            param['function_usage'] = 'QUERY';
            param['contract_id'] = record.get('contract_id');
            param['url_title'] = '拖车详情';
            param['winid'] = 'contract_trailer_win';
            hls_doc_get_layout_code('con_contract_get_layout_code_link', param, '${/parameter/@layout_code}_con_collection_income_link_id', 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>';
                }else if (name == 'call_resume') {
                    var url;
                    url = $('call_242_list_link').getUrl() + '?contract_number=' + record.get('contract_number')+'&call_time_from=' + null +'&call_time_to=' + null;
                    return '<a href="javascript:openWindow_return(\'' + url + '\');">' + "通话履历" + '</a>';
                } else if (name == 'attachment_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 == 'trailer_report') {
                    return '<a href="javascript:open_trailer_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + '明细' + '</a>';
                }


            return value;
        };
        ]]></script>

        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
