Files
yinmeng-admin-web/src/views/home/ChatpickAdminView.vue
2023-12-27 09:38:31 +08:00

210 lines
9.0 KiB
Vue

<template>
<section class="content">
<div class="box box-primary">
<div class="box-body">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1 id="itemTitle"></h1>
</section>
<div id="toolbar">
<div class="col-sm-12">
<button id="btnSearch" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>查询
</button>
<button id="btnAdd" class="btn btn-default">
<i class="glyphicon glyphicon-plus"></i>增加
</button>
</div>
</div>
</div>
<!-- .content -->
<div id="table"></div>
</div>
</section>
<div class="modal fade" id="roomTagModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<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">&times;</span>
</button>
<h4 class="modal-title" id="modalLabel">一键匹配</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" id="addForm">
<input type="hidden" name="id" id="id" />
<div class="form-group">
<label for="modal_erbanNos" class="col-sm-3 control-label">用户音萌号<font color="red">*</font>
:</label>
<div class="col-sm-9">
<input type="text" class="form-control validate[required]" name="erbanNos"
id="modal_erbanNos" placeholder="">
</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="add">确定</button>
</div>
</div>
</div>
</div>
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
export default {
name: "ChatPickAdminView",
setup() { },
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
var specialRoomTagType = 9;
$(function () {
$('.datetime').datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
autoclose: true
});
$('#table').bootstrapTable('destroy');
// 清空分页组件的容器
$('.fixed-table-pagination').empty();
$('#table').bootstrapTable({
columns: [
{ field: 'erbanNo', title: '音萌号', align: 'center', width: '20%' },
{ field: 'nick', title: '昵称', align: 'center', width: '20%' },
{
field: 'avatar',
title: '头像',
align: 'center',
valign: 'middle',
formatter: function (val, row, index) {
return "<img src='" + val + "' width='40' height='40'>";
}
},
{
field: 'gender', title: '性别', align: 'center', valign: 'middle', width: '20%',
formatter: function (val, row, index) {
if (val == 1) {
return '男'
} else {
return '女'
}
}
},
{ field: 'createTime', title: '配置时间', align: 'center', valign: 'middle', width: '20%', formatter: formatTime },
{
field: 'uid',
title: '操作',
align: 'center',
width: '20%',
formatter: function (val, row, index) {
var text = '';
text += '<button class="btn btn-sm btn-danger opt-remove" data-id=' + val + '>' +
' <i class="glyphicon glyphicon-remove"></i>删除' +
'</button>';
return text;
}
}
],
undefinedText: 0,
cache: false,
striped: true,
showRefresh: false,
pageSize: 20,
pagination: true,
pageList: [20, 50, 100, 200, 300, 500],
search: false,
sidePagination: "server", //表示服务端请求
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
page: params.pageNumber,
pageSize: params.pageSize
};
return param;
},
toolbar: '#toolbar',
url: '/admin/chat/pick/list',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
// 查询刷新
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
});
//新建标签
$("#btnAdd").click(function () {
$("#modal_erbanNo").val("");
$("#roomTagModal").modal('show');
});
$("#add").click(function () {
var erbanNo = $("#modal_erbanNos").val();
$.ajax({
type: "post",
url: "/admin/chat/pick/add?erbanNo=" + erbanNo,
dataType: "json",
success: function (json) {
if (json.code == 200) {
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
$("#roomTagModal").modal('hide');
} else {
$("#tipMsg").text("保存失败." + json.message);
$("#tipModal").modal('show');
}
}
});
});
$("#table").on("click", '.opt-remove', function () {
var id = $(this).attr("data-id");
if (id == 'undefined') {
$("#tipMsg").text("id参数有误");
$("#tipModal").modal('show');
return;
}
if (confirm("你确认删除该记录吗? \r\n 删除后再也不能找回,请谨慎操作!")) {
$.ajax({
type: 'delete',
url: "/admin/chat/pick/del?uid=" + id,
dataType: "json",
success: function (json) {
if (json.code == 200) {
$("#tipMsg").text("删除成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("删除失败");
$("#tipModal").modal('show');
}
}
});
}
});
});
function formatTime(val) {
if (val) {
var date = new Date(val);
return date.format('yyyy-MM-dd hh:mm:ss');
} else {
return '-';
}
}
}
}
};
</script>