<?xml version="1.0" encoding="UTF-8"?>

<!--
    $Author:
    $Date: 2018/8/2
    $Revision: 1.0
    10.项目 放款申请
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view template="default" package="leaf.ui.std">
        <a:link id="widget_csh_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="widget_csh_csh_payment_req_link_id" url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req.lview"/>
        <style>
            html,body{
            background-color:#eee;
            width:870px;
            height:355px;
            margin: 0;
            padding: 0;
            color:#758697;
            }
            .widget_cont_cshreq{
            width:870px;
            height:355px;
            background-color:#fff;
            position:relative;
            }
            .widget_cont_cshreq .hls-pagging-grid{
            width:870px;
            }
            .widget_cont_cshreq .hls-pagging-grid .grid-title{
            border-bottom:4px solid #F57B69;
            height:45px;
            }
            .widget_cont_cshreq .hls-pagging-grid .grid-title img{
            width:20px;
            height:20px;
            position:relative;
            top:5px;
            }
            .widget_cont_cshreq .hls-pagging-grid .grid-title>span{
            font-family:"Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Microsoft Yahei", "Hiragino Sans GB", sans-serif;
            font-size:13px;
            line-height:45px;
            color:#000;
            text-size-adjust:100%;
            font-weight:bold;
            }
        </style>
        <script><![CDATA[
        function cshreq_id_name_renderer(record,index){
            var html='<p style="width:150px;max-height:16px;">'+record.data['contract_number']+'</p>';
            html+='<p style="color:#9f9f9f;width:150px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;">'+record.data['contract_name']+'</p>';
            return html;
        }
        function cshreq_detail_renderer(record,index){
            return "<img onclick='winOpen_req_pay(\"" + record.ds.id + "\",\""+record.id+ "\")' style='cursor:pointer;width:15px;height:15px;display:inline-block;margin:0px;' src='${base.contextPath}/leafresource/images/widget/detail.png' alt='png'/>";
        }
        //打开放款申请维护页
        function winOpen_req_pay(ds_id,record_id) {
            var record = $(ds_id).findById(record_id);
            var param = {};
            param['function_usage'] = 'UPDATE';
            param['payment_req_id'] = record.get('payment_req_id');
            param['document_category'] = record.get('document_category');
            param['business_type'] = record.get('business_type');
            if(record.get('business_type')=='PAYMENT'){
                param['function_code'] = 'CSH501D';
            }else if(record.get('business_type')=='PREPAYMENT'){
                param['function_code'] = 'CSH501_PRE_D';
            }
            param['winid'] = 'csh_payment_update_window';
            param['url_title'] = '付款申请';
            var list_ds=ds_id;
            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            Leaf.request({
                url: $('widget_csh_get_layout_code_link_id').getUrl(),
                para: param,
                success: function(res) {
                    Leaf.Masker.unmask(Ext.getBody());
                    if (!res.result.layout_code) {
                        Leaf.showMessage('${l:PROMPT}', '${l:HLS.LAYOUT_CODE_IS_NULL}');
                        return;
                    }
                    param['layout_code'] = res.result.layout_code;
                    param['usage_type'] = res.result.usage_type;
                    var winid = 'hls_doc_get_layout_code_winid';
                    param['winid'] = winid;
                    param['calc_type'] = res.result.cond_para1;
                    var win= new Leaf.Window({
                        id: winid,
                        params: param,
                        url: $('widget_csh_csh_payment_req_link_id').getUrl(),
                        title: param['url_title'] + '(' + res.result.layout_code + ')',
                        fullScreen: true,
                        draggable: true
                    });
                    win.on('close', function() {
                        if (list_ds) {
                            $(list_ds).query();
                        }
                    });
                },
                failure: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }
        //添加放款申请
        function cshreq_add_handler(){
            <!--top.mainJumpCode('CSH501',true);-->
            location.href='/modules/csh/CSH501/csh_payment_req_selected.lview';
        }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="cont_cshreq_ds" autoQuery="true"  pageSize="5" model="csh.CSH911.csh_req">
                <a:fields>
                    <a:field name="payment_req_id" />
                    <a:field name="payment_req_number" />
                    <a:field name="contract_number" />
                    <a:field name="contract_name" />
                    <a:field name="bp_name" />
                    <a:field name="cf_description" />
                    <a:field name="real_pay_amount" />
                    <a:field name="approval_status" />
                    <a:field name="document_category" />
                    <a:field name="business_type" />
                    <a:field name="approval_status_n" />
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_cont_cshreq">
            <a:hapGrid id="cont_cshreq" title="投放申请" bindTarget="cont_cshreq_ds" titleImg="/leafresource/images/widget/receipt.png" canWheel="true">
                <a:toolBar>
                    <a:button icon="/leafresource/images/widget/add.png" click="cshreq_add_handler"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="payment_req_number" prompt="申请编号"/>
                    <a:column template="cshreq_id_name_renderer" prompt="合同编号/名称"/>
                    <a:column name="bp_name" prompt="承租人" />
                    <a:column name="cf_description"  prompt="应付项目"/>
                    <a:column name="real_pay_amount"  prompt="应付金额"/>
                    <a:column name="approval_status_n" prompt="申请状态"/>
                    <a:column template="cshreq_detail_renderer"  prompt="明细"/>
                </a:columns>
            </a:hapGrid>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>