<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: copy from hec  
    $Date: 2014-11-24 下午05:25:12  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query model="acr.acr_get_sys_import_head_id" rootPath="header"/>
        <a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="ACRIMPORT" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;ACRIMPORT&apos;" model="acr.acr_plan_import_get_header_status" rootPath="status"/>
        <a:model-query autoCount="false" defaultWhereClause="header_id=${/model/header/record/@header_id} order by line_id" fetchAll="true" model="acr.acr_plan_import_get_fnd_data" rootPath="importData"/>
    </a:init-procedure>
    <a:view>
        <a:link id="acp515_import_the_deduct_link" url="${/request/@context_path}/modules/acp/ACP515/acp_import_the_deduct.lview"/>
        <a:link id="acp515_check_data" model="acp.ACP515.acp_check_data" modelaction="execute"/>
        <!-- <a:link id="csh_error_message" url="${/request/@context_path}/modules/csh/CSH531/csh_error_message.lview"/> -->
        <!--  <a:link id="csh_trx_delete_link" model="csh.CSH531.csh_trx_batch_interface" modelaction="delete"/> -->
        <script type="text/javascript"><![CDATA[
			 // function drop_error_data(){
                // Leaf.request({
    	            // url:$('csh_trx_delete_link').getUrl(),
    	            // para:{batch_id :${/model/header/record/@header_id}},
    	            // success: function(){ },
    	            // scope: this
    	        // });
			 // }

			 // function csh531_error_info(){
    	        // var win = new Leaf.Window({
                    // id: 'csh_upload_window',
                    // url: $('csh_error_message').getUrl(),
                    // params:{
                        // batch_id: ${/model/header/record/@header_id}
                    // },
                    // title: '${l:CSH531.ERROR_PAGE}',
                    // width: 620,
                    // height: 335
                // }); 
                // win.on('close',function(){
                    // drop_error_data();
	               	// location.href = $('csh_import_the_deduct_link').getUrl();
                // });
    	    // }
        	
           function submmit(){
               var header_id = ${/model/header/record/@header_id};
               Leaf.request({
	                url: $('acp515_check_data').getUrl(),
	                para: {batch_id :header_id},
	                success: function(res) {
	                    if(res.result.err_count == 0){
	                        Leaf.SideBar.show({
	    	                        msg:'数据成功导入',
	    	                        duration:2000
	    	                    });
	                    }else{
	                        Leaf.SideBar.show({
	    	                        msg:'数据导入出错',
	    	                        duration:3000
	    	                    });
	                        
               			}
               			setTimeout(function(){location.href = $('acp515_import_the_deduct_link').getUrl()+'?header_id=' + header_id;},'500');
	                },
	                failure:function(){
	                    Leaf.showMessage('${l:PROMPT}','导入出错!',function(){
	                        location.href = $('acp515_import_the_deduct_link').getUrl()+'?header_id=' + header_id;
	                    });
	                },
	                error:function(){
	                    Leaf.showMessage('${l:PROMPT}','导入出错!',function(){
	                        location.href = $('acp515_import_the_deduct_link').getUrl()+'?header_id=' + header_id;
	                    });
	                },
	                scope: this
	            });
            }
            
        ]]></script>
        <script type="text/javascript"><![CDATA[
	  		Leaf.onReady(submmit());
	  	]]></script>
    </a:view>
</a:screen>