#@layout()
#define main()
<div>
    <div id="" class="nav-title">上级通知公告</div>


    <table id="dataTable" lay-filter="dataTable"></table>
</div>
#end
#define methods()

<script>


    myTable.list({
        url:"/notice/receiveList",
        postData:{orgid:JSON.parse(sessionStorage.loginData).orgid},
        elem:"#dataTable",
        toolbar:"#tableHeader",
        cols: [[
            {type: 'numbers', title: '序号'}
            ,{field: 'flag', title: '类型',align:'center',templet:function (d) {
                    if(d.flag == 0){
                        return "公告";
                    }else {
                        return "通知";
                    }
                }}
            ,{field: 'title', title: '发布主题',align:'center', event:'openMessage' ,style:'text-decoration-line: underline;color: #199ED8; cursor: pointer;'}
            ,{field: 'createtime', title: '发布时间', align:'center',templet:function(d){
                    if(null != d.createtime && "" != d.createtime){
                        return d.createtime.split(" ")[0];
                    } else {
                        return "";
                    }
                }}
            ,{field: 'orgname', title: '发布单位', align:'center'}
            ,{field: 'readstatus', title: '是否已读',align:'center',templet:function (d) {
                    if(d.readstatus == 0){
                        return "未读";
                    }else {
                        return "已读";
                    }
                }}
        ]]
    });

    table.on('tool(dataTable)', function(obj){
        if(obj.event === 'openMessage'){
            if(obj.data.filsurl == null){
                obj.data.filsurl = "";
            }
            downloadUrl = obj.data.filsurl;
            var filsurl = obj.data.filsurl;
            var index = filsurl .lastIndexOf("\/");
            filsurl  = filsurl .substring(index + 1, filsurl.length);
            obj.data.filsurl = filsurl.slice(13);
            //obj.data.filsurl = filsurl;
            if(obj.data.filsurl){
                obj.data.filsurl = "附件："+obj.data.filsurl;
            }
            console.log(obj)
            var noticeStr = '<div id="noticeContent">\n' +
                '    <h5>{{d.title}}</h5>\n' +
                '    <div class="noticeContentText">{{d.content}}</div>\n' +
                '    <footer style="margin-bottom: 0;"><div style="text-align: left;"><a onclick="downloadFile()">{{d.filsurl}}</a></div> ' +
                '<div>{{d.orgname}}</div>' +
                '<div>{{d.createtime.split(" ")[0]}}</div></footer>\n' +
                '</div>';
            laytpl(noticeStr).render(obj.data, function(string){
                noticeStr = string;
            });

            layer.open({
                title: "查看",
                type: 1,
                area: ['1000px', '500px'],
                skin: 'noticeStr',
                content: noticeStr,

            });
            $.ajax("/notice/setRead",{
                data:{id:obj.data.id},
                success:function(result){
                    if(result.code==200){

                    }
                }
            });
        }
    });
    function downloadFile(){
        console.log(downloadUrl);
        window.open('/file/downloadFile?filename='+downloadUrl);
    }
</script>
#end