<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-8-30 上午10:24:11  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <script type="text/javascript"><![CDATA[
        function hls_doc_get_layout_code(bm_url_link, param, win_url_link, list_ds, pre_layout_code) {

            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            var t1 = $(bm_url_link).getUrl();
            Leaf.request({
                url: $(bm_url_link).getUrl(),
                para: param,
                sync: true,
                success: function (res) {
                    Leaf.Masker.unmask(Ext.getBody());
                    if (!res.result.layout_code) {
                        Leaf.showMessage('${l:PROMPT}', '${l:HLS.LAYOUT_CODE_IS_NULL}');
                        return;
                    }
                    param['layout_code'] = res.result.layout_code;
                    param['usage_type'] = res.result.usage_type;
                    var winid = '';
                    if (!param['winid']) {
                        if (pre_layout_code) {
                            param['pre_layout_code'] = pre_layout_code;
                            winid = pre_layout_code + 'hls_doc_get_layout_code_winid';
                        } else {
                            winid = 'hls_doc_get_layout_code_winid';
                        }
                    } else {
                        winid = param['winid'];
                    }

                    param['winid'] = winid;
                    param['calc_type'] = res.result.cond_para1;

                    if (param['window_open_flag'] == 'Y') {
                        var window_open_url = $(win_url_link).getUrl() + '?';
                        var temp_num = 0;
                        for (var key in param) {
                            temp_num = temp_num + 1;
                            if (param[key] && param[key].toString().indexOf('%') == -1 && key != 'winid') {
                                if (temp_num == 1) {
                                    window_open_url = window_open_url + key + '=' + param[key];
                                } else {
                                    window_open_url = window_open_url + '&' + key + '=' + param[key];
                                }
                            }
                        }
                        var jsid = Leaf.getCookie('JSID');
                        window._mainwin = window.open(window_open_url, '_blank');
                    } else {
                        if (param['screen_width'] || param['screen_height']) {
                            win = new Leaf.Window({
                                id: winid,
                                params: param,
                                url: $(win_url_link).getUrl(),
                                title: param['url_title'] + '(' + res.result.layout_code + ')',
                                width: param['screen_width'],
                                height: param['screen_height'],
                                draggable: true
                            });
                        } else {
                            var win = new Leaf.Window({
                                id: winid,
                                params: param,
                                url: $(win_url_link).getUrl(),
                                title: param['url_title'] + '(' + res.result.layout_code + ')',
                                fullScreen: true,
                                draggable: true
                            });
                        }
                        win.on('close', function () {
                            if (list_ds) {
                                $(list_ds).query();
                            }
                        });
                    }
                },
                failure: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function () {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }

        //通过基表名获取ds_id

        function get_dsid_by_basetable(layoutDataSetList, base_table) {
            if (base_table) {
                var base_table_temp = base_table.toLowerCase() + '_ds';
                for (var i = 0; i < layoutDataSetList.length; i++) {
                    var dsId = layoutDataSetList[i];
                    if (dsId.substring(dsId.length - base_table_temp.length, dsId.length) == base_table_temp) {
                        return dsId;
                    }
                }
            }
            return '';
        }

        function get_dsid_by_tabcode_basetable(layoutDataSetList, tab_code, base_table) {
            if (base_table && tab_code) {
                var base_table_temp = tab_code + '_' + base_table.toLowerCase() + '_ds';
                for (var i = 0; i < layoutDataSetList.length; i++) {
                    var dsId = layoutDataSetList[i];
                    if (dsId.substring(dsId.length - base_table_temp.length, dsId.length) == base_table_temp) {
                        return dsId;
                    }
                }
            }
            return '';
        }
        ]]></script>
    </a:view>
</a:screen>
