<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-5-5 下午5:17:48  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="reg_settlement_query_link" url="${/request/@context_path}/modules/cont/CON558/con_settle_list_maintain.lview"/>
        <a:link id="reg_settlement_query_links" url="${/request/@context_path}/modules/cont/CON556/con_contract_storage_apply.lview"/>
        <script type="text/javascript"><![CDATA[
			function query_con_express_hd_result_ds(){
				$('con_express_hd_result_ds').query();
			}
			function reset_con_express_hd_query_ds(){
				$('con_express_hd_query_ds').reset();
			}
			
			function to_back_query(){
			    $('courier_number_query_window').close();
			}
			
			function con_express_hd_ds_indexchange(ds,record){
			    
			    $('courier_ln_query_ds').setQueryParameter('express_id', record.get('express_id'));
			    $('courier_ln_query_ds').query();
			}
			
			
             function reg_settlement_query(contract_id) {
                 var result_ds = $('con_express_hd_result_ds');
                    var record = result_ds.getCurrentRecord();
                    var  express_type=record.get('express_type');
                     if(express_type=='REG'){
                var add_win = new Leaf.Window({
                    id: 'reg_settlement_query_win',
                    params: {
                        'winid': 'reg_settlement_query_win',
                        contract_id: contract_id
                    },
                    url: $('reg_settlement_query_link').getUrl(),
                    fullScreen: true
                });
             }
             else{
                  var add_wins = new Leaf.Window({
                    id: 'con_infotmation_query_win',
                    params: {
                        'winid': 'con_infotmation_query_win',
                        contract_id: contract_id
                    },
                    url: $('reg_settlement_query_links').getUrl(),
                    fullScreen: true
                     });
             }
             }
             function contract_number_renderer(value, record, name) {
                if (name == 'contract_number') {
                     var contract_id = record.get('contract_id');
                     return '<a href="javascript:reg_settlement_query(' + contract_id + ');">' + value + '</a>';
                     
                }
            }
		]]></script>
        <a:dataSets>
            <a:dataSet id="archive_status_courier_ds" lookupCode="ARCHIVE_STATUS"/>
            <a:dataSet id="reg_status_courier_ds" lookupCode="REG_STATUS"/>
            <a:dataSet id="con_express_hd_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="express_number"/>
                    <a:field name="express_date_from"/>
                    <a:field name="express_date_to"/>
                    <a:field name="contract_number"/>
                    <a:field name="reg_status_n" displayField="code_value_name" options="reg_status_courier_ds" returnField="reg_status" valueField="code_value"/>
                    <a:field name="reg_status"/>
                    <a:field name="archive_status_n" displayField="code_value_name" options="archive_status_courier_ds" returnField="archive_status" valueField="code_value"/>
                    <a:field name="archive_status"/>
                    <a:field name="invoice_agent"/>
                    <a:field name="invoice_agent_n" lovHeight="400" lovService="cont.CON555A.hls_bp_master" lovWidth="600">
                        <a:mapping>
                            <a:map from="bp_id" to="invoice_agent"/>
                            <a:map from="bp_name" to="invoice_agent_n"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_express_hd_result_ds" autoQuery="true" model="cont.CON555A.con_express_hd" queryDataSet="con_express_hd_query_ds" queryUrl="${/request/@context_path}/autocrud/cont.CON555A.con_express_hd/query?express_type=${/parameter/@express_type}" selectable="true" selectionModel="single">
                <a:fields>
                    <a:field name="express_id"/>
                    <a:field name="express_number"/>
                    <a:field name="express_company"/>
                    <a:field name="express_province"/>
                    <a:field name="express_city"/>
                    <a:field name="express_address"/>
                    <a:field name="express_date"/>
                    <a:field name="express_person"/>
                    <a:field name="express_person_n"/>
                    <a:field name="express_tel"/>
                    <a:field name="express_note"/>
                    <a:field name="invoice_agent_desc"/>
                </a:fields>
                <a:events>
                    <a:event name="indexchange" handler="con_express_hd_ds_indexchange"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="courier_ln_query_ds" model="cont.CON555A.courier_ln_query">
                <a:fields>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number"/>
                    <a:field name="bp_id_tenant_name"/>
                    <a:field name="archive_status_n"/>
                    <a:field name="reg_status_n"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="to_back_query" text="返回"/>
                <a:gridButton click="query_con_express_hd_result_ds" text="查询"/>
            </a:screenTopToolbar>
            <a:form column="4" title="查询条件">
                <a:textField name="express_number" bindTarget="con_express_hd_query_ds" prompt="快递编号"/>
                <a:textField name="contract_number" bindTarget="con_express_hd_query_ds" prompt="合同编号"/>
                <a:datePicker name="express_date_from" bindTarget="con_express_hd_query_ds" prompt="快递日期从"/>
                <a:datePicker name="express_date_to" bindTarget="con_express_hd_query_ds" prompt="快递日期到"/>
                <a:comboBox name="archive_status_n" bindTarget="con_express_hd_query_ds" prompt="合同状态"/>
                <a:comboBox name="reg_status_n" bindTarget="con_express_hd_query_ds" prompt="登记证状态"/>
                <a:lov name="invoice_agent_n" bindTarget="con_express_hd_query_ds" prompt="经销商"/>
            </a:form>
            <a:grid bindTarget="con_express_hd_result_ds" height="180" marginWidth="60" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                    <a:button type="clear"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="express_number" prompt="快递编号" width="150"/>
                    <a:column name="express_company" prompt="快递公司" width="100"/>
                    <!--  <a:column name="express_province" prompt="快递省份" width="100"/>
                    <a:column name="express_city" prompt="快递城市" width="100"/> -->
                    <a:column name="express_date" prompt="快递日期" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="express_address" prompt="快递地址" width="300"/>
                    <a:column name="invoice_agent_desc" prompt="经销商" width="150"/>
                    <a:column name="express_person_n" prompt="寄送人" width="100"/>
                    <a:column name="express_tel" prompt="联系电话" width="150"/>
                </a:columns>
            </a:grid>
            <a:grid bindTarget="courier_ln_query_ds" marginHeight="380" marginWidth="60" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                    <a:button type="clear"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" renderer="contract_number_renderer" width="160"/>
                    <a:column name="bp_id_tenant_name" prompt="承租人" width="100"/>
                    <a:column name="archive_status_n" prompt="合同状态" width="100"/>
                    <a:column name="reg_status_n" prompt="登记证状态" width="100"/>
                </a:columns>
            </a:grid>
            <a:hBox/>
        </a:screenBody>
    </a:view>
</a:screen>