<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: 凭证模板头
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="basic.sys_session_info" rootPath="headScreen_sessionInfo"/>
    </a:init-procedure>
    <a:view>
        <a:link id="pageLink_match_rule" url="${/request/@context_path}/modules/gld/GLD110/gld_je_template_group_mapping_condition.lview"/>
        <a:link id="pageLink_template_assign" url="${/request/@context_path}/modules/gld/GLD110/gld_je_template_template_assign.lview"/>
        <script type="text/javascript"><![CDATA[
        
        function groupDs_grid_query() {
            $('groupDs').query();
        }
        
        function para_groupDs_reset()
        {
            $('para_groupDs').reset();
        }
        
        function groupDs_grid_add() {
            $('groupDs_grid').showEditorByRecord($('groupDs').create());
        }
        
        function groupDs_grid_remove() {
            $('groupDs_grid').remove();
        }
        
        function groupDs_grid_clear() {
            $('groupDs_grid').clear();
        }
        
        function groupDs_grid_save() {
            var ds = $('groupDs');
            if (ds.validate()) {
                ds.submit();
            }
        }
        
        function winOpen_matchRule(je_transaction_code,template_group_id)
        {
            new Leaf.Window({
                id: 'gld_je_template_group_mapping_condition',
                url: $('pageLink_match_rule').getUrl(),
                params:{
                    template_group_id:template_group_id,
                    je_transaction_code:je_transaction_code
                },
                title: '${l:GLD107.WIN_TITLE.MATCH_RULE}',
                height: 450,
                width: 900
            });
        }
        
        function winOpen_template_assign(je_transaction_code,template_group_id)
        {
            new Leaf.Window({
                id: 'gld_je_template_template_assign',
                url: $('pageLink_template_assign').getUrl(),
                params:{
                    template_group_id:template_group_id,
                    je_transaction_code:je_transaction_code
                },
                title: '${l:GLD110.GLD_JE_TEMPLATE_GRP.TEMPLATE_ASSIGN}',
                width: 700,
                height: 450
            });
        }
        
        
        function render_groupDs_grid(value, record, name)
        {
            var template_group_id=record.get('template_group_id');
            var je_transaction_code = record.get('je_transaction_code');
            
            if(!record.isNew)
            {
                if(name=='match_rule')
                {
                    return '<a href="javascript:winOpen_matchRule(\'' + je_transaction_code + '\','+ template_group_id +');">' + '${l:GLD107.WIN_TITLE.MATCH_RULE}' + '</a>';
                }
                else if(name=='template_assign')
                {
                    return '<a href="javascript:winOpen_template_assign(\'' + je_transaction_code + '\','+ template_group_id +');">' + '${l:GLD110.GLD_JE_TEMPLATE_GRP.TEMPLATE_ASSIGN}' + '</a>';
                }
                return '';
            }
            return '';
        }
        
        
        
        
        function groupDs_query()
        {
            $('groupDs').query();
        }
        
        function editorFunction_groupDs_grid(record,name)
        {
            if(record.isNew)
            {
                if(name=='je_template_set_desc'||name=='je_transaction_desc')
                {
                    return 'groupDs_grid_lov';
                }
                if(name=='template_group_code')
                {
                    return 'groupDs_grid_tf_upper';
                }
                return '';
            }
            return '';
        }
        
        
        ]]></script>
        <a:dataSets>
            <a:dataSet id="groupPage_enableFlagDs">
                <a:datas>
                    <a:record code_value="Y" code_value_name="是"/>
                    <a:record code_value="N" code_value_name="否"/>
                    <a:record code_value="" code_value_name="全部"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="para_groupDs" autoCreate="true" model="gld.GLD110.gld_je_template_grp">
                <a:fields>
                    <a:field name="je_template_set_code"/>
                    <a:field name="je_template_set_desc" lovGridHeight="300" lovHeight="500" lovService="gld.GLD105.gld_je_template_set_for_lov" lovWidth="550" title="GLD105.GLD_JE_TEMPLATE_SET.JE_TEMPLATE_SET_DESC">
                        <a:mapping>
                            <a:map from="je_template_set_desc" to="je_template_set_desc"/>
                            <a:map from="je_template_set_code" to="je_template_set_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="je_transaction_code"/>
                    <a:field name="je_transaction_desc" lovGridHeight="300" lovHeight="500" lovService="gld.GLD104.gld_je_transaction_for_lov" lovWidth="550" title="GLD104.GLD_JE_TRANSACTION.JE_TRANSACTION_DESC">
                        <a:mapping>
                            <a:map from="je_transaction_desc" to="je_transaction_desc"/>
                            <a:map from="je_transaction_code" to="je_transaction_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="enabled_flag" defaultValue="Y"/>
                    <a:field name="enabled_flag_desc" defaultValue="是" displayField="code_value_name" options="groupPage_enableFlagDs" prompt="启用" returnField="enabled_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="groupDs" autoPageSize="true" autoQuery="true" model="gld.GLD110.gld_je_template_grp" queryDataSet="para_groupDs" selectable="true">
                <a:fields>
                    <a:field name="template_group_code" required="true"/>
                    <a:field name="company_short_name" defaultValue="${/model/headScreen_sessionInfo/record/@company_short_name}"/>
                    <a:field name="je_template_set_desc" lovGridHeight="300" lovHeight="500" lovService="gld.GLD105.gld_je_template_set_for_lov" lovWidth="550" required="true" title="GLD105.GLD_JE_TEMPLATE_SET.JE_TEMPLATE_SET_DESC">
                        <a:mapping>
                            <a:map from="je_template_set_desc" to="je_template_set_desc"/>
                            <a:map from="je_template_set_code" to="je_template_set_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="je_transaction_desc" lovGridHeight="300" lovHeight="500" lovService="gld.GLD104.gld_je_transaction_for_lov" lovWidth="550" required="true" title="GLD104.GLD_JE_TRANSACTION.JE_TRANSACTION_DESC">
                        <a:mapping>
                            <a:map from="je_transaction_desc" to="je_transaction_desc"/>
                            <a:map from="je_transaction_code" to="je_transaction_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="je_template_desc"/>
                    <a:field name="je_desc"/>
                    <a:field name="priority" required="true"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="groupDs_grid_query" text="HLS.QUERY"/>
                <a:gridButton click="para_groupDs_reset" text="HLS.RESET"/>
                <a:gridButton click="groupDs_grid_add" text="HLS.NEW"/>
                <a:gridButton click="groupDs_grid_clear" text="HLS.CLEAR"/>
                <!-- <a:gridButton click="groupDs_grid_remove" text="HLS.REMOVE"/> -->
                <a:gridButton click="groupDs_grid_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="5" labelWidth="90" title="HAP_QUERY_TITLE">
                <a:lov name="je_template_set_desc" bindTarget="para_groupDs"/>
                <a:lov name="je_transaction_desc" bindTarget="para_groupDs"/>
                <a:textField name="template_group_code" bindTarget="para_groupDs"/>
                <a:textField name="template_group_desc" bindTarget="para_groupDs"/>
                <a:comboBox name="enabled_flag_desc" bindTarget="para_groupDs"/>
            </a:form>
            <a:grid id="groupDs_grid" bindTarget="groupDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="company_short_name" width="120"/>
                    <a:column name="je_template_set_desc" editorFunction="editorFunction_groupDs_grid" width="120"/>
                    <a:column name="je_transaction_desc" editorFunction="editorFunction_groupDs_grid" width="120"/>
                    <a:column name="priority" align="right" editor="groupDs_grid_nf" width="80"/>
                    <a:column name="match_rule" align="center" prompt="GLD107.WIN_TITLE.MATCH_RULE" renderer="render_groupDs_grid" width="80"/>
                    <!-- <a:column name="template_group_code" editorFunction="editorFunction_groupDs_grid" width="200"/> -->
                    <a:column name="template_group_code" editor="groupDs_grid_tf" width="200"/>
                    <a:column name="template_group_desc" editor="groupDs_grid_tf" width="250"/>
                    <a:column name="enabled_flag" align="center" editor="groupDs_grid_checkBox" width="60"/>
                    <a:column name="template_assign" align="center" prompt="GLD110.GLD_JE_TEMPLATE_GRP.TEMPLATE_ASSIGN" renderer="render_groupDs_grid" width="80"/>
                </a:columns>
                <a:editors>
                    <a:textField id="groupDs_grid_tf_upper" maxLength="30"/>
                    <a:textField id="groupDs_grid_tf"/>
                    <a:lov id="groupDs_grid_lov"/>
                    <a:checkBox id="groupDs_grid_checkBox"/>
                    <a:numberField id="groupDs_grid_nf" allowDecimals="false" allowNegative="false"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>