<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xuls  
    $Date: 2016-11-24 上午9:18:19  
    $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="zx5010_add_zx_link" model="zx.ZX5010.add_zx_base" modelaction="batch_update"/>
        <a:link id="zx5010_del_zx_link" model="zx.ZX5010.delete_zx_base" modelaction="batch_update"/>
        <a:link id="zx5010_create_zx_interface_link" model="zx.ZX5010.create_zx_file" modelaction="execute"/>
        <a:link id="zx5010_create_file_link" url="${/request/@context_path}/modules/zx/ZX5010/hls_zx_post_write.lsc"/>
        <a:link id="zx5010_file_down_link" url="${/request/@context_path}/modules/zx/ZX5010/hls_zx_post_download.lsc"/>
        <script type="text/javascript"><![CDATA[
			window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
			    var detail_mask = Ext.getBody();
			    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post');
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定生成新的征信数据?', function() {
                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    Leaf.request({
                        url: $('zx5010_create_zx_interface_link').getUrl(),
                        para: {},
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(detail_mask);
                            $(ds_id).query();
                        },
                        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 detail_mask = Ext.getBody();
			    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post');
			    var rs = $(ds_id).getSelected();
                if (rs.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定生成征信接口文件?', function() {
                     Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    Leaf.request({
                        url: $('zx5010_create_file_link').getUrl(),
                        para: {post_id:rs[0].get('post_id')},
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(detail_mask);
                            $(ds_id).query();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        error: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        scope: this
                    });
                });
            };
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
			    var detail_mask = Ext.getBody();
			    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post');
			    var rs = $(ds_id).getSelected();
                if (rs.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定下载征信接口文件?', function() {
                  var url_l = $('zx5010_file_down_link').getUrl() + '?file_name=' + rs[0].get('file_name') + '&file_path=' + rs[0].get('file_path');
                  window.open(href = url_l, target = "_self");
                });
            };
            
            window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function() {
			    var detail_mask = Ext.getBody();
			    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post_base');
			    var rs = $(ds_id).getSelected();
                if (rs.length < 1) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条要处理的单据');
                    return;
                }
                var post_data = [];
                
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定要删掉选中的合同?', function() {
                     Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                     for (var i = 0;i < rs.length;i++) {
	                   post_data.push({
	                       'post_id':rs[i].get('post_id'),
	                       'item_id':rs[i].get('item_id'),
	                       '_status':'update'
	                   });
	                }
                    Leaf.request({
                        url: $('zx5010_del_zx_link').getUrl(),
                        para: post_data,
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(detail_mask);
                            $(ds_id).query();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        error: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        scope: this
                    });
                });
            };
             window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function() {
			    var detail_mask = Ext.getBody();
			    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post_base');
			    var rs = $(ds_id).getSelected();
                if (rs.length < 1) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条要处理的单据');
                    return;
                }
                var post_data = [];
                
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定要新增选中的合同?', function() {
                     Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                     for (var i = 0;i < rs.length;i++) {
	                   post_data.push({
	                       'post_id':rs[i].get('post_id'),
	                       'item_id':rs[i].get('item_id'),
	                       '_status':'update'
	                   });
	                }
                    Leaf.request({
                        url: $('zx5010_add_zx_link').getUrl(),
                        para: post_data,
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '操作成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(detail_mask);
                            $(ds_id).query();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        error: function() {
                            Leaf.Masker.unmask(detail_mask);
                        },
                        scope: this
                    });
                });
            };
			//查询时调用(grid,table,gridBox)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
            	var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_zx_post_base');
            	if (ds.id == ds_id){
            	    var query_ds = $('ZX5010_F_QUERY__ds');
            	    var query_record = query_ds.getAt(0);
            	    var send_flag= query_record.get('send_flag');
            	    var overdue_flag = query_record.get('overdue_flag');
            	    qpara.send_flag = send_flag;
            	    qpara.overdue_flag = overdue_flag;
            	}
            };          
]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>