<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: copy from hec  
    $Date: 2011-7-29 下午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="hls_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="ali_import_link" url="${/request/@context_path}/modules/hls/HLS900/hls_csh_transaction_interface.lview"/>
        <a:link id="ali_import_save_data_link" url="${/request/@context_path}/modules/hls/HLS900/ins_import_save_data.lsc"/>
        <a:link id="hls_submmit_link_id" model="hls.HLS900.hls_import_interface" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
        
           function view() {
                 // var record = $(ds_id).findById(record_id);
                var param = new Object();
                param['function_code'] = 'HLS900';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '自动收款核销入口';
                param['master_type']='BP_MASTER';
                param['master_id'] = param['bp_id'];
                hls_doc_get_layout_code('hls_get_layout_code_link_id',param,'ali_import_link','import_ds');
          
            }
            
            function loadComplete() {			
                if ('${/model/status/record/@status}' == 'NEW') {
                    var importData = $('fnd_data_ds').getAll();
                    var param = {};
                    var saveData = [];
                    var errorData = "";
                    var importFlag = true;
                    param['batch_id'] = '${/parameter/@batch_id}';
                     param['header_id'] = '${/model/header/record/@header_id}';
                    // 必输字段先校验下
                    
                        Leaf.request({
                            url: $('ali_import_save_data_link').getUrl(),
                            para: param,
                            success: function() {
                                view();
                                //Ext.get('failure_form').setStyle('display', 'visible');
                              //  Ext.get('success_form').setStyle('visibility', 'none');
                            },
                            scope: this
                        });
                   
                } else {
                    //Ext.get('success_form').setStyle('display', 'none');
                    Ext.get('failure_form').setStyle('visibility', 'visible');
                }
            }
            
         
            function color_render(value,record,name){
                var status = record.get('status');
                if(status == 'E'){
                    return '<font color="red">'+value+'</font>';
                }else{
                  return '<font color="green">'+value+'</font>';
                }
            }
            
            function submmit(){
                Leaf.request({
                            url: $('hls_submmit_link_id').getUrl(),
                            para: {batch_id :${/parameter/@batch_id}},
                            success: function() {
                                view();
                            },
                            scope: this
                        });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="fnd_data_ds">
                <a:datas dataSource="/model/importData"/>
            </a:dataSet>
            <!-- model="csh.CSH6110.csh_cash_plan_import_get_error_data" -->
            <a:dataSet id="import_query_ds" autoCount="true">
                <a:fields>
                    <a:field name="batch_id" defaultValue="${/parameter/@batch_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="import_ds" model="hls.HLS900.hls_import_interface" queryDataSet="import_query_ds">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="bp_code"/>
                    <a:field name="cf_item"/>
                    <a:field name="payment_method_code"/>
                    <a:field name="payment_method"/>
                    <a:field name="bank_account"/>
                    <a:field name="times"/>
                    <a:field name="receipt_date"/>
                    <a:field name="receipt_amount"/>
                    <a:field name="write_off_date"/>
                    <a:field name="write_off_principal"/>
                    <a:field name="write_off_interest"/>
                    <a:field name="bank_slip_num"/>
                    <a:field name="status"/>
                    <a:field name="status_n"/>
                    <a:field name="error_msg"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <!--   <a:form id="success_form" style="visibility:hidden" title="IMPORT_SUCCESS" width="400">
                <a:button click="view" text="PROMPT.VIEW"/>
            </a:form> -->
            <a:form id="failure_form" title="导入信息" width="400">
                <a:hBox>
                    <a:button click="view" text="返回"/>
                    <a:button click="submmit" text="提交"/>
                </a:hBox>
                <a:grid bindTarget="import_ds" marginHeight="200" marginWidth="40" navBar="true">
                    <a:toolBar>
                        <a:button type="excel"/>
                    </a:toolBar>
                    <a:columns>
                        <a:column name="bank_slip_num" lock="true" prompt="银行流水号" sortable="true" width="120"/>
                        <a:column name="contract_number" lock="true" prompt="合同号" renderer="color_render" width="120"/>
                        <a:column name="bp_code" prompt="商业伙伴" width="80"/>
                        <a:column name="cf_item" prompt="现金流项目" width="100"/>
                        <a:column name="payment_method" prompt="支付方式" width="120"/>
                        <a:column name="bank_account" prompt="账户" width="100"/>
                        <a:column name="times" prompt="期数" width="100"/>
                        <a:column name="receipt_date" prompt="收款日期" renderer="Leaf.formatDate" width="100"/>
                        <a:column name="receipt_amount" align="right" prompt="收款金额" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="write_off_date" prompt="核销日期" renderer="Leaf.formatDate" width="100"/>
                        <a:column name="write_off_principal" align="right" prompt="核销本金" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="write_off_interest" align="right" prompt="核销利息" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="status_n" prompt="状态" sortable="true" width="150"/>
                        <a:column name="error_msg" editor="textaera_e" prompt="错误信息" width="200"/>
                    </a:columns>
                    <a:editors>
                        <a:textArea id="textaera_e"/>
                    </a:editors>
                </a:grid>
            </a:form>
        </a:screenBody>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <script type="text/javascript"><![CDATA[
	  		loadComplete();
	  	]]></script>
    </a:view>
</a:screen>
