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

<!--
    $Author:
    $Date: 2018/8/2
    $Revision: 1.0
    微件-资产信息
-->
<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_asset_into_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="widget_asset_into_con_contract_info_link" url="${/request/@context_path}/modules/prj/PRJ506/virtual_contract_query.lview"/>
        <style>
            html,body{
            width:1128px;
            height:552px;
            margin: 0;
            padding: 0;
            color:#000;
            }
            .widget_asset_info{
            box-sizing:border-box;
            width:1128px;
            height:552px;
            padding:0;
            background-color:#fff;
            position:relative;
            border:1px solid #F0F0F3;
            cursor:default;
            user-select:none;
            }
            .widget_asset_info .widget_label{
            position:absolute;
            width:40px;
            height:4px;
            top:0;
            left:16px;
            background-color:#5A7FFF;
            }
            .widget_asset_info .row1{
            position:relative;
            padding:16px 0 12px 16px;
            font-family: PingFangSC-Medium;
            font-size: 14px;
            color: rgba(75,80,90,0.85);
            letter-spacing: 0;
            border-bottom:1px solid  #F0F0F3;
            }
            .widget_asset_info .row2{
            box-sizing:border-box;
            height:109px;
            padding:26px 40px 22px 40px;
            border-bottom:1px solid  #F0F0F3;
            }
            .widget_asset_info .asset_query_form div{
            height:24px;
            line-height:24px;
            }
            .widget_asset_info .asset_query_form div:first-child{
            margin-bottom:18px;
            }
            .widget_asset_info .asset_query_form .label{
            display:inline-block;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #4B505A;
            }
            .widget_asset_info .asset_query_form .clickable{
            box-sizing:border-box;
            width:88px;
            height:26px;
            line-height:26px;
            display:inline-block;
            padding:0 5px;
            margin:0 16px;
            border-radius:2px;
            cursor:pointer;
            text-align:center;
            }
            .widget_asset_info .asset_query_form input[type='text']{
            box-sizing:border-box;
            width:200px;
            height:24px;
            margin:0 30px 0 16px;
            padding-left:8px;
            display:inline-block;
            border: 1px solid rgba(83,93,127,0.60);
            border-radius: 2px;
            font-family: PingFangSC-Medium;
            font-size: 12px;
            color: rgba(75,80,90,0.85);
            }
            .widget_asset_info .asset_query_form #submit{
            background: #5A7FFF;
            color:#fff;
            }
            .widget_asset_info .asset_query_form .asset_query_currency{
            border:1px solid rgba(83,93,127,0.50);
            color:#535D7F;
            }
            .widget_asset_info .asset_query_form .asset_query_currency_active{
            border-color:#5A7FFF;
            color:#5A7FFF;
            }
            .widget_asset_info .hls-pagging-grid{
            width:100%;
            height:392px;
            -webkit-box-shadow:none;
            box-shadow:none;
            }
            .widget_asset_info .hls-pagging-grid .grid-title{
            display:none;
            }
            .widget_asset_info .hls-pagging-grid .grid-body{
            padding:0 20px;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tr td{
            text-align:center;
            }
            /*表头*/
            .widget_asset_info .hls-pagging-grid .grid-body table>tr{
            height:48px;
            border-bottom:1px solid #F0F0F3;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #535D7F;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(1),
            .widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(2),
            .widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(4){
            text-align:left;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(6){
            text-align:right;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tbody tr{
            height:56px;
            font-family: PingFangSC-Medium;
            font-size: 12px;
            color: rgba(75,80,90,0.85);
            letter-spacing: 0;
            border-bottom:1px solid #F0F0F3;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tbody td{
            max-width:13em;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tbody td div p{
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            }
            .widget_asset_info .hls-pagging-grid .hls-table tbody tr:hover{
            background: rgba(90,127,255,0.08);
            }
            .widget_asset_info .hls-table-active{
            background-color: rgba(90,127,255,0.08);
            }
            .widget_asset_info .hls-pagging-grid .icon{
            cursor:pointer;
            width:16px;
            height:16px;
            }
            .widget_asset_info .hls-pagging-grid input[type='checkbox']{
            display:none;
            }
            .widget_asset_info .hls-pagging-grid input[type='checkbox'] ~ .label1{
            display:block;
            margin:0 auto;
            width:14px;
            height:14px;
            cursor:pointer;
            position:relative;
            top:0;
            left:0;
            border:1px solid #5A7FFF;
            border-radius:1.85px;
            color:#5A7FFF;
            }
            .widget_asset_info .hls-pagging-grid input[type='checkbox'] ~ .label0{
            display:none;
            margin:0 auto;
            width:14px;
            height:14px;
            cursor:pointer;
            position:relative;
            top:0;
            left:0;
            border:1px solid rgba(83,93,127,0.85);
            border-radius:1.85px;
            }
            .widget_asset_info .hls-pagging-grid input[type='checkbox']:checked ~ .label1{
            display:none;
            }
            .widget_asset_info .hls-pagging-grid input[type='checkbox']:checked ~ .label0{
            display:block;
            }
        </style>
        <script><![CDATA[
        function con_asset_prj_renderer(record,index){
            var number=record.data["project_id"]||'';
            var name=record.data["project_id_n"]||'';
            return '<p>'+ number +'</p>' + '<p title="' + name + '">'+ name +'</p>'
        }
        function con_asset_cont_renderer(record,index){
            var number=record.data["contract_number"]||'';
            var name=record.data["contract_name"]||'';
            return '<p>'+ number +'</p>' + '<p title="' + name + '">'+ name +'</p>'
        }
        function asset_employee_renderer(record,index){
            var name=record.data["employee_id_n"]||'';
            var unit=record.data["unit_id_n"]||'';
            return '<p>'+ name +'</p>' + '<p title="' + unit + '">'+ unit +'</p>'
        }
        function con_asset_detail_renderer(record,index){
            return "<img onclick='open_vir_con_modify_win(\"" + record.ds.id + "\",\""+record.id+ "\")' class='icon' src='${/request/@context_path}/leafresource/images/widget/menu_right_dot.png'/>";
        }

        function con_asset_factoring_renderer(record,index){
            var recourse_factoring=record.data["recourse_factoring"]||0;
            var number=record.data["contract_number"]||'';
            var html='';
            if(recourse_factoring){
                html='<input type="checkbox" class="icon" checked="checked" id="' + number + '_factoring_input"/>'
                    +'<label class="label1" for="' + number + '_factoring_input">√</label>'
                    +'<label class="label0" for="' + number + '_factoring_input"></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_factoring_input"/>'
                    +'<label class="label1" for="' + number + '_factoring_input">√</label>'
                    +'<label class="label0" for="' + number + '_factoring_input"></label>';
            }
            return html;
        }
        function con_asset_refinance_renderer(record,index){
            var refinance=record.data["refinance"]||0;
            var number=record.data["contract_number"]||'';
            var html='';
            if(refinance){
                html='<input type="checkbox" class="icon" checked="checked" id="' + number + '_refinance_input"/>'
                    +'<label class="label1" for="' + number + '_refinance_input">√</label>'
                    +'<label class="label0" for="' + number + '_refinance_input"></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_refinance_input"/>'
                    +'<label class="label1" for="' + number + '_refinance_input">√</label>'
                    +'<label class="label0" for="' + number + '_refinance_input"></label>';
            }
            return html;
        }
        function con_asset_securitization_renderer(record,index){
            var asset_securitization=record.data["asset_securitization"]||0;
            var number=record.data["contract_number"]||'';
            var html='';
            if(asset_securitization){
                html='<input type="checkbox" class="icon" checked="checked" id="' + number + '_securitization_input"/>'
                    +'<label class="label1" for="' + number + '_securitization_input">√</label>'
                    +'<label class="label0" for="' + number + '_securitization_input"></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_securitization_input"/>'
                    +'<label class="label1" for="' + number + '_securitization_input">√</label>'
                    +'<label class="label0" for="' + number + '_securitization_input"></label>';
            }
            return html;
        }
        jQuery(document).ready(function(){
            //查询条件数据结构
            var queryParam={
                "asset_query_unit":'',
                "asset_query_bp":'',
                "asset_query_con":'',
                "currency":''
            };
            jQuery(".widget_asset_info .asset_query_form").on('click',function(e){
                $this=jQuery(e.target);

                //人民币单选点击事件
                if($this.attr("class") && $this.attr("class").indexOf('asset_query_currency')>=0){
                    var currencys=jQuery(".asset_query_currency");
                    for(var i=0;i<currencys.length;i++){
                        if(currencys[i].id!=$this.attr("id")){
                            jQuery(currencys[i]).removeClass("asset_query_currency_active");
                        }
                    }
                    $this.toggleClass("asset_query_currency_active");
                    if($this.attr("class").indexOf('asset_query_currency')>=0){
                        queryParam.currency=$this.attr("id");
                    }else{
                        queryParam.currency="";
                    }
                }

                //查询按钮点击事件
                if($this.attr("id")=='submit'){
                    queryParam["asset_query_unit"]=jQuery("#asset_query_unit").val();
                    queryParam["asset_query_unit"]=jQuery("#asset_query_unit").val();
                    queryParam["asset_query_bp"]=jQuery("#asset_query_bp").val();
                    queryParam["asset_query_con"]=jQuery("#asset_query_con").val();
                    $("con_contract_asset_ds").qpara=queryParam;
                    $("con_contract_asset_ds").query();
                }
            });

        });
        function open_vir_con_modify_win(ds_id, record_id){
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['function_code'] = 'C0N301D_CON';
            param['function_usage'] = 'QUERY';
            param['maintain_type'] = 'READONLY';
            param['cond_para2'] = record.get('hn_industry_classification');
            param['url_title'] = '合同明细';
            param['winid'] = 'con301_virtual_contract_query_detail_link_id';

            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            Leaf.request({
                url: $('widget_asset_into_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;
                    win = new Leaf.Window({
                        id: winid,
                        params: param,
                        url: $('widget_asset_into_con_contract_info_link').getUrl(),
                        title: param['url_title'] + '(' + res.result.layout_code + ')',
                        fullScreen: true,
                        draggable: true
                    });
                    /*win.on('close', function() {
                        if (list_ds) {
                            $(list_ds).query();
                        }
                        if (function_name) {
                            window[function_name]();
                        }
                    });*/
                },
                failure: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="con_contract_asset_ds" autoQuery="true" pageSize="5" model="ast.AST511.con_contract_asset" >
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="project_id"/>
                    <a:field name="project_id_n"/>
                    <a:field name="business_type_n"/>
                    <a:field name="employee_id_n"/>
                    <a:field name="unit_id_n"/>
                    <a:field name="currency_n"/>
                    <a:field name="lease_item_amount"/>
                    <a:field name="contract_id"/>
                    <a:field name="recourse_factoring"/>
                    <a:field name="refinance"/>
                    <a:field name="asset_securitization"/>
                    <a:field name="bp_name"/>
                    <a:field name="hn_industry_classification"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_asset_info">
            <span class="widget_label"> </span>
            <div class="row1">资产信息</div>
            <div class="row2 asset_query_form">
                <div>
                    <span class="label">部门信息</span>
                    <input type="text" id="asset_query_unit" placeholder="部门名称/项目经办人"/>
                    <span class="label">承租人</span>
                    <input type="text" id="asset_query_bp" placeholder="承租人名称"/>
                    <span class="label">合同信息</span>
                    <input type="text" id="asset_query_con" placeholder="合同编号/合同名称"/>
                    <span class="clickable" id="submit">查询</span>
                </div>
                <div>
                    <span class="label" style="min-width:4em;">币种</span>
                    <span class="clickable asset_query_currency" id="CNY">人民币</span>
                    <span class="clickable asset_query_currency" id="USD">美元</span>
                </div>
            </div>
            <a:hapGrid id="con_contract_asset_grid" bindTarget="con_contract_asset_ds" canWheel="true">
                <a:columns>
                    <a:column template="con_asset_prj_renderer" prompt="项目编号/项目名称"/>
                    <a:column template="con_asset_cont_renderer" prompt="合同编号/合同名称"/>
                    <a:column name="business_type_n" prompt="租赁性质"/>
                    <a:column template="asset_employee_renderer" prompt="项目经办人/部门"/>
                    <a:column name="currency_n" prompt="币种"/>
                    <a:column name="lease_item_amount" prompt="资产金额"/>
                    <a:column template="con_asset_detail_renderer" prompt="明细"/>
                    <a:column template="con_asset_factoring_renderer" prompt="有追保理"/>
                    <a:column template="con_asset_refinance_renderer" prompt="再融资"/>
                    <a:column template="con_asset_securitization_renderer" prompt="资产证券化"/>
                </a:columns>
            </a:hapGrid>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>