feat: 添加防抖指令和任务管理功能

feat(anchor): 新增主播管理模块

feat(account): 完善客服账号管理功能

feat(knowledge): 添加任务列表查看和重新执行功能

feat(router): 增强路由组件动态导入逻辑

refactor: 优化多个视图的按钮防抖处理

style: 统一代码格式和样式

fix: 修复客服账号状态切换逻辑
This commit is contained in:
2026-04-20 10:20:45 +08:00
parent 4f547b5bff
commit c4bdfe2bb3
15 changed files with 1035 additions and 134 deletions

View File

@@ -3,14 +3,18 @@
<el-dialog :title="(formData.id ? '修改' : '添加') + '客服账号'" v-model="isShowDialog" width="769px">
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
<el-row :gutter="35">
<!-- 客服账号输入框 -->
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="客服账号" prop="accountName">
<el-input v-model="formData.accountName" placeholder="请输入客服账号cs_xhs_qixue" clearable />
<el-form-item label="账号编码" prop="accountCode">
<el-input v-model="formData.accountCode" placeholder="请输入账号编码" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="客服账号" prop="accountName">
<el-input v-model="formData.accountName" placeholder="请输入客服账号名称" clearable />
</el-form-item>
</el-col>
<!-- 客服平台选择 -->
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="客服平台" prop="platform">
<el-select v-model="formData.platform" placeholder="请选择客服平台" clearable style="width: 100%">
@@ -22,37 +26,35 @@
</el-col>
</el-row>
<!-- 高级配置可选 -->
<el-collapse v-model="activeNames" class="mt20">
<el-collapse-item title="高级配置(可选)" name="advanced">
<el-form-item label="自定义提示词" prop="prompt">
<el-input
type="textarea"
v-model="formData.prompt"
:rows="8"
placeholder="留空则使用系统默认提示词模板,如:你是专业的客服顾问,请用温暖关心的语气回答用户问题..."
/>
<div style="color: #909399; font-size: 12px; margin-top: 5px;">
提示系统会自动引用知识库内容您只需专注于业务话术即可留空将使用默认模板创建后也可在此修改
</div>
<el-form-item label="AI身份" prop="selfIdentity">
<el-input type="textarea" v-model="formData.selfIdentity" :rows="4" placeholder="AI客服身份描述你是专业的小红书客服顾问..." />
</el-form-item>
<el-form-item label="开场白" prop="greeting">
<el-input
type="textarea"
v-model="formData.greeting"
:rows="6"
:rows="4"
placeholder="WebSocket连接时发送的开场白你好有什么可以帮你的吗"
/>
<div class="form-tip">留空则不发送开场白</div>
</el-form-item>
<el-form-item label="关键词" prop="keywordOption">
<el-select v-model="formData.keywordOption" multiple placeholder="选择关键词选项" style="width: 100%">
<el-option label="推荐回复" value="recommend" />
<el-option label="智能问答" value="qa" />
<el-option label="人工转接" value="transfer" />
</el-select>
</el-form-item>
</el-collapse-item>
</el-collapse>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="onCancel" size="default"> </el-button>
<el-button type="primary" @click="onSubmit" size="default" :loading="loading">
<el-button v-debounce @click="onCancel" size="default"> </el-button>
<el-button type="primary" v-debounce @click="onSubmit" size="default" :loading="loading">
{{ formData.id ? '修 改' : '新 增' }}
</el-button>
</span>
@@ -64,17 +66,19 @@
<script lang="ts" setup>
import { ref, reactive, toRefs, nextTick } from 'vue';
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
import { addAccount, updateAccount } from '/@/api/customerService/account';
import { addAccount, updateAccount, getAccountOne } from '/@/api/customerService/account';
interface DialogFormData {
id?: string;
id?: number;
datasetIds: number[];
documentIds: number[];
accountCode: string;
accountName: string;
platform: string;
prompt?: string;
status?: number;
greeting?: string;
status: number;
creator: '';
modifier: '';
keywordOption?: string[];
selfIdentity?: string;
}
const emit = defineEmits<{
@@ -86,22 +90,21 @@ const state = reactive({
isShowDialog: false,
activeNames: [] as string[],
formData: {
id: '',
id: 0,
datasetIds: [] as number[],
documentIds: [] as number[],
accountCode: '',
accountName: '',
platform: '',
prompt: '',
greeting: '',
status: 1,
creator: '',
modifier: '',
greeting: '',
keywordOption: [] as string[],
selfIdentity: '',
} as DialogFormData,
});
const rules: FormRules = {
accountName: [
{ required: true, message: '客服账号不能为空', trigger: 'blur' },
{ min: 2, max: 50, message: '客服账号长度在 2 到 50 个字符', trigger: 'blur' },
],
accountCode: [{ required: true, message: '账号编码不能为空', trigger: 'blur' }],
platform: [{ required: true, message: '请选择客服平台', trigger: 'change' }],
};
@@ -111,21 +114,38 @@ const { loading, isShowDialog, formData, activeNames } = toRefs(state);
/**
* 打开对话框
*/
const openDialog = (row?: DialogFormData) => {
const openDialog = async (row?: DialogFormData) => {
resetForm();
if (row && row.id) {
// 编辑模式:填充数据
state.formData = { ...row };
} else {
// 新增模式重置ID和状态
state.formData.id = '';
state.formData.status = 1;
try {
state.loading = true;
const res = await getAccountOne({ id: row.id });
if (res.data) {
state.formData = {
...res.data,
id: res.data.id,
datasetIds: res.data.datasetIds || [],
documentIds: res.data.documentIds || [],
accountCode: res.data.accountCode || '',
accountName: res.data.accountName || '',
platform: res.data.platform || '',
status: res.data.status ?? 1,
greeting: res.data.greeting || '',
keywordOption: res.data.keywordOption || [],
selfIdentity: res.data.selfIdentity || '',
};
}
} catch (error) {
console.error('获取账号详情失败:', error);
ElMessage.error('获取账号详情失败');
} finally {
state.loading = false;
}
}
state.isShowDialog = true;
// 下次DOM更新后清除验证
nextTick(() => {
formRef.value?.clearValidate();
});
@@ -158,12 +178,10 @@ const onSubmit = async () => {
state.loading = true;
if (state.formData.id) {
// 修改操作
await updateAccount(state.formData);
await updateAccount(state.formData as any);
ElMessage.success('修改成功');
} else {
// 新增操作
await addAccount(state.formData);
await addAccount(state.formData as any);
ElMessage.success('添加成功');
}
@@ -171,9 +189,6 @@ const onSubmit = async () => {
emit('refresh');
} catch (error) {
console.error('操作失败:', error);
// 错误已由请求拦截器统一处理
} finally {
state.loading = false;
}
};
@@ -182,14 +197,16 @@ const onSubmit = async () => {
*/
const resetForm = () => {
state.formData = {
id: '',
id: 0,
datasetIds: [],
documentIds: [],
accountCode: '',
accountName: '',
platform: '',
prompt: '',
greeting: '',
status: 1,
creator: '',
modifier: '',
greeting: '',
keywordOption: [],
selfIdentity: '',
};
};