<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyi2652 $
    $Date: 2010/11/26 07:54:36 $
    $Revision: 1.5 $
    $Purpose: “汇率定义”功能的详细定义页面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
            
            
         
            //获取前一个页面的 rate_method_code 值,来决定此页面的显示列
            var mode='${/parameter/@rate_method_code}';

            //当此dataSet值发生改变时调用,主要是为了在record中加入两列值
            function gridDataUpdate(ds,record,name,value){
                record.set('currency_code','${/parameter/@currency_code}');
                record.set('type_code','${/parameter/@type_code}');	
            }

            //在添加数据时动态控制列的必填属性
            function gridDataAdd(ds,record,index){
                var dateField=record.getMeta().getField('conversion_date');
                var periodField=record.getMeta().getField('period_name');

                if (mode=='PERIOD'){
                    periodField.setRequired(true);
                }
                if (mode=='DAILY'){
                    dateField.setRequired(true);
                }
            }
            
           function fnd_1090_child_grid_add(){
                $('gld_exchange_rate_gird').showEditorByRecord($('gld_exchange_rate_detail_grid_ds').create());
            }
            function fnd_1090_child_grid_clear(){
                $('gld_exchange_rate_gird').clear();
            }
            function fnd_1090_child_grid_remove(){
                $('gld_exchange_rate_gird').remove();
            }
            function fnd_1090_child_grid_submit() {
                var result_ds = $('gld_exchange_rate_detail_grid_ds');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            function fnd_1090_child_next(){
                 history.go(1);
            }
            function fnd_1090_child_back(){
                history.go(-1);
            }
            function fnd_1090_child_quit(){
                location.href = $('sys_service_welcome_link').getUrl();
                parent.shMenu('show');
            }
        
        ]]></script>
        <a:dataSets>
            <a:dataSet id="quotation_ds" lookupCode="EXCHANGE_RATE_QUOTATION"/>
            <!--页面上方信息区域的数据,同时作为下面grid中数据查询的条件 -->
            <a:dataSet id="gld_exchange_rate_detail_fs_ds" autocreate="true">
                <a:fields>
                    <a:field name="currency_code" defaultvalue="${/parameter/@currency_code}" readonly="true"/>
                    <a:field name="currency_name" defaultvalue="${/parameter/@currency_name}" readonly="true"/>
                    <a:field name="type_code" defaultValue="${/parameter/@type_code}" readonly="true"/>
                    <a:field name="method_name" defaultValue="${/parameter/@rate_method_code}" readonly="true"/>
                    <a:field name="currency_code_frn" defaultValue="${/parameter/@currency_code_frn}" readonly="true"/>
                    <a:field name="period_from" defaultValue="${/parameter/@period_from}" readonly="true"/>
                    <a:field name="period_to" defaultValue="${/parameter/@period_to}" readonly="true"/>
                    <a:field name="date_from" defaultValue="${/parameter/@date_from}" readonly="true"/>
                    <a:field name="date_to" defaultValue="${/parameter/@date_to}" readonly="true"/>
                </a:fields>
            </a:dataSet>
            <!--下方grid中数据 -->
            <a:dataSet id="gld_exchange_rate_detail_grid_ds" autoQuery="true" fetchAll="false" model="gld.gld_exchange_rates_detail" notification="有数据没有保存" pageSize="15" queryDataSet="gld_exchange_rate_detail_fs_ds" selectable="true" submitUrl="${/request/@context_path}/autocrud/gld.FND1090.gld_exchange_rate_detail_update/batch_update">
                <!--queryUrl="${/request/@context_path}/autocrud/fnd.fnd_weekday_rules/query?ORDER_FIELD=weekday_number&amp;calendar_id=${/parameter/@calendar_id}" -->
                <a:fields>
                    <!-- lov携带参数,防止选出和本币相同的货币-->
                    <a:field name="to_currency" lovGridHeight="300" lovHeight="460" lovService="gld.gld_currency_lov?currency_code_frn=${/parameter/@currency_code}" lovWidth="490" required="true" title="GLD_EXCHANGE_RATES.TO_CURRENCY_CODE">
                        <a:mapping>
                            <a:map from="currency_code" to="to_currency"/>
                            <a:map from="currency_name" to="currency_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="quotation_display" displayField="code_value_name" options="quotation_ds" required="true" returnField="exchange_rate_quotation" valueField="code_value"/>
                    <a:field name="period_name" lovGridHeight="300" lovHeight="460" lovService="gld.gld_period_adj_incld_lov" lovWidth="490" title="GLD_EXCHANGE_RATE_DETAILS.PERIOD_NAME">
                        <a:mapping>
                            <a:map from="period_name" to="period_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="date_from" readonly="true"/>
                    <a:field name="date_to" readonly="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="gridDataUpdate"/>
                    <a:event name="add" handler="gridDataAdd"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="fnd_1090_child_back" text="HLS.BACK"/>
                <a:gridButton click="fnd_1090_child_next" text="HLS.FORWARD"/>
                <a:gridButton click="fnd_1090_child_grid_add" text="HLS.NEW"/>
                <a:gridButton click="fnd_1090_child_grid_remove" text="HLS.REMOVE"/>
                <a:gridButton click="fnd_1090_child_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="fnd_1090_child_grid_submit" text="HLS.SAVE"/>
                <a:gridButton click="fnd_1090_child_quit" text="HLS.EXIT"/>
            </a:screenTopToolbar>
            <a:fieldSet column="2" labelWidth="90" title="GLD_EXCHANGE_RATE.TITLE">
                <a:textField name="currency_code" bindTarget="gld_exchange_rate_detail_fs_ds" prompt="GLD_CURRENCY.CURRENCY_CODE"/>
                <a:textField name="currency_name" bindTarget="gld_exchange_rate_detail_fs_ds" prompt="GLD_CURRENCY.CURRENCY_NAME"/>
                <a:textField name="type_code" bindTarget="gld_exchange_rate_detail_fs_ds" prompt="GLD_EXCHANGERATE_TYPES.TYPE_CODE"/>
                <a:textField name="method_name" bindTarget="gld_exchange_rate_detail_fs_ds" prompt="GLD_EXCHANGE_RATE_DETAILS.EXCHANGE_TYPE"/>
            </a:fieldSet>
            <a:grid id="gld_exchange_rate_gird" bindTarget="gld_exchange_rate_detail_grid_ds" height="490" marginWidth="20" navBar="true" width="1000">
                <a:columns>
                    <a:column name="to_currency" align="center" editor="gerg_lov" prompt="GLD_EXCHANGE_RATES.TO_CURRENCY_CODE" sortable="true" width="100"/>
                    <a:column name="currency_name" align="left" prompt="GLD_CURRENCY.CURRENCY_NAME" sortable="true" width="100"/>
                    <a:column name="currency_volume" align="right" editor="gerg_nf" prompt="GLD_EXCHANGE_RATE_DETAILS.CURRENCY_VOLUME" sortable="true" width="100"/>
                    <a:column name="conversion_rate" align="right" editor="rate_nf" prompt="GLD_EXCHANGE_RATE_DETAILS.CONVERSION_RATE" sortable="true" width="100"/>
                    <a:column name="quotation_display" align="center" editor="gerg_cmb" prompt="GLD_EXCHANGE_RATE_DETAILS.QUOTATION" width="100"/>
                    <a:column name="conversion_date" align="center" editor="gerg_dp" prompt="GLD_EXCHANGE_RATE_DETAILS.CONVERSION_DATE" renderer="Leaf.formatDate" sortable="true" width="100"/>
                    <a:column name="period_name" align="center" editor="gerg_lov" prompt="GLD_EXCHANGE_RATE_DETAILS.PERIOD_NAME" sortable="true" width="100"/>
                </a:columns>
                <a:editors>
                    <a:lov id="gerg_lov"/>
                    <a:numberField id="gerg_nf"/>
                    <a:numberField id="rate_nf" decimalPrecision="4"/>
                    <a:comboBox id="gerg_cmb"/>
                    <a:datePicker id="gerg_dp"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            
            
         
            //隐藏列
            function hideRows(){
                var grid=$('gld_exchange_rate_gird');
                if (mode=='PERIOD'){
                    grid.hideColumn('conversion_date');
                }else if (mode=='DAILY'){
                    grid.hideColumn('period_name');
                }else{
                    grid.hideColumn('conversion_date');
                    grid.hideColumn('period_name');
                }
            }

            hideRows()
        
        ]]></script>
    </a:view>
</a:screen>