<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-4 下午01:58:31  
    $Revision: 1.0  
    $Purpose: 商业伙伴维护入口界面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="hls_bp_master_modify_link" url="${/request/@context_path}/modules/hls/HLS215N/hls_bp_master_query.lview"/>
        <a:link id="hls_master_vfs_command_id" url="${/request/@context_path}/modules/hls/HLS235/hls_master_vfs_command.lview"/>
        <a:link id="transfer_tongdun_link" url="${/request/@context_path}/modules/interface/INTERFACE_TONGDUN/deron_tongdun_interface.lsc"/>
        <script type="text/javascript"><![CDATA[
            //锁屏
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window'] = function() {
                var detail_mask;
                if ('${/parameter/@winid}') {
                    if (parent.$L.CmpManager.get('${/parameter/@winid}')) {
                        detail_mask = parent.$('${/parameter/@winid}').wrap;
                        parent.Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    } else {
                        detail_mask = $('${/parameter/@winid}').wrap;
                        Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    }
                } else {
                    detail_mask = Ext.getBody();
                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                }
            };
            //解屏
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'] = function() {
                var detail_mask;
                if ('${/parameter/@winid}') {
                    if (parent.$L.CmpManager.get('${/parameter/@winid}')) {
                        detail_mask = parent.$('${/parameter/@winid}').wrap;
                        parent.Leaf.Masker.unmask(detail_mask);
                    } else {
                        detail_mask = $('${/parameter/@winid}').wrap;
                        Leaf.Masker.unmask(detail_mask);
                    }
                } else {
                    detail_mask = Ext.getBody();
                    Leaf.Masker.unmask(detail_mask);
                }
                if (Ext.get(document.documentElement)) {
                    $L.Masker.unmask(Ext.get(document.documentElement));
                }
            };
            
            function open_bp_modify_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'HLS214D';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_master_modify_link', ds_id);
            
            }
            
            function open_bp_information_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var bp_id = record.get('bp_id');
                var vfs_url = $('hls_master_vfs_command_id').getUrl() + '?bp_id=' + bp_id;
                var win = new Leaf.Window({
                    url: vfs_url,
                    title: '同盾详细信息',
                    id: 'hls_master_vfs_command_winid',
                    width: 850,
                    height: 400
                });
                // win.on('close', function() {
                // $(ds_id).query();
                // });
            
            }
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'bp_code' && value) {
                    return '<a href="javascript:open_bp_modify_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                }
                if (name == 'watch') {
                    return '<a href="javascript:open_bp_information_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + '附件详情（' + record.get('tongdun_info_count') + '）</a>';
                }
                return value;
            };
            
            //同盾查询按钮
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
                var records = $(ds_id).getSelected();
                if (records.length == 0) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                var datas = [];
                var message = '';
                var message1;
                for (var i = 0;i < records.length;i++) {
                    var obj = {};
                    obj['bp_id'] = records[i].get('bp_id');
                    obj['bp_class'] = records[i].get('bp_class');
                    obj['_status'] = 'update';
                    datas[i] = obj;
                    if (records[i].get('bp_class') == 'NP') {
                        if (!records[i].get('bp_name') || !records[i].get('id_card_no') || !records[i].get('phone')) {
                            // Leaf.showMessage('${l:PROMPT}', '姓名,手机号和身份证号为空时不能查询!');
                            message1 = '请检查' + records[i].get('bp_name') + '的姓名,手机号和身份证号是否为空!';
                        }
                    } else if (records[i].get('bp_class') == 'ORG') {
                        if (!records[i].get('corporate_code') || !records[i].get('id_number') || !records[i].get('phone')) {
                            // Leaf.showMessage('${l:PROMPT}', '姓名,手机号和身份证号为空时不能查询!');
                            message1 = '请检查' + records[i].get('bp_name') + '的姓名,手机号和身份证号是否为空!';
                        }
                    }
                    if (records[i].get('tongdun_info_count') > 0) {
                        message = message + records[i].get('bp_name') + '已经存在' + '<font color="red">' + records[i].get('tongdun_info_count') + '</font>' + '条同盾数据，';
                    }
                }
                message = message + '确定查询同盾数据吗？';
            
                if (!message1) {
                    var url = $('transfer_tongdun_link').getUrl();
                    Leaf.showConfirm('提示', message, function() {
                        window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request({
                            url: url,
                            para: datas,
                            success: function(res) {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                $(ds_id).query();
                            },
                            failure: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            error: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }, function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    });
                }else{
                    Leaf.showMessage('提示', message1);
                }
            };
            window['${/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_bp_master');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=BP&amp;function_code=HLS214"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
