<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-6-6 上午09:32:17  
    $Revision: 1.0  
    $Purpose: 项目租赁物导入
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <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="CON_CONTRACT_LEASE_ITEM" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;CON_CONTRACT_LEASE_ITEM&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_lease_item_invoice_import_last_link" url="${/request/@context_path}/modules/cont/CON500/con_contract_lease_item_invoice_temp_import.lsc"/>
        <a:link id="con_contract_lease_item_invoice_import_save_link" model="cont.CON500.con_contract_lease_item_invoice_temp_import" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function con_contract_lease_item_import_last_back() {
                parent._input_window.close();
            }
            
            function con_contract_lease_item_import_last_confirm() {
                $('config_btn').disable();
                Leaf.request({
                    url: $('con_contract_lease_item_invoice_import_save_link').getUrl(),
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '操作成功！',
                            duration: 3000
                        });
                        parent._input_window.close();
                    },
                    failure: function() {
                        $('config_btn').enable();
                    },
                    error: function() {
                        $('config_btn').enable();
                    },
                    scope: this
                });
            }
            
            
            function auto_import() {
                if ('${/model/status/record/@status}' == 'NEW') {
                    Leaf.request({
                        url: $('con_contract_lease_item_invoice_import_last_link').getUrl(),
                        para: {
                            session_id: '${/parameter/@session_id}',
                            header_id: '${/model/header/record/@header_id}',
                            contract_id: '${/parameter/@contract_id}'
                        },
                        success: function() {
                            $('prj_project_lease_item_temp_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                            $('prj_project_lease_item_temp_ds').query();
                        },
                        failure: function() {},
                        error: function() {}
                    });
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="prj_project_lease_item_temp_ds" model="cont.CON500.con_contract_lease_item_temp_query" pageSize="100" queryUrl="${/request/@context_path}/autocrud/cont.CON500.con_contract_lease_item_temp_query/query?session_id=${/parameter/@session_id}"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con_contract_lease_item_import_last_back" text="HLS.BACK"/>
                <a:gridButton id="config_btn" click="con_contract_lease_item_import_last_confirm" text="HLS.CONFIRM"/>
            </a:screenTopToolbar>
            <a:grid bindTarget="prj_project_lease_item_temp_ds" height="400" navBar="true" width="900">
                <a:columns>
                    <a:column name="full_name" prompt="租赁物名称" width="150"/>
                    <a:column name="specification" prompt="规格型号" width="100"/>
                    <a:column name="invoice_amt" align="right" prompt="发票金额" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="invoice_date" align="right" prompt="发票日期" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="invoice_num" prompt="发票编号" width="100"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        	auto_import();
        
        ]]></script>
    </a:view>
</a:screen>
