<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc 9874 
    $Date: 
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="prj_project_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="prj_project_hzhan_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_query.lview"/>
        <a:link id="pri_project_houdu_link" url="${/request/@context_path}/modules/prj/PRJ520/project_houdu_query.lview"/>
        <a:link id="prj_project_tdxc_link" url="${/request/@context_path}/modules/hls/HLS235/hls_bp_master_query_wfl.lview"/>
        <a:link id="bmLink_submit" model="prj.PRJ500N.prj_history_commts" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj_atm_batch_dl" url="${/request/@context_path}/modules/prj/PRJ500N/prj_atm_batch_dl.lsc"/>
        <a:link id="get_cdd_count_link" model="prj.PRJ500N.get_cdd_count" modelaction="update"/>
        <a:link id="chk_list_query_link" url="${/request/@context_path}/modules/hls/HLS236/hls_bp_master_query_ccx_entrance.lview"/>
        <script type="text/javascript"><![CDATA[
            //保存
            
            function prj_save() {
                //
                $('phone_projectds').submit();
                prj_record = $('prj_project_ds').getCurrentRecord();
                var return_opinion = prj_record.get('return_opinion');
                Leaf.request({
                    url: $('bmLink_submit').getUrl(),
                    para: {
                        return_opinion: return_opinion,
                        project_id: ${/parameter/@project_id}
                    },
                    success: function(res) {
                        Leaf.SideBar.show({
                            msg: '保存成功',
                            duration: 2000
                        });
                        $('phone_projectds').query();
                        $('prj_project_ds').query();
                    },
                    failure: function() {
            
                       },
                    error: function() {},
                    scope: this
                });
            }
            
            function prj_rhzx() {
                var url = 'http://www.pbccrc.org.cn/';
                window.open(url);
            }
            
            function prj_gjfy() {
                var url = 'http://www.court.gov.cn/';
                window.open(url);
            }
            
            function prj_gsgl() {
                var url = 'http://www.gsxt.gov.cn/index.html';
                window.open(url);
            }
            
            function prj_zdw() {
                var url = 'http://www.zhongdengwang.org.cn/zhongdeng/index.shtml';
                window.open(url);
            }
            
            //后督事项
            
            function prj_houdu() {
                var url = $('pri_project_houdu_link').getUrl();
                var raise_status = 'CREDIT';
                var raise_status_desc = '信审阶段';
                var win = new Leaf.Window({
                    id: 'project_houdu_query_window',
                    url: url,
                    params: {
                        project_id: ${/parameter/@project_id},
                        raise_status: raise_status,
                        raise_status_desc: raise_status_desc
                    },
                    title: '后督事项',
                    fullScreen: true
                });
                win.on('close', function() {});
            }
            
            
            //业务核准函
            
            function prj_hzhan() {
                //
                var param = {};
                if ('${/parameter/@hzhan_flag}' == 'Y') {
                    var function_usage = 'MODIFY';
                    var maintain_type = 'MODIFY';
                } else if ('${/parameter/@hzhan_flag}' == 'O') {
                    function_usage = 'QUERY';
                    maintain_type = 'READONLY';
                }
                param['function_code'] = 'PRJ_NOTICE';
                param['function_usage'] = function_usage;
                param['maintain_type'] = maintain_type;
                param['project_id'] = '${/parameter/@project_id}';
                param['winId'] = 'prj_project_hzhan_link_winid';
                param['url_title'] = '核准函';
                hls_doc_get_layout_code('prj_project_get_layout_code_link_id', param, 'prj_project_hzhan_link');
            
            }
            
            //同盾数据查询
            
            
            function prj_tdcx() {
                //
                var param = {};
                param['tdxc_falg'] = '${/parameter/@tdxc_falg}';
                param['function_code'] = 'HLS235_WFL';
                param['project_id'] = '${/parameter/@project_id}';
                param['winId'] = 'prj_project_tdxc_link_winid';
                param['url_title'] = '同盾数据查询';
                hls_doc_get_layout_code('prj_project_get_layout_code_link_id', param, 'prj_project_tdxc_link','${/parameter/layout_code}');
            
            }
            
            //加载时控制字段的只读
            onLoad_headerDs = function(ds) {
                //
                if ('${/parameter/@phone_readOnly_flag}' == 'N') {
                    $('add_id').hide();
                    $('delete_id').hide();
                    $('save_id').hide();
                } else if ('${/parameter/@phone_readOnly_flag}' == 'Y') {
                    $('add_id').show();
                    $('delete_id').show();
                    $('save_id').show();
                }
            
            };
            
            function zjwfl5110_beforeapproveCheck(type) {
                prj_save();
                return true;
            }
            
            function contractDs_grid_editor_function(record, name) {
                //
                if ('${/parameter/@phone_readOnly_flag}' == 'Y') {
                    if (name == 'verify_date') {
                        return 'contractDs_grid_date_pick_id';
                    }
                    if (name == 'verify_to' || name == 'person_in_charge' || name == 'verify_result' || name == 'note') {
                        return 'contractDs_grid_editor_tf_id';
                    }
                    // return '';
                } else {
                    return '';
                }
            }
            
            function prj_ccx() {
                var win = new Leaf.Window({
                    url: $('chk_list_query_link').getUrl(),
                    params: {
                        project_id: '${/parameter/@project_id}'
                    },
                    title: '详细信息',
                    id: 'hls_master_ccx_report_id',
                    fullScreen: true
                });
            }
            
            //一键下载附件 打包下载
           function batch_download() {
                var project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var project_record = $(project_ds_id).getCurrentRecord();  
                var doc_code = '租赁申请资料';
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                //得到附件数量
                Leaf.request({
                    url: $('get_cdd_count_link').getUrl(),
                    para: {
                        document_table: 'PRJ_PROJECT',
                        document_id: project_record.get('project_id'),
                        project_number: project_record.get('project_number'),
                        cdd_list_id: project_record.get('cdd_list_id'),
                        doc_code: encodeURI(doc_code),
                        type: 'ZIP',
                        fnd_atm_flag: 'Y'
                    },
                    success: function(res) {
                        if(res.result.count > 0){
                        var url_l = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj_atm_batch_dl').getUrl() + '?document_table=PRJ_PROJECT&document_id=' + project_record.get('project_id') +  
                            '&project_number=' + project_record.get('project_number') +
                            '&cdd_list_id=' + project_record.get('cdd_list_id') +
                            '&doc_code=' + encodeURI(doc_code) + '&type=ZIP&fnd_atm_flag=Y';//&type=ZIP
                window.open(href = url_l, target = "_self");
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        }else{
                            Leaf.showMessage('${l:PROMPT}', '该租赁申请没有附件资料。');
                        }
                         
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
                
                
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="phone_projectds" autoPageSize="true" autoQuery="true" model="prj.PRJ500N.prj_project_phone_verify" queryUrl="${/request/@context_path}/autocrud/prj.PRJ500N.prj_project_phone_verify/query?project_id=${/parameter/@project_id}" selectable="true">
                <a:fields>
                    <a:field name="verify_date"/>
                    <a:field name="verify_to"/>
                    <a:field name="person_in_charge"/>
                    <a:field name="verify_result"/>
                    <a:field name="note"/>
                    <a:field name="project_id" defaultValue="${/parameter/@project_id}"/>
                    <a:field name="bp_id_tenant" defaultValue="${/parameter/@bp_id_tenant}"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onLoad_headerDs"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="history_contractDs" autoPageSize="true" autoQuery="true" model="prj.PRJ500N.prj_history_contract" queryUrl="${/request/@context_path}/autocrud/prj.PRJ500N.prj_history_contract/query?project_id=${/parameter/@project_id}">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="contract_status_n"/>
                    <a:field name="business_type_n"/>
                    <a:field name="product_name"/>
                    <a:field name="price_list_n"/>
                    <a:field name="finance_amount"/>
                    <a:field name="overdue_amount"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="prj_project_ds" autoQuery="true" model="prj.PRJ500N.prj_history_commts" queryUrl="${/request/@context_path}/autocrud/prj.PRJ500N.prj_history_commts/query?project_id=${/parameter/@project_id}" selectable="true">
                <a:fields>
                    <a:field name="write_off_amount" readOnly="true"/>
                    <a:field name="risk_open" readOnly="true"/>
                    <a:field name="return_opinion"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form marginWidth="30" title="征信查询">
                <a:screenTopToolbar>
                    <!-- <a:gridButton click="prj_save" text="保存"/> -->
                    <a:gridButton click="prj_rhzx" text="人行征信"/>
                    <a:gridButton click="prj_gjfy" text="高级法院网"/>
                    <a:gridButton click="prj_gsgl" text="企信网"/>
                    <a:gridButton click="prj_zdw" text="中登网"/>
                    <a:gridButton click="prj_tdcx" text="同盾数据查询"/>
                    <a:gridButton click="prj_ccx" text="中诚信数据查询"/>
                    <a:gridButton click="batch_download" text="一键下载"/>
                    <a:switch test="/parameter/@hzhan_flag">
                        <a:case value="Y">
                            <a:gridButton click="prj_hzhan" style="float:left;margin-right:1px;margin-top:10px;margin-left:5px;;width:60px;" text="业务核准函"/>
                        </a:case>
                        <a:case value="O">
                            <a:gridButton click="prj_hzhan" style="float:left;margin-right:1px;margin-top:10px;margin-left:5px;;width:60px;" text="业务核准函"/>
                        </a:case>
                    </a:switch>
                    <a:switch test="/parameter/@houdu_flag">
                        <a:case value="Y">
                            <a:gridButton click="prj_houdu" style="float:left;margin-right:1px;margin-top:10px;margin-left:5px;;width:60px;" text="后督事项"/>
                        </a:case>
                    </a:switch>
                </a:screenTopToolbar>
            </a:form>
            <a:screen-include screen="modules/prj/PRJ500N/prj_project_query.lview?layout_code=${/parameter/@layout_code}&amp;project_id=${/parameter/@project_id}&amp;bp_class=${/parameter/@bp_class}&amp;function_code=PRJ500N_WFL&amp;maintain_type=READONLY"/>
            <a:form marginWidth="30">
                <a:screenTopToolbar>
                    <a:gridButton click="prj_save" text="保存"/>
                </a:screenTopToolbar>
            </a:form>
            <a:tabPanel id="acr510n_detail_tabpanel_id" marginHeight="140" marginWidth="50">
                <a:tabs>
                    <a:tab prompt="电核信息">
                        <a:grid id="phoneDs_grid" bindTarget="phone_projectds" marginHeight="170" marginWidth="70" navBar="true">
                            <a:toolBar>
                                <a:button id="add_id" type="add"/>
                                <a:button id="delete_id" type="delete"/>
                                <a:button id="save_id" type="save"/>
                            </a:toolBar>
                            <a:columns>
                                <a:column name="verify_date" editorFunction="contractDs_grid_editor_function" prompt="电核时间" renderer="Leaf.formatDate"/>
                                <a:column name="verify_to" editorFunction="contractDs_grid_editor_function" prompt="电核对象"/>
                                <a:column name="person_in_charge" editorFunction="contractDs_grid_editor_function" prompt="负责人" width="150"/>
                                <a:column name="verify_result" editorFunction="contractDs_grid_editor_function" prompt="电核结果"/>
                                <a:column name="note" editorFunction="contractDs_grid_editor_function" prompt="备注"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="contractDs_grid_editor_tf_id"/>
                                <a:datePicker id="contractDs_grid_date_pick_id"/>
                                <!-- <a:numberField id="selectedDs_grid_editor_nf"/> -->
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="历史单据信息" width="80">
                        <a:grid id="contractDs_grid" bindTarget="history_contractDs" marginHeight="170" marginWidth="70" navBar="true">
                            <a:columns>
                                <a:column name="contract_number" prompt="支付表编号" width="120"/>
                                <a:column name="contract_name" prompt="支付表名称" width="150"/>
                                <a:column name="contract_status_n" prompt="支付表状态" width="120"/>
                                <a:column name="business_type_n" prompt="业务类型" width="80"/>
                                <a:column name="product_name" prompt="产品名称" width="120"/>
                                <a:column name="price_list_n" prompt="还款方式" width="150"/>
                                <a:column name="finance_amount" prompt="融资总额" renderer="Leaf.formatMoney" width="100"/>
                                <a:column name="overdue_amount" prompt="逾期金额" renderer="Leaf.formatMoney" width="100"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <a:form Width="1200" column="2" height="400">
                <a:numberField name="risk_open" bindTarget="prj_project_ds" prompt="当前风险敞口"/>
                <a:numberField name="write_off_amount" bindTarget="prj_project_ds" prompt="当前核准金额"/>
                <a:textArea name="return_opinion" bindTarget="prj_project_ds" height="200" prompt="内部意见" width="800"/>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>