<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: configFormulaScreen
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[
        
        function configFormulaScreen_add() {
            $('configFormulaScreen_mainDs_grid').showEditorByRecord($('configFormulaScreen_mainDs').create());
        }
        
        function configFormulaScreen_close(){
            $('hls_fin_calc_config_formula').close();
        }
        function configformulascreen_remove(){
            $('configFormulaScreen_mainDs_grid').remove();
        }
        function configFormulaScreen_query() {
            $('configFormulaScreen_mainDs').query();
        }
        
        function configFormulaScreen_save() {
            var ds = $('configFormulaScreen_mainDs');
            if (ds.validate()) {
                ds.submit();
            }
        }
        
        function editFunction_configFormulaScreen_schedule_name(record, name) {
            if(record.isNew)
            {
                return 'configFormulaScreen_mainDs_grid_tf';
            }
            else
            {
                return '';
            }
        }
        
        function configFormulaScreen_load()
        {
            Leaf.request({
                url: $('bmLink_configFormulaScreen_load').getUrl(),
                para:{
                },
                success: function (res)
                {
                    configFormulaScreen_query();
                },
                scope: this
            });
        }
        
        function editFunction_configFormulaScreen_price_list(record,name)
        {
    	    if(record.isNew){
    	        return 'configFormulaScreen_mainDs_grid_tf_upper';
    	    }else{
    	        return '';
    	    }
        }
        
        function winOpen_configFormulaScreen_set_up(price_list)
        {
            new Leaf.Window({
                id: 'hls_fin_calc_config',
                url: $('pageLink_configFormulaScreen_set_up').getUrl(),
                params:{
                	price_list:price_list
                },
                title: '${l:FND050.WIN_TITLE.SET_UP}',
                fullScreen:true
            });
        }
        
        function onSubmitSuccess_configFormulaScreen_mainDs(ds,res)
        {
            ds.query(ds.currentPage);
        }
         
        function onupdate_configFormulaScreen_mainDs(ds,record,name,value,old_value){
            if(name=='matrix_j_type'){
                if(value=='CYCLE'){
                    record.getField('matrix_j_interval').setRequired(true);
                }else{
                    record.getField('matrix_j_interval').setRequired(false);
                }
            }
        }
        function hls050_editor_calc_seq(record,name){
            if('${/parameter/@layout_area_seq}'=='L'){
                record.getField(name).setRequired(true);
            }else{
                record.getField(name).setRequired(false);
            }
            return 'configFormulaScreen_mainDs_grid_nf';
        }
          function hls050_editor_matrix_j_type_display(record,name){
            if('${/parameter/@layout_area_seq}'=='L'){
                record.getField(name).setRequired(true);
            }else{
                record.getField(name).setRequired(false);
            }
            return 'configFormulaScreen_mainDs_grid_comb';
        }  
         function hls050_editor_matrix_j_initial(record,name){
            if('${/parameter/@layout_area_seq}'=='L'){
                record.getField(name).setRequired(true);
            }else{
                record.getField(name).setRequired(false);
            }
            return 'configFormulaScreen_mainDs_grid_tf';
        }
        function hls050_editor_calc_formula(record,name){
            /* if('${/parameter/@layout_area_seq}'=='L'){
                record.getField(name).setRequired(true);
            }else{
                record.getField(name).setRequired(false);
            } */
            return 'configFormulaScreen_mainDs_grid_af';
        }
        function onload_mainds(ds){
            var rs = ds.getAll();
            for (var i=0;i<rs.length;i++){
                rs[i].getField('loop_remain_times_only').setPropertity('tooltip','公式仅针对变更期数');
            }
        	/* 	var ref_v03 = ds.getCurrentRecord().get('ref_v03');
        		if (!ref_v03 || ref_v03=='N'){
        			$('configFormulaScreen_mainDs_grid').hideColumn('loop_remain_times_only');
        		} */
        }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="configFormulaScreen_matrixJTypeDs" lookupCode="HLS050_MATRIX_J_TYPE"/>
            <a:dataSet id="calcConfigScreen_defaultDs" autoQuery="true" fetchAll="true" model="hls.HLS050.hls_fin_calc_config_default_value" queryUrl="${/request/@context_path}/autocrud/hls.HLS050.hls_fin_calc_config_default_value/query?config_id=${/parameter/@config_id}">
                <a:fields>
                    <a:field name="column_code" readOnly="true"/>
                    <a:field name="column_name" readOnly="true"/>
                    <a:field name="prompt" readOnly="true"/>
                    <a:field name="data_type_display" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="configFormulaScreen_mainDs" autoQuery="true" model="hls.HLS050.hls_fin_calc_config_formula" queryUrl="${/request/@context_path}/autocrud/hls.HLS050.hls_fin_calc_config_formula/query?config_id=${/parameter/@config_id}" selectable="true">
                <a:fields>
                    <a:field name="layout_area_seq" defaultValue="${/parameter/@layout_area_seq}"/>
                    <a:field name="matrix_i" defaultValue="${/parameter/@column_id}"/>
                    <a:field name="matrix_j_type_display" displayField="code_value_name" options="configFormulaScreen_matrixJTypeDs" returnField="matrix_j_type" valueField="code_value"/>
                    <a:field name="config_id" defaultValue="${/parameter/@config_id}"/>
                    <a:field name="company_id"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="calc_seq"/>
                    <a:field name="matrix_j_initial"/>
                    <a:field name="calc_formula" required="true"/>
                    <a:field name="matrix_j_type"/>
                    <a:field name="loop_remain_times_only" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="onSubmitSuccess_configFormulaScreen_mainDs"/>
                    <a:event name="update" handler="onupdate_configFormulaScreen_mainDs"/>
                    <a:event name="load" handler="onload_mainds"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="configFormulaScreen_add" text="HLS.NEW"/>
                <a:gridButton click="configFormulaScreen_close" text="HLS.CLOSE"/>
                <a:gridButton click="configFormulaScreen_save" text="HLS.SAVE"/>
                <a:gridButton click="configformulascreen_remove" text="HLS.REMOVE"/>
                <a:gridButton click="configFormulaScreen_query" text="HLS.QUERY"/>
            </a:screenTopToolbar>
            <a:form bindTarget="calcConfigScreen_defaultDs" column="4" title=" " width="860">
                <a:textField name="column_code" bindTarget="calcConfigScreen_defaultDs" style="margin-left:23px"/>
                <a:textField name="column_name" bindTarget="calcConfigScreen_defaultDs" style="margin-left:10px"/>
                <a:textField name="data_type_display" bindTarget="calcConfigScreen_defaultDs" style="margin-left:10px"/>
                <a:textField name="prompt" bindTarget="calcConfigScreen_defaultDs" style="margin-left:10px"/>
            </a:form>
            <a:switch test="/parameter/@layout_area_seq">
                <a:case value="L">
                    <a:grid id="configFormulaScreen_mainDs_grid" bindTarget="configFormulaScreen_mainDs" height="300" navBar="true" width="860">
                        <a:columns>
                            <a:column name="layout_area_seq" width="60"/>
                            <a:column name="matrix_i" width="50"/>
                            <a:column name="calc_seq" align="right" editorFunction="hls050_editor_calc_seq" width="60"/>
                            <a:column name="matrix_j_type_display" editorFunction="hls050_editor_matrix_j_type_display" width="60"/>
                            <a:column name="matrix_j_initial" editorFunction="hls050_editor_matrix_j_initial" width="54"/>
                            <a:column name="matrix_j_interval" editor="configFormulaScreen_mainDs_grid_tf" width="50"/>
                            <a:column name="calc_formula" editorFunction="hls050_editor_calc_formula" width="400"/>
                            <a:column name="enabled_flag" editor="configFormulaScreen_mainDs_grid_check" width="60"/>
                            <a:column name="loop_remain_times_only" editor="configFormulaScreen_mainDs_grid_check" prompt="LRTO" showTitle="true" width="40"/>
                        </a:columns>
                        <a:editors>
                            <a:textField id="configFormulaScreen_mainDs_grid_tf"/>
                            <a:textArea id="configFormulaScreen_mainDs_grid_af"/>
                            <a:lov id="configFormulaScreen_mainDs_grid_lov"/>
                            <a:checkBox id="configFormulaScreen_mainDs_grid_check"/>
                            <a:numberField id="configFormulaScreen_mainDs_grid_nf" allowDecimals="false"/>
                            <a:comboBox id="configFormulaScreen_mainDs_grid_comb"/>
                        </a:editors>
                    </a:grid>
                </a:case>
                <a:case value="H">
                    <a:grid id="configFormulaScreen_mainDs_grid" bindTarget="configFormulaScreen_mainDs" height="300" navBar="true" width="860">
                        <a:columns>
                            <a:column name="layout_area_seq" width="60"/>
                            <a:column name="matrix_i" width="60"/>
                            <a:column name="calc_formula" editor="configFormulaScreen_mainDs_grid_tf" width="500"/>
                            <a:column name="enabled_flag" editor="configFormulaScreen_mainDs_grid_check" width="60"/>
                        </a:columns>
                        <a:editors>
                            <a:textArea id="configFormulaScreen_mainDs_grid_tf"/>
                            <a:checkBox id="configFormulaScreen_mainDs_grid_check"/>
                        </a:editors>
                    </a:grid>
                </a:case>
            </a:switch>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        	var calc_usage = $('priceListScreen_mainDs').getCurrentRecord().get('calc_usage');
        	if (!calc_usage || calc_usage =='NORMAL'){
        	    $('configFormulaScreen_mainDs_grid').hideColumn('loop_remain_times_only');
        	}
        ]]></script>
    </a:view>
</a:screen>
