<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-9-19 上午10:33:42  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <a:link id="hls_fin_calc_config_quote_execute_link_id" model="hls.HLS500.hls_fin_calc_config_quote_execute" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
            function hls500_show_display_line() {
                hls500_show_display_line_btn_enable();
                var records = $('show_display_line_ds').getAll();
                if (records.length) {
                    var quote_data = [];
                    for (var i = 0;i < records.length;i++) {
                        var record = records[i];
                        if (record.dirty) {
                            if (record.get('layout_area_seq') == 'L') {
                                if (record.get('display_flag') == 'Y') {
                                    $('${/parameter/@calc_grid_id}').showColumn(record.get('column_name'));
                                    $('${/parameter/@calc_export_grid_id}').showColumn(record.get('column_name'));
                                } else {
                                    $('${/parameter/@calc_grid_id}').hideColumn(record.get('column_name'));
                                    $('${/parameter/@calc_export_grid_id}').hideColumn(record.get('column_name'));
                                }
                            }
                            record.set('calc_session_id', '${/parameter/@calc_session_id}');
                            record.set('_status', 'update');
                            quote_data.push(record.data);
                        }
                    }
                    Leaf.request({
                        url: $('hls_fin_calc_config_quote_execute_link_id').getUrl(),
                        para: quote_data,
                        success: function() {
                            success_sidebar_show();
                            $('${/parameter/@winid}').close();
                        },
                        failure: function() {
                            hls500_show_display_line_btn_enable('Y');
                        },
                        error: function() {
                            hls500_show_display_line_btn_enable('Y');
                        },
                        scope: this
                    });
                } else {
                    hls500_show_display_line_btn_enable('Y');
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS500.CALC_CONFIG_QUOTE_NULL_FIELD}');
                    return;
                }
            }
            
            function hls500_show_display_line_btn_enable(flag) {
                if (flag == 'Y') {
                    $('hls500_show_display_line_id').enable();
                } else {
                    $('hls500_show_display_line_id').disable();
                }
            }
            
            function on_show_display_query_ds_update(ds, record, name, value, oldvalue) {
                if (name == 'layout_area_seq') {
                    if (!value) {
                        $('show_display_line_ds').removeAll();
                    } else {
                        $('show_display_line_ds').query();
                    }
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="layout_area_seq_display_ds">
                <a:datas>
                    <a:record code_value="H" code_value_name="头配置"/>
                    <a:record code_value="L" code_value_name="行配置"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="show_display_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="layout_area_seq_display" defaultValue="行配置" displayField="code_value_name" options="layout_area_seq_display_ds" required="true" returnField="layout_area_seq" valueField="code_value"/>
                    <a:field name="layout_area_seq" defaultValue="L"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="on_show_display_query_ds_update"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="show_display_line_ds" autoQuery="true" fetchAll="true" queryDataSet="show_display_query_ds" queryUrl="${/request/@context_path}/autocrud/hls.HLS500N.hls_fin_calc_config_ln_n/query?enabled_flag=Y&amp;display_flag=C&amp;calc_session_id=${/parameter/@calc_session_id}">
                <a:fields>
                    <a:field name="display_flag" checkedValue="Y" uncheckedValue="C"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton id="hls500_show_display_line_id" click="hls500_show_display_line" text="HLS.CONFIRM"/>
            </a:screenTopToolbar>
            <a:form column="1">
                <a:comboBox name="layout_area_seq_display" bindTarget="show_display_query_ds" prompt="头行选择"/>
            </a:form>
            <a:grid id="show_display_line_grid_id" bindTarget="show_display_line_ds" height="370" width="500">
                <a:columns>
                    <a:column name="display_flag" editor="show_display_line_grid_checkbox_id" prompt="HLS.DISPLAY_FLAG" width="60"/>
                    <a:column name="upper_column_name" prompt="HLS.COLUMN_NAME" width="210"/>
                    <a:column name="prompt" prompt="HLS.COLUMN_DESC" width="210"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="show_display_line_grid_checkbox_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
