<?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>
        <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}" fetchAll="true" model="prj.PRJ500.prj_hls_doc_layout_tab_query" rootPath="textarea_tab_layout_detail_path"/>
        <!-- <s:server-script xmlns:s='leaf.plugin.script'><![CDATA[
        	var m=$ctx.get('/model/textarea_tab_layout_detail_path');
        	println(m.toXML());
        ]]></s:server-script> -->
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            window['${/parameter/@bp_seq}${/parameter/@textarea_tab_code}_on_con_header_textarea_init'] = function(ds) {
                var head_record = ds.getCurrentRecord() || ds.create();
                head_record.set('bp_seq', '${/parameter/@bp_seq}');
                head_record.set('project_id', '${/parameter/@document_id}');
                head_record.set('project_id_n', '${/model/textarea_tab_layout_detail_path/record/@project_name}');
                head_record.set('bp_category', '${/model/textarea_tab_layout_detail_path/record/@query_bp_category}');
                head_record.set('bp_category_n', '${/model/textarea_tab_layout_detail_path/record/@query_bp_category_name}');
                if (!'${/parameter/@document_id}' && '${/parameter/@default_value_dsid}') {
                    var default_record = (parent == top ? self : parent)['$']('${/parameter/@default_value_dsid}').getCurrentRecord();
                    for (var name in head_record.data) {
                        if (!Ext.isEmpty(default_record.get(name))) {
                            head_record.set(name, default_record.get(name));
                        }
                    }
                }
                $L.Masker.unmask(Ext.get(document.documentElement));
            };
            
            window['${/parameter/@bp_seq}${/parameter/@textarea_tab_code}_temp_processfunction'] = function(datas) {
                var ds = $('${/parameter/@bp_seq}${/model/textarea_tab_layout_detail_path/record/@form_binder_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/@bp_seq')!""}${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/@bp_seq')!""}${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/prj/PRJ500/prj_project_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")!""}&amp;bp_seq=${model.getObject("/parameter/@bp_seq")!""}&amp;bp_category=${model.getObject("/model/textarea_tab_layout_detail_path/record/@query_bp_category")!""}' submitUrl='${r"${/request/@context_path}"}/modules/prj/PRJ500/prj_project_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;root_tree_code=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("root_tree_code")}&amp;tab_code=${model.getObject("/parameter").getString("textarea_tab_code")}&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")!""}&amp;function_code=${model.getObject("/parameter/@function_code")!""}&amp;function_usage=${model.getObject("/parameter/@function_usage")!""}'>
	            					<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')}" 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="window['${model.getObject('/parameter/@bp_seq')!""}${model.getObject('/parameter/@textarea_tab_code')!""}_on_con_header_textarea_init']"/>
	                					<a:event name="add" handler="window['${model.getObject('/parameter/@bp_seq')!""}${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/@bp_seq')!""}${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/@bp_seq')!""}${model.getObject('/parameter/@textarea_tab_code')!""}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')!""}_ds" fetchAll="true" bindName="${model.getObject('/parameter/@bp_seq')!""}${model.getObject('/parameter/@textarea_tab_code')!""}_${model.getObject('/model/textarea_tab_layout_detail_path/record/@base_table')!""}" queryUrl='${r"${/request/@context_path}"}/modules/prj/PRJ500/prj_project_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")!""}&amp;bp_seq=${model.getObject("/parameter/@bp_seq")!""}&amp;bp_category=${model.getObject("/model/textarea_tab_layout_detail_path/record/@query_bp_category")!""}'  bindTarget="${model.getObject('/model/textarea_tab_layout_detail_path/record/@repeat_bp_seq')!""}${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/prj/PRJ500/prj_project_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;root_tree_code=${model.getObject("/model/textarea_tab_layout_detail_path/record").getString("root_tree_code")}&amp;tab_code=${model.getObject("/parameter").getString("textarea_tab_code")}&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")!""}&amp;function_code=${model.getObject("/parameter/@function_code")!""}&amp;function_usage=${model.getObject("/parameter/@function_usage")!""}'>
	            					<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="window['${model.getObject('/parameter/@bp_seq')!""}${model.getObject('/parameter/@textarea_tab_code')!""}_on_con_header_textarea_init']"/>
	                					<a:event name="add" handler="window['${model.getObject('/parameter/@bp_seq')!""}${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/@bp_seq')!""}${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{
	                            		    (function(callback){
	                            		        var parent_ds=$('${model.getObject('/model/textarea_tab_layout_detail_path/record/@repeat_bp_seq')!""}${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(!parent_ds.getAll().length){
			                        		    	parent_ds.on('indexchange',function(){
			                            		        callback(parent_ds);
			                        		    	});
		                        		    	}else{
		                        		    	        callback(parent_ds);
		                        		    	}
	                            		    })(function(parent_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 padding="0">
            <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>
                            <div>
                                <div><![CDATA[${@prompt}]]></div>
                                <a:textArea name="${@column_name}" bindTarget="${/parameter/@bp_seq}${/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}" style="margin-top:${@margin_top}px;margin-bottom:${@margin_top}px;" width="${/model/textarea_tab_layout_detail_path/record/@width}"/>
                            </div>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>