<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ericyin  
    $Date: 2013-3-28 下午1:26:42  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.document_category=&apos;PROJECT&apos;" model="basic.hls_document_type_v_simple_lov" rootPath="project_type_list"/>
        <a:model-query defaultWhereClause="t1.document_category=&apos;CONTRACT&apos;" model="basic.hls_document_type_v_simple_lov" rootPath="contract_type_list"/>
        <a:model-query defaultWhereClause="t1.document_category=&apos;CHANCE&apos;" model="basic.hls_document_type_v_simple_lov" rootPath="chance_type_list"/>
    </a:init-procedure>
    <a:view>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
        	function hls_109_query() {
                $('hls_default_param_result_ds').query();
            }
            function hls_109_reset(){
			    $('hls_default_param_query_ds').reset();
			}
            function hls_109_back() {
                history.go(-1);
            }
            
            function hls_109_next() {
                history.go(1);
            }
            
            function hls_109_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
            }
            
            function hls_109_grid_add() {
                var grid=$('hls_default_param_result_ds_grid');
                $('hls_default_param_result_ds_grid').showEditorByRecord($('hls_default_param_result_ds').create());
            }
            
            function hls_109_grid_clear() {
                $('hls_default_param_result_ds_grid').clear();
            }
            
            function hls_109_grid_delete() {
                $('hls_default_param_result_ds_grid').remove();
            }
            
            function hls_109_grid_submit() {
                $('hls_default_param_result_ds').submit();
            }
            
            function hls109ComboxFunction(record,name){
			    if(record.isNew){
                    return 'hls109GridComb';
                }else{
                    return '';
                }
			}
			
			function hls109LovFunction(record,name){
			    if(record.isNew){
                    return 'hls109GridLov';
                }else{
                    return '';
                }
			}
			
			function hls109Submitsuccess(){
                $('hls_default_param_result_ds').query();
            }
            function hls109Update(ds,record,name,value){
                if (name =='company_id'){
                    record.getField('lease_organization_name').setLovPara('company_id',value);
                }
            }
            function hls109CompanyFunction(record,name){
                var company_id=record.get('company_id');
                if (!company_id){
                    record.getField('lease_organization_name').setLovPara('company_id','-1');
                }
                else{
                    record.getField('lease_organization_name').setLovPara('company_id',company_id);
                }
			    return 'hls109GridLov';
			    
			}
			
			function editorFun_hls_default_param_result_ds_grid(record,name)
			{
			    if(name=='price_list_name')
			    {
			        var company_id=record.get('company_id');
			        var field =  record.getField(name);
			        if(Ext.isEmpty(company_id))
			        {
			            field.setLovPara('company_id',null);
			        }
			        else
			        {
			            field.setLovPara('company_id',company_id);
			        }
			        return 'hls109GridLov';
			    }
			    
			}
        ]]></script>
        <a:dataSets>
            <a:dataSet id="chance_type_ds">
                <a:datas dataSource="/model/chance_type_list"/>
            </a:dataSet>
            <a:dataSet id="project_type_ds">
                <a:datas dataSource="/model/project_type_list"/>
            </a:dataSet>
            <a:dataSet id="contract_type_ds">
                <a:datas dataSource="/model/contract_type_list"/>
            </a:dataSet>
            <a:dataSet id="company_list" loadData="true" model="fnd.fnd_companies_vl"/>
            <a:dataSet id="lease_channel_list" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="division_list" loadData="true" model="basic.hls_division_for_lov"/>
            <a:dataSet id="lov_search_rule_ds" lookupCode="HLS109_LOV_SEARCH_RULE"/>
            <a:dataSet id="hls_default_param_query_ds" autoCreate="true" model="hls.HLS109.hls_default_parameter">
                <a:fields>
                    <a:field name="role_code" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="sys.sys_role_vl_for_lov" lovWidth="500" title="HLS.ROLE_SELECT">
                        <a:mapping>
                            <a:map from="role_code" to="role_code"/>
                            <a:map from="role_id" to="role_id"/>
                            <a:map from="description" to="role_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="role_desc" readOnly="true"/>
                    <a:field name="company_desc" displayField="company_full_name" options="company_list" returnField="company_id" valueField="company_id"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls_default_param_result_ds" autoQuery="true" model="hls.HLS109.hls_default_parameter" queryDataSet="hls_default_param_query_ds" selectable="true" submitUrl="${/request/@context_path}/autocrud/hls.HLS109.hls_default_parameter/batch_update">
                <a:fields>
                    <a:field name="price_list_name" autoComplete="true" fetchSingle="true" lovGridHeight="350" lovHeight="500" lovService="hls.HLS109.hls_price_list_lov_need_company" lovWidth="500" title="HLS.PRICE_LIST">
                        <a:mapping>
                            <a:map from="price_list" to="price_list"/>
                            <a:map from="description" to="price_list_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="role_code" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="sys.sys_role_vl_for_lov" lovWidth="500" required="true" title="HLS.ROLE_SELECT">
                        <a:mapping>
                            <a:map from="description" to="role_desc"/>
                            <a:map from="role_code" to="role_code"/>
                            <a:map from="role_id" to="role_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="role_desc" readOnly="true"/>
                    <a:field name="company_id"/>
                    <a:field name="company_desc" displayField="company_full_name" options="company_list" required="true" returnField="company_id" valueField="company_id"/>
                    <a:field name="lease_organization_name" lovGridHeight="320" lovHeight="450" lovLabelWidth="120" lovService="basic.hls_lease_organization_for_lov" lovWidth="550" title="HLS.LEASE_ORGANIZATION">
                        <a:mapping>
                            <a:map from="description" to="lease_organization_name"/>
                            <a:map from="lease_organization" to="lease_organization"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="lease_organization"/>
                    <a:field name="lease_channel_desc" displayField="description" options="lease_channel_list" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="division_desc" displayField="description" options="division_list" returnField="division" valueField="division"/>
                    <a:field name="lease_chance_type_desc" displayField="document_type_desc" options="chance_type_ds" returnField="lease_chance_type" valueField="document_type"/>
                    <a:field name="project_type_desc" displayField="document_type_desc" options="project_type_ds" returnField="project_type" valueField="document_type"/>
                    <a:field name="contract_type_desc" displayField="document_type_desc" options="contract_type_ds" returnField="contract_type" valueField="document_type"/>
                    <a:field name="lov_search_rule_name" displayField="code_value_name" options="lov_search_rule_ds" returnField="lov_search_rule" valueField="code_value"/>
                    <a:field name="lov_search_rule"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="hls109Submitsuccess"/>
                    <a:event name="update" handler="hls109Update"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hls_109_back" text="HLS.BACK"/>
                <a:gridButton click="hls_109_next" text="HLS.FORWARD"/>
                <a:gridButton click="hls_109_quit" text="HLS.EXIT"/>
                <a:gridButton click="hls_109_grid_add" text="HLS.NEW"/>
                <a:gridButton click="hls_109_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="hls_109_grid_delete" text="HLS.REMOVE"/>
                <a:gridButton click="hls_109_grid_submit" text="HLS.SAVE"/>
                <a:gridButton click="hls_109_query" text="HLS.QUERY"/>
                <a:gridButton click="hls_109_reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form column="3" title="SYS_PROMPT.QUERY_TITLE" width="800">
                <a:lov name="role_code" bindTarget="hls_default_param_query_ds" prompt="HLS.ROLE_CODE">
                    <a:events>
                        <a:event name="enterdown" handler="hls_109_query"/>
                    </a:events>
                </a:lov>
                <a:textField name="role_desc" bindTarget="hls_default_param_query_ds" prompt="HLS.ROLE_DESCRIPTION">
                    <a:events>
                        <a:event name="enterdown" handler="hls_109_query"/>
                    </a:events>
                </a:textField>
                <a:comboBox name="company_desc" bindTarget="hls_default_param_query_ds" prompt="HLS.COMPANY_NAME">
                    <a:events>
                        <a:event name="enterdown" handler="hls_109_query"/>
                    </a:events>
                </a:comboBox>
            </a:form>
            <a:grid id="hls_default_param_result_ds_grid" bindTarget="hls_default_param_result_ds" marginHeight="160" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="role_code" editorFunction="hls109LovFunction" prompt="HLS.ROLE_CODE" width="100"/>
                    <a:column name="role_desc" prompt="HLS.ROLE_DESCRIPTION" width="120"/>
                    <a:column name="company_desc" editorFunction="hls109ComboxFunction" prompt="HLS.COMPANY_NAME" width="140"/>
                    <a:column name="lease_organization_name" editorFunction="hls109CompanyFunction" prompt="HLS.LEASE_ORGANIZATION_NAME" width="100"/>
                    <a:column name="lease_channel_desc" editor="hls109GridComb" prompt="HLS.LEASE_CHANNEL_CODE" width="100"/>
                    <a:column name="division_desc" editor="hls109GridComb" prompt="HLS.DIVISION_CODE" width="100"/>
                    <a:column name="lease_chance_type_desc" editor="hls109GridComb" prompt="HLS.LEASE_CHANCE_TYPE" width="100"/>
                    <a:column name="project_type_desc" editor="hls109GridComb" prompt="HLS.PROJECT_TYPE" width="100"/>
                    <a:column name="contract_type_desc" editor="hls109GridComb" prompt="HLS.CONTRACT_TYPE" width="100"/>
                    <a:column name="lov_search_rule_name" editor="hls109GridComb" prompt="HLS.LOV_SEARCH_RULE" width="100"/>
                    <a:column name="price_list_name" editorFunction="editorFun_hls_default_param_result_ds_grid" prompt="HLS.PRICE_LIST"/>
                </a:columns>
                <a:editors>
                    <a:textField id="hls109GridTf"/>
                    <a:comboBox id="hls109GridComb"/>
                    <a:lov id="hls109GridLov"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
