<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-9-25 上午09:33:57  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <a:link id="pageLink_bpQueryScreen_welcome" url="${/request/@context_path}/welcome.lview"/>
        <a:link id="hls_bp_master_dynamic_update_link_id" url="${/request/@context_path}/modules/hls/HLS213/hls_bp_master_dynamic_update.lview"/>
        <a:link id="hls_bp_master_get_layout_code_link_id" model="hls.HLS213.hls_bp_master_get_layout_code" modelaction="update"/>
        <a:link id="hls_bp_master_credit_apply_link" url="${/request/@context_path}/modules/hls/HLS214/hls_bp_master_credit_apply.lview"/>
        <a:link id="hls_bp_master_legal_apply_link" url="${/request/@context_path}/modules/hls/HLS214/hls_bp_master_legal_apply.lview"/>
        <script type="text/javascript"><![CDATA[
            function bpQueryScreen_forward() {
                history.go(1);
            }
            
            function bpQueryScreen_back() {
                history.go(-1);
            }
            
            function bpQueryScreen_query() {
                $('bpQueryDs').query();
            }
            
            function bpQueryScreen_quit() {
                location.href = $('pageLink_bpQueryScreen_welcome').getUrl();
                parent.shMenu('show');
            }
            
            function construct_from_to() {
                var config = ['bp_code', 'bp_code_desc', 'search_term_1', 'search_term_2'];
                var pattern = ['_from', '_to'];
                var obj = {};
                for (var i = 0,
                    j = config.length;i < j;i++) {
                    for (var m = 0,
                        n = pattern.length;m < n;m++) {
                        obj[config[i] + pattern[m]] = config[i] + pattern[n - 1 - m];
                    }
                }
                return obj;
            }
            
            function onUpdate_para_bpQueryDs(ds, record, name, value, oldvalue) {
                var from_to = construct_from_to();
                var opposite_name = from_to[name];
                if (!Ext.isEmpty(opposite_name)) {
                    var opposite_value = record.get(opposite_name);
                    if (!Ext.isEmpty(value) && Ext.isEmpty(opposite_value)) {
                        record.set(opposite_name, value);
                    }
                }
            
            }
            
            function winOpen_bpMaintainScreen(id) {
                var current_record = $('bpQueryDs').findById(id);
                var param = current_record.data;
                hls214_param_set_value(param);
            }
            
            function bpQueryScreen_bpMaintain() {
                var record = $('bpQueryDs').getCurrentRecord();
                var param = record.data;
                hls214_param_set_value(param);
            }
            
            function hls214_param_set_value(param) {
                param['function_code'] = 'HLS214';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                param['master_type'] = 'BP_MASTER';
                param['master_id'] = param['bp_id'];
                hls_doc_get_layout_code('hls_bp_master_get_layout_code_link_id', param, 'hls_bp_master_dynamic_update_link_id', 'bpQueryDs');
            }
            
            function render_bpQueryDs_grid(value, record, name) {
                if (name == 'bp_code') {
                    var bp_id = record.get('bp_id');
                    if (!Ext.isEmpty(bp_id) && !Ext.isEmpty(value)) {
                        return '<a href="javascript:winOpen_bpMaintainScreen(' + record.id + ');">' + value + '</a>';
                    }
                }
                return '';
            }
            
            //征信信息查询申请
            
            function bpQueryScreen_apply() {
                var record = $('bpQueryDs').getCurrentRecord();
                if (!Ext.isEmpty(record)) {
                    var params = {
                        'winId': 'hls_bp_master_credit_apply_win'
                    };
                    if ((record.get('bp_class') == 'ORG' || record.get('bp_class') == 'NP')) {
            
                        if (record.get('bp_id')) {
                            var bp_id = record.get('bp_id');
                            var bp_class = record.get('bp_class');
                            new Leaf.Window({
                                id: 'hls_bp_master_credit_apply_win',
                                title: '${l:HLS212.CREDIT_INFO_APPLY}',
                                url: $('hls_bp_master_credit_apply_link').getUrl() + '?bp_id=' + bp_id + '&bp_class=' + bp_class,
                                params: params,
                                width: 800,
                                height: 220
                            });
                            // win.on('close', function() {
                                // var result_ds = $('bpQueryDs');
                                // result_ds.query(result_ds.currentPage);
                            // });
                        }
                    } else {
                        Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS212.CHOOSE_BP_CLASS_NP_OR_ORG}');
                    }
                }
            }
            //被执行人信息查询申请
            
            function bpQueryScreen_legal_apply() {
                var record = $('bpQueryDs').getCurrentRecord();
                if (!Ext.isEmpty(record)) {
                    var params = {
                        'winId': 'hls_bp_master_legal_apply_win'
                    };
                    if ((record.get('bp_class') == 'ORG' || record.get('bp_class') == 'NP')) {
                        if (record.get('bp_id')) {
                            var bp_id = record.get('bp_id');
                            var bp_class = record.get('bp_class');
                             Leaf.Window({
                                id: 'hls_bp_master_legal_apply_win',
                                title: '${l:HLS212.LEGAL_INFO_APPLY}',
                                url: $('hls_bp_master_legal_apply_link').getUrl() + '?bp_id=' + bp_id + '&bp_class=' + bp_class,
                                params: params,
                                width: 600,
                                height: 220
                            });
                            // win.on('close',function(){
                                // $('bpQueryDs').query($('bpQueryDs').currentPage);
                            // });
                        }
                    } else {
                        Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS212.CHOOSE_BP_CLASS_NP_OR_ORG}');
                    }
                }
            }
        ]]></script>
        <a:screen-include screen="modules/hls/HLS213/hls_bp_master_get_layout_code.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?master_type=BP&amp;function_code=HLS214"/>
        <a:dataSets>
            <a:dataSet id="enabled_flag_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="bpClassDs" lookupCode="HLS211_BP_CLASS"/>
            <a:dataSet id="para_bpQueryDs" model="hls.HLS212.hls_bp_master_all_data_v">
                <a:fields>
                    <a:field name="bp_class_desc" displayField="code_value_name" options="bpClassDs" returnField="bp_class" valueField="code_value"/>
                    <a:field name="bp_class"/>
                    <a:field name="bp_type_desc" readOnly="true"/>
                    <a:field name="bp_type" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_type_v_for_lov?enabled_flag=Y" lovWidth="500" prompt="HLS_BP_TYPE.BP_TYPE" title="HLS_BP_TYPE.BP_TYPE">
                        <a:mapping>
                            <a:map from="description" to="bp_type_desc"/>
                            <a:map from="bp_type" to="bp_type"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_code_from" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code_from"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_code_to" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code_to"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_name"/>
                    <a:field name="bp_project_number" lovGridHeight="300" lovHeight="450" lovService="prj.PRJ501.prj_project_for_lov" lovWidth="600">
                        <a:mapping>
                            <a:map from="project_id" to="bp_project_id"/>
                            <a:map from="project_number" to="bp_project_number"/>
                            <a:map from="project_name" to="bp_project_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_project_id"/>
                    <a:field name="bp_project_name"/>
                    <a:field name="bp_contract_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_id" to="bp_contract_id"/>
                            <a:map from="contract_number" to="bp_contract_number"/>
                            <a:map from="contract_name" to="bp_contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="enabled_flag" defaultValue="Y"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="enabled_flag_ds" prompt="HLS.ENABLED_FLAG" returnField="enabled_flag" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_para_bpQueryDs"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="bpQueryDs" autoPageSize="true" autoQuery="true" model="hls.HLS212.hls_bp_master_all_data_v" queryDataSet="para_bpQueryDs" selectable="true" selectionModel="single">
                <a:fields>
                    <a:field name="hls_bp_credit_apply_attach" defaultValue="附件"/>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="bpQueryScreen_back" text="HLS.BACK"/>
                <a:gridButton click="bpQueryScreen_forward" text="HLS.FORWARD"/>
                <a:gridButton click="bpQueryScreen_quit" text="HLS.EXIT"/>
                <a:gridButton click="bpQueryScreen_query" text="HLS.QUERY"/>
                <a:gridButton click="bpQueryScreen_bpMaintain" text="HLS212.BUTTON.MAINTAIN"/>
                <!-- <a:gridButton click="bpQueryScreen_apply" text="HLS212.CREDIT_INFO_APPLY"/> -->
                <!-- <a:gridButton click="bpQueryScreen_legal_apply" text="HLS212.LEGAL_INFO_APPLY"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="30" title="HLS.QUERY_TITLE">
                <a:lov name="bp_code_from" bindTarget="para_bpQueryDs" prompt="HLS.BP_CODE_FROM">
                    <a:events>
                        <a:event name="focus" handler="on_std_focus"/>
                    </a:events>
                </a:lov>
                <a:lov name="bp_code_to" bindTarget="para_bpQueryDs" prompt="HLS.BP_CODE_TO">
                    <a:events>
                        <a:event name="focus" handler="on_std_focus"/>
                    </a:events>
                </a:lov>
                <a:textField name="bp_name" bindTarget="para_bpQueryDs" prompt="HLS.BP_NAME"/>
                <a:textField name="extra_nam" bindTarget="para_bpQueryDs" prompt="HLS.SHORT_NAME"/>
                <a:lov name="bp_type" bindTarget="para_bpQueryDs" prompt="HLS.BP_TYPE"/>
                <a:textField name="bp_type_desc" bindTarget="para_bpQueryDs" prompt="HLS212.BP_TYPE_DESC"/>
                <a:lov name="bp_project_number" bindTarget="para_bpQueryDs" prompt="HLS.PROJECT_NUMBER">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;PROJECT&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:textField name="bp_project_name" bindTarget="para_bpQueryDs" prompt="HLS.PROJECT_NAME"/>
                <a:lov name="bp_contract_number" bindTarget="para_bpQueryDs" prompt="HLS.CONTRACT_NUMBER">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;CONTRACT&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:textField name="bp_contract_name" bindTarget="para_bpQueryDs" prompt="HLS.CONTRACT_NAME"/>
                <a:comboBox name="bp_class_desc" bindTarget="para_bpQueryDs" prompt="HLS_BP_MASTER.BP_CLASS"/>
                <a:comboBox name="enabled_flag_desc" bindTarget="para_bpQueryDs"/>
            </a:form>
            <a:grid id="bpQueryDs_grid" bindTarget="bpQueryDs" marginHeight="250" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="bp_code" renderer="render_bpQueryDs_grid" width="180"/>
                    <a:column name="bp_name" width="250"/>
                    <a:column name="extra_nam" prompt="HLS.SHORT_NAME" width="150"/>
                    <a:column name="bp_class_desc" width="120"/>
                    <a:column name="bp_type_desc" width="120"/>
                    <a:column name="bp_category_desc" width="120"/>
                    <a:column name="license_terms" prompt="执照日期" renderer="Leaf.formatDate" width="80"/>
                    <a:column name="enabled_flag_desc" width="60"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
