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

<!--
    $Date: 2018/9/4
    微件-客户最新动态
    WIDGET-BP-TREND
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view template="default" package="leaf.ui.std">
        <!--<meta name="_csrf" content="${/session/@_csrf.token}"/>-->
        <!--<meta name="_csrf_header" content="X-CSRF-TOKEN" />-->
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="hls_bp_master_modify_link" url="${/request/@context_path}/modules/hls/HLS214N/hls_bp_master_modify.lview"/>
        <!--单独微件测试用-->
        <!--<script src="${/request/@context_path}/leafresource/js/attach/g2.min.js"></script>-->
        <style>
            html,body{
            background-color:#eee;
            width:264px;
            height:360px;
            margin: 0;
            padding: 0;
            }
            .widget_bp_trend{
            box-sizing:border-box;
            width:264px;
            height:360px;
            background-color:#fff;
            position:relative;
            border:1px solid #F0F0F3;
            cursor:default;
            }
            .widget_bp_trend .widget_label{
            position:absolute;
            width:40px;
            height:4px;
            top:0;
            left:16px;
            background-color: #5A7FFF;
            }
            .widget_bp_trend .row1{
            position:relative;
            height:20px;
            padding:12px 0 9px 16px;
            font-family: PingFangSC-Medium;
            font-size: 14px;
            color: #4B505A;
            }
            .widget_bp_trend #bp_trend_grid-wraper{
            display:inline-block;
            position:relative;
            width:100%;
            height:319px;
            font-family: PingFangSC-Regular;
            font-size: 12px;
            color: #5A7FFF;
            letter-spacing: 0;
            -webkit-box-shadow:none;
            box-shadow:none;
            }
            .widget_bp_trend .hls-pagging-grid .grid-title{
            display:none;
            }
            .widget_bp_trend .hls-pagging-grid .grid-body{
            padding:0;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table>tr:first-child{
            display:none;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tbody tr:first-child{
            height:56px;
            border-top:1px solid #F0F0F3;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr:hover{
            background: rgba(90,127,255,0.08);
            }
            .widget_bp_trend .hls-pagging-grid .hls-table-active{
            background: rgba(90,127,255,0.08);
            }
            .widget_bp_trend .hls-pagging-grid .grid-foot{
            margin-top:0;
            line-height:36px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr{
            height:56px;
            border-bottom:1px solid #F0F0F3;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td{
            height:56px;
            width:100%;
            padding:0 16px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left{
            float:left;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .bp_name{
            font-family: PingFangSC-Regular;
            font-size: 12px;
            color: rgba(0,0,0,0.65);
            height:17px;
            line-height:17px;
            max-width:180px;
            overflow:hidden;
            text-overflow:ellipsis;
            white-space:nowrap;
            cursor:pointer;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .left_row2{
            height:17px;
            line-height:17px;
            margin-top:6px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .left_row2 .type_icon{
            width:15px;
            height:14px;
            vertical-align:bottom;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .left_row2 .type_new{
            font-family: PingFangSC-Regular;
            font-size: 12px;
            color: #4866CC;
            margin-left:5px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .left_row2 .type_update{
            font-family: PingFangSC-Regular;
            font-size: 12px;
            color: #FF8665;
            margin-left:5px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .left .left_row2 .date{
            font-family: PingFangSC-Regular;
            font-size: 12px;
            color: rgba(75,80,90,0.50);
            margin-left:35px;
            }
            .widget_bp_trend .hls-pagging-grid .hls-table tr td .right{
            width:14px;
            height:14px;
            float:right;
            position:relative;
            right:0;
            top:13px;
            cursor:pointer;
            }
            .widget_bp_trend .clearFloat{
            clear:both;
            height:0;
            line-height:0;
            font-size:0;
            }
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_last_end_page,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_last_page,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_page_number,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_next_page,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_next_end_page,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page_count_total_message,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page-message .page_message_refresh,
            .widget_bp_trend .hls-pagging-grid .grid-foot .page-message .page_message_num{
            margin-right:1px;
            }
        </style>
        <script><![CDATA[
        function bp_trend_grid_renderer(record,index){
            var bp_name = record.data['bp_name'] || '商业伙伴名称';
            var latest_date = record.data['latest_date'] || new Date;
            var type = record.data['type'] || 'new';

            var latest_date_str = latest_date.format("yyyy-mm-dd HH:MM");
            var type_str = (type=='new') ? '<span class="type_new">新增</span>' : '<span class="type_update">更新</span>';

            var html='';
            html+='<div class="left">'
                +'<div class="bp_name" title="'+ record.data['bp_name'] +'">' + record.data['bp_name'] + '</div>'
                +'<div class="left_row2">'
                +'<img class="type_icon" src="${/request/@context_path}/leafresource/images/widget/' + type + '_bp.png"/>'
                +type_str
                +'<span class="date">' + latest_date_str + '</span>'
                +'</div></div>'
                +'<img class="right goDetail" src="${/request/@context_path}/leafresource/images/widget/rightSquare.png" onclick="open_bp_modify_win(\'' + record.ds.id + '\',' + record.id + ')"/>'
                +'<div class="clearFloat"></div>';
            return html;
        };
        function open_bp_modify_win(ds_id, record_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
            param['cond_para2'] = param['bp_type'];
            param['function_code'] = 'HLS224D';
            param['function_usage'] = 'MODIFY';
            param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';

            var bm_url_link='con_contract_get_layout_code_link_id';
            var list_ds=ds_id;

            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            Leaf.request({
                url: $(bm_url_link).getUrl(),
                para: param,
                success: function(res) {
                    Leaf.Masker.unmask(Ext.getBody());
                    param['layout_code'] = 'BP_MODIFY';
                    param['winid'] = 'hls_doc_get_layout_code_winid';
                    var win = new Leaf.Window({
                        id: param['winid'],
                        params: param,
                        url: $('hls_bp_master_modify_link').getUrl(),
                        title: param['url_title'] + '(BP_MODIFY)',
                        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
            });
        }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="bp_trend_ds" autoQuery="true" pageSize="5" model="bp.bp_trend">
                <a:fields>
                    <a:field name="type"/>
                    <a:field name="bp_name"/>
                    <a:field name="latest_date"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_bp_trend">
            <span class="widget_label"> </span>
            <div class="row1">最新动态</div>
            <a:hapGrid id="bp_trend_grid" bindTarget="bp_trend_ds" canWheel="true">
                <a:columns>
                    <a:column template="bp_trend_grid_renderer"/>
                </a:columns>
            </a:hapGrid>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
        <!--<a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=BP&amp;function_code=HLS214"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>-->
    </a:view>
</a:screen>