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

265 lines
10 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">
<section class="content-header">
<h1 id="itemTitle"></h1>
</section>
<section class="content">
<div id="table"></div>
<div id="toolbar">
平台号:<input type="text" class="input-sm validate[required]" name="erbanNo" id="erbanNum">
<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="addAnchor" 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="addAnchorForm" class="form-horizontal">
<div class="form-group">
<label for="erbanNo" class="col-sm-3 control-label"><span
style="color: red; ">*</span>平台号</label>
<div class="col-sm-8">
<input type="text" class="form-control validate[required]" name="erbanNo" id="erbanNo"
placeholder='多个平台号请用-隔开'>
</div>
</div>
<div class="form-group">
<label for="reason" class="col-sm-3 control-label"><span
style="color: red; ">*</span>原因</label>
<div class="col-sm-8">
<input type="text" class="form-control validate[required]" name="reason" id="reason">
</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: "AnchorAdminView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
{ field: 'uid', title: 'UID', align: 'center', valign: 'middle', visible: false, width: '20%' },
{ field: 'erbanNo', title: '平台号', align: 'center', valign: 'middle', width: '5%' },
{ field: 'nick', title: '昵称', align: 'center', valign: 'middle', width: '5%' },
{
field: 'status',
title: '状态',
align: 'center',
width: '5%',
valign: 'middle',
formatter: function (val, row, index) {
switch (val) {
case 1:
return '白名单';
case 2:
return '非白名单';
}
}
},
{ field: 'operateReason', title: '原因', align: 'center', valign: 'middle', width: '5%' },
{
field: 'operateTime',
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: 'tmp',
title: '操作',
align: 'center',
width: '10%',
valign: 'middle',
formatter: function (val, row, index) {
var key = row.erbanNo;
return "<button class='btn btn-sm btn-success opt-release' data-id=" + key + ">取消</button>&nbsp;&nbsp;";
}
}
],
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,
erbanNo: $('#erbanNum').val()
};
console.log("")
return param;
},
uniqueId: 'erbanNo',
toolbar: '#toolbar',
url: '/admin/anchor/whitelist',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
})
/*查询刷新*/
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
})
/*保存*/
$('#addSave').on('click', function () {
if ($('#addAnchorForm').validationEngine('validate')) {
$("#tipMsg").text("正在处理,请稍后");
$("#tipModal").modal('show');
$.ajax({
type: "post",
url: "/admin/anchor/whitelist/save",
data: {
erbanNo: $("#erbanNo").val(),
reason: $("#reason").val()
},
dataType: 'json',
success: function (data) {
if (data.code == 200) {
$('#addAnchor').modal('hide');
$("#tipMsg").text("保存成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("保存失败,错误码:" + data.message);
$("#tipModal").modal('show');
}
}
})
}
})
//增加主播白名单
$('#add').on('click', function () {
console.log("add")
$('#addAnchorForm')[0].reset();
$('#addAnchor').modal('show');
})
//更改
$('#table').on('click', '.opt-release', function () {
var key = parseInt($(this).data('id'));
console.log(key, typeof key);
if (confirm("确定要取消平台号:" + key + "的白名单资格吗?")) {
$.ajax({
type: 'post',
url: '/admin/anchor/whitelist/update',
data: { 'erbanNo': key, 'status': 2 },
dataType: 'json',
success: function (data) {
if (data.code == 200) {
$("#tipMsg").text("操作成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("操作失败,错误信息:" + data.message);
$("#tipModal").modal('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;
}
</style>