|
@@ -0,0 +1,243 @@
|
|
|
+<script setup>
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import SearchItemWrapper from '@/components/SearchItemWrapper';
|
|
|
+import useTableHeight from '@/composables/useTableHeight';
|
|
|
+import { waiteListApi } from '@/api/voice/whiteList';
|
|
|
+
|
|
|
+const { tableContainer, tableMaxHeight } = useTableHeight();
|
|
|
+
|
|
|
+const loading = ref(false);
|
|
|
+const total = ref(0);
|
|
|
+const tableData = ref([]);
|
|
|
+const dialogVisible = ref(false);
|
|
|
+const formRef = ref(null);
|
|
|
+const rules = {
|
|
|
+ phone: [
|
|
|
+ { required: true, message: '请输入电话号码', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ description: [
|
|
|
+ { required: true, message: '请输入备注', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+}
|
|
|
+const queryParams = ref({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ phone: '',
|
|
|
+ description: ''
|
|
|
+})
|
|
|
+
|
|
|
+const formData = ref({
|
|
|
+ id: '',
|
|
|
+ phone: '',
|
|
|
+ description: ''
|
|
|
+});
|
|
|
+
|
|
|
+// 气泡弹窗 - 是否删除该项
|
|
|
+const onConfirm = async (row) => {
|
|
|
+ await waiteListApi.delWhiteList(row.id);
|
|
|
+ getList();
|
|
|
+ ElMessage.success('删除成功');
|
|
|
+}
|
|
|
+
|
|
|
+const getList = async () => {
|
|
|
+
|
|
|
+ loading.value = true;
|
|
|
+
|
|
|
+ const { rows, total: t } = await waiteListApi.getWhiteList({...queryParams.value, type: 1});
|
|
|
+
|
|
|
+ tableData.value = rows
|
|
|
+
|
|
|
+ loading.value = false;
|
|
|
+
|
|
|
+ total.value = t;
|
|
|
+};
|
|
|
+
|
|
|
+// 弹窗 - 新增
|
|
|
+const handleAddPhoneNum = () => {
|
|
|
+ dialogVisible.value = true;
|
|
|
+}
|
|
|
+
|
|
|
+// 弹窗 - 编辑
|
|
|
+const handleEditRow = ({ id, phone, description }) => {
|
|
|
+ dialogVisible.value = true;
|
|
|
+ formData.value = { id, phone, description };
|
|
|
+}
|
|
|
+
|
|
|
+// 弹窗 - 确定
|
|
|
+const onDialogConfirm = () => {
|
|
|
+ formRef.value.validate(async (valid) => {
|
|
|
+ if ( valid ) {
|
|
|
+ dialogVisible.value = false;
|
|
|
+ if ( !formData.value.id ) {
|
|
|
+ await waiteListApi.postWhiteList({...formData.value, type: 1});
|
|
|
+ ElMessage.success('新增电话号码成功');
|
|
|
+ } else {
|
|
|
+ await waiteListApi.putWhiteList({...formData.value, type: 1});
|
|
|
+ ElMessage.success('更新电话号码成功');
|
|
|
+ }
|
|
|
+ getList();
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 弹窗 - 取消
|
|
|
+const onDialogCancel = () => {
|
|
|
+ formData.value = {
|
|
|
+ id: '',
|
|
|
+ phone: '',
|
|
|
+ description: ''
|
|
|
+ };
|
|
|
+ dialogVisible.value = false;
|
|
|
+}
|
|
|
+
|
|
|
+// 清除检索条件
|
|
|
+const handleCleanOptions = () => {
|
|
|
+ queryParams.value = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ phone: '',
|
|
|
+ description: ''
|
|
|
+ };
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getList();
|
|
|
+})
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="notice-viewprot">
|
|
|
+ <div class="search-card">
|
|
|
+ <el-row :gutter="24" class="mb-[24px]">
|
|
|
+ <el-col :span="6">
|
|
|
+ <SearchItemWrapper>
|
|
|
+ <el-input class="search-input" placeholder="电话号码" v-model="queryParams.phone"></el-input>
|
|
|
+ </SearchItemWrapper>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <SearchItemWrapper>
|
|
|
+ <el-input class="search-input" placeholder="备注" v-model="queryParams.description"></el-input>
|
|
|
+ </SearchItemWrapper>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6" :offset="6">
|
|
|
+ <div class="flex items-center justify-end space-x-[10px]">
|
|
|
+ <div class="custom-btn custom-btn_primary" @click="getList">搜索</div>
|
|
|
+ <div class="custom-btn custom-btn_default" @click="handleCleanOptions">重置</div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="add-btn-card space-x-[15px]">
|
|
|
+ <div class="btn space-x-[5px]" @click="handleAddPhoneNum">
|
|
|
+ <el-icon><CirclePlus /></el-icon>
|
|
|
+ <span>新增机器人白名单</span>
|
|
|
+ </div>
|
|
|
+ <span class="text-[#999]">本功能主要用于测试, 配置完成后1分钟生效。</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="table-card">
|
|
|
+ <div style="height: 100%;" ref="tableContainer">
|
|
|
+ <el-table :data="tableData" style="width: 100%" :max-height="tableMaxHeight" v-loading="loading">
|
|
|
+ <el-table-column prop="phone" label="电话号码" align="center" :width="130"/>
|
|
|
+ <el-table-column prop="description" label="备注" align="center" />
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total >= 0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialogVisible"
|
|
|
+ title="新增电话号码"
|
|
|
+ width="600"
|
|
|
+ modal-class="custom-workbench-dialog"
|
|
|
+ align-center
|
|
|
+ @closed="resetDialogStatus"
|
|
|
+ >
|
|
|
+ <template #header>
|
|
|
+ <div class="dialog-header">
|
|
|
+ <h4>新增电话号码</h4>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="dialog-body">
|
|
|
+ <div class="dialog-form_inner">
|
|
|
+ <el-form :model="formData" label-width="auto" style="width: 100%;" :rules="rules" ref="formRef">
|
|
|
+ <el-form-item label="电话号码" prop="phone">
|
|
|
+ <el-input v-model.trim="formData.phone" placeholder="请输入"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="description">
|
|
|
+ <el-input v-model.trim="formData.description" type="textarea" :autosize="{ minRows: 5, maxRows: 6 }" resize="none" placeholder="请输入"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer space-x-[14px]">
|
|
|
+ <div class="custom-btn custom-btn_primary" @click="onDialogConfirm">确定</div>
|
|
|
+ <div class="custom-btn custom-btn_default" @click="onDialogCancel">取消</div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.notice-viewprot {
|
|
|
+ display: flex;
|
|
|
+ flex-flow: column;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ padding: 28px 24px 18px 24px;
|
|
|
+ border-radius: 8px;
|
|
|
+ background: #fff;
|
|
|
+
|
|
|
+ .search-card {
|
|
|
+ border-bottom: 1px dashed #E5E6EB;
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-btn-card {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: flex-start;
|
|
|
+ margin: 20px 0;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 14px;
|
|
|
+ border-radius: 8px;
|
|
|
+ padding: 7px 16px;
|
|
|
+ background: #165DFF;
|
|
|
+ color: #fff;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .table-card {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+.dialog-form_inner {
|
|
|
+ width: 500px;
|
|
|
+ margin: 0 auto;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+.dialog-footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+</style>
|