<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-6-24 下午07:14:16  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:c="leaf.application.action" xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <!-- <s:server-script><![CDATA[
            var n = $ctx.model.getChild('textarea_layout_config_path');
            if (n) $ctx.model.removeChild(n);
            n = $ctx.model.getChild('textarea_tab_layout_detail_path');
            if (n) $ctx.model.removeChild(n);
        ]]></s:server-script> -->
        <a:model-query defaultWhereClause="t1.enabled_flag=&apos;Y&apos;" fetchAll="true" model="hls.HLS030.hls_doc_layout_config_grid_field" rootPath="textarea_layout_config_nodisplay_path"/>
        <a:model-query defaultWhereClause="t1.enabled_flag=&apos;Y&apos; and t1.display_flag=&apos;Y&apos;" fetchAll="true" model="hls.HLS030.hls_doc_layout_config_grid_field" rootPath="textarea_layout_config_path"/>
        <a:model-query defaultWhereClause="t1.tab_code=${/parameter/@textarea_tab_code} and t1.enabled_flag=&apos;Y&apos;" fetchAll="true" model="cont.CON500.con_hls_doc_layout_tab_query" rootPath="textarea_tab_layout_detail_path"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            window['${/parameter/@textarea_tab_code}_on_con_header_textarea_init'] = function(ds) {
                var head_record = ds.getCurrentRecord() || ds.create();
                if (!'${/parameter/@document_id}' && '${/parameter/@default_value_dsid}') {
                    var default_value_ds = $('${/parameter/@default_value_dsid}'),
                        default_record = default_value_ds.getCurrentRecord();
                    for (var name in head_record.data) {
                        if (!Ext.isEmpty(default_record.get(name)) && name.indexOf('price_list') == '-1') {
                            head_record.set(name, default_record.get(name));
                        }
                    }
                }
                unlock_current_window();
            };
            
            window['${/parameter/@textarea_tab_code}_temp_processfunction'] = function(datas) {
                var ds = $('${/model/textarea_tab_layout_detail_path/record/@parent_table_tab_code}_${/model/textarea_tab_layout_detail_path/record/@base_table}_ds'),
                    f = $('temp_ds').fields;
                for (var name in f) {
                    ds.addField(f[name].pro);
                    var record = ds.getCurrentRecord(),
                        df = f[name].pro['defaultvalue'];
                    if (record && record.isNew && !Ext.isEmpty(df)) {
                        record.set(name, df, true);
                    }
                }
            
                return datas;
            };
            
            function temp_Load() {
                $('temp_ds').destroy();
            }
        ]]></script>
        <a:dataSets>
            <a:freeMarker><![CDATA[
            	<#if model.getObject("/model/textarea_tab_layout_detail_path").getChilds()??>
            		<#if model.getObject("/model/textarea_tab_layout_detail_path/record/@parent_tab_code_flag")=='N'>
	            		<a:dataSet id="temp_ds" processFunction="${model.getObject('/parameter/@textarea_tab_code')}_temp_processfunction" >
	                		<a:fields>
		                		<#if model.getObject("/model/textarea_layout_config_nodisplay_path").getChilds()??>
		                			<#list model.getObject('/model/textarea_layout_config_nodisplay_path').getChilds() as item>
	        							<#if item.getString('validation_type') =='TEXTAREA'>
	        							    <a:field name="${item.getString('column_name')}" requiredMessage="${model.getObject("/model/textarea_tab_layout_detail_path/record/@tab_desc")!""}${item.getString('prompt')!''}${buildSession.getLocalizedPrompt('HLS.NOT_NULL')}" defaultValue="${item.getString('default_value')!""}" readOnly="${item.getString('readonly_input_mode')}" required="${item.getString('required_input_mode')}"/>
	        							</#if>
	                                </#list>
	                            </#if>
	                		</a:fields>
	                		<a:datas>
	                			<a:record name="temp"/>
	                		</a:datas>
	                		<a:events>
	                			<a:event name="load" handler="temp_Load" />
	                		</a:events>
	                	</a:dataSet>
            		<#else>
	            			<#if model.getObject("/model/textarea_tab_layout_detail_path/record/@parent_table_flag")=='N'>
	            				<a:dataSet id="${model.getObject('/parameter/@textarea_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')}_ds" fetchAll="true" queryUrl='${r"${/request/@context_path}"}/modules/cont/CON500/con_contract_base_query.lsc?document_id=${model.getObject("/parameter/@document_id")!""}&amp;document_category=${model.getObject("/parameter/@document_category")!""}&amp;document_type=${model.getObject("/parameter/@document_type")!""}&amp;tab_code=${model.getObject("/parameter/@textarea_tab_code")!""}&amp;layout_code=${model.getObject("/parameter/@layout_code")!""}' submitUrl='${r"${/request/@context_path}"}/modules/cont/CON500/con_contract_save.lsc?base_table=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("base_table")}&amp;query_only=${model.getObject("/model/textarea_tab_layout_detail_path/record/@query_only")!""}&amp;tab_code=${model.getObject("/parameter").getString("textarea_tab_code")}&amp;function_code=${model.getObject("/parameter").getString("function_code")}&amp;function_usage=${model.getObject("/parameter").getString("function_usage")}&amp;document_id=${model.getObject("/parameter/@document_id")!""}&amp;document_category=${model.getObject("/parameter/@document_category")!""}&amp;document_type=${model.getObject("/parameter/@document_type")!""}&amp;parent_table=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("parent_table")!""}&amp;parent_base_table_pk=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("parent_base_table_pk")!""}'>
	            					<a:fields>
		            					<#if model.getObject("/model/textarea_layout_config_nodisplay_path").getChilds()??>
		            						<#list model.getObject('/model/textarea_layout_config_nodisplay_path').getChilds() as item>
		            							<#if item.getString('validation_type') =='TEXTAREA'>
		            							    <a:field name="${item.getString('column_name')}" requiredMessage="${model.getObject("/model/textarea_tab_layout_detail_path/record/@tab_desc")!""}${item.getString('prompt')!''}${buildSession.getLocalizedPrompt('HLS.NOT_NULL')}" defaultValue="${item.getString('default_value')!""}" readOnly="${item.getString('readonly_input_mode')}" required="${item.getString('required_input_mode')}"/>
		            							</#if>
		                                    </#list>
		                                </#if>
	                                </a:fields>
	                                <a:events>
	                					<a:event name="load" handler="${model.getObject('/parameter/@textarea_tab_code')}_on_con_header_textarea_init"/>
	                					<a:event name="add" handler="${model.getObject('/parameter/@textarea_tab_code')}_on_con_header_textarea_init"/>
	                				</a:events>
                            	</a:dataSet>
                            	<script type="text/javascript">
                            	(function(){
                            	    var base_ds=$('${model.getObject('/parameter/@textarea_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')}_ds');
                            		if(!'${model.getObject("/parameter/@document_id")!""}'){
                            			base_ds.create();
                            		}else{
                            		    base_ds.setQueryParameter('${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_base_table_pk')!""}','${model.getObject("/parameter/@document_id")!""}');
                            		    base_ds.query();
                            		    base_ds.on('load',function(){
                            		       if(!base_ds.getAll().length){
                            		      	 base_ds.create(); 
                            		       }
                            		    });
                            		}
                            	})();
                            	</script>
                            <#else>
                                 <a:dataSet id="${model.getObject('/parameter/@textarea_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')}_ds" fetchAll="true" bindName="${model.getObject('/parameter/@textarea_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')}" queryUrl='${r"${/request/@context_path}"}/modules/cont/CON500/con_contract_base_query.lsc?document_id=${model.getObject("/parameter/@document_id")!""}&amp;document_category=${model.getObject("/parameter/@document_category")!""}&amp;document_type=${model.getObject("/parameter/@document_type")!""}&amp;tab_code=${model.getObject("/parameter/@textarea_tab_code")!""}&amp;layout_code=${model.getObject("/parameter/@layout_code")!""}'  bindTarget="${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_table_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_table')}_ds" submitUrl='${r"${/request/@context_path}"}/modules/cont/CON500/con_contract_save.lsc?base_table=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("base_table")}&amp;query_only=${model.getObject("/model/textarea_tab_layout_detail_path/record/@query_only")!""}&amp;tab_code=${model.getObject("/parameter").getString("textarea_tab_code")}&amp;function_code=${model.getObject("/parameter").getString("function_code")}&amp;function_usage=${model.getObject("/parameter").getString("function_usage")}&amp;document_id=${model.getObject("/parameter/@document_id")!""}&amp;document_category=${model.getObject("/parameter/@document_category")!""}&amp;document_type=${model.getObject("/parameter/@document_type")!""}&amp;parent_table=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("parent_table")!""}&amp;parent_base_table_pk=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("parent_base_table_pk")!""}'>
	            					<a:fields>
		            					<#if model.getObject("/model/textarea_layout_config_nodisplay_path").getChilds()??>
		            						<#list model.getObject('/model/textarea_layout_config_nodisplay_path').getChilds() as item>
		            							<#if item.getString('validation_type') =='TEXTAREA'>
		            							    <a:field name="${item.getString('column_name')}" requiredMessage="${model.getObject("/model/textarea_tab_layout_detail_path/record/@tab_desc")!""}${item.getString('prompt')!''}${buildSession.getLocalizedPrompt('HLS.NOT_NULL')}" defaultValue="${item.getString('default_value')!""}" readOnly="${item.getString('readonly_input_mode')}" required="${item.getString('required_input_mode')}"/>
		            							</#if>
		                                    </#list>
		                                </#if>
	                                </a:fields>
	                                <a:events>
	                					<a:event name="load" handler="${model.getObject('/parameter/@textarea_tab_code')}_on_con_header_textarea_init"/>
	                					<a:event name="add" handler="${model.getObject('/parameter/@textarea_tab_code')}_on_con_header_textarea_init"/>
	                				</a:events>
                            	</a:dataSet>
                            	<script type="text/javascript">
                            		(function(){
                            		    var base_ds=$('${model.getObject('/parameter/@textarea_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')}_ds');
	                            		var parent_ds=$('${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_table_tab_code')}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_table')}_ds');
	                            		if(!'${model.getObject("/parameter/@document_id")!""}'){
	                            			base_ds.create();
	                            		}else{
	                            		     parent_ds.on('indexchange',function(ds){
	                            		     	base_ds.setQueryParameter('${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_base_table_pk')!""}',parent_ds.getCurrentRecord().get('${model.getObject('/model/textarea_tab_layout_detail_path/record/@parent_base_table_pk')!""}'));
		                            		    base_ds.query();
		                            		    base_ds.on('load',function(){
		                            		       if(!base_ds.getAll().length){
		                            		      	 base_ds.create(); 
		                            		       }
		                            		    });
	                            		    });
	                            		}
                            		})();
                            	</script>
	            			</#if>
            		</#if>
            	</#if>
            ]]></a:freeMarker>
        </a:dataSets>
        <a:hBox>
            <a:placeHolder id="dynamicHeadTextArea_id"/>
        </a:hBox>
    </a:view>
    <a:view-config>
        <c:create-config targetId="dynamicHeadTextArea_id">
            <p:loop source="/model/textarea_layout_config_path">
                <p:switch test="@validation_type">
                    <p:case value="TEXTAREA">
                        <c:process-config>
                            <a:textArea name="${@column_name}" bindTarget="${/model/textarea_tab_layout_detail_path/record/@form_binder_tab_code}_${/model/textarea_tab_layout_detail_path/record/@base_table}_ds" height="${/model/textarea_tab_layout_detail_path/record/@height}" marginHeight="${/model/textarea_tab_layout_detail_path/record/@margin_height}" marginWidth="${/model/textarea_tab_layout_detail_path/record/@margin_width}" prompt="${@prompt}" style="margin-top:${@margin_top}px;margin-bottom:${@margin_top}px" width="${/model/textarea_tab_layout_detail_path/record/@width}"/>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>
