<?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" xmlns:s="leaf.plugin.script" customizationEnabled="true" dynamiccreateenabled="true"
          trace="true">
    <a:init-procedure>
        <a:model-query model="cont.CON620.get_sys_role" rootPath="role_info"/>
    </a:init-procedure>
    <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_bp_master_op_modify_link"
                url="${/request/@context_path}/modules/hls/HLS215N/hls_bp_master_op_query.lview"/>
        <a:link id="hls_bp_master_billing_link"
                url="${/request/@context_path}/modules/hls/HLS214N/hls_bp_master_billing.lview"/>
        <a:link id="hls_bp_ccx_info_link"
                url="${/request/@context_path}/modules/hls/HLS236/hls_bp_master_query_ccx_report.lview"/>
        <a:link id="hls_bp_ccx_icinfo_link"
                url="${/request/@context_path}/modules/hls/HLS236/hls_bp_master_query_ccx_icinfo.lview"/>
<!--        <script src="${/request/@context_path}/javascripts/hap/dynamicStopAutoQuery.js" type="text/javascript"/>-->
        <a:link id="identify_cert_link" model="hls.HLS214N.hls_bp_master_modify_user"
                modelaction="query"/>
        <script type="text/javascript"><![CDATA[
        // stopDymanicAutoQuery('${/parameter/@layout_code}', 'G_BP_RESULT', 'hls_bp_master');

        //信息变更
        window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function () {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'hls_bp_master');
            var data=$(ds_id).selected[0];
            var bp_class = data.get('bp_class');

            if(bp_class == 'NP'){
                Leaf.showMessage('${l:PROMPT}', '只有法人类型商业伙伴才有开票信息！');
                return false;
            }else if(bp_class == 'ORG'){
                var invoice_bp_bank_account = data.get('invoice_bp_bank_account');
                var invoice_title = data.get('invoice_title');
                var invoice_bp_address_phone_num = data.get('invoice_bp_address_phone_num');
                var phone =data.get('phone');
                var taxpayer_type =data.get('taxpayer_type');
                var invoice_bp_bank =data.get('invoice_bp_bank');
                var bp_id=data.get('bp_id');
                new Leaf.Window({
                    id: 'hls_bp_master_billing',
                    url: $('hls_bp_master_billing_link').getUrl(),
                    params: {
                        function_code:'HLS214NST',
                        invoice_bp_bank_account:invoice_bp_bank_account,
                        invoice_title:invoice_title,
                        function_usage : 'QUERY',
                        maintain_type  : 'READONLY',
                        invoice_bp_address_phone_num:invoice_bp_address_phone_num,
                        phone:phone,
                        taxpayer_type:taxpayer_type,
                        invoice_bp_bank:invoice_bp_bank,
                        bp_id:bp_id
                    },
                    title: '开票信息查看',
                    fullScreen: true
                });
            }

        }
        function open_bp_modify_win(ds_id, record_id) {
            debugger;
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            var bpType=record.data.bp_type;
            //商业伙伴是经营性租赁
            if(bpType=='RENTER' || bpType=='MAN_FACTURER' || bpType=='ASSET_REGULATOR'){
                param['function_code'] = 'HLS215D_OP';
                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_op_modify_link', ds_id);
            }else {
                param['function_code'] = 'HLS215D';
                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_ccx_detail_win(ds_id, record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'HLS236Q';
            param['bp_id'] = record.get('bp_id');
            param['function_usage'] = 'QUERY';
            param['url_title'] = '查询明细';
            hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_ccx_info_link', ds_id);

        }

        function open_ccx_icionfo_win(ds_id, record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'HLS236I';
            param['bp_id'] = record.get('bp_id');
            param['function_usage'] = 'QUERY';
            param['url_title'] = '查询明细';
            hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_ccx_icinfo_link', ds_id);

        }

        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 == 'detail') {
                return '<a href="javascript:open_ccx_detail_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
            }
            if (name == 'icinfo') {
                return '<a href="javascript:open_ccx_icionfo_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</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 != 1) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                return;
            }
            var record = records[0];
            open_bp_modify_win(ds_id, record.id);
        };
        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);
            }

            //异步打印
            // ds.setQueryParameter('__async__', 'Y');
        };
        // window.addEventListener("load", function (_event) {
        //     Leaf.request({
        //         url: $('identify_cert_link').getUrl(),
        //         para: {},
        //         success: function(res) {
        //             var code=res.result.record.employee_type_id;
        //             if(code==64){
        //                 //代理店进行隐藏
        //
        //             }
        //         },
        //         failure: function() {
        //         },
        //         error: function() {
        //         },
        //         scope: this
        //     });

       // });

        Leaf.onReady(function() {
            if("${/model/role_info/record/@role_code}"!="0018"&&"${/model/role_info/record/@role_code}"!="0019") {

            } else {
                $('BP_MODIFY_ENTRANCE_G_BP_RESULT_hls_bp_master_layout_grid_id').hideColumn('SBO_BP_MESSAGE');
                var elements=document.querySelector('td[title="SBO反馈信息"]');
                elements.remove();
            }

        });
        ]]></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>
