<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei5743  
    $Date: 2015-04-09 上午10:07:29  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure outputPath="/parameter">
        <a:model-query model="basic.hls_fnd_attribute_sequence" rootPath="header"/>
        <a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="SDIC_ACR_INVOICE" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;SDIC_ACR_INVOICE&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
        <a:model-update model="sdic.SDIC001.sdic_acr_invoice_import_check"/>
    </a:init-procedure>
    <a:view>
        <a:link id="import_sdic_acr_invoice_link_id" model="sdic.SDIC001.sdic_acr_invoice_import_check" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function backBtn() {
                parent._input_window.close();
            }
            
            var import_flag=0;
            function import_btn() {
                var ds = $('sdic_acr_invoice_ds');
                record = ds.getAll();
                if(import_flag==0){
                for (i = 0;i < record.length;i++) {
                    if (record[i].get('status') == 'ERROR') {
                        Leaf.showMessage('${l:PROMPT}', '导入的数据存在错误，请查看错误信息！');
                        return;
                    }
                }
              Leaf.request({
                    url: $('import_sdic_acr_invoice_link_id').getUrl(),
                    para: {
                        header_id:'${/model/header/record/@header_id}'
                        
                    },
                    scope: this,
                    success: function() {
                        import_flag=import_flag+1;
                        Leaf.SideBar.show({
                            msg: '操作成功',
                            duration: 2000
                        });

                    }
                });
                }else{
                   Leaf.showMessage('${l:PROMPT}', '数据已导入不能重复导入！');
                        return;  
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="sdic_acr_invoice_ds" autoQuery="true" fetchAll="true" model="sdic.SDIC001.fnd_interface_info" queryUrl="${/request/@context_path}/autocrud/sdic.SDIC001.fnd_interface_info/query?header_id=${/model/header/record/@header_id}"/>
        </a:dataSets>
        <a:screenBody>
            <a:form id="success_form" height="400" title="THE_IMPORTED_DATA" width="980">
                <a:screenTopToolbar>
                    <a:gridButton click="backBtn" text="退出"/>
                    <a:gridButton click="import_btn" text="导入"/>
                </a:screenTopToolbar>
                <a:grid id="grid_ds_id" bindTarget="sdic_acr_invoice_ds" height="340" navBar="true" width="980">
                    <a:columns>
                        <a:column name="error_message" prompt="错误信息" width="150"/>
                        <a:column name="attribute_1" prompt="单据编号"/>
                        <a:column name="attribute_2" prompt="合同编号" width="150"/>
                        <a:column name="attribute_3" prompt="购货单位" width="180"/>
                        <a:column name="attribute_4" prompt="纳税人识别号" width="130"/>
                        <a:column name="attribute_5" prompt="地址" width="180"/>
                        <a:column name="attribute_6" prompt="电话"/>
                        <a:column name="attribute_7" prompt="开户行"/>
                        <a:column name="attribute_8" prompt="账号" width="130"/>
                        <a:column name="attribute_9" prompt="货物或应税劳务名称" width="120"/>
                        <a:column name="attribute_10" prompt="规格型号"/>
                        <a:column name="attribute_11" prompt="单位"/>
                        <a:column name="attribute_12" prompt="数量"/>
                        <a:column name="attribute_13" align="right" prompt="单价"/>
                        <a:column name="attribute_14" align="right" prompt="金额"/>
                        <a:column name="attribute_15" align="right" prompt="税种"/>
                        <a:column name="attribute_16" align="right" prompt="税率"/>
                        <a:column name="attribute_17" align="right" prompt="税额"/>
                        <a:column name="attribute_18" align="right" prompt="价税合计"/>
                        <a:column name="attribute_19" prompt="期数"/>
                        <a:column name="attribute_20" prompt="开票日期"/>
                        <a:column name="attribute_21" prompt="发票号"/>
                        <a:column name="attribute_22" align="right" prompt="发票代码"/>
                        <a:column name="attribute_23" align="right" prompt="开票金额"/>
                        <a:column name="attribute_24" align="right" prompt="开票税率"/>
                        <a:column name="attribute_25" align="right" prompt="开票税额"/>
                        <a:column name="attribute_26" align="right" prompt="价税合计"/>
                    </a:columns>
                </a:grid>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
	  		
	  	]]></script>
    </a:view>
</a:screen>
