<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhenwei.yin  
    $Date: 2013-4-16 下午3:55:42  
    $Revision: 1.0  
    $Purpose: 单据类型定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[     
    ]]></a:init-procedure>
    <a:view>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
            function documentTypeDs_grid_query() {
                $('documentTypeDs').query();
            }
            
            function para_documentTypeDs_reset() {
                $('para_documentTypeDs').reset();
            }
            
            function documentTypeScreen_next() {
                history.go(1);
            }
            
            function documentTypeScreen_back() {
                history.go(-1);
            }
            
            function documentTypeScreen_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
            }
            
            function documentTypeDs_grid_add() {
                $('documentTypeDs_grid').showEditorByRecord($('documentTypeDs').create());
            }
            
            function documentTypeDs_grid_clear() {
                $('documentTypeDs_grid').clear();
            }
            
            function documentTypeDs_grid_submit() {
                $('documentTypeDs').submit();
            }
            
            function documentTypeScreen_submitsuccess() {
                $('documentTypeDs').query();
            }
            
            function editorFun_documentTypeDs_grid(record, name) {
                if(name=='workflow_desc')
                {
                    var field =  record.getField(name);
                    if(record.get('approval_method')=='WORK_FLOW')
                    {
                        field.setRequired(true);
                        return 'documentTypeDs_grid_lov';
                    }
                    else
                    {
                        field.setRequired(false);
                        return '';
                    }
                }
                if (record.isNew) {
                    if(name=='document_type')
                    {
                        return 'documentTypeDs_grid_tf_upper';
                    }
                    if(name=='document_category_desc')
                    {
                        return 'documentTypeDs_grid_comb';
                    }
                    if(name=='business_type_desc')
                    {
                        return 'documentTypeDs_grid_lov';
                    }
                    return '';
                    
                }
                return '';
            }
            
            function onUpdate_documentTypeDs(ds,record,name,value,oldValue)
            {
                if(name=='document_category')
                {
                    record.set('business_type_desc','');
                    record.set('business_type','');
                    record.getField('business_type_desc').setLovPara('document_category',value);
                }
                if(name=='approval_method')
                {
                    if(value=='WORK_FLOW')
                    {
                        
                    }
                    
                }
            }
            
            function validator_documentTypeDs(record, name, value)
            {
                if(name=='business_type_desc')
                {
                    if(record.isNew&&Ext.isEmpty(value))
                    {
                        return '${l:HLS.VALIDATE_REQUIRED}';
                    }
                    return true;
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="coding_rule_ds" lookupCode="HLS003_CODING_RULE"/>
            <a:dataSet id="approval_method_ds" lookupCode="HLS003_APPROVAL_METHOD"/>
            <a:dataSet id="coding_rule_doc_category_ds" loadData="true" model="hls.HLS002.hls_document_category"/>
            <a:dataSet id="ref_document_type_ds" loadData="true" model="basic.hls_document_type_v_simple_lov"/>
            <a:dataSet id="para_documentTypeDs" model="hls.HLS003.hls_document_type">
                <a:fields>
                    <a:field name="document_category_desc" displayField="description" options="coding_rule_doc_category_ds" returnField="document_category" valueField="document_category"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="documentTypeDs" autoQuery="true" fetchAll="false" model="hls.HLS003.hls_document_type" pageSize="18" queryDataSet="para_documentTypeDs" selectable="true">
                <a:fields>
                    <a:field name="document_type" required="true"/>
                    <a:field name="description" required="true"/>
                    <a:field name="document_category_desc" displayField="description" options="coding_rule_doc_category_ds" required="true" returnField="document_category" valueField="document_category"/>
                    <a:field name="business_type_desc" lovGridHeight="300" lovHeight="450" lovService="basic.hls_doc_category_biz_type_v_lov" lovWidth="400" title="HLS.BUSINESS_TYPE">
                        <a:mapping>
                            <a:map from="business_type_desc" to="business_type_desc"/>
                            <a:map from="business_type" to="business_type"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="coding_rule_desc" displayField="code_value_name" options="coding_rule_ds" returnField="coding_rule" valueField="code_value"/>
                    <a:field name="ref_document_type_desc" displayField="document_type_desc" options="ref_document_type_ds" returnField="ref_document_type" valueField="document_type"/>
                    <a:field name="ln_starting"/>
                    <a:field name="ln_step_length"/>
                    <a:field name="printing_format_desc"/>
                    <a:field name="approval_method_desc" displayField="code_value_name" options="approval_method_ds" returnField="approval_method" valueField="code_value"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="workflow_desc" lovGridHeight="300" lovHeight="480" lovLabelWidth="100" lovService="basic.hls_wfl_workflow_v_lov" lovWidth="750" title="HLS.WORKFLOW_DESC">
                        <a:mapping>
                            <a:map from="workflow_desc" to="workflow_desc"/>
                            <a:map from="workflow_id" to="workflow_id"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_documentTypeDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="documentTypeScreen_back" text="HLS.BACK"/>
                <a:gridButton click="documentTypeScreen_next" text="HLS.FORWARD"/>
                <a:gridButton click="documentTypeScreen_quit" text="HLS.EXIT"/>
                <a:gridButton click="documentTypeDs_grid_add" text="HLS.NEW"/>
                <a:gridButton click="documentTypeDs_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="documentTypeDs_grid_submit" text="HLS.SAVE"/>
                <a:gridButton click="documentTypeDs_grid_query" text="HLS.QUERY"/>
                <a:gridButton click="para_documentTypeDs_reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form column="2" labelWidth="100" title="HLS.QUERY_TITLE">
                <a:comboBox name="document_category_desc" bindTarget="para_documentTypeDs" prompt="HLS.DOCUMENT_CATEGORY">
                    <a:events>
                        <a:event name="enterdown" handler="documentTypeDs_grid_query"/>
                    </a:events>
                </a:comboBox>
                <a:textField name="document_type" bindTarget="para_documentTypeDs" typeCase="upper">
                    <a:events>
                        <a:event name="enterdown" handler="documentTypeDs_grid_query"/>
                    </a:events>
                </a:textField>
            </a:form>
            <a:grid id="documentTypeDs_grid" bindTarget="documentTypeDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="document_type" editorFunction="editorFun_documentTypeDs_grid" width="100"/>
                    <a:column name="description" editor="documentTypeDs_grid_tf" width="140"/>
                    <a:column name="document_category_desc" editorFunction="editorFun_documentTypeDs_grid" width="120"/>
                    <a:column name="business_type_desc" editorFunction="editorFun_documentTypeDs_grid" width="100"/>
                    <a:column name="coding_rule_desc" editor="documentTypeDs_grid_comb" width="100"/>
                    <a:column name="ref_document_type_desc" editor="documentTypeDs_grid_comb" width="100"/>
                    <a:column name="ln_starting" editor="documentTypeDs_grid_nf" width="80"/>
                    <a:column name="ln_step_length" editor="documentTypeDs_grid_nf" width="80"/>
                    <a:column name="printing_format_desc" editor="documentTypeDs_grid_comb" width="100"/>
                    <a:column name="approval_method_desc" editor="documentTypeDs_grid_comb" width="100"/>
                    <a:column name="workflow_desc" editorFunction="editorFun_documentTypeDs_grid" width="100"/>
                    <a:column name="enabled_flag" editor="documentTypeDs_grid_check" width="50"/>
                </a:columns>
                <a:editors>
                    <a:textField id="documentTypeDs_grid_tf_upper" typeCase="upper"/>
                    <a:textField id="documentTypeDs_grid_tf"/>
                    <a:checkBox id="documentTypeDs_grid_check"/>
                    <a:comboBox id="documentTypeDs_grid_comb"/>
                    <a:lov id="documentTypeDs_grid_lov"/>
                    <a:numberField id="documentTypeDs_grid_nf" allowDecimals="false" allowNegative="false"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
