588 lines
26 KiB
Vue
588 lines
26 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<div class="box-body">
|
||
<section class="content-header">
|
||
<h1 id="itemTitle"></h1>
|
||
</section>
|
||
<section class="content">
|
||
<div id="table"></div>
|
||
<div id="toolbar">消息类型:<select name="msgType" id="type" class="input-m">
|
||
<option value="0">文本</option>
|
||
<option value="1">图片</option>
|
||
<option value="100">图文</option>
|
||
</select>
|
||
<label for="erbanNum" class="col-sm-2 control-label">平台号:</label>
|
||
<div class="col-sm-3">
|
||
<span><input type="text" class="form-control validate[required]" name="erbanNo"
|
||
id="erbanNum"></span>
|
||
</div>
|
||
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>
|
||
<button id="add" class="btn btn-default">
|
||
<i class="glyphicon glyphicon-plus"></i>增加
|
||
</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<div class="modal fade" id="addSendMessage" tabindex="-1" role="dialog" aria-labelledby="modalLabel2">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||
aria-hidden="true">x</span></button>
|
||
<h4 class="modal-title" id="addModalLabel">新增消息</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form id="addMsgForm" class="form-horizontal">
|
||
<div class="form-group">
|
||
<label for="receiver" class="col-sm-3 control-label">接收者:</label>
|
||
<div class="col-sm-8">
|
||
<select name="receivers" id="receiver" class="col-sm-3">
|
||
<option value=1>所有用户</option>
|
||
<option value=0>指定用户</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="appIdDiv">
|
||
<label for="appId" class="col-sm-3 control-label">渠道:</label>
|
||
<div class="col-sm-8">
|
||
<select name="appId" id="appId" class="col-sm-3">
|
||
<option value="">全部</option>
|
||
<option value="official">安卓官方包</option>
|
||
<option value="google">安卓谷歌包</option>
|
||
<option value="peko_Enterprise">ios企业包</option>
|
||
<option value="youmi_appstore">ios商店包</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="msgType" class="col-sm-3 control-label">消息类型:</label>
|
||
<div class="col-sm-8">
|
||
<select name="msgTypeList" id="msgType" class="col-sm-3">
|
||
<option value="0">文本</option>
|
||
<option value="1">图片</option>
|
||
<option value="100">图文</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="skipUrlDiv">
|
||
<label for="skip" class="col-sm-3 control-label">跳转来源:</label>
|
||
<div class="col-sm-8">
|
||
<select name="skip" id="skip" class="col-sm-3">
|
||
<option value="">无</option>
|
||
<option value="2">跳H5页面</option>
|
||
<option value="1" id="skipRoomType">跳转房间</option>
|
||
</select>
|
||
</div>
|
||
<div class="col-sm-6">
|
||
<input type="text" class="form-control" name="skipUri" id="skipUrlContent">
|
||
</div>
|
||
</div>
|
||
<div class="form-group" id="mmm">
|
||
<label for="aimErbanNo" class="col-sm-3 control-label">请输入指定平台号,多个平台号用逗号隔开:</label>
|
||
<div class="col-sm-8">
|
||
<input class="form-control validate[required]" name="aimErbanNo" id="aimErbanNo">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="nnn">
|
||
<label for="words" class="col-sm-3 control-label">文本:</label>
|
||
<div class="col-sm-8">
|
||
<input class="form-control validate[required]" name="words" id="words">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="ppp">
|
||
<label for="pic" class="col-sm-3 control-label">图片:</label>
|
||
<div class="col-sm-8">
|
||
<img src="" id="imgUrl" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="uploadFile" name="uploadFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="uploadBtn">上传</button>
|
||
<span class="attention">注意:图片尺寸请注意在750*250,选择图片后请点击上传按钮</span>
|
||
<input type="hidden" id="pic" name="pic" class="form-control validate[required]" />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="ooo">
|
||
<label for="wordsAndPic1" class="col-sm-3 control-label">图文:</label>
|
||
<div class="col-sm-8">
|
||
标题:<input class="form-control validate[required]" name="title" id="title">
|
||
内容:<input class="form-control validate[required]" name="desc" id="desc">
|
||
<!--封面图-->
|
||
<img src="" id="imgUrl1" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="uploadFile1" name="uploadFile"
|
||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
|
||
<button class="btn btn-success" type="button" id="uploadBtn1">上传</button>
|
||
封面图:<span class="attention">尺寸小于750*250,选择图片后请点击上传按钮</span>
|
||
<input type="hidden" id="wordsAndPic1" name="wordsAndPic1"
|
||
class="form-control validate[required]" />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="pushTime" class="col-sm-3 control-label">推送时间(非必填):</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="input-sm form-control datetime" name="pushTime" id="pushTime">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||
<button type="button" class="btn btn-primary" id="addSave">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
|
||
export default {
|
||
name: "MessageAdminView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
$(function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'recordId', title: 'id', align: 'center', valign: 'middle', width: '0%' },
|
||
{ field: 'fromAccid', title: '发送人', align: 'center', valign: 'middle', width: '10%' },
|
||
{ field: 'toAccids', title: '接收人', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'appId', title: 'app', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if ("tutu" == val) {
|
||
return "66";
|
||
} else if ("qingxun" == val) {
|
||
return "66";
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'msgType',
|
||
title: '消息类型',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
switch (val) {
|
||
case 0:
|
||
return '文本';
|
||
|
||
case 1:
|
||
return '图片';
|
||
|
||
case 100:
|
||
return '图文';
|
||
|
||
}
|
||
}
|
||
},
|
||
|
||
{
|
||
field: 'toObjType', title: '指定对象', align: 'center', width: '10%', valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
switch (val) {
|
||
case 1:
|
||
return '所有人';
|
||
|
||
case 0:
|
||
return '指定用户';
|
||
|
||
}
|
||
}
|
||
},
|
||
{ field: 'toErbanNos', title: '指定平台号', align: 'center', width: '10%', valign: 'middle' },
|
||
|
||
{ field: 'title', title: '标题', align: 'center', width: '10%', valign: 'middle' },
|
||
{ field: 'webUrl', title: '点击查看URL', align: 'center', width: '10%', valign: 'middle' },
|
||
{ field: 'picUrl', title: '图片', align: 'center', width: '10%', valign: 'middle' },
|
||
{ field: 'msgDesc', title: '消息内容', align: 'center', width: '10%', valign: 'middle' },
|
||
{
|
||
field: 'skipType', title: '跳转类型', align: 'center', valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
switch (val) {
|
||
case 1:
|
||
return '跳app页面';
|
||
|
||
case 2:
|
||
return '跳聊天室';
|
||
|
||
case 3:
|
||
return '跳h5页面';
|
||
|
||
}
|
||
}
|
||
},
|
||
{ field: 'skipUri', title: '跳转链接', align: 'center', width: '10%', valign: 'middle' },
|
||
{
|
||
field: 'crateTime',
|
||
title: '创建时间',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format("yyyy-MM-dd hh:mm");
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'pushTime',
|
||
title: '发送时间',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format("yyyy-MM-dd hh:mm");
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'pushStatus',
|
||
title: '状态',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
if (val == 0) {
|
||
return '未推送';
|
||
} else if (val == 1) {
|
||
return '已推送';
|
||
} else if (val == 2) {
|
||
return '已撤回';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'tmp',
|
||
title: '操作',
|
||
align: 'center',
|
||
width: '12%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
var key = row.recordId;
|
||
var pushTime = row.pushTime;
|
||
var date = new Date(pushTime);
|
||
let format = date.format("yyyy-MM-dd hh:mm");
|
||
let now = new Date().format("yyyy-MM-dd hh:mm");
|
||
console.log("format: " + format)
|
||
console.log("now: " + now)
|
||
let condition = format > now;
|
||
console.log("condition: " + condition)
|
||
if (condition && row.pushStatus == 0) {
|
||
var str = "<button class='btn btn-sm btn-danger opt-del' data-id=" + key + ">撤销</button>";
|
||
return str;
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
}
|
||
],
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 10,
|
||
pagination: true,
|
||
pageList: [10, 20, 30, 50],
|
||
sidePagination: "server", //表示服务端请求
|
||
queryParamsType: "undefined",
|
||
|
||
|
||
queryParams: function queryParams(params) {
|
||
var param = {
|
||
pageSize: params.pageSize,
|
||
pageNumber: params.pageNumber,
|
||
erbanNOs: $('#erbanNum').val(),
|
||
msgType: $('#type').val()
|
||
};
|
||
return param;
|
||
},
|
||
uniqueId: 'code',
|
||
toolbar: '#toolbar',
|
||
url: '/admin/msgAdmin/getMsgList.action',
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
console.log("load success");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
})
|
||
|
||
/*查询刷新*/
|
||
$('#btnSearch').on('click', function () {
|
||
TableHelper.doRefresh('#table');
|
||
})
|
||
|
||
|
||
|
||
/*保存*/
|
||
$('#addSave').on('click', function () {
|
||
if ($('#addMsgForm').validationEngine('validate')) {
|
||
if ($("#msgType").val() == 100 && ($("#skipUrlContent").val() == undefined || $("#skipUrlContent").val().length <= 0)) {
|
||
alert("未填写跳转链接");
|
||
} else {
|
||
$('#addSave').attr("disabled", true);
|
||
if ($("#msgType").val() == 1) {
|
||
$('#skipUrlContent').val('');
|
||
}
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/messageAdmin/saveMessage.action",
|
||
data: {
|
||
erbanNos: $("#aimErbanNo").val(),
|
||
msgType: $("#msgType").val(),
|
||
toObjType: $('#receiver').val(),
|
||
words: $('#words').val(),
|
||
pic: $('#pic').val(),
|
||
title: $('#title').val(),
|
||
desc: $('#desc').val(),
|
||
picUrl: $('#wordsAndPic1').val(),
|
||
skipType: $('#skip').val(),
|
||
skipContent: $('#skipUrlContent').val(),
|
||
appId: $("#appId").val(),
|
||
pushTime: $("#pushTime").val()
|
||
},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if (data == 1) {
|
||
$('#addSendMessage').modal('hide');
|
||
$("#tipMsg").text("保存成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else if (data == 2) {
|
||
$('#addSendMessage').modal('hide');
|
||
$("#tipMsg").text("您已掉线,请重新登录");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("保存失败,错误码:" + data);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
$('#addSave').attr("disabled", false);
|
||
}
|
||
})
|
||
}
|
||
}
|
||
})
|
||
|
||
// 撤销
|
||
$('#table').on('click', '.opt-del', function () {
|
||
var recordId = $(this).attr("data-id");
|
||
console.log('recordId', recordId)
|
||
|
||
if (recordId == 'undefined' || !recordId) {
|
||
return;
|
||
}
|
||
|
||
if (confirm("确认撤销?")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: "/admin/messageAdmin/recall.action",
|
||
data: JSON.stringify({
|
||
'recordId': recordId
|
||
}),
|
||
dataType: "json",
|
||
contentType: "application/json",
|
||
success: function (res) {
|
||
if (res.code == 200) {
|
||
$("#tipMsg").text("撤销成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("撤销失败,错误码:" + res.code + ", 错误信息: " + res.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
})
|
||
|
||
//增加
|
||
$('#add').on('click', function () {
|
||
clear();
|
||
$('#addMsgForm')[0].reset();
|
||
$("#skipUrlDiv").show();
|
||
$('#addSendMessage').modal('show');
|
||
$('#addSave').attr("disabled", false);
|
||
|
||
})
|
||
|
||
$(document).ready(function () {
|
||
$("#mmm").hide();
|
||
$("#ppp").hide();
|
||
$("#ooo").hide();
|
||
}
|
||
);
|
||
|
||
$('#receiver').on('change', function (e) {
|
||
var selected = $('#receiver').val();
|
||
if (selected == 1) {
|
||
$("#mmm").hide();
|
||
}
|
||
if (selected == 0) {
|
||
$("#mmm").show();
|
||
$("#appIdDiv").hide();
|
||
$("#appId").val('');
|
||
e.stopPropagation();
|
||
}
|
||
}
|
||
)
|
||
|
||
$('#msgType').on('change', function (e) {
|
||
var msgType = $('#msgType').val();
|
||
if (msgType == 0) {
|
||
$("#skipUrlDiv").show();
|
||
$("#skipRoomType").show();
|
||
$("#nnn").show();
|
||
$("#ppp").hide();
|
||
$("#ooo").hide();
|
||
}
|
||
if (msgType == 1) {
|
||
$("#skipUrlDiv").hide();
|
||
$("#skipUrlDiv").val('');
|
||
$("#skipRoomType").hide();
|
||
$("#ppp").show();
|
||
$("#nnn").hide();
|
||
$("#ooo").hide();
|
||
|
||
}
|
||
if (msgType == 100) {
|
||
$("#skipUrlDiv").show();
|
||
$("#skipRoomType").hide();
|
||
$("#ooo").show();
|
||
$("#ppp").hide();
|
||
$("#nnn").hide();
|
||
e.stopPropagation();
|
||
}
|
||
}
|
||
);
|
||
|
||
|
||
|
||
$('#uploadBtn').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/msg/headimg.action',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#pic').val(json.path);
|
||
$('#imgUrl').attr("src", json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
}
|
||
$("#addMsgForm").ajaxSubmit(options);
|
||
})
|
||
$('#uploadBtn1').on('click', function () {
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/msg/headimg.action',
|
||
dataType: 'json',
|
||
success: function (json) {
|
||
if (json.path) {
|
||
$('#wordsAndPic1').val(json.path);
|
||
$('#imgUrl1').attr('src', json.path);
|
||
console.log(json.path);
|
||
} else {
|
||
$('#tipMsg').text(json.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#addMsgForm').ajaxSubmit(options);
|
||
})
|
||
|
||
$('#pushTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
})
|
||
}
|
||
},
|
||
|
||
};
|
||
|
||
function clear() {
|
||
$('#imgUrl').attr('src', '');
|
||
$('#imgUrl1').attr('src', '');
|
||
$('#imgUrl2').attr('src', '');
|
||
$("#nnn").show();
|
||
$("#mmm").hide();
|
||
$("#ppp").hide();
|
||
$("#ooo").hide();
|
||
$("#appIdDiv").show();
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.bar1,
|
||
.bar2 {
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
label.col-sm-1 {
|
||
padding: 0;
|
||
line-height: 30px;
|
||
text-align: right;
|
||
/*padding-right: 4px;*/
|
||
}
|
||
|
||
label.col-sm-1 {
|
||
padding: 0;
|
||
line-height: 30px;
|
||
text-align: right;
|
||
/*padding-right: 4px;*/
|
||
}
|
||
|
||
input,
|
||
select {
|
||
margin-left: 8px;
|
||
margin-right: 8px;
|
||
}
|
||
|
||
#btnSearch {
|
||
margin-left: 36px;
|
||
}
|
||
|
||
.record {
|
||
margin-top: 10px;
|
||
}
|
||
|
||
.record .title {
|
||
font-size: 16px;
|
||
}
|
||
|
||
#waKaKa {
|
||
display: none;
|
||
}</style> |