调整黑白名单

This commit is contained in:
yangduo 2024-08-28 14:36:39 +08:00
parent b3d480f01e
commit 1115e1e814
3 changed files with 61 additions and 52 deletions

View File

@ -16,21 +16,21 @@ export function getWhiteList(data) {
}) })
} }
/* export function updateWhiteList(data) { export function updateWhiteList(data) {
return request({ return request({
url: '/white_list/edit', url: '/white_list/edit',
method: 'post', method: 'post',
data data
}) })
} */ }
export function delWhiteList(data) { /* export function delWhiteList(data) {
return request({ return request({
url: '/white_list/del', url: '/white_list/del',
method: 'post', method: 'post',
data data
}) })
} } */
export function uploadWhiteList(data) { export function uploadWhiteList(data) {
return request({ return request({

View File

@ -22,7 +22,7 @@
</el-upload> </el-upload>
</div> </div>
<el-table <el-table
:data="blockplayerList" :data="blacklist"
border border
fit fit
highlight-current-row highlight-current-row
@ -32,8 +32,8 @@
height="480" height="480"
> >
<el-table-column <el-table-column
label="账号" label="账号/钱包/email"
prop="account_id" prop="user_identity"
/> />
<el-table-column <el-table-column
label="是否拉黑" label="是否拉黑"
@ -41,7 +41,7 @@
align=" " align=" "
> >
<template slot-scope="scope"> <template slot-scope="scope">
<svg-icon v-if="scope.row.blocked === 1" icon-class="ok" style="font-size: 20px;" /> <svg-icon v-if="scope.row.enable === 1" icon-class="ok" style="font-size: 20px;" />
<svg-icon v-else icon-class="no" style="font-size: 20px;" /> <svg-icon v-else icon-class="no" style="font-size: 20px;" />
</template> </template>
</el-table-column> </el-table-column>
@ -71,7 +71,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button> <el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDel(scope.row)">删除</el-button> <!-- <el-button type="text" size="small" @click="handleDel(scope.row)">删除</el-button> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -84,13 +84,13 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
/> />
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()"> <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="90px" style="width: 400px; margin-left:50px;"> <el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
<el-form-item label="账号" prop="account_id"> <el-form-item label="账号/钱包/email" prop="user_identity">
<el-input v-model="form.account_id" :readonly="dialogStatus!=='create'" /> <el-input v-model="form.user_identity" :readonly="dialogStatus!=='create'" />
</el-form-item> </el-form-item>
<el-form-item label="是否拉黑"> <el-form-item label="是否拉黑">
<el-switch <el-switch
v-model="form.blocked" v-model="form.enable"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
active-color="#13ce66" active-color="#13ce66"
@ -124,20 +124,20 @@ export default {
data() { data() {
return { return {
form: { form: {
account_id: '', user_identity: '',
blocked: 1 enable: 1
}, },
dialogFormVisible: false, dialogFormVisible: false,
dialogStatus: '', dialogStatus: '',
listLoading: true, listLoading: true,
blockplayerList: [], blacklist: [],
dialogTitle: '新增', dialogTitle: '新增',
emptytext: ' ', emptytext: ' ',
totalpage: 0, totalpage: 0,
curpage: 1, curpage: 1,
page_size: 8, page_size: 8,
rules: { rules: {
account_id: [{ required: true, message: 'required', trigger: 'blur' }] user_identity: [{ required: true, message: 'required', trigger: 'blur' }]
}, },
uploadUrl: '', uploadUrl: '',
uploadData: { uploadData: {
@ -155,8 +155,8 @@ export default {
// this.getList() // this.getList()
}, },
handleUpdate(row) { handleUpdate(row) {
this.form.blocked = row.blocked this.form.enable = row.enable
this.form.account_id = row.account_id this.form.user_identity = row.user_identity
this.dialogStatus = 'update' this.dialogStatus = 'update'
this.dialogTitle = '编辑' this.dialogTitle = '编辑'
this.dialogFormVisible = true this.dialogFormVisible = true
@ -170,9 +170,9 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
delBlockPlayer({ account_id: row.account_id }).then(response => { delBlockPlayer({ user_identity: row.user_identity }).then(response => {
if (response.code === 0) { if (response.code === 0) {
if (this.blockplayerList.length === 1 && this.curpage === this.totalpage && this.curpage > 1) { if (this.blacklist.length === 1 && this.curpage === this.totalpage && this.curpage > 1) {
this.curpage-- this.curpage--
} }
this.getList() this.getList()
@ -195,11 +195,11 @@ export default {
} }
} }
getBlockPlayerList(data).then(response => { getBlockPlayerList(data).then(response => {
this.blockplayerList = response.data this.blacklist = response.data
this.totalpage = response.total_page this.totalpage = response.total_page
this.curpage = response.cur_page this.curpage = response.cur_page
// this.pager = response.cur_page // this.pager = response.cur_page
if (this.blockplayerList === undefined || this.blockplayerList.length <= 0) { if (this.blacklist === undefined || this.blacklist.length <= 0) {
this.emptytext = 'No data' this.emptytext = 'No data'
} }
}) })
@ -219,8 +219,8 @@ export default {
}, },
resetTemp() { resetTemp() {
this.form = { this.form = {
account_id: '', user_identity: '',
blocked: 0 enable: 0
} }
}, },
createData() { createData() {

View File

@ -32,13 +32,18 @@
height="480" height="480"
> >
<el-table-column <el-table-column
label="账号" label="账号/钱包/email"
prop="account_id" prop="user_identity"
/> />
<el-table-column <el-table-column
label="类型" label="是否生效"
prop="type" prop="enable"
/> >
<template slot-scope="scope">
<svg-icon v-if="scope.row.enable === 0" icon-class="no" style="font-size: 20px;" />
<svg-icon v-else icon-class="ok" style="font-size: 20px;" />
</template>
</el-table-column>
<!--el-table-column <!--el-table-column
prop="createtime" prop="createtime"
label="创建时间" label="创建时间"
@ -64,8 +69,8 @@
label="操作" label="操作"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<!--el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button--> <el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDel(scope.row)">删除</el-button> <!-- <el-button type="text" size="small" @click="handleDel(scope.row)">删除</el-button> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -78,12 +83,18 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
/> />
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()"> <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="90px" style="width: 400px; margin-left:50px;"> <el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
<el-form-item label="账号" prop="account_id"> <el-form-item label="账号/钱包/email" prop="user_identity">
<el-input v-model="form.account_id" /> <el-input v-model="form.user_identity" />
</el-form-item> </el-form-item>
<el-form-item label="类型" prop="type"> <el-form-item label="是否生效" prop="enable">
<el-input v-model="form.type" /> <el-switch
v-model="form.enable"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
@ -101,7 +112,7 @@
<script> <script>
// import Pagination from '@/components/Pagination/index.vue' // import Pagination from '@/components/Pagination/index.vue'
import { addWhiteList, getWhiteList, delWhiteList, uploadWhiteList } from '@/api/whitelist' import { addWhiteList, getWhiteList, updateWhiteList, uploadWhiteList } from '@/api/whitelist'
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
export default { export default {
@ -112,8 +123,8 @@ export default {
data() { data() {
return { return {
form: { form: {
account_id: '', user_identity: '',
blocked: 1 enable: 1
}, },
dialogFormVisible: false, dialogFormVisible: false,
dialogStatus: '', dialogStatus: '',
@ -125,7 +136,7 @@ export default {
curpage: 1, curpage: 1,
page_size: 8, page_size: 8,
rules: { rules: {
account_id: [{ required: true, message: 'required', trigger: 'blur' }], user_identity: [{ required: true, message: 'required', trigger: 'blur' }],
type: [{ required: true, message: 'required', trigger: 'blur' }] type: [{ required: true, message: 'required', trigger: 'blur' }]
}, },
uploadUrl: '', uploadUrl: '',
@ -144,8 +155,8 @@ export default {
// this.getList() // this.getList()
}, },
handleUpdate(row) { handleUpdate(row) {
this.form.type = row.type this.form.enable = row.enable
this.form.account_id = row.account_id this.form.user_identity = row.user_identity
this.dialogStatus = 'update' this.dialogStatus = 'update'
this.dialogTitle = '编辑' this.dialogTitle = '编辑'
this.dialogFormVisible = true this.dialogFormVisible = true
@ -153,13 +164,13 @@ export default {
this.$refs['form'].clearValidate() this.$refs['form'].clearValidate()
}) })
}, },
handleDel(row) { /* handleDel(row) {
this.$confirm('此操作将无法恢复, 是否继续?', '提示', { this.$confirm('此操作将无法恢复, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
delWhiteList({ account_id: row.account_id }).then(response => { delWhiteList({ user_identity: row.user_identity }).then(response => {
if (response.code === 0) { if (response.code === 0) {
if (this.whitelist.length === 1 && this.curpage === this.totalpage && this.curpage > 1) { if (this.whitelist.length === 1 && this.curpage === this.totalpage && this.curpage > 1) {
this.curpage-- this.curpage--
@ -175,7 +186,7 @@ export default {
}) })
}).catch(() => { }).catch(() => {
}) })
}, }, */
getList() { getList() {
const data = { const data = {
'page_dto': { 'page_dto': {
@ -187,7 +198,6 @@ export default {
this.whitelist = response.data this.whitelist = response.data
this.totalpage = response.total_page this.totalpage = response.total_page
this.curpage = response.cur_page this.curpage = response.cur_page
// this.pager = response.cur_page
if (this.whitelist === undefined || this.whitelist.length <= 0) { if (this.whitelist === undefined || this.whitelist.length <= 0) {
this.emptytext = 'No data' this.emptytext = 'No data'
} }
@ -208,8 +218,8 @@ export default {
}, },
resetTemp() { resetTemp() {
this.form = { this.form = {
account_id: '', user_identity: '',
blocked: 0 enable: 0
} }
}, },
createData() { createData() {
@ -230,8 +240,7 @@ export default {
} }
}) })
}, },
/* updateData() { updateData() {
console.log('update', this.form)
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
updateWhiteList(this.form).then(response => { updateWhiteList(this.form).then(response => {
@ -248,7 +257,7 @@ export default {
}) })
} }
}) })
}, */ },
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// //
console.log('File uploaded successfully:', response) console.log('File uploaded successfully:', response)