Files
peko-admin-web/src/views/firstpage/RecommendRoomAdminView.vue
2023-11-14 18:00:42 +08:00

339 lines
15 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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">
<label for="erban_no" class="qry_col control-label">平台号:</label>
<div class="col-sm-2"><input type="text" class="form-control" name="erbanNo" id="erban_no"></div>
<label for="label_type" class="qry_col control-label">标签分类:</label>
<div class="col-sm-2"><select name="status" id="label_type" class="form-control"
data-btn-class="btn-warning">
<option value="" selected="selected">全部</option>
<option value="1"></option>
<option value="2"></option>
</select>
</div>
<label for="status" class="qry_col control-label">状态:</label>
<div class="col-sm-2"><select name="status" id="status" class="form-control"
data-btn-class="btn-warning">
<option value="" selected="selected">全部</option>
<option value="1">待推荐</option>
<option value="2">推荐中</option>
<option value="3">已失效</option>
</select></div>
</div>
<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="recommendModal" 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">
<div class="form-group">
<label for="erbanNo" class="col-sm-2 control-label">平台号:</label>
<div class="col-sm-10">
<input type="text" class="form-control validate[required]" name="erbanNo" id="erbanNo">
</div>
</div>
<div class="form-group">
<label for="labelType" class="col-sm-2 control-label">标签分类</label>
<div class="col-sm-10">
<select name="labelType" class="form-control" id="labelType">
<option value="1"></option>
<option value="2"></option>
</select>
</div>
</div>
<div class="form-group">
<label for="seqNo" class="col-sm-2 control-label">排序</label>
<div class="col-sm-10">
<input type="text" class="form-control validate[required]" name="seqNo" id="seqNo">
</div>
<span style="padding-left: 120px">*必填!数字小的排前面相同推荐时间内不可重复</span>
</div>
<div class="form-group">
<label for="startTime" class="col-sm-2 control-label">开始时间</label>
<div class="col-sm-10">
<input id="startTime" type="text" name="startTime"
class="form-control validate[required]">
</div>
</div>
<div class="form-group">
<label for="endTime" class="col-sm-2 control-label">结束时间</label>
<div class="col-sm-10">
<input id="endTime" type="text" name="endTime"
class="form-control validate[required]">
</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: "RecommendRoomAdminView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
{ field: 'roomUid', title: '房主uid', align: 'center', width: '10%' },
{ field: 'erbanNo', title: '平台号', align: 'center', width: '10%' },
{ field: 'roomTitle', title: '房间标题', align: 'center', width: '15%' },
{
field: 'labelType', title: '标签分类', align: 'center', valign: 'middle', width: '10%',
formatter: function (val, row, index) {
if (val == 1) {
return '男';
} else if (val == 2) {
return '女';
} else {
return '-';
}
}
},
{
field: 'status', title: '列表状态', align: 'center', valign: 'middle', width: '10%',
formatter: function (val, row, index) {
if (val == 1) {
return '待推荐';
} else if (val == 2) {
return '推荐中';
} else {
return '已失效';
}
}
},
{ field: 'seqNo', title: '排序', align: 'center', width: '5%' },
{
field: 'startTime', 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');
} else {
return '-';
}
}
},
{
field: 'endTime', 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');
} else {
return '-';
}
}
},
{
field: 'id',
title: '操作',
align: 'center',
width: '5%',
formatter: function (val, row, index) {
if (row.status != 3) {
return '<button class="btn btn-sm btn-success opt-remove" data-id=' + val + '>' +
'<i class="glyphicon glyphicon-remove"></i>下线</button>';
} else {
return '-';
}
}
}
],
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 = {
pageNum: params.pageNumber,
pageSize: params.pageSize,
erbanNo: $('#erban_no').val(),
status: $('#status').val(),
labelType: $('#label_type').val()
};
return param;
},
toolbar: '#toolbar',
url: '/admin/firstpage/room/recommend/list.action',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
// 查询刷新
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
});
var chargeStart = $('#startTime').datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
autoclose: true,
startDate: new Date()
});
var chargeEnd = $('#endTime').datetimepicker({
format: 'yyyy-mm-dd hh:ii:00',
autoclose: true,
startDate: new Date()
});
//新建标题
$("#btnAdd").click(function () {
$("#erbanNo").val("");
$("#seqNo").val("");
$("#startTime").val("");
$("#endTime").val("");
$("#recommendModal").modal('show');
});
$("#add").click(function () {
var erbanNo = $("#erbanNo").val();
var seqNo = $("#seqNo").val();
var labelType = $("#labelType").val();
var startTime = $("#startTime").val();
var endTime = $("#endTime").val();
if (seqNo <= 0) {
$("#tipMsg").text("请填写合理的排序位置");
$("#tipModal").modal('show');
return;
}
if (endTime <= new Date().format('yyyy-MM-dd hh:mm:ss') || endTime <= startTime) {
$("#tipMsg").text("请选择合理的结束时间");
$("#tipModal").modal('show');
return;
}
if ($("#addForm").validationEngine('validate')) {
$.ajax({
type: "post",
url: "/admin/firstpage/room/recommend/add.action",
data: {
erbanNo: erbanNo,
seqNo: seqNo,
labelType: labelType,
startTime: startTime,
endTime: endTime
},
dataType: "json",
success: function (json) {
if (json.code == 200) {
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
$("#recommendModal").modal('hide');
} else {
$("#tipMsg").text("保存失败,错误信息:" + json.data);
$("#tipModal").modal('show');
//TableHelper.doRefresh("#table");
// $("#recommendModal").modal('hide');
}
}
});
}
});
$("#table").on("click", '.opt-remove', function () {
var id = $(this).attr("data-id");
if (id == 'undefined') {
$("#tipMsg").text("id参数有误");
$("#tipModal").modal('show');
return;
}
if (confirm("你确认下线该房间吗?")) {
$.ajax({
type: 'post',
url: "/admin/firstpage/room/recommend/offline.action",
data: { id: id },
dataType: "json",
success: function (json) {
console.log(json)
if (json.success == 'true') {
$("#tipMsg").text("下线成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("下线失败,错误信息:" + json.msg);
$("#tipModal").modal('show');
}
}
});
}
});
});
}
},
};
</script>
<style scoped>
.qry_col {
float: left;
}</style>