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

<!--
    $Author:WJW
    $Date: 2018/9/12
    $Revision: 1.0
    leaf微件-资产信息
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view template="default" package="leaf.ui.std">
        <a:link id="leaf_info_prj910_project_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="leaf_info_con301_con_contract_info_link" url="${/request/@context_path}/modules/prj/PRJ506/virtual_contract_query.lview"/>
        <style>
            html,body{
            width:1185px;
            height:553px;
            margin: 0;
            padding: 0;
            color:#000;
            }
            .leaf_widget_asset_info{
            box-sizing:border-box;
            width:1185px;
            height:553px;
            padding:0;
            background-color:#fff;
            position:relative;
            border:1px solid #F0F0F3;
            cursor:default;
            user-select:none;
            }
            .leaf_widget_asset_info .leaf-asset-img{
                width: 20px;
                display: inline-block;
                margin: 33px 0 0 38px;
            }
            .leaf_widget_asset_info .row1{
                display: inline-block;
            position:absolute;
                top: 37px;
                margin-left: 16px;
            /*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;*/
                font-family: NotoSansHans-Bold;
                font-size: 17px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 2px;
                color: #333333;
            }
            .leaf_widget_asset_info .asset-info{
                margin: 29px 0px 0px 75px;
                font-family: NotoSansHans-Bold;
                font-size: 13px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #333333;
            }
            .leaf_widget_asset_info .asset-info-line{
                width: 28px;
                height: 5px;
                background-color: #657efe;
                margin-left: 75px;
                margin-top: 4px;
            }
            .leaf_widget_asset_info .row2{
            box-sizing:border-box;
            /*height:109px;*/
            padding:24px 83px 0 75px;
            /*border-bottom:1px solid  #F0F0F3;*/
            }
            .leaf_widget_asset_info .row2 .row2-child{
               display: inline-block;
                padding-right: 29px;
                padding-left: 29px;
                border-right: 7px solid #ccc
            }
            .leaf_widget_asset_info .row2 .row2-child:first-child{

                padding-left: 0px;

            }
            .leaf_widget_asset_info .row2 .row2-child:last-child{

                border-right: 0px;

            }
            /*.leaf_widget_asset_info .row2 .func-divide-line{*/
                /*display: inline-block;*/
                /*width: 7px;*/
                /*height: 66px;*/
                /*background-color: #dcdcdc;*/
                /*opacity: 0.59;*/
                /*margin: 0 29px;*/
            /*}*/
            .leaf_widget_asset_info .row2 .row2-child .divide-line{
                width: 248px;
                height: 3px;
                background-color: #657efe;
                opacity: 0.07;
                margin: 7px 0 9px 0;
            }
            .leaf_widget_asset_info .asset_query_form div{
            /*height:24px;*/
            /*line-height:24px;*/
            }
            .leaf_widget_asset_info .asset_query_form div:first-child{
            /*margin-bottom:18px;*/
            }
            .leaf_widget_asset_info .asset_query_form .label{
            display:block;
                font-family: NotoSansHans-DemiLight;
                font-size: 12px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #333333;
            }
            .leaf_widget_asset_info .asset_query_form .clickable{
            box-sizing:border-box;
            width:66px;
            height:22px;
            line-height:22px;
            display:inline-block;
            /*padding:0 5px;*/
            margin:0 6px 0 0;
            border-radius:4px;
            cursor:pointer;
            text-align:center;
                font-family: NotoSansHans-Light;
                font-size: 12px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #999999;
            }
            .leaf_widget_asset_info .asset_query_form input[type='text']{
            box-sizing:border-box;
            width:248px;
            height:27px;
            /*margin:0 30px 0 0;*/
            padding-left:8px;
            display: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);
                background: #fff;
            }
            .leaf_widget_asset_info .asset_query_form #leaf_submit{
            background: #5A7FFF;
            color:#fff;
                right: 83px;
                position: absolute;
                margin-right: 0px;
                margin-top: 35px;
            }
            .leaf_widget_asset_info .asset_query_form .asset_query_currency{
            border:1px solid rgba(83,93,127,0.50);

            }
            .leaf_widget_asset_info .asset_query_form .asset_query_currency_active{
                background-color: #657efe;
                color:#fff;
            }
            .leaf_widget_asset_info .hls-pagging-grid{
            width:100%;
            /*height:392px;*/
            -webkit-box-shadow:none;
            box-shadow:none;
            }
            .leaf_widget_asset_info .hls-pagging-grid .grid-title{
            display:none;
            }
            .leaf_widget_asset_info .hls-pagging-grid .grid-body{
                padding: 0px 83px 0px 75px;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tr td{
            text-align:center;
            }
            /*表头*/
            .leaf_widget_asset_info .hls-pagging-grid .grid-body table{
                width: 100% !important;
            }
            .leaf_widget_asset_info .hls-pagging-grid .grid-body table>tr{
            height:48px;
            border-bottom:1px solid #F0F0F3;
                font-family: NotoSansHans-Medium;
                font-size: 13px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #333333;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(1),
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(2),
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(4){
            text-align:left;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tr td:nth-child(6){
            text-align:right;
            }
            .leaf_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;
                background: #fff;
                font-family: NotoSansHans-Light;
                font-size: 12px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #333333;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tbody td{
            max-width:13em;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tbody td div p{
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
                font-family: NotoSansHans-Light;
                font-size: 12px;
                font-weight: normal;
                font-stretch: normal;
                letter-spacing: 1px;
                color: #333333;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tbody td div p:last-child{
                color: #999999;
            }
            .leaf_widget_asset_info .hls-pagging-grid .hls-table tbody tr:hover{
                background-color: rgba(238,238,238,.32);
                /*opacity: 0.32;*/
                font-family: NotoSansHans-Medium;
                color: #333333;
            }
            .leaf_widget_asset_info .hls-table-active{
            /*background-color: rgba(90,127,255,0.08);*/
            }
            .leaf_widget_asset_info .hls-pagging-grid .icon{
            cursor:pointer;
            width:16px;
            height:16px;
            }
            .leaf_widget_asset_info .hls-pagging-grid input[type='checkbox']{
            display:none;
            }
            .leaf_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;
            }
            .leaf_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;
            }
            .leaf_widget_asset_info .hls-pagging-grid input[type='checkbox']:checked ~ .label1{
            display:none;
            }
            .leaf_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 title="' + name + '">'+ name +'</p>' + '<p >'+ number +'</p>'
        }
        function con_asset_cont_renderer(record,index){
            var number=record.data["contract_number"]||'';
            var name=record.data["contract_name"]||'';
            return '<p title="' + name + '">'+ name +'</p>' + '<p>'+ number +'</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/asset-detail@2x.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"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_factoring_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_factoring_input"/>'
                    +'<label class="label1" for="' + number + '_factoring_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_factoring_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></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"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_refinance_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_refinance_input"/>'
                    +'<label class="label1" for="' + number + '_refinance_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_refinance_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></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"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_securitization_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></label>';
            }else{
                html='<input type="checkbox" class="icon" id="' + number + '_securitization_input"/>'
                    +'<label class="label1" for="' + number + '_securitization_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/choose-asset.png"/></label>'
                    +'<label class="label0" for="' + number + '_securitization_input"><img style="width: 16px" src="${/request/@context_path}/leafresource/images/widget/unchoose-asset.png"/></label>';
            }
            return html;
        }
        jQuery(document).ready(function(){
            //查询条件数据结构
            var queryParam={
                "leaf_asset_query_unit":'',
                "leaf_asset_query_bp":'',
                "leaf_asset_query_con":'',
                "currency":''
            };
            jQuery(".leaf_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")=='leaf_submit'){
                    queryParam["asset_query_unit"]=jQuery("#leaf_asset_query_unit").val();
                    queryParam["asset_query_bp"]=jQuery("#leaf_asset_query_bp").val();
                    queryParam["asset_query_con"]=jQuery("#leaf_asset_query_con").val();
                    $("leaf_con_contract_asset_ds").qpara=queryParam;
                    $("leaf_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: $('leaf_info_prj910_project_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: $('leaf_info_con301_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="leaf_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="leaf_widget_asset_info">
            <!--<span class="widget_label"> </span>-->
            <img class="leaf-asset-img" src="${/request/@context_path}/leafresource/images/widget/leaf-asset@2x.png"/>
            <div class="row1">资产信息查询</div>
            <div class="row2 asset_query_form">
                <div class="row2-child">
                    <span class="label">部门信息</span>
                    <div class="divide-line"></div>
                    <input type="text" id="leaf_asset_query_unit" placeholder="部门名称/项目经办人"/>
                </div>
                <div class="row2-child">
                    <span class="label">承租人/合同信息</span>
                    <div class="divide-line"></div>
                    <input type="text" id="leaf_asset_query_con" placeholder="合同编号/合同名称"/>
                    <!--<span class="label">合同信息</span>-->
                    <!--<input type="text" id="leaf_asset_query_con" placeholder="合同编号/合同名称"/>-->
                    <!--<span class="clickable" id="leaf_submit">查询</span>-->
                </div>
                <div class="row2-child" style="border: 0px">
                    <span class="label" style="min-width:4em;">币种</span>
                    <div class="divide-line"></div>
                    <span class="clickable asset_query_currency" id="CNY">人民币</span>
                    <span class="clickable asset_query_currency" id="USD">美元</span>
                </div>
                <span class="clickable" id="leaf_submit">查询</span>
            </div>
            <div class="asset-info">资产信息</div>
            <div class="asset-info-line"></div>
            <a:hapGrid id="leaf_con_contract_asset_grid" bindTarget="leaf_con_contract_asset_ds" canWheel="true">
                <a:columns>
                    <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: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:columns>
            </a:hapGrid>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>