<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xuls  
    $Date: 2015-8-6 上午9:48:26  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="gps1010_open_link" model="cus_gps.gps1010.gps_open_ln" modelaction="batch_update"/>
        <a:link id="gps1010_open_query_link" model="cus_gps.gps1010.gps_open_ln_result" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
	
		window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'cus_gps_open_req_ln');
                var records = $(ds_id).getSelected();
                if (records.length<1){
                    Leaf.showMessage('提示','请选择需要开通的机器');
                    return;
                }
                var params = [];
                for (var i=0;i<records.length;i++){
                    if (records[i].get('req_ln_status')=='NEW'){
                        var param={_status:'update',
                                   req_ln_id:records[i].get('req_ln_id'),
                                   tradingtime:records[i].get('trading_time')};
                        params.push(param);           
                    }
                }
                    Leaf.showConfirm('${HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function() {
                      var detail_mask = Ext.getBody();
	                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
	                    var param = records.data;
	                    Leaf.request({
	                    url: $('gps1010_open_link').getUrl(),
	                    para: params,
	                    success: function(res) {
	                        Leaf.Masker.unmask(detail_mask);
	                        Leaf.showMessage('提示','提交成功',function(){
	                          $(ds_id).query($(ds_id).currentPage); 
	                        });
	                    },
	                    failure: function() {
	                        Leaf.Masker.unmask(detail_mask);
	                    },
	                    error: function() {
	                        Leaf.Masker.unmask(detail_mask);
	                    },
	                    scope: this
	                });  
                    });
                    
                };
             window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'cus_gps_open_req_ln');
                var records = $(ds_id).getSelected();
                if (records.length<1){
                    Leaf.showMessage('提示','请选择需要查询的机器');
                    return;
                }
                var params = [];
                for (var i=0;i<records.length;i++){
                    if (records[i].get('req_ln_status')=='SUBMIT'){
                        var param={_status:'update',
                                   req_ln_id:records[i].get('req_ln_id')};
                        params.push(param);           
                    }
                }
                    Leaf.showConfirm('${HLS.PROMPT}', '确定查询吗', function() {
                      var detail_mask = Ext.getBody();
	                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
	                    var param = records.data;
	                    Leaf.request({
	                    url: $('gps1010_open_query_link').getUrl(),
	                    para: params,
	                    success: function(res) {
	                        Leaf.Masker.unmask(detail_mask);
	                        Leaf.showMessage('提示','查询成功',function(){
	                          $(ds_id).query($(ds_id).currentPage); 
	                        });
	                    },
	                    failure: function() {
	                        Leaf.Masker.unmask(detail_mask);
	                    },
	                    error: function() {
	                        Leaf.Masker.unmask(detail_mask);
	                    },
	                    scope: this
	                });  
                    });
                    
                };   
                
	
]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>