<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-12 下午03:52:10  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="bmLink_calcConfigScreen_calc_formula" url="${/request/@context_path}/modules/hls/HLS055/hls_fin_calc_config_tplt_fl.lview"/>
        <a:link id="bmLink_calcConfigScreen_calc_btn" url="${/request/@context_path}/modules/hls/HLS055/hls_fin_calc_config_btn.lview"/>
        <script type="text/javascript"><![CDATA[
            function calcConfigScreen_getTabType() {
                var config = {
                    0: 'H',
                    1: 'L',
                    2: 'BTN'
                };
                return config[$('calcConfigScreen_tab').selectedIndex];
            
            }
            
            function calcConfigScreen_getDs() {
                var config = {
                    'H': 'calcConfigScreen_mainDs',
                    'L': 'calcConfigScreen_lineDs',
                    'BTN': 'calcConfigScreen_btnDs'
                };
                return config[calcConfigScreen_getTabType()];
            }
            
            function calcConfigScreen_query() {
                var dsName = calcConfigScreen_getDs();
                $(dsName).query();
            }
            
            function calcConfigScreen_save() {
                var dsName = calcConfigScreen_getDs();
                var ds = $(dsName);
                if (ds.validate()) {
                    ds.submit();
                }
            }
            
           
            
            function render_calcConfigScreen_calc_formula(value, record, name) {
                if (!record.isNew) {
                    return '<a href="javascript:winOpen_calcConfigScreen_calc_formula(' + record.get('column_id') + ',\''+key_field_flag+'\'));">' + '${l:HLS050.LINK.CALC_FORMULA}' + '</a>';
                }
                return '';
            }
            
            function render_calcConfigScreen_column_name(value, record, name) {
                var key_field_flag=record.get('key_field_flag');
                if (!record.isNew) {
                    return '<a href="javascript:winOpen_calcConfigScreen_calc_formula(' + record.get('column_id') + ',\''+key_field_flag+'\');">' + value + '</a>';
                }
                return '';
            }
            
            function render_calcConfigScreen_calc_btn(value, record, name) {
                if (!record.isNew) {
                    return '<a href="javascript:winOpen_calcConfigScreen_calc_btn(\'' + record.get('button_code') + '\');">' + '${l:HLS050.BTN_PROCEDURE}' + '</a>';
                }
                return '';
            }
            
            function winOpen_calcConfigScreen_calc_btn(button_code) {
                new Leaf.Window({
                    id: 'hls_fin_calc_config_btn',
                    url: $('bmLink_calcConfigScreen_calc_btn').getUrl(),
                    params: {
                        button_code: button_code
            
                    },
                    title: '${l:HLS050.BTN_UPDATE}',
                    width: 800,
                    height: 400
                });
            }
            
            function winOpen_calcConfigScreen_calc_formula(column_id,key_field_flag) {
                if(key_field_flag=='Y')
                {
                    Leaf.showMessage('${l:PROMPT}','${l:HLS050.IS_KEY_FILED_FLAG}');
                }
                else
                {
	                var layout_area_seq = calcConfigScreen_getTabType();
	                new Leaf.Window({
	                    id: 'hls_fin_calc_config_tplt_fl',
	                    url: $('bmLink_calcConfigScreen_calc_formula').getUrl(),
	                    params: {
	                        layout_area_seq: layout_area_seq,
	                        column_id: column_id
	            
	                    },
	                    title: '${l:HLS050.WIN_TITLE.CALC_FORMULA}',
	                    width: 900,
	                    height: 500
	                });
                }
            }
            
            function setField_validation_sql(record,name,ds_name)
	    	{
	    	    var field=record.getField(name);
		        field.setLovUrl('${/request/@context_path}/modules/hls/HLS055/hls_fin_calc_config_sql_validate.lview');
		        field.setMapping([
		        	{from:'sql_text', to: 'validation_sql'}
		        ]);
		        field.setLovWidth(600);
		        field.setLovHeight(350);
	            field.setLovPara('ds_name',ds_name);
		        field.setTitle('SQL校验');
	    	}
	    	
	    	function editorFun_calcConfigScreen_mainDs_grid(record,name)
	    	{
	    	    if(name=='validation_sql')
	    	    {
	    	        setField_validation_sql(record,name,'calcConfigScreen_mainDs');
	    	        return 'calcConfigScreen_mainDs_grid_lov';
	    	    }
	    	    if(name=='enabled_flag')
	    	    {
	    	        if(record.get('key_field_flag')=='Y')
	    	        {
	    	            return '';
	    	        }
	    	        return 'calcConfigScreen_mainDs_grid_check';
	    	    }
    	        return '';
	    	    
	    	}
	    	
	    	function editorFun_calcConfigScreen_lineDs_grid(record,name)
	    	{
	    	    if(name=='validation_sql')
	    	    {
	    	        setField_validation_sql(record,name,'calcConfigScreen_lineDs');
	    	        return 'calcConfigScreen_lineDs_grid_lov';
	    	    }
	    	    if(name=='enabled_flag')
	    	    {
	    	        if(record.get('key_field_flag')=='Y')
	    	        {
	    	            return '';
	    	        }
	    	        return 'calcConfigScreen_lineDs_grid_check';
	    	    }
    	        return '';
	    	    
	    	}
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="layout_area_seq_ds">
                <a:datas>
                    <a:record code_value="H" code_value_name="头界面"/>
                    <a:record code_value="L" code_value_name="行界面"/>
                    <a:record code_value="BOTH" code_value_name="通用"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="alignment_ds" lookupCode="HLS050_ALIGNMENT"/>
            <a:dataSet id="calcConfigScreen_inputModeDs" lookupCode="HLS050_INPUT_MODE"/>
            <a:dataSet id="calcConfigScreen_validationTypeDs" lookupCode="HLS050_VALIDATION_TYPE"/>
            <a:dataSet id="cashflow_item_ds">
                <a:datas dataSource="/model/cashflow_item_path"/>
            </a:dataSet>
            <a:dataSet id="checkboxValueDs" lookupCode="HLS_CHECKBOX"/>
            <a:dataSet id="checkboxValue2Ds">
                <a:datas>
                    <a:record code_value="TRUE" code_value_name="是"/>
                    <a:record code_value="FALSE" code_value_name="否"/>
                    <a:record code_value="ALL" code_value_name="全部"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="dataTypeDs" lookupCode="HLS050_DATA_TYPE"/>
            <a:dataSet id="queryParaDs" autoCreate="true" model="hls.HLS055.hls_fin_calc_config_templt">
                <a:fields>
                    <a:field name="column_code"/>
                    <a:field name="column_name"/>
                    <a:field name="data_type"/>
                    <a:field name="data_type_display" displayField="code_value_name" options="dataTypeDs" returnField="data_type" valueField="code_value"/>
                    <a:field name="input_mode"/>
                    <a:field name="input_mode_display" displayField="code_value_name" options="calcConfigScreen_inputModeDs" returnField="input_mode" valueField="code_value"/>
                    <a:field name="validation_type_display" displayField="code_value_name" options="calcConfigScreen_validationTypeDs" returnField="validation_type" valueField="code_value"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="checkboxValueDs" prompt="启用" returnField="enabled_flag" valueField="code_value"/>
                    <a:field name="display_flag_desc" displayField="code_value_name" options="checkboxValueDs" prompt="显示" returnField="display_flag" valueField="code_value"/>
                    <a:field name="allow_decimal_desc" displayField="code_value_name" options="checkboxValue2Ds" prompt="小数" returnField="allow_decimal" valueField="code_value"/>
                    <a:field name="alignment_display" displayField="code_value_name" options="alignment_ds" returnField="alignment" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="calcConfigScreen_mainDs" autoQuery="true" fetchAll="true" model="hls.HLS055.hls_fin_calc_config_templt" queryDataSet="queryParaDs" queryUrl="${/request/@context_path}/autocrud/hls.HLS055.hls_fin_calc_config_templt/query?layout_area_seq=H" selectable="true">
                <a:fields>
                    <a:field name="validation_sql"/>
                    <a:field name="data_type_display" readOnly="true"/>
                    <a:field name="input_mode_display" displayField="code_value_name" options="calcConfigScreen_inputModeDs" returnField="input_mode" valueField="code_value"/>
                    <a:field name="validation_type_display" displayField="code_value_name" options="calcConfigScreen_validationTypeDs" returnField="validation_type" valueField="code_value"/>
                    <a:field name="system_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="display_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="key_field_flag" checkedValue="Y" defaultValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="lov_return_vcode" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="zero_fill" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="allow_format" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="allow_decimal" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="percent" checkedValue="%" defaultValue="%" uncheckedValue=""/>
                    <a:field name="alignment_display" displayField="code_value_name" options="alignment_ds" returnField="alignment" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="calcConfigScreen_lineDs" autoQuery="true" fetchAll="true" model="hls.HLS055.hls_fin_calc_config_templt" queryDataSet="queryParaDs" queryUrl="${/request/@context_path}/autocrud/hls.HLS055.hls_fin_calc_config_templt/query?layout_area_seq=L" selectable="true">
                <a:fields>
                    <a:field name="data_type_display" readOnly="true"/>
                    <a:field name="input_mode_display" displayField="code_value_name" options="calcConfigScreen_inputModeDs" returnField="input_mode" valueField="code_value"/>
                    <a:field name="validation_type_display" displayField="code_value_name" options="calcConfigScreen_validationTypeDs" returnField="validation_type" valueField="code_value"/>
                    <a:field name="system_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="display_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="key_field_flag" checkedValue="Y" defaultValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="lov_return_vcode" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="zero_fill" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="allow_format" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="allow_decimal" checkedValue="TRUE" defaultValue="TRUE" uncheckedValue="FALSE"/>
                    <a:field name="percent" checkedValue="%" defaultValue="%" uncheckedValue=""/>
                    <a:field name="alignment_display" displayField="code_value_name" options="alignment_ds" returnField="alignment" valueField="code_value"/>
                    <a:field name="cf_item_display" lovGridHeight="350" lovHeight="500" lovLabelWidth="120" lovService="hls.HLS050.hls_cashflow_item_company_v" lovWidth="600" prompt="HLS.CF_ITEM_DESC">
                        <a:mapping>
                            <a:map from="cf_item" to="cf_item"/>
                            <a:map from="cf_item_desc" to="cf_item_display"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="calcConfigScreen_btnDs" autoQuery="true" fetchAll="true" model="hls.HLS055.hls_fin_calc_button_templt" queryUrl="${/request/@context_path}/autocrud/hls.HLS055.hls_fin_calc_button_templt/query" selectable="true">
                <a:fields>
                    <a:field name="layout_area_seq_desc" displayField="code_value_name" options="layout_area_seq_ds" returnField="layout_area_seq" valueField="code_value"/>
                    <a:field name="button_code" required="true"/>
                    <a:field name="prompt" required="true"/>
                    <a:field name="save_data_first" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="system_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="display_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="calcConfigScreen_query" text="HLS.QUERY"/>
                <a:gridButton click="calcConfigScreen_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="5" title="HLS.QUERY_TITLE">
                <a:textField name="column_code" bindTarget="queryParaDs"/>
                <a:textField name="column_name" bindTarget="queryParaDs"/>
                <a:comboBox name="data_type_display" bindTarget="queryParaDs"/>
                <a:textField name="prompt" bindTarget="queryParaDs"/>
                <a:comboBox name="input_mode_display" bindTarget="queryParaDs"/>
                <a:comboBox name="validation_type_display" bindTarget="queryParaDs"/>
                <a:comboBox name="enabled_flag_desc" bindTarget="queryParaDs"/>
                <a:comboBox name="display_flag_desc" bindTarget="queryParaDs"/>
                <a:comboBox name="alignment_display" bindTarget="queryParaDs"/>
                <a:comboBox name="allow_decimal_desc" bindTarget="queryParaDs"/>
            </a:form>
            <a:tabPanel id="calcConfigScreen_tab" marginHeight="200" marginWidth="30">
                <a:tabs>
                    <a:tab prompt="HLS050.HEAD_TITLE" selected="true">
                        <a:grid id="calcConfigScreen_mainDs_grid" bindTarget="calcConfigScreen_mainDs" marginHeight="250" marginWidth="60">
                            <a:columns>
                                <a:column name="column_code" autoAdjust="false" sortable="true" width="40"/>
                                <a:column name="column_name" autoAdjust="false" renderer="render_calcConfigScreen_column_name" showtitle="true" sortable="true" width="150"/>
                                <a:column name="data_type_display" autoAdjust="false" width="35"/>
                                <a:column name="system_flag" autoAdjust="false" width="35"/>
                                <a:column name="enabled_flag" autoAdjust="false" editorFunction="editorFun_calcConfigScreen_mainDs_grid" sortable="true" width="35"/>
                                <a:column name="display_flag" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" sortable="true" width="35"/>
                                <a:column name="prompt" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_tf" showtitle="true" width="100"/>
                                <a:column name="display_order" align="right" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_tf" sortable="true" width="40"/>
                                <a:column name="input_mode_display" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_comb" width="60"/>
                                <a:column name="validation_type_display" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_comb" width="80"/>
                                <a:column name="allow_decimal" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" width="35"/>
                                <a:column name="precision" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_integer_nf" width="35"/>
                                <a:column name="zero_fill" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" width="35"/>
                                <a:column name="allow_format" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" width="40"/>
                                <a:column name="key_field_flag" autoAdjust="false" width="60"/>
                                <a:column name="lov_return_vcode" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" width="80"/>
                                <a:column name="percent" align="right" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_check" width="40"/>
                                <a:column name="alignment_display" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_comb" width="60"/>
                                <a:column name="validation_sql" autoAdjust="false" editorFunction="editorFun_calcConfigScreen_mainDs_grid" showtitle="true" width="100"/>
                                <a:column name="default_value" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_tf" width="60"/>
                                <a:column name="lower_limit" align="right" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_nf" width="35"/>
                                <a:column name="upper_limit" align="right" autoAdjust="false" editor="calcConfigScreen_mainDs_grid_nf" width="35"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="calcConfigScreen_mainDs_grid_tf"/>
                                <a:comboBox id="calcConfigScreen_mainDs_grid_comb"/>
                                <a:lov id="calcConfigScreen_mainDs_grid_lov"/>
                                <a:checkBox id="calcConfigScreen_mainDs_grid_check"/>
                                <a:numberField id="calcConfigScreen_mainDs_grid_integer_nf" allowDecimals="false"/>
                                <a:numberField id="calcConfigScreen_mainDs_grid_nf" allowDecimals="false"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="HLS050.LINE_TITLE">
                        <a:grid id="calcConfigScreen_lineDs_grid" bindTarget="calcConfigScreen_lineDs" marginHeight="250" marginWidth="60">
                            <a:columns>
                                <a:column name="column_code" autoAdjust="false" sortable="true" width="40"/>
                                <a:column name="column_name" autoAdjust="false" renderer="render_calcConfigScreen_column_name" showtitle="true" sortable="true" width="150"/>
                                <a:column name="data_type_display" autoAdjust="false" width="35"/>
                                <a:column name="system_flag" autoAdjust="false" width="35"/>
                                <a:column name="enabled_flag" autoAdjust="false" editorFunction="editorFun_calcConfigScreen_lineDs_grid" sortable="true" width="35"/>
                                <a:column name="display_flag" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" sortable="true" width="35"/>
                                <a:column name="prompt" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_tf" showtitle="true" width="100"/>
                                <a:column name="display_order" align="right" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_tf" sortable="true" width="40"/>
                                <a:column name="input_mode_display" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_comb" width="60"/>
                                <a:column name="validation_type_display" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_comb" width="80"/>
                                <a:column name="allow_decimal" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" width="35"/>
                                <a:column name="precision" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_integer_nf" width="35"/>
                                <a:column name="zero_fill" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" width="35"/>
                                <a:column name="allow_format" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" width="40"/>
                                <a:column name="key_field_flag" autoAdjust="false" width="60"/>
                                <a:column name="lov_return_vcode" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" width="80"/>
                                <a:column name="percent" align="right" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_check" width="40"/>
                                <a:column name="alignment_display" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_comb" width="60"/>
                                <a:column name="cf_item_display" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_lov" width="70"/>
                                <a:column name="width" align="right" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_integer_nf" width="60"/>
                                <a:column name="validation_sql" autoAdjust="false" editorFunction="editorFun_calcConfigScreen_lineDs_grid" showtitle="true" width="100"/>
                                <a:column name="lower_limit" align="right" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_nf" width="35"/>
                                <a:column name="upper_limit" align="right" autoAdjust="false" editor="calcConfigScreen_lineDs_grid_nf" width="35"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="calcConfigScreen_lineDs_grid_tf"/>
                                <a:comboBox id="calcConfigScreen_lineDs_grid_comb"/>
                                <a:lov id="calcConfigScreen_lineDs_grid_lov"/>
                                <a:checkBox id="calcConfigScreen_lineDs_grid_check"/>
                                <a:numberField id="calcConfigScreen_lineDs_grid_integer_nf" allowDecimals="false"/>
                                <a:numberField id="calcConfigScreen_lineDs_grid_nf" allowDecimals="false"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="HLS050.BTN_TITLE">
                        <a:grid id="calcConfigScreen_btnDs_grid" bindTarget="calcConfigScreen_btnDs" marginHeight="250" marginWidth="60">
                            <a:columns>
                                <a:column name="layout_area_seq_desc" editor="calcConfigScreen_btnDs_grid_comb" prompt="用途"/>
                                <a:column name="display_order" align="right" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_tf" width="35"/>
                                <a:column name="button_code" autoAdjust="false" width="150"/>
                                <a:column name="prompt" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_tf" width="100"/>
                                <a:column name="system_flag" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_check" width="35"/>
                                <a:column name="enabled_flag" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_check" width="35"/>
                                <a:column name="display_flag" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_check" width="35"/>
                                <a:column name="save_data_first" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_check" width="80"/>
                                <a:column name="calc_btn" align="center" autoAdjust="false" prompt="HLS050.BTN_PROCEDURE" renderer="render_calcConfigScreen_calc_btn" width="80"/>
                                <a:column name="javascript" autoAdjust="false" editor="calcConfigScreen_btnDs_grid_tf" width="300"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="calcConfigScreen_btnDs_grid_tf"/>
                                <a:comboBox id="calcConfigScreen_btnDs_grid_comb"/>
                                <a:lov id="calcConfigScreen_btnDs_grid_lov"/>
                                <a:checkBox id="calcConfigScreen_btnDs_grid_check"/>
                                <a:numberField id="calcConfigScreen_btnDs_grid_integer_nf" allowDecimals="false"/>
                                <a:numberField id="calcConfigScreen_btnDs_grid_nf" allowDecimals="false"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>
