Files
peko-admin-web/src/views/room/RoomSearchAdminView.vue

1361 lines
47 KiB
Vue
Raw Normal View History

2023-09-25 22:05:31 +08:00
<template>
2024-10-21 14:50:11 +08:00
<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">
<div class="col-sm-12">
<label for="erbanNo"
class="col-sm-1 control-label">平台号:</label>
<div class="col-sm-2">
<input type="text"
name="erbanNo"
id="erbanNo"
placeholder="请输入平台号"
class="form-control">
</div>
2024-10-21 14:50:11 +08:00
<label for="sort"
class="col-sm-1 control-label">排序:</label>
<div class="col-sm-2">
<select name="sort"
id="sort"
class="form-control">
<option value="0">默认</option>
<option value="1">创建时间</option>
</select>
</div>
2024-10-21 14:50:11 +08:00
<label for="roomPermitType"
class="col-sm-1 control-label">房间类型:</label>
<div class="col-sm-2">
<select name="roomPermitType"
id="roomPermitType"
class="form-control">
<option value="0"></option>
<option value="1">牌照房</option>
<option value="2">非牌照房</option>
<option value="4">个播房</option>
</select>
</div>
2024-10-21 14:50:11 +08:00
<label for="partitionId"
class="col-sm-1 control-label">地区:</label>
<div class="col-sm-2">
<select name="partitionId"
id="partitionId"
class="form-control"></select>
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
<button id="btnSearch"
class="btn btn-sm btn-primary">查询</button>
</div>
</section>
</div>
</div>
</section>
<div class="modal fade"
id="robotModal"
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">x</span></button>
<h4 class="modal-title"
id="robotModalLabel">机器人管理</h4>
<h5 id="robotUsingNum">当前房间机器人配置数量</h5>
<h5 id="robotOnlineNum">当前房间机器人在线数量</h5>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
<div class="modal-body">
<form id="editRobot"
class="form-horizontal">
人数: <input type="text"
name="count"
id="addRobotCount" /><span style="color: red;">(人数不能超过100)</span>
<input type="hidden"
name="uid"
id="addRobotUid" />
</form>
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-primary"
id="robot-sync">同步房间机器人</button>
<button type="button"
class="btn btn-primary"
id="robot-save">新增</button>
<button type="button"
class="btn btn-primary"
id="robot-remove">移除</button>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
<div class="modal fade"
id="roomTypeModal"
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">x</span></button>
<h4 class="modal-title"
id="roomTypeModalLabel">房间类型管理</h4>
</div>
<div class="modal-body">
<form id="roomType"
class="form-horizontal">
房间类型:
<select id="permitType"
name="permitType"
class="form-control"
data-btn-class="btn-warning">
<option value="1">牌照房</option>
<option value="2">普通房</option>
<option value="4">个播房</option>
</select>
<input type="hidden"
name="uid"
id="roomTypeUid" />
</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="room-type-update">保存</button>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
<div class="modal fade"
id="editModal"
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">x</span></button>
<h4 class="modal-title"
id="editModalLabel">修改房间信息</h4>
</div>
<div class="modal-body">
<form id="editRoom"
class="form-horizontal">
<input type="hidden"
name="uid"
id="uid">
<div class="form-group">
<label for="tag"
class="col-sm-3 control-label">标签:</label>
<div class="col-sm-8 control-label">
<select name="tag"
id="tag"
class="col-sm-5">
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
</select>
</div>
</div>
<div class="form-group"
id="close_single_sort">
<label for="sortId"
class="col-sm-3 control-label">房间分类:</label>
<div class="col-sm-8 control-label">
<select name="sortId"
id="sortId"
class="col-sm-5">
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
</select>
</div>
</div>
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
<div class="form-group">
<label class="col-sm-3 control-label">角标图:</label>
<div class="col-sm-8">
<img src=""
id="addImgUrl"
style="width:70px;height:20px;"
alt="">
<input type="file"
id="addUploadFile"
name="uploadBadge"
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
<button class="btn btn-success"
type="button"
id="uploadBtn">上传</button>
<input type="hidden"
id="badge"
name="badge"
class="form-control" />
<a href="javascript:void(0)"
id="removeBadge">下角标</a>
</div>
</div>
2024-10-28 12:13:22 +08:00
<div class="form-group">
<label class="col-sm-3 control-label">头像:</label>
<div class="col-sm-8">
<img src=""
id="addAvatarImg"
style="width:60px;height:90px"
alt="">
<input type="file"
id="addAvatar"
name="uploadAvatar"
accept="image/gif,image/jpeg,image/jpg,image/png">
<button class="btn btn-success"
type="button"
id="uploadAvatar">上传</button>
<input type="hidden"
id="avatar"
name="avatar"
class="form-control" />
<a href="javascript:void(0)"
id="removeAvatar">去除头像</a>
</div>
</div>
2024-10-21 14:50:11 +08:00
<div class="form-group">
<label class="col-sm-3 control-label">房间背景图:</label>
<div class="col-sm-8">
<img src=""
id="addBackPic"
style="width:60px;height:90px"
alt="">
<input type="file"
id="addBackground"
name="uploadBackground"
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
<button class="btn btn-success"
type="button"
id="uploadBtn2">上传</button>
<input type="hidden"
id="backPic"
name="backPic"
class="form-control" />
<a href="javascript:void(0)"
id="removeBackground">去除背景</a>
</div>
</div>
2023-09-25 22:05:31 +08:00
2024-10-28 12:13:22 +08:00
<!-- <div class="form-group">
2024-10-21 14:50:11 +08:00
<label class="col-sm-3 control-label">是否有龙珠游戏:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="hasDragonGame"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="hasDragonGame"
value="1" /></label>
</div>
2024-10-28 12:13:22 +08:00
</div> -->
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
<div class="form-group">
<label class="col-sm-3 control-label">是否开启纯净模式:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="isPureMode"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="isPureMode"
value="1" /></label>
</div>
</div>
2023-09-25 22:05:31 +08:00
2024-10-28 12:13:22 +08:00
<!-- <div class="form-group"
2024-10-21 14:50:11 +08:00
id="close_box_group">
<label class="col-sm-3 control-label">是否关闭转盘入口:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="closeBox"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="closeBox"
value="1" /></label>
</div>
2024-10-28 12:13:22 +08:00
</div> -->
<!-- <div class="form-group">
2024-10-21 14:50:11 +08:00
<label class="col-sm-3 control-label">是否有KTV权限:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="hasKTVPriv"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="hasKTVPriv"
value="1" /></label>
</div>
2024-10-28 12:13:22 +08:00
</div> -->
2024-10-21 14:50:11 +08:00
<div class="form-group">
<label class="col-sm-3 control-label">是否有相亲房权限:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="hasBlindDateRoomPri"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="hasBlindDateRoomPri"
value="1" /></label>
</div>
</div>
2023-09-25 22:05:31 +08:00
2024-10-28 12:13:22 +08:00
<!-- <div class="form-group"
2024-10-21 14:50:11 +08:00
id="close_recommend">
<label class="col-sm-3 control-label">是否设置为卡片推荐位:</label>
<div class="col-sm-8">
<label class="radio-inline"><input type="radio"
name="recommendStatus"
value="0" /></label>
<label class="radio-inline"><input type="radio"
name="recommendStatus"
value="1" /></label>
</div>
2024-10-28 12:13:22 +08:00
</div> -->
2024-10-21 14:50:11 +08:00
</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="save">保存</button>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
<div class="modal fade"
id="editRoomTitleModal"
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">x</span></button>
<h4 class="modal-title"
id="editRoomTitleModalLabel">修改房间标题</h4>
</div>
<div class="modal-body">
<form id="editRoomTitleForm"
class="form-horizontal">
<input type="hidden"
name="uid"
id="editRoomTitleUid">
<input type="hidden"
name="erbanId"
id="erbanId">
<div class="form-group">
<label for="titleInput"
class="col-sm-2 control-label">标题:</label>
<div class="col-sm-10">
<input type="text"
class="form-control validate[required]"
name="title"
id="titleInput">
<button class="btn btn-warning pull-left"
type="button"
id="default_title">恢复默认</button>
</div>
<div class="col-sm-10">
<div id="msgDiv"
style="color: #ee0101;float: right">
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
</div>
<div class="form-group">
<label for="modal-roomDesc"
class="col-sm-2 control-label">公告标题:</label>
<div class="col-sm-10">
<input type="text"
class="form-control"
name="roomDesc"
id="modal-roomDesc"
placeholder="公告标题仅限输入15字">
<button class="clear-content"
id="clear-roomDesc"
type="button">清空</button>
</div>
</div>
<div class="form-group">
<label for="modal-roomDesc"
class="col-sm-2 control-label">公告内容:</label>
<div class="col-sm-10">
<textarea type=""
class="form-control"
name="introduction"
id="modal-introduction"
placeholder="公告内容仅限输入300字"></textarea>
<button class="clear-content"
id="clear-introduction"
type="button">清空</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否发送通知:</label>
<div class="col-sm-9">
<label class="radio-inline"><input type="radio"
name="sendMsg"
id="needSend"
value="1"
checked></label>
<label class="radio-inline"><input type="radio"
name="sendMsg"
id="notSend"
value="0"></label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"> </label>
<div class="col-sm-9"
id="msgContentDiv">
<textarea type="text"
class="form-control"
name="msgContent"
id="msgContent"
maxlength="100"
placeholder="请填写通知书内容100字符内"></textarea>
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</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="saveRoomTitle">保存</button>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
2023-09-25 22:05:31 +08:00
</div>
2024-10-21 14:50:11 +08:00
</div>
2023-09-25 22:05:31 +08:00
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
2024-04-09 19:05:17 +08:00
import { getPartitionInfoList } from '@/api/partition/partitionInfo';
import { buildSelectOption } from '@/utils/system-helper';
2023-09-25 22:05:31 +08:00
export default {
2024-10-21 14:50:11 +08:00
name: "RoomSearchAdminView",
setup () {
return {};
},
created () {
this.$nextTick(function () {
this.initPartition();
this.initData();
});
},
methods: {
initData () {
$(function () {
//选择select时触发
$("#sendDays").change(function () {
var val = $(this).val();
if (val == "999") {
$('.sortId').show();
} else {
$('.sortId').hide();
$('.sortId input').val('');
}
2023-09-25 22:05:31 +08:00
});
2024-10-21 14:50:11 +08:00
$('#table').bootstrapTable('destroy');
getRoomTag();
getSingleRoomSort();
$('#table').bootstrapTable({
cache: false,
striped: true,
showRefresh: false,
pageSize: 10,
pagination: true,
pageList: [10, 20, 30, 50],
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams (params) { //设置查询参数
var param = {
pageSize: params.pageSize,
pageNumber: params.pageNumber,
sort: $('#sort').val(),
roomPermitType: $('#roomPermitType').val(),
erbanNo: $('#erbanNo').val(),
partitionId: $('#partitionId').val(),
};
return param;
},
uniqueId: 'erbanNo',
toolbar: '#toolbar',
url: '/admin/roomAdmin/getAll',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
},
columns: [
{ field: 'room.uid', title: 'Uid', align: 'center', valign: 'middle' },
{ field: 'erbanNo', title: '平台号', align: 'center', valign: 'middle' },
{ field: 'room.title', title: '标题', align: 'center', valign: 'middle' },
{ field: 'partitionDesc', title: '地区', align: 'center', valign: 'middle' },
{
field: 'room.avatar',
title: '房间头像',
align: 'center',
valign: 'middle',
width: '5%',
formatter: function (val, row, index) {
2024-10-28 12:13:22 +08:00
if ('' == val || undefined == val || null == val) {
return '';
}
2024-10-21 14:50:11 +08:00
return "<img src='" + val + "' width='40' height='40'>"
+ (row.isReview ? "<br>审核中" : "");
}
},
{ field: 'room.roomPwd', title: '房间密码', align: 'center', valign: 'middle' },
{ field: 'room.roomTag', title: '房间标签', align: 'center', valign: 'middle' },
{
field: 'room.badge',
title: '角标',
align: 'center',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
return "<img src='" + val + "' width='60' height='20'>";
} else {
return '-';
}
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
}
},
{
field: 'room.type',
title: '房间类型',
align: 'center',
valign: 'middle',
width: '5%',
formatter: function (val, row, index) {
switch (val) {
case 3:
return '普通房间';
case 6:
return '个播房间';
case 7:
return '游戏房间';
case 8:
return '聚会房间';
case 9:
return '狂欢房间';
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
}
}
},
{
field: 'room.backPic',
title: '房间背景',
align: 'center',
valign: 'middle',
width: '5%',
formatter: function (val, row, index) {
if (val) {
return "<img src='" + val + "' width='60' height='100'>";
} else {
return '-';
}
}
},
{
field: 'room.isPermitRoom',
title: '牌照类型',
align: 'center',
valign: 'middle',
formatter: function (val, row, index) {
switch (val) {
case 1:
return '牌照房';
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
case 2:
return '非牌照房';
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
case 4:
return '个播房';
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
}
}
},
{
field: 'room.createTime',
title: '创建时间',
align: 'center',
valign: 'middle',
width: '10%',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
{
field: 'room.canShow',
title: '展示状态',
align: 'center',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
return '展示';
} else {
return '不展示';
}
}
},
2024-10-28 12:13:22 +08:00
// {
// field: 'room.hasDragonGame',
// title: '龙珠游戏',
// align: 'center',
// valign: 'middle',
// formatter: function (val, row, index) {
// if (val) {
// return '有';
// } else {
// return '没有';
// }
// }
// },
// {
// field: 'room.hasKTVPriv',
// title: 'KTV权限',
// align: 'center',
// valign: 'middle',
// formatter: function (val, row, index) {
// if (val) {
// return '有';
// } else {
// return '没有';
// }
// }
// },
2024-10-21 14:50:11 +08:00
{
field: 'room.canOpenBlindDate',
title: '相亲房权限',
align: 'center',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
return '有';
} else {
return '没有';
}
}
},
{
field: 'tmp',
title: '操作',
align: 'center',
width: '12%',
valign: 'middle',
formatter: function (val, row, index) {
var key = row.erbanNo;
var canShow = row.room.canShow;
var str = "<button class='btn btn-sm btn-success opt-edit' style='margin-right: 4px;' data-id=" + key + ">编辑</button>";
if (canShow) {
str += "<button class='btn btn-sm btn-warning opt-show' data-id=" + key + ">不显示</button>";
} else {
str += "<button class='btn btn-sm btn-success opt-show' data-id=" + key + ">显示</button>";
}
str += "<button class='btn btn-sm btn-success opt-set-room' data-id=" + key + ">设为房间类型</button>";
str += "<button class='btn btn-sm btn-success opt-set-room-title' data-id=" + key + ">设置房间标题公告</button>";
str += "<button class='btn btn-sm btn-success opt-add-robot' data-id=" + key + ">机器人管理</button>";
str += "<button class='btn btn-sm btn-success opt-update-onlinenum' data-id=" + key + ">同步房间人数</button>";
return str;
}
}
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
]
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$("#table").on('click', '.opt-set-room', function () {
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
$("#roomTypeUid").val(data.room.uid);
$('#permitType').val(data.room.isPermitRoom);
$("#roomTypeModal").modal('show');
});
2024-05-17 10:56:39 +08:00
2024-10-21 14:50:11 +08:00
$('#clear-roomDesc').on('click', function () {
$('#modal-roomDesc').val('');
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#clear-introduction').on('click', function () {
$('#modal-introduction').val('');
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#table').on('click', '.opt-add-robot', function () {
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
$("#addRobotUid").val(data.room.uid);
$("#addRobotCount").val('');
$("#robotModal").modal('show');
// 查询房间机器人配置数量和在线数量
getRoomRobotNum();
getOnlineRobotNum();
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#robot-save').on('click', function () {
if ($('#editRobot').validationEngine('validate')) {
if ($("#addRobotCount").val() > 100) {
alert('人数不能超过100');
return;
}
$.ajax({
type: 'post',
url: '/admin/roomAdmin/addRobot',
dataType: 'json',
data: {
uid: $('#addRobotUid').val(),
count: $('#addRobotCount').val()
},
success: function (res) {
if (res.code == 200) {
$("#robotModal").modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
} else {
$("#tipMsg").text("保存失败,错误码:" + res.code + res.message);
$("#tipModal").modal('show');
}
}
})
}
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
// 同步机器人
$('#robot-sync').on('click', function () {
$.ajax({
type: 'get',
url: '/admin/roomAdmin/syncRobot',
dataType: 'json',
data: {
uid: $('#addRobotUid').val(),
},
success: function (res) {
if (res.code == 200) {
$("#robotModal").modal('hide');
$("#tipMsg").text("同步成功");
$("#tipModal").modal('show');
} else {
$("#tipMsg").text("同步失败,错误码:" + res.code + res.message);
$("#tipModal").modal('show');
}
}
})
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$("#room-type-update").on('click', function () {
if ($('#roomPermitType').validationEngine('validate')) {
let roomUid = $('#roomTypeUid').val();
let permitType = $('#permitType').val();
let roomType = 3;
//牌照房
if (permitType == 1) {
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
// 普通房
} else if (permitType == 2) {
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
// 个播房
} else if (permitType == 4) {
roomType = 6;
}
$.ajax({
type: 'post',
url: '/admin/roomAdmin/resetRoom',
dataType: 'json',
data: {
uid: roomUid,
roomType: roomType,
permitType: permitType,
},
success: function (res) {
if (res.code == 200) {
$("#roomTypeModal").modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("保存失败,错误码:" + res.code + ",错误信息:" + res.message);
$("#tipModal").modal('show');
}
}
})
}
});
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#robot-remove').on('click', function () {
if ($('#editRobot').validationEngine('validate')) {
$.ajax({
type: 'post',
url: '/admin/roomAdmin/removeRobot',
dataType: 'json',
data: {
uid: $('#addRobotUid').val(),
count: $('#addRobotCount').val()
},
success: function (res) {
if (res.code == 200) {
$("#robotModal").modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
} else {
$("#tipMsg").text("保存失败,错误码:" + res.code);
$("#tipModal").modal('show');
2023-09-25 22:05:31 +08:00
}
2024-10-21 14:50:11 +08:00
}
})
}
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#table').on('click', '.opt-edit', function () {
cleanModal();
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
$.ajax({
type: 'post',
url: '/admin/single/room/sort/getSingRoomSortRecommend',
dataType: 'json',
data: {
roomUid: data.room.uid,
},
success: function (res) {
var recommendStatus = parseNum(res)
console.log("recommendStatus", recommendStatus)
$("input:radio[name='recommendStatus']")[recommendStatus].checked = true;
}
})
// 仅个播房展示
if (data.room.isPermitRoom == 4) {
$('#close_recommend').show();
$('#close_single_sort').show();
} else {
$('#close_recommend').hide();
$('#close_single_sort').hide();
}
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
//纯净模式隐藏砸蛋设置
if (data.room.isPureMode) {
$('#close_box_group').hide();
} else {
$('#close_box_group').show();
}
$('#uid').val(data.room.uid);
if (data.room.tagId) {
$('#tag').val(data.room.tagId);
} else {
$('#tag').val(8);
}
if (data.room.singleRoomSortId) {
$('#sortId').val(data.room.singleRoomSortId);
} else {
$('#sortId').val(999);
}
if (data.room.badge) {
$('#badge').val(data.room.badge);
$('#addImgUrl').attr('src', data.room.badge);
}
2024-10-28 12:13:22 +08:00
if (data.room.avatar) {
$('#avatar').val(data.room.avatar);
$('#addAvatarImg').attr('src', data.room.avatar);
}
2024-10-21 14:50:11 +08:00
if (data.room.backPic) {
$('#backPic').val(data.room.backPic);
$('#addBackPic').attr('src', data.room.backPic);
}
2024-10-28 12:13:22 +08:00
//var hasDragonGame = parseNum(data.room.hasDragonGame);
//$("input:radio[name='hasDragonGame']")[hasDragonGame].checked = true;
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
var isPureMode = parseNum(data.room.isPureMode);
console.log("isPureMode", isPureMode)
$("input:radio[name='isPureMode']")[isPureMode].checked = true;
2023-09-25 22:05:31 +08:00
2024-10-28 12:13:22 +08:00
//var closeBox = parseNum(data.room.closeBox);
//$("input:radio[name='closeBox']")[closeBox].checked = true;
2023-09-25 22:05:31 +08:00
2024-10-28 12:13:22 +08:00
//var hasKTVPriv = parseNum(data.room.hasKTVPriv);
//$("input:radio[name='hasKTVPriv']")[hasKTVPriv].checked = true;
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
var hasBlindDateRoomPri = parseNum(data.room.canOpenBlindDate);
$("input:radio[name='hasBlindDateRoomPri']")[hasBlindDateRoomPri].checked = true;
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#editModal').modal('show');
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
function parseNum (val) {
if (val == undefined || val == 'false' || val == 0) {
return 0;
}
else {
return 1;
}
}
$('#table').on('click', '.opt-show', function () {
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
var status = (data.room.canShow) ? 0 : 1;
$.ajax({
type: 'post',
url: '/admin/roomAdmin/changeRoomStatus',
data: {
status: status,
uid: data.room.uid
},
dataType: 'json',
success: function (res) {
if (res.code == 200) {
$("#tipMsg").text("修改状态成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("修改失败,错误码:" + res.code);
$("#tipModal").modal('show');
}
}
})
});
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$("#table").on("click", '.opt-update-onlinenum', function () {
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined') {
$("#tipMsg").text("参数有误");
$("#tipModal").modal('show');
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
if (confirm("你确认同步吗?")) {
$.ajax({
type: 'post',
url: '/admin/roomAdmin/roomOnlineNum/update',
data: {
uid: data.room.uid
},
dataType: 'json',
success: function (json) {
if (json.success == 'true') {
$("#tipMsg").text("同步成功");
$("#tipModal").modal('show');
//TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("同步失败,错误码:" + json.msg);
$("#tipModal").modal('show');
2023-09-25 22:05:31 +08:00
}
2024-10-21 14:50:11 +08:00
}
2023-09-25 22:05:31 +08:00
});
2024-10-21 14:50:11 +08:00
}
});
$("#table").on('click', '.opt-set-new-room', function () {
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
$.ajax({
type: 'post',
url: '/admin/roomAdmin/resetNewRoom',
data: {
uid: data.room.uid
},
dataType: 'json',
success: function (res) {
if (res.code == 200) {
$("#tipMsg").text("修改状态成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("修改失败,错误码:" + res.code);
$("#tipModal").modal('show');
}
}
})
});
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
})
$('#uploadBtn').on('click', function () {
var options = {
type: 'post',
2024-10-28 12:13:22 +08:00
url: '/admin/roomAdmin/uploadBadge',
2024-10-21 14:50:11 +08:00
dataType: 'json',
success: function (json) {
if (json.path) {
$('#badge').val(json.path);
$('#addImgUrl').attr("src", json.path);
console.log(json.path);
} else {
$("#tipMsg").text(json.msg);
$("#tipModal").modal('show');
}
}
}
$("#editRoom").ajaxSubmit(options);
})
$('#uploadBtn2').on('click', function () {
var options = {
type: 'post',
2024-10-28 12:13:22 +08:00
url: '/admin/roomAdmin/uploadBackground',
2024-10-21 14:50:11 +08:00
dataType: 'json',
success: function (json) {
if (json.path) {
$('#backPic').val(json.path);
$('#addBackPic').attr("src", json.path);
console.log(json.path);
} else {
$("#tipMsg").text(json.msg);
$("#tipModal").modal('show');
}
}
}
$("#editRoom").ajaxSubmit(options);
})
2024-10-28 12:13:22 +08:00
$('#uploadAvatar').on('click', function () {
var options = {
type: 'post',
url: '/admin/roomAdmin/uploadAvatar',
dataType: 'json',
success: function (json) {
if (json.path) {
$('#avatar').val(json.path);
$('#addAvatarImg').attr("src", json.path);
console.log(json.path);
} else {
$("#tipMsg").text(json.msg);
$("#tipModal").modal('show');
}
}
}
$("#editRoom").ajaxSubmit(options);
})
2024-10-21 14:50:11 +08:00
$('#save').on('click', function () {
if ($('#editRoom').validationEngine('validate')) {
$.ajax({
type: 'post',
url: '/admin/roomAdmin/saveRoom',
dataType: 'json',
data: {
uid: $('#uid').val(),
tagId: $('#tag').val(),
singleRoomSortId: $('#sortId').val(),
badge: $('#badge').val(),
2024-10-28 12:13:22 +08:00
avatar: $('#avatar').val(),
2024-10-21 14:50:11 +08:00
backPic: $('#backPic').val(),
2024-10-28 12:13:22 +08:00
//hasDragonGame: $("input[name='hasDragonGame']:checked").val(),
2024-10-21 14:50:11 +08:00
isPureMode: $("input[name='isPureMode']:checked").val(),
2024-10-28 12:13:22 +08:00
//hasKTVPriv: $("input[name='hasKTVPriv']:checked").val(),
2024-10-21 14:50:11 +08:00
hasBlindDateRoomPri: $("input[name='hasBlindDateRoomPri']:checked").val(),
2024-10-28 12:13:22 +08:00
//closeBox: $("input[name='closeBox']:checked").val(),
//recommendStatus: $("input[name='recommendStatus']:checked").val(),
2024-10-21 14:50:11 +08:00
},
success: function (res) {
if (res.code == 200) {
$("#editModal").modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
2023-09-25 22:05:31 +08:00
} else {
2024-10-21 14:50:11 +08:00
$("#tipMsg").text("保存失败,错误码:" + res.code);
$("#tipModal").modal('show');
2023-09-25 22:05:31 +08:00
}
2024-10-21 14:50:11 +08:00
}
})
}
})
$('#removeBadge').on('click', function () {
$('#addImgUrl').attr('src', '');
$('#addUploadFile').val('');
$('#badge').val('');
})
2024-10-28 12:13:22 +08:00
$('#removeAvatar').on('click', function () {
$('#addAvatarImg').attr('src', '');
$('#avatar').val('');
$('#addAvatar').val('');
})
2024-10-21 14:50:11 +08:00
$('#removeBackground').on('click', function () {
$('#addBackPic').attr('src', '');
$('#backPic').val('');
$('#addBackground').val('');
})
function cleanModal () {
$('#uid').val('');
$('#tag').val('');
$('#sortId').val('');
$('#badge').val('');
$('#addUploadFile').val('');
$('#addImgUrl').attr('src', '');
$('#addBackPic').attr('src', '');
$('#backPic').val('');
$('#addBackground').val('');
}
function getRoomTag () {
$.ajax({
type: 'GET',
url: '/admin/roomAdmin/getRoomTags',
dataType: 'json',
success: function (res) {
var data = res.data;
var $select = $('#editModal #tag');
for (var i = 0; i < data.length; i++) {
var $option = $('<option />');
$option.html(data[i].name);
$option.attr('value', data[i].id);
$select.append($option);
}
$select.append($('<option value="">其他</option>'));
}
})
}
function getSingleRoomSort () {
$.ajax({
type: 'GET',
url: '/admin/single/room/sort/sortList',
dataType: 'json',
success: function (res) {
var data = res.data;
var $select = $('#editModal #sortId');
for (var i = 0; i < data.length; i++) {
var $option = $('<option />');
$option.html(data[i].sortName);
$option.attr('value', data[i].id);
$select.append($option);
}
$select.append($('<option value="">推荐(默认)</option>'));
}
})
}
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('input[name="sendMsg"]').change(function () {
if ($("#needSend").is(":checked")) {
$('#msgContentDiv').show();
} else if ($("#notSend").is(":checked")) {
$('#msgContentDiv').hide();
}
});
})
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#table').on('click', '.opt-set-room-title', function () {
$("#erbanId").val($(this).data('id'));
$('#editRoomTitleUid').val('');
$('#titleInput').val('');
var erbanNo = $(this).data('id');
if (erbanNo == 'undefined' || !erbanNo) {
return;
}
var data = $('#table').bootstrapTable('getRowByUniqueId', erbanNo);
$('#editRoomTitleUid').val(data.room.uid);
$('#titleInput').val(data.room.title);
$('#modal-roomDesc').val(data.room.roomDesc);
$('#modal-introduction').val(data.room.introduction);
$("#needSend").prop("checked", true);
$('#msgContent').val('');
$('#msgContentDiv').show();
2023-09-25 22:05:31 +08:00
2024-10-21 14:50:11 +08:00
$('#editRoomTitleModal').modal('show');
})
$("#saveRoomTitle").on('click', function () {
if ($('#modal-roomDesc').val().length > 15) {
$("#tipMsg").text("公告标题仅限输入15字");
$("#tipModal").modal('show');
return;
}
if ($('#modal-introduction').val().length > 300) {
$("#tipMsg").text("公告内容仅限输入300字");
$("#tipModal").modal('show');
return;
}
var sendMsg = $('input[name="sendMsg"]:checked').val();
if (sendMsg == 1 && !$("#msgContent").val()) {
$("#tipMsg").text("请填写通知内容");
$("#tipModal").modal('show');
return;
}
if ($('#editRoomTitleForm').validationEngine('validate')) {
$.ajax({
type: 'post',
url: '/admin/roomAdmin/resetRoomTitle',
dataType: 'json',
data: {
uid: $('#editRoomTitleUid').val(),
title: $('#titleInput').val(),
roomDesc: $('#modal-roomDesc').val(),
introduction: $('#modal-introduction').val(),
msg: $('#msgContent').val(),
sendMsg: sendMsg
},
success: function (res) {
if (res.code == 200) {
$("#editRoomTitleModal").modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("保存失败," + res.message);
$("#tipModal").modal('show');
}
}
})
}
});
$("#titleInput").bind('input propertychange', function () {
if ($('#titleInput').val().length > 15) {
$('#msgDiv').html("不能超过15个字");
} else {
$('#msgDiv').html("");
}
});
$("input[name=isPureMode]").click(function () {
switch ($(this).val()) {
case "0":
$('#close_box_group').show();
break;
case "1":
$('#close_box_group').hide();
break;
default:
break;
}
});
$('#default_title').on('click', function () {
var erbanNo = $("#erbanId").val();
$.ajax({
type: "post",
url: "/admin/roomAdmin/getDefaultRoomTitle",
data: {
erbanNo: erbanNo
},
dataType: 'json',
success: function (res) {
if (res.code == 200) {
$("#titleInput").val(res.data);
}
}
})
})
},
initPartition () {
getPartitionInfoList().then(res => {
let data = res.data;
buildSelectOption(
"#partitionId",
null,
[{
value: '',
text: '全部',
}].concat(data.map((v) => {
return {
value: v.id,
text: v.desc,
};
}))
);
});
2023-09-25 22:05:31 +08:00
},
2024-10-21 14:50:11 +08:00
},
2023-11-14 17:59:51 +08:00
2023-09-25 22:05:31 +08:00
};
// 通过接口获取所有房间配置机器人数量
2024-10-21 14:50:11 +08:00
function getRoomRobotNum () {
$.ajax({
url: "/admin/roomAdmin/roomRobotNum", //后台controller中的请求路径
type: 'GET',
data: {
uid: $('#addRobotUid').val(),
},
datatype: 'json',
success: function (res) {
console.log(res);
if (res) {
$("#robotUsingNum").html('当前房间机器人配置数量:' + res.data);
}
},
error: function () {
alert('查询房间机器人配置数量出错');
}
});
2023-09-25 22:05:31 +08:00
}
// 通过接口获取房间在线机器人数量
2024-10-21 14:50:11 +08:00
function getOnlineRobotNum () {
$.ajax({
url: "/admin/roomAdmin/countRobot", //后台controller中的请求路径
type: 'GET',
data: {
uid: $('#addRobotUid').val(),
},
datatype: 'json',
success: function (res) {
console.log(res);
if (res) {
$("#robotOnlineNum").html('当前房间机器人在线数量:' + res.data);
}
},
error: function () {
alert('查询房间在线机器人数量出错');
}
});
2023-09-25 22:05:31 +08:00
}
</script>
<style scoped>
#removeBadge {
2024-10-21 14:50:11 +08:00
margin-left: 10px;
2023-09-25 22:05:31 +08:00
}
</style>