157 lines
6.5 KiB
JavaScript
157 lines
6.5 KiB
JavaScript
/*
|
||
* 版 本 PIT-ADMS V7.0.3 敏捷开发框架
|
||
* Copyright (c) 2013-2018 Hexagon PPM
|
||
* 创建人:研发部
|
||
* 日 期:2018.06.01
|
||
* 描 述:聊天记录查询
|
||
*/
|
||
var userId = request('userId');
|
||
var mypage;
|
||
var bootstrap = function ($, learun) {
|
||
"use strict";
|
||
var page = {
|
||
init: function () {
|
||
page.initGrid();
|
||
page.bind();
|
||
page.updateIsRead();
|
||
},
|
||
bind: function () {
|
||
$('#F_IsRead').lrDataItemSelect({
|
||
code: 'msgIsread',
|
||
select: () => {
|
||
$('#btn_Search').click();
|
||
$('#F_IsRead .lr-select-placeholder').text('===状态===')
|
||
}
|
||
});
|
||
// 查询
|
||
$('#btn_Search').on('click', function () {
|
||
var keyword = $.trim($('#txt_Keyword').val());
|
||
var Isread = $("#F_IsRead").lrselectGet();
|
||
page.search({ keyWord: keyword, Isread });
|
||
});
|
||
// 刷新
|
||
$('#lr_refresh').on('click', function () {
|
||
location.reload();
|
||
});
|
||
},
|
||
updateIsRead: function () {
|
||
$('#F_IsRead .lr-select-placeholder').text('===状态===')
|
||
},
|
||
initGrid: function () {
|
||
let ProjectId = getQueryString('ProjectId');
|
||
$('#gridtable').jfGrid({
|
||
url: top.$.rootUrl + '/LR_IM/IMMsg/GetMsgPageList?userId=' + userId + '&ProjectId=' + ProjectId,
|
||
headData: [
|
||
//{
|
||
// label: '项目', name: 'ProjectId', width: 200, align: 'left',
|
||
//},
|
||
{
|
||
label: '类别', name: 'TypeId', width: 150, align: 'center',
|
||
formatterAsync: function (callback, value, row, op, $cell) {
|
||
learun.clientdata.getAsync('dataItem', {
|
||
key: value,
|
||
code: 'msgType',
|
||
callback: function (_data) {
|
||
callback(_data.text);
|
||
}
|
||
});
|
||
}
|
||
},
|
||
{
|
||
label: '消息标题', name: 'Title', width: 600, align: 'left',
|
||
formatter: function (cellvalue, row) {
|
||
if (ProjectId && ProjectId != "" && ProjectId != "null") {
|
||
return `<a style='color: #337ab7;' onclick='showContent("${row.F_Content}","${row.F_MsgId}","${row.F_IsRead}")'>${cellvalue}</a>`;
|
||
} else {
|
||
var projectName = (row.ProjectName && row.ProjectName != "") ? ("【" + row.ProjectName + "】") : "";
|
||
return `<a style='color: #337ab7;' onclick='showContent("${row.F_Content}","${row.F_MsgId}","${row.F_IsRead}")'>${projectName}${cellvalue}</a>`;
|
||
}
|
||
}
|
||
},
|
||
{
|
||
label: '发送人', name: 'F_SendUserId', width: 100, align: 'center',
|
||
formatterAsync(callback, cellvalue) {
|
||
var loginInfo = learun.clientdata.get(['userinfo']);
|
||
if (loginInfo.userId == cellvalue) {
|
||
callback('我');
|
||
}
|
||
else {
|
||
// 获取人员数据
|
||
learun.clientdata.getAsync('user', {
|
||
key: cellvalue,
|
||
callback: function (data, op) {
|
||
callback(data.name);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
{
|
||
label: '发送时间', name: 'F_CreateDate', width: 150, align: 'center',
|
||
formatter: function (cellvalue) {
|
||
return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
|
||
}
|
||
},
|
||
{
|
||
label: '状态', name: 'F_IsRead', width: 100, align: 'center',
|
||
formatter: function (cellvalue) {
|
||
if (cellvalue == 1) {
|
||
return '<span class="label label-default" style="cursor: pointer;">已读</span>'
|
||
} else {
|
||
return '<span class="label label-success" style="cursor: pointer;">未读</span>'
|
||
}
|
||
}
|
||
},
|
||
{name:""}
|
||
],
|
||
mainId: 'F_MsgId',
|
||
sidx: 'F_CreateDate',
|
||
sord: 'DESC',
|
||
isPage: true
|
||
});
|
||
page.search();
|
||
},
|
||
search: function (param) {
|
||
$('#gridtable').jfGridSet('reload', param);
|
||
},
|
||
|
||
};
|
||
mypage = page;
|
||
page.init();
|
||
}
|
||
function showContent(content, id, isRead) {
|
||
top.layer.open({
|
||
type: 1,
|
||
content: `<div style="font-size:18px;margin:20px 20px 0px 20px">${content}</div>`,
|
||
area: [1000 + 'px', 600 + 'px'],
|
||
title: '内容详情',
|
||
maxmin: true,
|
||
success: function (layero, index) {
|
||
$.post(top.$.rootUrl + '/LR_IM/IMMsg/UpdateIsread', { msgId: id, isRead: "1" }, function (data) {
|
||
let str = window.parent.$("#getMsgCount").text();
|
||
let str1 = str.substring(1, str.length - 1);
|
||
if (str1 && isRead == 0) {
|
||
if ((str1 - 1) == 0) {
|
||
window.parent.$("#getMsgCount").text("")
|
||
window.parent.$("#lr-im-alarm-model").animate({ bottom: '-500px' }, 1000);
|
||
} else {
|
||
window.parent.$("#getMsgCount").text("(" + (str1 - 1) + ")")
|
||
window.parent.$("#" + id).remove();
|
||
}
|
||
}
|
||
})
|
||
},
|
||
cancel: () => {
|
||
mypage.search();
|
||
}
|
||
});
|
||
}
|
||
//获取参数
|
||
function getQueryString(name) {
|
||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||
var r = window.parent.location.search.substr(1).match(reg);
|
||
if (r != null) return unescape(r[2]);
|
||
return null;
|
||
}
|
||
|