feat: 新增违禁词

This commit is contained in:
wanglihui 2023-08-06 13:31:13 +08:00
parent d814cf1263
commit 914bdcea67
4 changed files with 158 additions and 9 deletions

View File

@ -44,6 +44,22 @@ export function messageProhibitWordsGet(params: any) {
params
});
}
// 新增违禁词
export function messageProhibitWordsPost(params: any) {
return request({
url: '/manager/message/prohibit_words',
method: 'post',
params
});
}
// 删除违禁词
export function messageProhibitWordsDelete(params: any) {
return request({
url: '/manager/message/prohibit_words',
method: 'delete',
params
});
}
// 单聊天消息
export function messageRecordpersonalGet(params: any) {

View File

@ -0,0 +1,82 @@
<template>
<el-dialog
:model-value="value"
:width="600"
:align-center="true"
:close-on-click-modal="false"
:close-on-press-escape="false"
:draggable="true"
:z-index="99"
title="添加违禁词"
@close="onClose"
>
<div>
<el-input v-model="content" :rows="6" type="textarea" placeholder="请输入违禁词" />
</div>
<template #footer>
<el-space>
<el-button @click="onClose">取消</el-button>
<el-button type="primary" :loading="loaging" @click="onSend">发送</el-button>
</el-space>
</template>
</el-dialog>
</template>
<script lang="ts" name="BdProhitWords" setup>
import { ref } from 'vue';
import { ElMessage } from 'element-plus';
// API
import { messageProhibitWordsPost } from '@/api/message';
interface IProps {
value: boolean;
}
const props = withDefaults(defineProps<IProps>(), {
value: false
});
const content = ref('');
const loaging = ref<boolean>(false);
const emits = defineEmits<{
(e: 'update:value', item: boolean): void;
(e: 'ok', item: any): void;
}>();
watch(
() => props.value,
(n, _o) => {
console.log(props.value);
props.value = n;
}
);
//
const onClose = () => {
emits('update:value', false);
};
//
const onSend = () => {
if (!content.value) {
return ElMessage.info('请输入违禁词!');
}
const fromData = {
content: content.value
};
loaging.value = true;
messageProhibitWordsPost(fromData)
.then((res: any) => {
loaging.value = false;
if (res.status == 200) {
ElMessage.success('发送成功!');
content.value = '';
onClose();
emits('ok', true);
}
})
.catch(err => {
loaging.value = false;
if (err.status == 400) {
ElMessage.error(err.msg);
}
});
};
</script>

View File

@ -13,7 +13,7 @@
</el-form-item>
<el-form-item class="mb-0 !mr-0">
<el-button type="primary" @click="getTableList">查询</el-button>
<el-button type="primary">新增违禁词</el-button>
<el-button type="primary" @click="onAddProhitWords">新增违禁词</el-button>
</el-form-item>
</el-form>
</div>
@ -54,6 +54,8 @@
/>
</div>
</div>
<!-- 新增违禁词 -->
<bd-prohit-words v-model:value="prohitWordsValue" @ok="okSand" />
</bd-page>
</template>
@ -64,9 +66,9 @@ meta:
</route>
<script lang="tsx" setup>
import { ElButton, ElSpace } from 'element-plus';
import { ElButton, ElSpace, ElText, ElMessage, ElMessageBox } from 'element-plus';
// API
import { messageProhibitWordsGet } from '@/api/message';
import { messageProhibitWordsGet, messageProhibitWordsDelete } from '@/api/message';
/**
* 表格
*/
@ -79,8 +81,9 @@ const column = reactive<Column.ColumnOptions[]>([
prop: 'is_deleted',
label: '是否删除',
width: 160,
formatter(row: any) {
return row['is_deleted'] === 1 ? '是' : '否';
render: (scope: any) => {
const type = scope.row['is_deleted'] === 1 ? 'danger' : '';
return <ElText type={type}> {scope.row['is_deleted'] === 1 ? '是' : '否'}</ElText>;
}
},
{
@ -95,10 +98,11 @@ const column = reactive<Column.ColumnOptions[]>([
fixed: 'right',
width: 120,
render: (scope: any) => {
const type = scope.row['is_deleted'] === 0 ? 'danger' : 'warning';
return (
<ElSpace>
<ElButton type="primary" onClick={() => aa(scope.row)}>
删除
<ElButton type={type} onClick={() => onDel(scope.row)}>
{scope.row['is_deleted'] == 0 ? '删除' : '恢复'}
</ElButton>
</ElSpace>
);
@ -138,8 +142,54 @@ const onCurrentChange = (current: number) => {
getTableList();
};
const aa = (a: any) => {
console.log(a);
//
const prohitWordsValue = ref<boolean>(false);
const onAddProhitWords = () => {
prohitWordsValue.value = true;
};
//
const okSand = () => {
getTableList();
};
//
const prohitWordsDel = (item: any) => {
console.log(item);
const formData = {
is_deleted: item.is_deleted == 1 ? 0 : 1,
id: item.id
};
const msg = item.is_deleted === 0 ? '删除违禁词成功!' : '恢复违禁词成功!';
messageProhibitWordsDelete(formData).then((res: any) => {
if (res.status == 200) {
getTableList();
ElMessage({
type: 'success',
message: msg
});
}
});
};
//
const onDel = (item: any) => {
const title = item.is_deleted === 0 ? '删除违禁词' : '恢复违禁词';
const content = item.is_deleted === 0 ? `确定要删除违禁词[${item.content}]吗` : `确定要恢复违禁词[${item.content}]吗`;
ElMessageBox.confirm(content, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
closeOnClickModal: false,
type: 'warning'
})
.then(() => {
prohitWordsDel(item);
})
.catch(() => {
ElMessage({
type: 'info',
message: '取消成功!'
});
});
};
//

View File

@ -11,6 +11,7 @@ declare module 'vue' {
Approver: typeof import('./../components/bdWorkflow/nodes/approver.vue')['default']
BdMsg: typeof import('./../components/BdMsg/index.vue')['default']
BdPage: typeof import('./../components/BdPage/index.vue')['default']
BdProhitWords: typeof import('./../components/BdProhitWords/index.vue')['default']
BdSandAllMsg: typeof import('./../components/BdSandAllMsg/index.vue')['default']
BdSendMsg: typeof import('./../components/BdSendMsg/index.vue')['default']
BdStatistic: typeof import('./../components/BdStatistic/index.vue')['default']