<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="general_upload_excel_control_link" url="${/request/@context_path}/modules/csh/CSH531N/csh_gathering_excel_execute.lview"/>
        <a:link id="csh_file_name_verify_link" model="csh.CSH531N.csh_file_name_verify" modelaction="execute"/>
        <!-- <a:link id="csh_delete_trx_by_name_link" model="csh.CSH531N.csh_file_name_verify" modelaction="delete"/> -->
        <a:link id="csh_file_download_link" url="${/request/@context_path}/modules/csh/CSH531N/csh_template_download.lsc"/>
        <script type="text/javascript"><![CDATA[
        	
        	//覆盖逻辑(导入中已经实现覆盖逻辑)
        	// function delete_trx_by_name(){
                // var fileName = document.getElementById('general_importFile').value;
                // var fileType_2 = fileName.substr(fileName.lastIndexOf("\\"));
                // var file_name = fileType_2.substr(1,fileType_2.length);
        	    // Leaf.request({
        	        // url:$('csh_delete_trx_by_name_link').getUrl(),
        	        // para:{file_name:file_name},
        	        // success:function(){},
        	        // scope:this
        	    // });
        	// }
        	
        	function templateDownload(){
        	    //server:file_path  'D:\\project\\web\\excel_template\\'
                var url = $('csh_file_download_link').getUrl() + '?file_path=' + 'D:\\project\\web\\excel_template\\' + '&file_name=' + '汇款导入模版.xlsx';
                window.open(url, '_self');
        	}
        	
        	function saveConfirm(){
        	    Leaf.showConfirm('${l:PROMPT}','导入的文件已经存在,是否覆盖?',function(){
        	         // delete_trx_by_name();
                     document.getElementById('general_importForm').submit();
        	    },function(){
        	        
        	    });
        	}
        
            function saveClick() {
                if (document.getElementById('general_importFile').value) {
                    //
	                // Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
                    var detail_mask = $('${/parameter/@winid}').wrap;
                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    var fileName = document.getElementById('general_importFile').value;
                    var fileType = fileName.substr(fileName.lastIndexOf("."));
                    
                    var fileType_2 = fileName.substr(fileName.lastIndexOf("\\"));
                    var file_name = fileType_2.substr(1,fileType_2.length);
                    
                    if (fileType != '.xls' && fileType != '.xlsx') {
                        alert('请选择正确的导入文件!');
                    } else{
                        Leaf.request({
	                        url:$('csh_file_name_verify_link').getUrl(),
	                        para:{file_name:file_name},
	                        success:function(res){
	                            if(res.result.count != 0){
					        	    saveConfirm();
	                            }else{
	                                document.getElementById('general_importForm').submit();
	                            }
	                        },
	                        scope:this
	                    });
                    }
                    Leaf.Masker.mask(detail_mask);
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="csh713_label_ds" autoCreate="true">
                <a:fields>
                    <a:field name="label2" defaultValue="1、请严格按照导入模板整理数据,检查必输项是否缺失。"/>
                    <a:field name="label3" defaultValue="2、目前仅支持 MS Excel。"/>
                    <a:field name="label4" defaultValue="3、执行导入前,请先关闭Excel文件。"/>
                    <a:field name="label6" defaultValue="4、导入完毕后,请在系统中核对数据。"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:fieldSet style="margin-left:10px;margin-top:10px;" title="注意事项" width="400">
            <!--<a:label name="label1" bindTarget="label_ds" width="380"/>-->
            <a:label name="label2" bindTarget="csh713_label_ds" style="margin-left:10px;" width="380"/>
            <a:label name="label3" bindTarget="csh713_label_ds" style="margin-left:10px;" width="380"/>
            <a:label name="label4" bindTarget="csh713_label_ds" style="margin-left:10px;" width="380"/>
            <a:label name="label6" bindTarget="csh713_label_ds" style="margin-left:10px;" width="380"/>
        </a:fieldSet>
        <a:fieldSet style="margin-left:10px;margin-top:10px;" title="导入文件" width="400">
            <form name="upload" id="general_importForm" action="csh_gathering_excel_execute.lview" enctype="multipart/form-data" method="post">
                <input name="CONTENT" id="general_importFile" style="margin-bottom:4px;width:250px;height:22px;" type="file"/>
                <input onclick="saveClick()" style="margin-left:10px;margin-top:10px;width:60px;" type="button" value="导入"/>
            </form>
        </a:fieldSet>
        <a:fieldSet showBorder="false" style="margin-left:10px;margin-top:10px;" width="400">
            <a:button click="templateDownload" text="模版下载"/>
        </a:fieldSet>
    </a:view>
</a:screen>