<?xml version="1.0" encoding="UTF-8"?>
<!--
	&author:DJ
	$date:2014/01/27
	$purpose:快递打印
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <a:link id="pageLink_view_sto" url="${/request/@context_path}/modules/gj/GJSYS501/sto_express.lview"/>
        <a:link id="bmLink_submit_express" model="gj.GJSYS501.gj_express" modelaction="execute"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <script type="text/javascript"><![CDATA[
        	function print_sto_express(express_id)
        	{
        	    window.open($('pageLink_view_sto').getUrl() + '?express_id=' + express_id);
        	}
        	
	        function contractDs_grid_query() {
	            $('contractDs').query();
	        }
	        
	        var temp_res = {};
	        function submit_sto_express(contract_id)
			{
        	    f_hls.winMask();
        	    
			    Leaf.request({
	                url: $('bmLink_submit_express').getUrl(),
	                para: {
	                    source_type : 'CONTRACT',
	                	pk_id : contract_id
	                },
	                sync: true,
	                success: function(res) {
	                    f_hls.winNoMask();
	                    temp_res=res;
	                },
	                failure: function() {
	                    f_hls.winNoMask();
	                },
	                error: function() {
	                    f_hls.winNoMask();
	                },
	                scope: this
	            });
	            print_sto_express(temp_res['result']['express_id']);
			}
			
			function render_contractDs_grid(value,record,name){
			    if(name=='sto_express')
			    {
			        return '<a href="javascript:submit_sto_express(' + record.get('contract_id') + ')">申通快递</a>';
			    }
			    return value;
			}
			
		]]></script>
        <a:dataSets>
            <a:dataSet id="para_contractDs" autoCreate="true" model="gj.GJSYS501.gj_express_contract"><![CDATA[
        	]]></a:dataSet>
            <a:dataSet id="contractDs" autoPageSize="true" autoQuery="true" model="gj.GJSYS501.gj_express_contract" queryDataSet="para_contractDs" selectable="true">
                <a:fields><![CDATA[
                ]]></a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="contractDs_grid_query" text="HLS.QUERY"/>
            </a:screenTopToolbar>
            <a:form column="2" title="HLS.QUERY_TITLE">
                <a:textField name="contract_number" bindTarget="para_contractDs"/>
                <a:textField name="contract_name" bindTarget="para_contractDs"/>
            </a:form>
            <a:grid id="contractDs_grid" bindTarget="contractDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" width="120"/>
                    <a:column name="contract_name" autoAdjust="false" showTitle="true" width="400"/>
                    <a:column name="sto_express" align="center" renderer="render_contractDs_grid"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>