'use strict';
/**
 * 待办页js
 *
 * @author EllisRan.
 * @date 2019/3/19
 * @version
 */
$(document).ready(() => {
    // $('a[href="#view-msg"]').on('click', function () {
    //     const id = $(this).attr('msg-id');
    //     const msgInfo = _.find(msgList,{ id: parseInt(id) });
    //     $('#title').html(msgInfo.title);
    //     $('#creator').html(msgInfo.creator);
    //     $('#release_time').html(moment(msgInfo.release_time*1000).format('YYYY-MM-DD'));
    //     $('#content').html(msgInfo.content);
    //     $('#user_permission').html('');
    //     if (userMsgPermission && parseInt(uid) === msgInfo.create_uid ) {
    //         const permissionHtml = '编辑';
    //         $('#user_permission').html(permissionHtml);
    //     }
    // });
    $('.list-group-item a').on('click', function () {
        const id = $(this).attr('msg-id');
        const msgInfo = _.find(msgList, {id: parseInt(id)});
        $('#title').html(msgInfo.title);
        $('#release_time').html(moment(msgInfo.release_time * 1000).format('YYYY-MM-DD'));
        $('#content').html(msgInfo.content);
        $('#user_permission').html('');
        if (type && parseInt(type) === 1) {
            $('#creator').html(msgInfo.creator);
            $('#view-msg .modal-title').text('项目通知');
            if (userMsgPermission && parseInt(uid) === msgInfo.create_uid) {
                const permissionHtml = '编辑';
                $('#user_permission').html(permissionHtml);
            }
        } else {
            $('#creator').html('');
            $('#view-msg .modal-title').text('系统通知');
        }
    });
    $('.system-msg').on('click', function () {
        const id = $(this).attr('msg-id');
        const msgInfo = _.find(sysMsgList, {id: parseInt(id)});
        $('#title').html(msgInfo.title);
        $('#creator').html('');
        $('#release_time').html(moment(msgInfo.release_time * 1000).format('YYYY-MM-DD'));
        $('#content').html(msgInfo.content);
        $('#view-msg .modal-title').text('系统通知');
        $('#user_permission').html('');
    })
});