<?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="HLS_LEASE_ITEM_LIST" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;HLS_LEASE_ITEM_LIST&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_lease_item_list_ipt_link_id" url="${/request/@context_path}/modules/cont/CON501N/con_lease_item_list_ipt.lsc"/>
        <script type="text/javascript"><![CDATA[
        	var li_list_type;
            function loadComplete() {
                if ('${/model/status/record/@status}' == 'NEW') {
                    var param = {};
                    var errorData = "";
                    var importFlag = true;
                    param['lease_item_id']='${/parameter/@lease_item_id}';
                    param['session_id'] = '${/parameter/@session_id}';
                    param['header_id'] = '${/model/header/record/@header_id}';
                    if (importFlag) {
                        Leaf.request({
                            url: $('con_lease_item_list_ipt_link_id').getUrl(),
                            para: param,
                            success: function(res) {
                                li_list_type=res.result.li_list_type;
                                $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                                $('temp_interface_ds').query();
                                parent.parent.$L.Masker.unmask(parent.parent.Ext.get('mainFrame2_id'));
                            },
                            scope: this
                        });
                    } else {
                        errorData = errorData.substr(0, errorData.length - 1);
                        Leaf.showMessage('${l:PROMPT}', '${l:VERIFY_INFORMATION}');
                    }
                }
            }
            
            function saveBtn() {
                $('saveBtn_id').disable();
                Leaf.Masker.mask(Ext.getBody(), '${l:BEING_IMPLEMENTED}');
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/cont.CON501N.con_lease_item_list_load_data/update',
                    para: {
                        session_id: '${/parameter/@session_id}',
                        lease_item_id: '${/parameter/@lease_item_id}',
                        li_list_type:li_list_type
                    },
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '${l:IMPORT_WAS_SUCCESSFUL}',
                            duration: 2000
                        });
                        Leaf.Masker.unmask(Ext.getBody());
                        
                    },
                    error: function() {
                        $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                        $('temp_interface_ds').query();
                        $('saveBtn_id').enable();
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function() {
                        $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                        $('temp_interface_ds').query();
                        $('saveBtn_id').enable();
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }
            
            function backBtn() {
                parent._input_window.close();
            }
            function temp_interface_load(){
                if (li_list_type == 'LEASE') {
                    $('temp_interface_grid_id').hideColumn('net_asset_value');
                    $('temp_interface_grid_id').hideColumn('invoice_amt');
                    $('temp_interface_grid_id').hideColumn('invoice_num');
                    $('temp_interface_grid_id').hideColumn('invoice_date');
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="temp_interface_ds" fetchAll="true" model="cont.CON501N.hls_li_list_temp" queryUrl="${/request/@context_path}/autocrud/cont.CON501N.hls_li_list_temp/query?session_id=${/parameter/@session_id}&amp;lease_item_id=${/parameter/@lease_item_id}">
                <a:events>
                    <a:event name="load" handler="temp_interface_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form id="success_form" height="400" title="THE_IMPORTED_DATA" width="980">
                <a:grid id="temp_interface_grid_id" bindTarget="temp_interface_ds" height="340" navBar="true" width="980">
                    <a:toolBar>
                        <a:button type="excel"/>
                    </a:toolBar>
                    <a:columns>
                        <a:column name="seq" prompt="序号"/>
                        <a:column name="asset_name" prompt="物件名称"/>
                        <a:column name="specification" prompt="规格型号"/>
                        <a:column name="quantity" prompt="数量"/>
                        <a:column name="price" prompt="单价" renderer="Leaf.formatMoney"/>
                        <a:column name="total_amount" prompt="金额" renderer="Leaf.formatMoney"/>
                        <a:column name="brand" prompt="品牌"/>
                        <a:column name="type1" prompt="大分类"/>
                        <a:column name="type2" prompt="中分类"/>
                        <a:column name="manufacturer" prompt="厂商"/>
                        <a:column name="installation_site" prompt="安装地点"/>
                        <a:column name="net_asset_value" prompt="净现值" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_amt" prompt="发票金额" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_num" prompt="发票号码"/>
                        <a:column name="invoice_date" prompt="发票日期" renderer="Leaf.formatDate"/>
                    </a:columns>
                </a:grid>
                <a:screenTopToolbar>
                    <a:gridButton click="backBtn" text="退出"/>
                    <a:gridButton id="saveBtn_id" click="saveBtn" text="导入"/>
                </a:screenTopToolbar>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
	  		loadComplete();
	  	]]></script>
    </a:view>
</a:screen>
