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

<!--
    $Date: 2018/9/4
    微件-公告栏
    WIDGET-SYS-MSG
-->
<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="sys_notice_msg_url" url="${/request/@context_path}/modules/sys/SYS100/sys_notice_msg_html.lview"/>
        <a:link id="all_sys_notice_msg_url" url="${/request/@context_path}/modules/sys/SYS100/sys_notice_msg.lview"/>
        <style>
            html,body{
                background-color:#eee;
                width:241px;
                height:273px;
                margin: 0;
                padding: 0;
            }
            .widget_leaf_sys_msg{
                box-sizing:border-box;
                width:241px;
                height:273px;
                background-color:#fff;
                position:relative;
                border:1px solid #F0F0F3;
                cursor:default;
            }
            .widget_leaf_sys_msg .widget_label{
                position:absolute;
                width:40px;
                height:4px;
                top:0;
                left:16px;
                background-color: #5A7FFF;
            }
            .widget_leaf_sys_msg .header{
                position:relative;
                height:22px;
                padding:12px 12px 6px 16px;
                font-family: PingFangSC-Medium;
                font-size: 14px;
                color: #4B505A;
            }
            .widget_leaf_sys_msg .header{
                position:relative;
                height:22px;
                padding:24px 12px 6px 27px;
                font-family: PingFangSC-Medium;
                font-size: 14px;
                color: #4B505A;
                /*border-bottom:1px solid #F0F0F3;*/
            }
            .widget_leaf_sys_msg .header .more-notice-img{
                width: 8px;
                position: absolute;
                right: 18px;
                top: 25px;
                cursor: pointer;
            }
            .widget_leaf_sys_msg .header .title-line{
                width: 29px;
                height: 5px;
                background-color: #657efe;
                margin-top: 4px;
            }
            .widget_leaf_sys_msg .header .more-notice{
                width: 175px;
                margin-left: 33px;
            }
            .widget_leaf_sys_msg .header a{
                font-family: PingFangSC-Regular;
                font-size: 12px;
                color: rgba(93,97,103,0.70);
                float:right;
            }
            .widget_leaf_sys_msg .top_msg{
                margin: 11px 0 0 30px;
            }
            .widget_leaf_sys_msg .top_msg img{
                width:173px;

            }
            .widget_leaf_sys_msg .top_msg .title{
                width: 240px;
                height: 24px;
                box-sizing: border-box;
                font-family: PingFangSC-Regular;
                font-size: 12px;
                color: #FFFFFF;
                z-index: 10;
                background: rgba(41,66,97,0.7);
                line-height: 24px;
                padding-left: 8px;
                position: relative;
                top: -24px;
            }

            .widget_leaf_sys_msg .msg_list{
                position: relative;
                box-sizing: border-box;
                padding: 17px 20px 0 21px;
            }
            .widget_leaf_sys_msg .msg_list .msg_title{
                width:120px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                display: inline-block;
            }
            .widget_leaf_sys_msg .msg_list .list_row{
                margin-bottom: 8px;
                cursor: pointer;
            }
            .widget_leaf_sys_msg .msg_start_date{
                font-family: PingFangSC-Regular;
                font-size: 13px;
                color: rgba(0,0,0,0.40);
                position: absolute;
                right: 20px;
            }
        </style>
        <script><![CDATA[
        function on_sys_notice_msg_ds_load(ds){
            var records = ds.data;
            var html='';
            records.forEach(function(record){
                var title = record.data["msg_title"] || '';
                var date = record.data["msg_start_date"] || new Date;
                var id = record.data["notice_msg_id"] || 0;
                var source_id = record.data["source_id"] || 0;
                var notice_type = record.data["notice_type"] || '';
                var url = record.data["notice_url"] || '';
                var dateStr = date.format("yyyy-mm-dd");
                var clickJsStr = '';
                if (notice_type == 'URL') {
                    clickJsStr = 'openWin_sys_msg_detail_url(\'' + url + '\',' + source_id + ')';
                } else if (notice_type == 'HTML') {
                    clickJsStr = 'openWin_sys_msg_detail_html(' + record.get('notice_msg_id') + ')';
                } else {
                    clickJsStr = '';
                }
                html += '<div class="list_row" onclick="' + clickJsStr + '">';
                html += '<span class="msg_title">【系统公告】' + title + '</span>';
                html += '<span class="msg_start_date">' + dateStr + '</span>';
                html += '</div>';
            });
            jQuery(".widget_leaf_sys_msg .msg_list").html(html);
        };
        function openWin_sys_msg_detail_url(url,instance_id){
            new Leaf.Window({
                id: 'sys_notice_url',
                url: '${/request/@context_path}/modules/' + url,
                params: {
                    instance_id: instance_id
                },
                title: '明细',
                fullScreen: true
            });
        }
        function openWin_sys_msg_detail_html(notice_msg_id){
            new Leaf.Window({
                id: 'sys_notice_msg_html',
                url: $('sys_notice_msg_url').getUrl(),
                params: {
                    notice_msg_id: notice_msg_id
                },
                title: '明细',
                fullScreen: true
            });
        }
        function openWin_all_sys_msg(){
            new Leaf.Window({
                id: 'all_sys_notice_msg',
                url: $('all_sys_notice_msg_url').getUrl(),
                title: '全部系统公告',
                fullScreen: true
            });
        }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="leaf_sys_notice_msg_ds" autoQuery="true" pageSize="3" model="sys.SYS8300.sys_notice_msg">
                <a:fields>
                    <a:field name="msg_title"/>
                    <a:field name="msg_start_date"/>
                    <a:field name="notice_msg_id"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="on_sys_notice_msg_ds_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <div class="widget_leaf_sys_msg">
            <div class="header">
                <span class="title">系统公告</span>
                <div class="title-line"></div>
                <!--<a href="javascript:openWin_all_sys_msg()">查看更多></a>-->
                <img onclick="openWin_all_sys_msg()" class="more-notice-img" src="${/request/@context_path}/leafresource/images/widget/more-notice@2x.png"/>
            </div>
            <div class="top_msg">
                <img class="more-notice" src="${/request/@context_path}/leafresource/images/widget/system-notice@2x.png"/>
                <!--<div class="title">热烈庆祝公司移动端产品上线</div>-->
            </div>
            <div class="msg_list"> </div>
        </div>
        <a:screenBody style="display:none"> </a:screenBody>
    </a:view>
</a:screen>