This commit is contained in:
dute7liang
2024-01-28 17:08:00 +08:00
parent d60805b3e4
commit a58041e87f
3 changed files with 0 additions and 348 deletions

View File

@@ -1,44 +0,0 @@
import request from '@/utils/request'
// 查询黑名单列表
export function listBlack(query) {
return request({
url: '/cai/black/list',
method: 'get',
params: query
})
}
// 查询黑名单详细
export function getBlack(id) {
return request({
url: '/cai/black/' + id,
method: 'get'
})
}
// 新增黑名单
export function addBlack(data) {
return request({
url: '/cai/black',
method: 'post',
data: data
})
}
// 修改黑名单
export function updateBlack(data) {
return request({
url: '/cai/black',
method: 'put',
data: data
})
}
// 删除黑名单
export function delBlack(id) {
return request({
url: '/cai/black/' + id,
method: 'delete'
})
}

View File

@@ -1,100 +0,0 @@
<template>
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" clearable size="small">
<el-option
v-for="dict in ipMicList"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="IP/MIC" prop="ipAddress">
<el-input v-model="form.ipAddress" placeholder="请输入ip地址" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="open = false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import {addBlack, getBlack, updateBlack} from "@/api/cai/black";
import {ipMicList} from "@/constant/statusMap";
export default {
components: {
},
data () {
return {
ipMicList,
open: false,
title: '',
form:{
id: undefined,
type: 1,
ipAddress: undefined,
},
// 表单校验
rules: {
type: [
{ required: true, message: "数据不能为空", trigger: "blur" }
],
ipAddress: [
{ required: true, message: "数据不能为空", trigger: "blur" }
],
},
buttonLoading: false,
}
},
created() {
},
methods: {
init (id) {
this.form.id = id || undefined;
this.title = (id ? "修改" : "新增") + "黑名单";
this.open = true;
this.$nextTick(() => {
this.$refs['form'].resetFields();
if(this.form.id){
getBlack(id).then(response => {
this.form = response.data;
});
}
})
},
// 表单提交
submitForm () {
this.$refs['form'].validate((valid) => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updateBlack(this.form).then(data => {
this.$modal.msgSuccess("修改成功");
this.$modal.buttonLoading = false;
this.open = false
this.$emit('refreshDataList')
}).finally(() => {
this.buttonLoading = false;
});
}else{
addBlack(this.form).then(data => {
this.$modal.msgSuccess("修改成功");
this.buttonLoading = false;
this.open = false
this.$emit('refreshDataList')
}).finally(() => {
this.buttonLoading = false;
});
}
}
})
},
}
}
</script>

View File

@@ -1,204 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="IP/MIC" prop="ipAddress">
<el-input
v-model="queryParams.ipAddress"
placeholder="请输入IP/MIC"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="queryParams.type" clearable size="small">
<el-option
v-for="dict in ipMicList"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@keyup.enter.native="handleQuery"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['cai:black:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['cai:black:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="blackList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="类型" align="center" prop="type" >
<template v-slot="scope">
<cai-dict-tag :options="ipMicList" :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column label="IP/MIC" align="center" prop="ipAddress" />
<el-table-column label="启用状态" align="center" prop="enableStatus" >
<template v-slot="scope">
<el-switch
v-model="scope.row.enableStatus"
:active-value="1"
:inactive-value="0"
@change="handleEnableStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="操作时间" align="center" prop="createTime" />
<el-table-column label="创建人名" align="center" prop="createByName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['cai:black:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<black-add-update-dialog v-if="blackAddUpdateDialogVisible" ref="blackAddUpdateDialog" @refreshDataList="getList" />
</div>
</template>
<script>
import {delBlack, listBlack, updateBlack} from "@/api/cai/black";
import {ipMicList} from "@/constant/statusMap";
import BlackAddUpdateDialog from "@/views/cai/black/black-add-update-dialog";
export default {
name: "Black",
components:{
BlackAddUpdateDialog
},
data() {
return {
ipMicList,
blackAddUpdateDialogVisible:false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 黑名单表格数据
blackList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ipAddress: undefined,
type: undefined,
},
};
},
created() {
this.getList();
},
methods: {
/** 查询黑名单列表 */
getList() {
this.loading = true;
listBlack(this.queryParams).then(response => {
this.blackList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.blackAddUpdateDialogVisible = true
this.$nextTick(() => {
this.$refs.blackAddUpdateDialog.init()
})
},
handleEnableStatusChange(row){
let text = row.enableStatus === 0 ? '禁用' : '启用'
this.$confirm('确认要' + text + '该数据吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return updateBlack({ id: row.id, enableStatus: row.enableStatus })
}).then(() => {
this.$modal.msgSuccess(text + '成功')
}).catch(function() {
row.enableStatus = row.enableStatus === 1 ? 0 : 1
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除黑名单编号为"' + ids + '"的数据项?').then(() => {
this.loading = true;
return delBlack(ids);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
}
};
</script>