<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-4-23 上午09:39:41  
    $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_hls500_formula_back() {
                $('${/parameter/@winid}').close();
            }
            
            function hls_hls500_formula_save() {
                $('formula_save_id').disable();
                var record = $('formula_update_ds').getAt(0),
                    formula = record.get('formula');
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calc_formula_update/update',
                    para: {
                        calc_session_id: '${/parameter/@calc_session_id}',
                        calc_line_id: '${/parameter/@calc_line_id}',
                        column_name: '${/parameter/@column_name}',
                        document_id: '${/parameter/@document_id}',
                        document_category: '${/parameter/@document_category}',
                        formula: formula
                    },
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        $('formula_save_id').enable();
                        var tooltip_formula = $L.escapeHtml(formula),
                            column_name = '${/parameter/@column_name}';
                            
                        if ('${/parameter/@calc_line_id}') {
                            var ln_formula_record = $('hls_fin_cal_ln_formula_ds').find('calc_line_id', '${/parameter/@calc_line_id}');
                            var ln_record = $('hls_fin_calculator_ln_ds').find('calc_line_id', '${/parameter/@calc_line_id}');
                            ln_formula_record.set(column_name, formula);
                            ln_record.getField(column_name).setPropertity('tooltip', tooltip_formula);
            
                        } else {
                            var hd_formula_record = $('hls_fin_cal_hd_formula_ds').find('calc_session_id', '${/parameter/@calc_session_id}');
                            if ('${/parameter/@calc_form_flag}' == 'Y') {
                                var hd_form_record = $('hls_fin_calculator_hd_ds').getAt(0);
                                hd_form_record.getField(column_name).setPropertity('tooltip', tooltip_formula);
                                hd_formula_record.set(column_name, formula);
                                if ('${/parameter/@validation_type}' == 'LOV') {
                                    hd_form_record.getField(column_name+'_lovname').setPropertity('tooltip', tooltip_formula);
                                }
                            } else {
                                var hd_record = $('hls_fin_calculator_hd_ds').find('column_name', column_name);
                                hd_formula_record.set(column_name, formula);
                                hd_record.getField('column_code').setPropertity('tooltip', tooltip_formula);
                                hd_record.getField('prompt').setPropertity('tooltip', tooltip_formula);
                                hd_record.getField('column_value').setPropertity('tooltip', tooltip_formula);
                            }
                        }
                        $('formula_update_ds').query();
                    },
                    failure: function() {
                        $('formula_save_id').enable();
                    },
                    error: function() {
                        $('formula_save_id').enable();
                    },
                    scope: this
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="formula_update_ds" autoQuery="true" model="hls.HLS500.hls_fin_calc_formula" queryUrl="${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calc_formula/query?calc_session_id=${/parameter/@calc_session_id}&amp;column_name=${/parameter/@column_name}&amp;column_code=${/parameter/@column_code}&amp;calc_line_id=${/parameter/@calc_line_id}">
                <a:fields>
                    <a:field name="column_code" readOnly="true"/>
                    <a:field name="prompt" readOnly="true"/>
                    <a:field name="formula"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="hls_hls500_formula_back" text="HLS.BACK"/>
                <a:gridButton id="formula_save_id" click="hls_hls500_formula_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form width="350">
                <a:textField name="column_code" bindTarget="formula_update_ds" prompt="HLS050.HLS_FIN_CALC_CONFIG.COLUMN_CODE" width="275"/>
                <a:textField name="prompt" bindTarget="formula_update_ds" prompt="HLS500.PROMPT" width="275"/>
                <a:textField name="formula" bindTarget="formula_update_ds" prompt="HLS.FORMULA" width="275"/>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>
