2025-11-22 16:39:01 +08:00
|
|
|
|
<template>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<div class="system-role-container">
|
|
|
|
|
|
<el-card shadow="hover">
|
|
|
|
|
|
<div class="system-user-search mb15">
|
|
|
|
|
|
<el-form :inline="true">
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<el-form-item label="客服账号">
|
2025-12-01 16:30:31 +08:00
|
|
|
|
<el-input
|
|
|
|
|
|
size="default"
|
2025-12-26 15:35:11 +08:00
|
|
|
|
v-model="tableData.param.accountName"
|
|
|
|
|
|
placeholder="请输入客服账号"
|
2025-12-01 16:30:31 +08:00
|
|
|
|
class="w-50 m-2"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
@keyup.enter="handleSearch"
|
|
|
|
|
|
/>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="客服平台" prop="status" style="width: 200px">
|
2025-11-25 17:02:31 +08:00
|
|
|
|
<el-select v-model="tableData.param.platform" placeholder="请选择客服平台" clearable size="default" style="width: 240px">
|
2025-11-28 17:17:07 +08:00
|
|
|
|
<el-option label="小红书" value="小红书" />
|
|
|
|
|
|
<el-option label="抖音" value="抖音" />
|
|
|
|
|
|
<el-option label="快手" value="快手" />
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
2025-12-01 16:30:31 +08:00
|
|
|
|
<el-button size="default" type="primary" class="ml10" @click="handleSearch" :loading="tableData.loading">
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<el-icon>
|
|
|
|
|
|
<ele-Search />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
查询
|
|
|
|
|
|
</el-button>
|
2025-12-12 16:56:13 +08:00
|
|
|
|
<el-button size="default" type="success" class="ml10 " @click="onOpenAddRole">
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<el-icon>
|
|
|
|
|
|
<ele-FolderAdd />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
新增客服
|
|
|
|
|
|
</el-button>
|
2025-12-02 16:21:00 +08:00
|
|
|
|
<el-button size="default" class="ml10" @click="handleReset" :disabled="tableData.loading">
|
2025-12-01 16:30:31 +08:00
|
|
|
|
<el-icon>
|
|
|
|
|
|
<ele-Refresh />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
重置
|
2025-12-02 16:21:00 +08:00
|
|
|
|
</el-button>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
2025-11-25 17:02:31 +08:00
|
|
|
|
<el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<el-table-column type="index" label="序号" width="60" />
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<el-table-column prop="accountName" label="客服账号" show-overflow-tooltip></el-table-column>
|
2025-12-01 16:30:31 +08:00
|
|
|
|
<el-table-column prop="isDisabled" label="客服状态" show-overflow-tooltip>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<template #default="scope">
|
2025-11-28 17:17:07 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
size="small"
|
2025-12-01 16:30:31 +08:00
|
|
|
|
:type="scope.row.isDisabled == 1 ? 'success' : 'info'"
|
2025-11-28 17:17:07 +08:00
|
|
|
|
@click="handleStatusChange(scope.row)"
|
|
|
|
|
|
:loading="scope.row.statusLoading"
|
|
|
|
|
|
>
|
2025-12-01 16:30:31 +08:00
|
|
|
|
{{ scope.row.isDisabled == 1 ? '启用' : '禁用' }}
|
2025-11-28 17:17:07 +08:00
|
|
|
|
</el-button>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2025-11-28 17:17:07 +08:00
|
|
|
|
<el-table-column prop="platform" label="客服平台" show-overflow-tooltip></el-table-column>
|
2025-11-25 17:02:31 +08:00
|
|
|
|
<el-table-column prop="creator" label="创建人" show-overflow-tooltip></el-table-column>
|
2025-12-02 17:05:20 +08:00
|
|
|
|
<el-table-column prop="updater" label="修改人" show-overflow-tooltip></el-table-column>
|
2025-12-01 16:30:31 +08:00
|
|
|
|
<el-table-column prop="createdAt" label="创建时间" show-overflow-tooltip>
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
{{ formatTime(row.createdAt) }}
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="updatedAt" label="修改时间" show-overflow-tooltip>
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
{{ formatTime(row.updatedAt) }}
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<el-table-column label="操作" width="300">
|
2025-11-24 16:55:18 +08:00
|
|
|
|
<template #default="scope">
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<el-button style="color: deepskyblue" size="small" text type="primary" @click="onOpenEditRole(scope.row)">
|
2025-11-25 17:02:31 +08:00
|
|
|
|
<el-icon><ele-EditPen /></el-icon>修改
|
|
|
|
|
|
</el-button>
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<el-button style="color: #e6a23c" size="small" text type="warning" @click="onOpenPromptConfig(scope.row)">
|
|
|
|
|
|
<el-icon><ele-SetUp /></el-icon>配置提示词
|
|
|
|
|
|
</el-button>
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<pagination
|
|
|
|
|
|
v-show="tableData.total > 0"
|
|
|
|
|
|
:total="tableData.total"
|
|
|
|
|
|
v-model:page="tableData.param.pageNum"
|
|
|
|
|
|
v-model:limit="tableData.param.pageSize"
|
2025-11-28 17:17:07 +08:00
|
|
|
|
@pagination="getList"
|
2025-11-24 16:55:18 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</el-card>
|
2025-12-05 15:45:14 +08:00
|
|
|
|
<EditAccount ref="editRoleRef" @refresh="getList" />
|
2025-12-26 15:35:11 +08:00
|
|
|
|
<PromptConfig ref="promptConfigRef" @refresh="getList" />
|
2025-11-24 16:55:18 +08:00
|
|
|
|
</div>
|
2025-11-22 16:39:01 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
<script lang="ts" setup>
|
2025-11-28 17:17:07 +08:00
|
|
|
|
import { ref, reactive, onMounted } from 'vue';
|
2025-11-22 16:39:01 +08:00
|
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
2025-12-01 16:30:31 +08:00
|
|
|
|
import EditAccount from './component/editAccount.vue';
|
2025-12-26 15:35:11 +08:00
|
|
|
|
import PromptConfig from './component/promptConfig.vue';
|
2025-12-05 15:45:14 +08:00
|
|
|
|
import { addAccount, getaccountList, updatestate } from '/@/api/customerService/account';
|
2025-11-25 17:02:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 定义类型接口
|
|
|
|
|
|
interface TableDataItem {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
id: string;
|
2025-12-26 15:35:11 +08:00
|
|
|
|
accountName: string;
|
2025-12-01 16:30:31 +08:00
|
|
|
|
isDisabled: number; // 修正:应该是isDisabled而不是status
|
2025-11-28 17:17:07 +08:00
|
|
|
|
platform: string;
|
|
|
|
|
|
creator: string;
|
|
|
|
|
|
modifier: string;
|
|
|
|
|
|
createdAt: number;
|
|
|
|
|
|
updatedAt: number;
|
|
|
|
|
|
statusLoading?: boolean;
|
2025-11-22 16:39:01 +08:00
|
|
|
|
}
|
2025-11-25 17:02:31 +08:00
|
|
|
|
|
|
|
|
|
|
interface TableParam {
|
2025-12-26 15:35:11 +08:00
|
|
|
|
accountName: string;
|
2025-11-25 17:02:31 +08:00
|
|
|
|
platform: string;
|
|
|
|
|
|
pageNum: number;
|
|
|
|
|
|
pageSize: number;
|
2025-12-01 16:30:31 +08:00
|
|
|
|
isDisabled: number;
|
2025-11-22 16:39:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
interface TableState {
|
|
|
|
|
|
data: TableDataItem[];
|
|
|
|
|
|
total: number;
|
|
|
|
|
|
loading: boolean;
|
|
|
|
|
|
param: TableParam;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-01 16:30:31 +08:00
|
|
|
|
// 初始参数(用于重置)
|
|
|
|
|
|
const initialParam: TableParam = {
|
2025-12-26 15:35:11 +08:00
|
|
|
|
accountName: '',
|
2025-12-01 16:30:31 +08:00
|
|
|
|
platform: '',
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
isDisabled: 0,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
// 响应式数据
|
|
|
|
|
|
const tableData = reactive<TableState>({
|
|
|
|
|
|
data: [],
|
|
|
|
|
|
total: 0,
|
|
|
|
|
|
loading: false,
|
2025-12-01 16:30:31 +08:00
|
|
|
|
param: { ...initialParam },
|
2025-11-25 17:02:31 +08:00
|
|
|
|
});
|
2025-11-22 16:39:01 +08:00
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
// 模板引用
|
2025-12-03 15:29:05 +08:00
|
|
|
|
const editRoleRef = ref<InstanceType<typeof EditAccount>>();
|
2025-11-25 17:02:31 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-28 17:17:07 +08:00
|
|
|
|
* 获取客服账号列表
|
2025-11-25 17:02:31 +08:00
|
|
|
|
*/
|
2025-11-28 17:17:07 +08:00
|
|
|
|
const getList = async () => {
|
2025-11-25 17:02:31 +08:00
|
|
|
|
try {
|
|
|
|
|
|
tableData.loading = true;
|
2025-12-01 16:30:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 构建查询参数,过滤空值
|
|
|
|
|
|
const queryParams: any = {
|
|
|
|
|
|
pageNum: tableData.param.pageNum,
|
|
|
|
|
|
pageSize: tableData.param.pageSize,
|
2025-12-26 15:35:11 +08:00
|
|
|
|
accountName: tableData.param.accountName || undefined,
|
2025-12-01 16:30:31 +08:00
|
|
|
|
platform: tableData.param.platform || undefined,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const res = await getaccountList(queryParams);
|
|
|
|
|
|
|
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
|
tableData.data = (res.data.list || []).map((item: TableDataItem) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
statusLoading: false,
|
|
|
|
|
|
}));
|
|
|
|
|
|
tableData.total = res.data.total || 0;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
tableData.data = [];
|
|
|
|
|
|
tableData.total = 0;
|
|
|
|
|
|
ElMessage.warning('暂无数据');
|
|
|
|
|
|
}
|
2025-11-25 17:02:31 +08:00
|
|
|
|
} catch (error) {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
console.error('获取客服账号列表失败:', error);
|
2025-11-25 17:02:31 +08:00
|
|
|
|
ElMessage.error('获取数据失败');
|
2025-12-01 16:30:31 +08:00
|
|
|
|
tableData.data = [];
|
|
|
|
|
|
tableData.total = 0;
|
2025-11-25 17:02:31 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
tableData.loading = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-12-01 16:30:31 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理搜索
|
|
|
|
|
|
*/
|
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
|
tableData.param.pageNum = 1; // 搜索时重置到第一页
|
|
|
|
|
|
getList();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 重置查询条件
|
|
|
|
|
|
*/
|
|
|
|
|
|
const handleReset = () => {
|
|
|
|
|
|
// 重新获取数据
|
2025-12-02 16:21:00 +08:00
|
|
|
|
tableData.param = { ...initialParam };
|
2025-12-01 16:30:31 +08:00
|
|
|
|
getList();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 时间处理函数 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 格式化时间显示
|
|
|
|
|
|
*/
|
|
|
|
|
|
const formatTime = (time: string | number | Date): string => {
|
|
|
|
|
|
if (!time) return '-';
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
let date: Date;
|
|
|
|
|
|
|
|
|
|
|
|
if (time instanceof Date) {
|
|
|
|
|
|
date = time;
|
|
|
|
|
|
} else if (typeof time === 'string') {
|
|
|
|
|
|
date = new Date(time);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let timestamp = time;
|
|
|
|
|
|
if (timestamp > 1000000000000) {
|
|
|
|
|
|
// 已经是毫秒时间戳
|
|
|
|
|
|
} else if (timestamp > 1000000000) {
|
|
|
|
|
|
// 秒时间戳,转换为毫秒
|
|
|
|
|
|
timestamp = timestamp * 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
date = new Date(timestamp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isNaN(date.getTime())) {
|
|
|
|
|
|
return String(time);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const year = date.getFullYear();
|
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
|
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
|
|
|
|
|
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('时间格式化错误:', error);
|
|
|
|
|
|
return String(time);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-28 17:17:07 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理客服状态切换
|
|
|
|
|
|
*/
|
|
|
|
|
|
const handleStatusChange = async (row: TableDataItem) => {
|
|
|
|
|
|
try {
|
2025-12-26 15:35:11 +08:00
|
|
|
|
await ElMessageBox.confirm(`确定要${row.isDisabled == 1 ? '禁用' : '启用'}客服账号 "${row.accountName}" 吗?`, '提示', {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
row.statusLoading = true;
|
2025-12-01 16:30:31 +08:00
|
|
|
|
const newStatus = row.isDisabled == 1 ? 0 : 1; // 修正:使用isDisabled字段
|
|
|
|
|
|
|
2025-11-28 17:17:07 +08:00
|
|
|
|
await updatestate({
|
|
|
|
|
|
id: row.id,
|
2025-12-02 16:21:00 +08:00
|
|
|
|
isDisabled: newStatus, // 接口可能需要status字段
|
2025-11-28 17:17:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-01 16:30:31 +08:00
|
|
|
|
ElMessage.success(`客服账号已${newStatus == 0 ? '禁用' : '启用'}`);
|
|
|
|
|
|
await getList(); // 重新获取数据
|
2025-11-28 17:17:07 +08:00
|
|
|
|
} catch (error) {
|
2025-12-01 16:30:31 +08:00
|
|
|
|
if (error == 'cancel') {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
console.error('状态切换失败:', error);
|
|
|
|
|
|
ElMessage.error('状态切换失败');
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
row.statusLoading = false;
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
/**
|
2025-11-28 17:17:07 +08:00
|
|
|
|
* 打开新增客服对话框
|
2025-11-25 17:02:31 +08:00
|
|
|
|
*/
|
|
|
|
|
|
const onOpenAddRole = () => {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
editRoleRef.value?.openDialog();
|
2025-11-25 17:02:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-28 17:17:07 +08:00
|
|
|
|
* 打开编辑客服对话框
|
2025-11-25 17:02:31 +08:00
|
|
|
|
*/
|
2025-12-08 14:54:23 +08:00
|
|
|
|
const onOpenEditRole = (row: any) => {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
editRoleRef.value?.openDialog(row);
|
2025-11-25 17:02:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-12-26 15:35:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 打开提示词配置对话框
|
|
|
|
|
|
*/
|
|
|
|
|
|
const onOpenPromptConfig = (row: any) => {
|
|
|
|
|
|
promptConfigRef.value?.openDialog(row);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-25 17:02:31 +08:00
|
|
|
|
// 生命周期
|
|
|
|
|
|
onMounted(() => {
|
2025-11-28 17:17:07 +08:00
|
|
|
|
getList();
|
2025-11-22 16:39:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
</script>
|
2025-11-25 17:02:31 +08:00
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.system-user-search {
|
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.mb15 {
|
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ml10 {
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.w-50 {
|
|
|
|
|
|
width: 240px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.system-role-container {
|
|
|
|
|
|
padding: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-table) {
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|