<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ $
    $Date: 2013/05/09 07:47:05 $
    $Revision: 1.2 $
    $Purpose: 编码规则定义
    
    modify by peter soong 重构代码
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <a:link id="fnd_coding_rules_link" model="fnd.FND1910.fnd_coding_rules" modelaction="query"/>
        <a:link id="pageLink_ruleScreen_rule_detail" url="${/request/@context_path}/modules/fnd/FND1910/fnd_coding_rule_details.lview"/>
        <script type="text/javascript"><![CDATA[
            function editorFunction_ruleDs_grid(record, name) {
                if (name == 'coding_rule_code') {
                    if (record.isNew) {
                        return 'ruleDs_grid_editor_tf_upper';
                    }
                    return '';
                }
                if (name == 'document_category_desc') {
                    if (record.isNew) {
                        return 'ruleDs_grid_editor_comb';
                    }
                    return '';
                }
            }
            
            function render_ruleDs_grid(value, record, name) {
                if (!record.isNew) { /* var coding_rule_object_id = record.get('coding_rule_object_id'); */
                    var coding_rule_id = record.get('coding_rule_id');
                    if (name == 'rule_detail') {
                        return '<a href="javascript:winOpen_rule_detail(' + coding_rule_id + ')">${l:FND1910.LINK.RULE_DETAIL}</a>';
                    }
                }
            }
            
            function winOpen_rule_detail(coding_rule_id) {
                new Leaf.Window({
                    id: 'fnd_coding_rule_details',
                    url: $('pageLink_ruleScreen_rule_detail').getUrl(),
                    params: {
                        coding_rule_id: coding_rule_id
                    },
                    title: '${l:FND1910.WIN_TITLE.RULE_DETAIL}',
                    height: 550,
                    width: 700
                });
            }
            
            function ruleDs_grid_add() {
                $('ruleDs_grid').showEditorByRecord($('ruleDs').create());
            }
            
            function ruleDs_grid_clear() {
                $('ruleDs_grid').clear();
            }
            
            function ruleDs_grid_submit() {
                var result_ds = $('ruleDs');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            
            function ruleDs_grid_query() {
                $('ruleDs').query();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="resetFrequencyDs" lookupCode="CODING_RULE_RESET_FREQUENCY"/>
            <a:dataSet id="documentCategoryDs" loadData="true" model="fnd.FND1910.fnd_code_rule_doc_category_v"/>
            <a:dataSet id="enabledflagDs" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="queryDs">
                <a:fields>
                    <a:field name="document_category_desc" displayField="description" options="documentCategoryDs" returnField="document_category" valueField="document_category"/>
                    <a:field name="document_category"/>
                    <a:field name="coding_rule_code"/>
                    <a:field name="reset_frequence_name" displayField="code_value_name" options="resetFrequencyDs" returnField="reset_frequence" valueField="code_value"/>
                    <a:field name="reset_frequence"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="enabledflagDs" returnField="enabled_flag" valueField="code_value"/>
                    <a:field name="enabled_flag"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="ruleDs" autoQuery="true" fetchAll="false" model="fnd.FND1910.fnd_coding_rules" queryDataSet="queryDs" selectable="true" submitUrl="${/request/@context_path}/modules/fnd/FND1910/fnd_coding_rules.lsc">
                <a:fields>
                    <a:field name="document_category_desc" displayField="description" options="documentCategoryDs" prompt="单据类别" returnField="document_category" valueField="document_category"/>
                    <a:field name="document_type_desc" readOnly="true"/>
                    <a:field name="coding_rule_code" required="true"/>
                    <a:field name="coding_rule_desc" required="true"/>
                    <a:field name="reset_frequence_name" displayField="code_value_name" options="resetFrequencyDs" required="true" returnField="reset_frequence" valueField="code_value"/>
                    <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="ruleDs_grid_add" text="HLS.NEW"/>
                <a:gridButton click="ruleDs_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="ruleDs_grid_query" text="HLS.QUERY"/>
                <a:gridButton click="ruleDs_grid_submit" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="90" title="编码规则">
                <a:comboBox name="document_category_desc" bindTarget="queryDs" prompt="单据类别"/>
                <a:textField name="coding_rule_code" bindTarget="queryDs" prompt="编码规则代码"/>
                <a:comboBox name="reset_frequence_name" bindTarget="queryDs" prompt="重复频率"/>
                <a:comboBox name="enabled_flag_desc" bindTarget="queryDs" prompt="启用"/>
            </a:form>
            <a:grid id="ruleDs_grid" bindTarget="ruleDs" height="365" navBar="true" width="1200">
                <a:columns>
                    <a:column name="document_category_desc" align="left" editorFunction="editorFunction_ruleDs_grid" width="120"/>
                    <a:column name="coding_rule_code" align="left" editorFunction="editorFunction_ruleDs_grid" width="120"/>
                    <a:column name="coding_rule_desc" align="left" editor="ruleDs_grid_editor_tf" width="200"/>
                    <a:column name="note" align="left" editor="ruleDs_grid_editor_tf" width="240"/>
                    <a:column name="reset_frequence_name" align="left" editor="ruleDs_grid_editor_comb" width="70"/>
                    <a:column name="enabled_flag" editor="ruleDs_grid_editor_check" width="50"/>
                    <a:column name="rule_detail" align="center" prompt="FND1910.WIN_TITLE.RULE_DETAIL" renderer="render_ruleDs_grid"/>
                </a:columns>
                <a:editors>
                    <a:comboBox id="ruleDs_grid_editor_comb"/>
                    <a:textField id="ruleDs_grid_editor_tf_upper" typeCase="upper"/>
                    <a:textField id="ruleDs_grid_editor_tf"/>
                    <a:checkBox id="ruleDs_grid_editor_check"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>