You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
332 lines
9.2 KiB
332 lines
9.2 KiB
let accountId = cookieHandler.get("accountId");
|
|
let messsage = [];
|
|
window.onload = function() {
|
|
Array.prototype.myForEach = function myForEach(callback, context) {
|
|
context = context || window;
|
|
if (Array.prototype.forEach) {
|
|
// 调用forEach方法,不做任何处理
|
|
this.forEach(callback, context);
|
|
return;
|
|
}
|
|
}
|
|
if (cookieHandler.get("userType") === "0" || cookieHandler.get("isliCode") == "undefined" || cookieHandler.get(
|
|
"isliCode") == undefined || cookieHandler.get("isliCode") == "") {
|
|
$(".tabs_item").hide()
|
|
}
|
|
// 页面权限
|
|
if (!cookieHandler.get("normal_login_token")) {
|
|
Dreamer.error("请先登录");
|
|
setTimeout(function() {
|
|
window.location.href = 'login.html?time=' + new Date().getTime();
|
|
}, 1000)
|
|
}
|
|
// 获取表格数据
|
|
$("#mytable").bootstrapTable({
|
|
// url: PortalMessage + 'noti/v1/notification/message?accountId=' + accountId + '&pageRows=100000',
|
|
// url: PortalMessage + 'v1/notification/message?accountId=' + accountId + '&pageRows=100000',
|
|
url: api + 'noti/v1/notification/message?accountId=' + accountId + '&pageRows=100000',
|
|
contentType: "application/x-www-form-urlencoded",
|
|
contentType: "application/x-www-form-urlencoded",
|
|
ajaxOptions: {
|
|
headers: {
|
|
"normal_login_token": cookieHandler.get("normal_login_token")
|
|
}
|
|
},
|
|
method: 'GET',
|
|
pageNumber: 1,
|
|
pagination: true,
|
|
sidePagination: 'client',
|
|
pageSize: 20, //每页的记录行数(*)
|
|
pageList: [10, 20, 50, 100], //可供选择的每页的行数(*)
|
|
queryParamsType: "limit",
|
|
ajaxOptions: {
|
|
headers: {
|
|
"normal_login_token": cookieHandler.get("normal_login_token")
|
|
}
|
|
},
|
|
queryParams: function(params) {
|
|
//获取已读未读状态
|
|
var text = document.getElementsByClassName("current")[0].innerText;
|
|
var temp = null;
|
|
if (text == "全部") {
|
|
temp = {
|
|
pageIndex: 1, //页面大小
|
|
pageRows: params.limit
|
|
}
|
|
} else {
|
|
temp = {
|
|
pageIndex: 1, //页面大小
|
|
pageRows: params.limit,
|
|
state: text //0:未读 1:已读
|
|
}
|
|
}
|
|
return temp;
|
|
},
|
|
responseHandler: function(res) {
|
|
if (res.resultCode != "00000000") {
|
|
cookieHandler.del("isliCode")
|
|
cookieHandler.del("normal_login_token")
|
|
cookieHandler.del("accountId")
|
|
cookieHandler.del("cellPhone")
|
|
cookieHandler.del("userType")
|
|
Dreamer.error("请先登录");
|
|
setTimeout(function() {
|
|
window.location.href = 'login.html?time=' + new Date().getTime();
|
|
}, 1500)
|
|
} else {
|
|
return res.data.pageDataList
|
|
}
|
|
},
|
|
// 请求失败
|
|
onLoadError: function(err) {
|
|
console.log(err == 401, 'err')
|
|
if (err == 401) {
|
|
cookieHandler.del("isliCode")
|
|
cookieHandler.del("normal_login_token")
|
|
cookieHandler.del("accountId")
|
|
cookieHandler.del("cellPhone")
|
|
cookieHandler.del("userType")
|
|
Dreamer.error("请先登录");
|
|
setTimeout(function() {
|
|
window.location.href = 'login.html?time=' + new Date().getTime();
|
|
}, 1500)
|
|
}
|
|
},
|
|
columns: [{
|
|
field: '',
|
|
checkbox: true,
|
|
align: 'center',
|
|
valign: 'middle',
|
|
// formatter: formatCheck
|
|
}, {
|
|
title: '序号',
|
|
field: '',
|
|
align: 'center',
|
|
formatter: function(value, row, index) {
|
|
return index + 1;
|
|
}
|
|
},
|
|
{
|
|
title: '消息标题',
|
|
field: 'subject',
|
|
sortable: true, //是否显示排序
|
|
align: 'center', //水平居中
|
|
valign: 'middle' //垂直居中
|
|
}, {
|
|
title: '状态',
|
|
field: 'state',
|
|
align: 'center',
|
|
valign: 'middle'
|
|
},
|
|
{
|
|
title: '发送时间',
|
|
field: 'sendAt',
|
|
align: 'center',
|
|
valign: 'middle',
|
|
formatter: formatTime
|
|
},
|
|
{
|
|
title: '操作',
|
|
field: '',
|
|
align: 'center',
|
|
valign: 'middle',
|
|
formatter: formatLook
|
|
}
|
|
],
|
|
//点击全选框时触发的操作
|
|
onCheckAll: function(row) {
|
|
messsage = [];
|
|
messsage = row;
|
|
if (messsage.length != 0) {
|
|
$(".delBtn").attr("disabled", false);
|
|
$(".MarkRead").attr("disabled", false);
|
|
}
|
|
},
|
|
//点击取消全选
|
|
onUncheckAll: function(row, tr, flied) {
|
|
messsage = [];
|
|
if (messsage.length == 0) {
|
|
$(".delBtn").attr("disabled", true);
|
|
$(".MarkRead").attr("disabled", true);
|
|
}
|
|
},
|
|
// 点击每一个单选框时触发的操作
|
|
onCheck: function(row) {
|
|
messsage.push(row);
|
|
if (messsage.length != 0) {
|
|
$(".delBtn").attr("disabled", false);
|
|
$(".MarkRead").attr("disabled", false);
|
|
}
|
|
},
|
|
//取消每一个单选框时对应的操作;
|
|
onUncheck: function(row) {
|
|
messsage.myForEach(function(v, index, arr) {
|
|
if (v.messageId == row.messageId) {
|
|
messsage.splice(index, 1);
|
|
}
|
|
});
|
|
if (messsage.length == 0) {
|
|
$(".delBtn").attr("disabled", true);
|
|
$(".MarkRead").attr("disabled", true);
|
|
}
|
|
},
|
|
})
|
|
$(".delBtn").attr("disabled", true);
|
|
$(".MarkRead").attr("disabled", true);
|
|
}
|
|
|
|
// 复选框
|
|
function formatCheck(value, row, index) {
|
|
//已读状态下不能选择删除
|
|
if (row.messageStatus != '' && row.messageStatus != '0') {
|
|
return {
|
|
disabled: true
|
|
}
|
|
}
|
|
}
|
|
|
|
// //value代表该列的值,row代表当前对象
|
|
// function formatSex(value, row, index) {
|
|
// return value == 0 ? "未读" : "已读";
|
|
// }
|
|
|
|
// 时间操作
|
|
function formatTime(value, row, index) {
|
|
return formatDate(value)
|
|
}
|
|
|
|
//添加查看按钮
|
|
function formatLook(value, row, index) {
|
|
var htm = "<button onclick=\"handelLook('" + row.messageId + "','" + row.sendAt + "','" + row.state + "','" + row
|
|
.subject + "','" + row.type + "','" + index + "')\">查看</button>";
|
|
return htm;
|
|
}
|
|
var detail = [];
|
|
|
|
// 点击查看按钮操作
|
|
function handelLook(messageId, sendAt, state, subject, type, index) {
|
|
let getList = new AJAX_OBJ(api + "noti/v1/notification/loadContent?messageId=" + messageId, newgetSuccess,
|
|
onUrlError);
|
|
getList.getRequestData();
|
|
|
|
function newgetSuccess(xmlHttp) {
|
|
let res = eval("(" + xmlHttp.responseText + ")");
|
|
if (res.resultCode === "00000000") {
|
|
$('#tableBox').css('display', 'none');
|
|
$('#table_details').css('display', 'block');
|
|
$('#box').css('display', 'none');
|
|
$('#details_title').html(res.data.subject);
|
|
if (res.data.content == undefined || res.data.content == '') {
|
|
$('#details_box').html('暂无详情信息');
|
|
} else {
|
|
$('#details_box').html(res.data.content);
|
|
}
|
|
$('#detailsTime').html("发送时间:" + res.data.sendAt);
|
|
detail.push(messageId);
|
|
detail.push(sendAt);
|
|
detail.push(state);
|
|
detail.push(subject);
|
|
detail.push(type);
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 删除
|
|
function handelDelete() {
|
|
let rows = $("#mytable").bootstrapTable('getSelections');
|
|
let postList = new AJAX_OBJ(api + "noti/v1/notification/deleteMessage", deleteMessage, onUrlError);
|
|
postList.postRequestData(setJson(rows));
|
|
|
|
function deleteMessage(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
$("#mytable").bootstrapTable('refresh');
|
|
location.reload();
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
};
|
|
}
|
|
|
|
function setJson(rows) {
|
|
var datas = "";
|
|
for (var i = 0; i < rows.length; i++) {
|
|
if (i == rows.length - 1) {
|
|
datas += '{"messageId":' + rows[i].messageId + ',"sendAt":"' + rows[i].sendAt + '","state":"' + rows[i]
|
|
.state + '","subject":"' + rows[i].subject + '","type":"' + rows[i].type + '"}';
|
|
} else {
|
|
datas += '{"messageId":' + rows[i].messageId + ',"sendAt":"' + rows[i].sendAt + '","state":"' + rows[i]
|
|
.state + '","subject":"' + rows[i].subject + '","type":"' + rows[i].type + '"},';
|
|
}
|
|
}
|
|
return results = '{' + '"notis":[' + datas + "]" + '}';
|
|
}
|
|
|
|
function detailJson(messageId, sendAt, state, subject, type) {
|
|
var datas = '{"messageId":' + messageId + ',"sendAt":"' + sendAt + '","state":"' + state + '","subject":"' +
|
|
subject + '","type":"' + type + '"}';
|
|
return results = '{' + '"notis":[' + datas + "]" + '}';
|
|
|
|
}
|
|
// 标记已读
|
|
function handelRead() {
|
|
var rows = $("#mytable").bootstrapTable('getSelections');
|
|
let postList = new AJAX_OBJ(api + "noti/v1/notification/markRead", markRead, onUrlError);
|
|
postList.postRequestData(setJson(rows));
|
|
|
|
function markRead(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
$("#mytable").bootstrapTable('refresh');
|
|
location.reload();
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
};
|
|
}
|
|
|
|
/*
|
|
详情页js处理
|
|
*/
|
|
|
|
// 详情页数据删除
|
|
function handelDeleteDetails() {
|
|
// let postList = new AJAX_OBJ(PortalMessage + "v1/notification/deleteMessage", deleteMessage, onUrlError);
|
|
let postList = new AJAX_OBJ(api + "noti/v1/notification/deleteMessage", deleteMessage, onUrlError);
|
|
postList.postRequestData(detailJson(detail[0], detail[1], detail[2], detail[3], detail[4]));
|
|
|
|
function deleteMessage(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
$('#alert_success').css('display', 'block');
|
|
setTimeout(function() {
|
|
$('#alert_success').css('display', 'none');
|
|
window.location = 'MyMessage.html';
|
|
}, 1000)
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
};
|
|
}
|
|
|
|
/*
|
|
日期时间处理
|
|
*/
|
|
function formatDate(now) {
|
|
if (typeof now == "string") {
|
|
now = new Date(now.replace(/-/g, "/"));
|
|
}
|
|
const t = new Date(now)
|
|
var year = t.getFullYear();
|
|
var month = t.getMonth() + 1;
|
|
var date = t.getDate();
|
|
return year + "/" + month + "/" + date;
|
|
}
|
|
|
|
|
|
// 页面跳转添加时间戳
|
|
function handelBuyOrder(url) {
|
|
window.location.href = url + '?time=' + new Date().getTime();
|
|
}
|
|
|