156 lines
4.9 KiB
Vue
Raw Normal View History

2025-05-21 15:29:38 +08:00
<template>
<div class="app-container">
<el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="90px" size="small">
<el-form-item label="白名单信息" prop="user">
<el-input v-model="queryParams.user" clearable :placeholder="whitelistType == 0 ? '请输入用户Id' : '请输入设备号'"
style="width: 240px" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" size="mini" type="primary" @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 v-hasPermi="['system:config:delete']" :disabled="multiple" icon="el-icon-plus" plain size="mini"
type="info" @click="handleDelete">批量删除
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column :show-overflow-tooltip="true" align="center" :label="whitelistType == 0 ? '用户Id' : '设备号'"
prop="user" />
<el-table-column :show-overflow-tooltip="true" align="center" label="添加时间" prop="createTime" />
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="250">
<template slot-scope="scope">
<el-button v-hasPermi="['system:config:edit']" icon="el-icon-edit" size="mini" type="text"
@click="handleEdit(scope.row)">编辑
</el-button>
<el-button v-hasPermi="['system:config:delete']" icon="el-icon-delete" size="mini" type="text"
@click="handleDelete(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :limit.sync="queryParams.pageSize" :page.sync="queryParams.pageNum" :total="total"
@pagination="getList" />
<EditWhiteList v-if="editWhiteListOpen" @close="closeEditWhiteList" :user="user" :id='id'
:whitelistType="whitelistType" />
</div>
</template>
<script>
import { listWhitelistMember, delWhitelistMember } from '@/api/FDS/whiteList'
import EditWhiteList from './components/editWhiteList.vue'
export default {
name: 'WhiteListDetail',
components: { EditWhiteList },
dicts: ['sys_yes_no'],
data () {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 参数表格数据
dataList: [],
// 弹出层标题
title: '',
editWhiteListOpen: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
user: undefined,
whitelistId: ''
},
user: '',
id: '',
// 表单参数
form: {},
whitelistId: '',
whitelistType: ''
}
},
created () {
this.getList()
},
mounted () {
this.whitelistId = this.$route.query.id
this.whitelistType = this.$route.query.whitelistType
},
methods: {
/** 查询参数列表 */
getList () {
this.loading = true
this.queryParams.whitelistId = this.$route.query.id;
listWhitelistMember(this.queryParams).then(response => {
this.dataList = response.rows
this.total = response.total
this.loading = false
}
)
},
// 表单重置
reset () {
this.form = {
phoneNumber: undefined
}
this.resetForm('form')
},
/** 搜索按钮操作 */
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
},
/** 删除按钮操作 */
handleDelete (row) {
const configIds = row.id || this.ids
this.$modal.confirm('是否确认删除编号为"' + configIds + '"的数据项?').then(function () {
return delWhitelistMember(configIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
}).catch(() => {
})
},
/** 修改按钮操作 */
handleEdit (row) {
this.reset()
this.user = row.user
this.id = row.id
this.editWhiteListOpen = true
},
/** 关闭新增弹出框*/
closeEditWhiteList () {
this.editWhiteListOpen = false
this.getList()
},
}
}
</script>