<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xuls
    $Date: 2014-9-15   
    $Revision: 1.0  
    $Purpose: copy_layout_code
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <!-- <a:model-query model="hls.HLS030.hls_doc_layout_batch_column" fetchAll="true" defaultWhereClause="t.config_id = ${/parameter/@config_id}" rootPath="hls030_columns" /> --><![CDATA[
    	
   	]]></a:init-procedure>
    <a:view>
        <a:link id="layout_copy_batch_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_batch_copy.lsc"/>
        <script type="text/javascript"><![CDATA[
			function hls030_copy_close(){
			    $('hls_layout_copy_screen').close();
			}
			function hls030_copy_sumbmit(){
				var data={};
                data['datas']=[];
                var layout_code='${/parameter/@layout_code}';
                var config_id = '${/parameter/@config_id}';
                data['datas'][0] = {
                	name:'FROM_LAYOUT_CODE_CONFIG_ID',
                	value_list:[{value:config_id}]
                };
                var tab_records=$('hls030_batch_copy_tab_code_ds').getSelected();
                
                if(tab_records.length<1)
                {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS050.ERROR.PLEASE_CHOOSE_TO_TAB_CODE}');
                    return ;
                }
                var column_records = $('hls030_batch_column_ds').getSelected();
                if(column_records.length<1)
                {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS050.ERROR.PLEASE_CHOOSE_COLUMN_NAME}');
                    return ;
                }
                var tab_list=[];
                for(var i = 0,j=tab_records.length;i<j;i++)
                {
                    tab_list[i]={
                    	value:tab_records[i].get('tab_code_disp')
                    };
                }
                
                data['datas'][1] = {
                	name:'TO_LAYOUT_CODE.TAB_CODE',
                	value_list:tab_list
                };
                var column_list=[];
                for(var i = 0,j=column_records.length;i<j;i++)
                {
                    column_list[i]={
                    	value:column_records[i].get('column_name')
                    };
                }
                
                data['datas'][2] = {
                	name:'COLUMN_NAME',
                	value_list:column_list
                };
                
                Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE}', function()
            	{
            	    Leaf.request({
	                    url: $('layout_copy_batch_link').getUrl(),
	                    para: data,
	                    success: function(res) {
	                        Leaf.SideBar.show({
	                            msg: '${l:HLS.SUBMIT_SUCCESS}',
	                            duration: 2000
	                        });
	                        hls030_copy_close();
	                    },
	                    scope: this
	                });
        		});    
			}
			function hls030_copy_query(){
			    $('hls030_batch_copy_tab_code_ds').query();
			}
			function hls_030_addColumnName(column_name,description)
        	{
        	    $('hls030_batch_column_ds').create({
        	        column_name:column_name,
        	        description:description
        	    });
        	}
			function init_columnNameDs()
            {
                hls_030_addColumnName('PROMPT','${l:HLS050.HLS_FIN_CALC_CONFIG.PROMPT}');
				hls_030_addColumnName('ENABLED_FLAG','${l:HLS050.HLS_FIN_CALC_CONFIG.ENABLED_FLAG}');
				hls_030_addColumnName('DISPLAY_FLAG','${l:HLS050.HLS_FIN_CALC_CONFIG.DISPLAY_FLAG}');
				hls_030_addColumnName('DISPLAY_ORDER','${l:HLS050.HLS_FIN_CALC_CONFIG.DISPLAY_ORDER}');
				hls_030_addColumnName('INPUT_MODE','${l:HLS050.HLS_FIN_CALC_CONFIG.INPUT_MODE}');
				hls_030_addColumnName('VALIDATION_TYPE','${l:HLS050.HLS_FIN_CALC_CONFIG.VALIDATION_TYPE}');
				hls_030_addColumnName('ALLOW_DECIMAL','${l:HLS050.HLS_FIN_CALC_CONFIG.ALLOW_DECIMAL}');
				hls_030_addColumnName('PRECISION','${l:HLS050.HLS_FIN_CALC_CONFIG.PRECISION}');
				hls_030_addColumnName('ZERO_FILL','${l:HLS050.HLS_FIN_CALC_CONFIG.ZERO_FILL}');
				hls_030_addColumnName('ALLOW_FORMAT','${l:HLS050.HLS_FIN_CALC_CONFIG.ALLOW_FORMAT}');
				hls_030_addColumnName('PERCENT','${l:HLS050.HLS_FIN_CALC_CONFIG.PERCENT}');
				hls_030_addColumnName('ALIGNMENT','${l:HLS050.HLS_FIN_CALC_CONFIG.ALIGNMENT}');
				hls_030_addColumnName('VALIDATION_SQL','${l:HLS050.HLS_FIN_CALC_CONFIG.VALIDATION_SQL}');
				hls_030_addColumnName('DEFAULT_VALUE','${l:HLS050.HLS_FIN_CALC_CONFIG.DEFAULT_VALUE}');
				var ds = $('hls030_batch_column_ds');
				ds.locate(1);
            }			
		]]></script>
        <a:dataSets>
            <a:dataSet id="hls030_batch_copy_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="layout_code" defaultValue="${/parameter/@layout_code}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls030_batch_copy_tab_code_ds" autoQuery="true" model="hls.HLS030.hls_doc_layout_batch_tab" queryDataSet="hls030_batch_copy_query_ds" selectable="true"/>
            <a:dataSet id="hls030_batch_column_ds" fetchAll="true" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="hls030_copy_close" text="HLS.CLOSE"/>
                <a:gridButton click="hls030_copy_query" text="HLS.QUERY"/>
                <a:gridButton click="hls030_copy_sumbmit" text="HLS.UPDATE"/>
            </a:screenTopToolbar>
            <a:form column="2" title="查询">
                <a:textField name="layout_code" bindTarget="hls030_batch_copy_query_ds" prompt="HLS.LAYOUT_CODE" width="150"/>
            </a:form>
            <a:form column="2">
                <a:grid id="hls030_batch_tab" bindTarget="hls030_batch_copy_tab_code_ds" height="320" navBar="true" width="400">
                    <a:columns>
                        <a:column name="layout_code" prompt="layout_code" width="100"/>
                        <a:column name="tab_code" prompt="tab_code" width="100"/>
                        <a:column name="tab_desc" prompt="描述" width="150"/>
                    </a:columns>
                </a:grid>
                <a:grid id="hls030_batch_column" bindTarget="hls030_batch_column_ds" height="320" width="300">
                    <a:columns>
                        <a:column name="column_name" prompt="HLS050.HLS_FIN_CALC_CONFIG.COLUMN_NAME"/>
                        <a:column name="description" prompt="HLS050.HLS_FIN_CALC_CONFIG.PROMPT"/>
                    </a:columns>
                </a:grid>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            Leaf.onReady(function() {
                init_columnNameDs();
            });
        ]]></script>
    </a:view>
</a:screen>
