新增私聊管理功能

This commit is contained in:
liaozetao
2023-12-11 15:14:40 +08:00
parent 130a125129
commit bc10184afd

View File

@@ -0,0 +1,355 @@
<template>
<section class="content">
<div class="box box-primary">
<div class="box-body">
<!-- Content Header (Page header) -->
<section class="content-header">
<div id="itemTitle"></div>
</section>
<!-- .content -->
<section>
<div id="table"></div>
<div id="toolbar">
<div class="col-sm-12">
<label for="erBanNoStr" class="col-sm-3 control-label">用户平台ID:</label>
<div class="col-sm-3">
<input type="text" class="form-control" name="erBanNoStr" id="erBanNoStr">
</div>
</div>
<div class="col-sm-12">
<label for="startTime" class="col-sm-2 control-label">发送消息时间:</label>
<div class="col-sm-2"><input type="text" class="form-control" name="startTime" id="startTime">
</div>
<label for="endTime" class="col-sm-1 control-label">-</label>
<div class="col-sm-2"><input type="text" class="form-control" name="endTime" id="endTime"></div>
</div>
<div class="col-sm-12">
<button id="btnSearch" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>查询
</button>
</div>
</div>
</section>
</div>
</div>
</section>
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content" style="width: 190%; left: 50%; transform: translateX(-50%);">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="modalLabel"></h4>
</div>
<div class="modal-body">
<input type="hidden" name="fromUid" id="fromUid" />
<input type="hidden" name="toUid" id="toUid" />
<div id="detailTable"></div>
<div id="detailToolbar">
<div class="col-sm-12">
<label for="detailStartTime" class="col-sm-3 control-label">发送消息时间:</label>
<div class="col-sm-3"><input type="text" class="form-control" name="detailStartTime"
id="detailStartTime"></div>
<label for="detailEndTime" class="col-sm-1 control-label">-</label>
<div class="col-sm-3"><input type="text" class="form-control" name="detailEndTime"
id="detailEndTime"></div>
</div>
<div class="col-sm-12">
<button id="btnDetailSearch" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>查询
</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="btnExport">导出</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="tipModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">提示信息</h4>
</div>
<div class="modal-body" id="tipMsg"></div>
</div>
</div>
</div>
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
import { cleanArray } from '@/utils/maintainer';
export default {
name: "UserChatMsgRecordView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
{ field: 'fromErBanNo', title: '搜索ID', align: 'center', width: '5%' },
{ field: 'fromNick', title: '搜索人昵称', align: 'center', width: '5%' },
{ field: 'toErBanNo', title: '聊天对象ID', align: 'center', width: '5%' },
{ field: 'toNick', title: '聊天对象昵称', align: 'center', width: '5%' },
{ field: 'firstTouchTime', title: '首次接触时间', align: 'center', width: '5%' },
{
field: 'isInitiative',
title: '首次接触情况',
align: 'center',
width: '5%',
formatter: function (val, row, index) {
var value = '';
if (val == 0) {
value = '被动回复';
} else if (val == 1) {
value = '主动发起';
}
return value;
}
},
{ field: 'chatMsgNum', title: '聊天条目数', align: 'center', width: '5%' },
{
field: 'handle',
title: '查看详情',
align: 'center',
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
return '<a class="detail" data-index="' + index + '">查看详情></a>';
}
}
],
cache: false,
striped: true,
showRefresh: false,
pageSize: 20,
pagination: true,
pageList: [20, 50, 100],
search: false,
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
page: params.pageNumber,
pageSize: params.pageSize,
erBanNoStr: $('#erBanNoStr').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val(),
};
return param;
},
toolbar: '#toolbar',
url: '/admin/userChatMsgRecord/page',
onLoadSuccess: function (json) { //加载成功时执行
console.log("load success");
if (json.code && json.code != 200) {
$("#tipMsg").text(json.message);
$("#tipModal").modal('show');
}
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
// 查询刷新
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
});
var picker1 = $("#startTime").datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
todayBtn: true,
autoclose: true,
});
var picker2 = $("#endTime").datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
todayBtn: true,
autoclose: true
});
picker1.on('changeDate', function () {
var date = $('#startTime').datetimepicker('getDate');
picker2.datetimepicker('setStartDate', date);
});
picker2.on('changeDate', function () {
var date = $('#endTime').datetimepicker('getDate');
picker1.datetimepicker('setEndDate', date);
});
$('#table').on('click', '.detail', function () {
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
const fromErBanNo = currentData.fromErBanNo;
const fromNick = currentData.fromNick;
const toErBanNo = currentData.toErBanNo;
const toNick = currentData.toNick;
$("#detailModal").modal('show');
$('#modalLabel').html(fromNick + '(' + fromErBanNo + ')与' + toNick + '(' + toErBanNo + ')的聊天记录');
var fromUid = currentData.fromUid;
var toUid = currentData.toUid;
$('#fromUid').val(fromUid);
$('#toUid').val(toUid);
$('#detailTable').bootstrapTable('destroy');
$('#detailTable').bootstrapTable({
columns: [
{ field: 'fromErBanNo', title: '发消息人ID', align: 'center', width: '5%' },
{ field: 'fromNick', title: '发消息人昵称', align: 'center', width: '5%' },
{ field: 'toErBanNo', title: '接收人ID', align: 'center', width: '5%' },
{ field: 'toNick', title: '接收人昵称', align: 'center', width: '5%' },
{ field: 'createTime', title: '发消息时间', align: 'center', width: '5%' },
{
field: 'content',
title: '消息内容',
align: 'center',
width: '5%',
formatter: function (val, row, index) {
var value = '';
var msgType = row.msgType;
if (msgType == 'PICTURE') {
value = "<img src='" + val + "' width='40' height='40'>";
} else if (msgType == 'AUDIO') {
value = '<audio controls="controls"><source src="' + val + '" type="audio/mpeg"></audio>';
} else {
value = val;
}
return value;
}
},
{
field: 'msgStatus',
title: '消息状态',
align: 'center',
width: '5%',
formatter: function (val, row, index) {
var value = '';
if (val == 0) {
value = '<span sylte="color: red;">屏蔽</span>';
} else if (val == 1) {
value = '正常';
}
return value;
}
},
],
cache: false,
striped: true,
showRefresh: false,
pageSize: 50,
pagination: true,
pageList: [20, 50, 100],
search: false,
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
page: params.pageNumber,
pageSize: params.pageSize,
fromUid: fromUid,
toUid: toUid,
startTime: $('#startTime').val(),
endTime: $('#endTime').val(),
detailStartTime: $('#detailStartTime').val(),
detailEndTime: $('#detailEndTime').val(),
};
return param;
},
toolbar: '#detailToolbar',
url: '/admin/userChatMsgRecord/detailPage',
onLoadSuccess: function (json) { //加载成功时执行
console.log("load success");
if (json.code && json.code != 200) {
$("#tipMsg").text(json.message);
$("#tipModal").modal('show');
}
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
// 查询刷新
$('#btnDetailSearch').on('click', function () {
TableHelper.doRefresh('#detailTable');
});
function param(json) {
if (!json) return ''
return cleanArray(Object.keys(json).map(key => {
if (json[key] === undefined) return ''
return encodeURIComponent(key) + '=' +
encodeURIComponent(json[key])
})).join('&')
}
function getQueryParams() {
var param = {
fromUid: $('#fromUid').val(),
toUid: $('#toUid').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val(),
detailStartTime: $('#detailStartTime').val(),
detailEndTime: $('#detailEndTime').val(),
};
return param;
}
// 导出
$('#btnExport').on('click', function () {
window.location.href = `/admin/userChatMsgRecord/export?${param(getQueryParams())}`;
$("#detailModal").modal('hide');
})
var detailPicker1 = $("#detailStartTime").datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
todayBtn: true,
autoclose: true,
});
var detailPicker2 = $("#detailEndTime").datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
todayBtn: true,
autoclose: true
});
detailPicker1.on('changeDate', function () {
var date = $('#detailStartTime').datetimepicker('getDate');
detailPicker2.datetimepicker('setStartDate', date);
});
detailPicker2.on('changeDate', function () {
var date = $('#detailEndTime').datetimepicker('getDate');
detailPicker1.datetimepicker('setEndDate', date);
});
});
});
}
},
};
</script>
<style scoped></style>