复聊话术页面接口对接

This commit is contained in:
雷校云
2026-03-05 17:41:02 +08:00
parent ff1f5b4cab
commit dae0eeab69
7 changed files with 835 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
import request from '@/utils/request'
/*
* 复聊管理
* */
// 获取复聊配置列表
export const ApiFollowupConfigs = () => {
return request({
url: `/api/followup-configs`,
method: 'get'
})
}
// 获取单个复聊配置
export const ApiFollowupConfigsId = (id: string) => {
return request({
url: `/api/followup-configs/${id}`,
method: 'get'
})
}
// 创建复聊配置
export const ApiFollowupConfigsAdd = (data: any) => {
const formData = new FormData()
formData.append('name', data.name)
formData.append('position', data.position)
formData.append('followup_days', data.followup_days)
formData.append('is_active', data.is_active)
return request({
url: `/api/followup-configs`,
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 更新复聊配置
export const ApiFollowupConfigsEditor = (data: any) => {
const formData = new FormData()
formData.append('followup_days', data.followup_days)
formData.append('is_active', data.is_active)
return request({
url: `/api/followup-configs/${data.id}`,
method: 'put',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 删除复聊配置
export const ApiFollowupConfigsDelete = (id: string) => {
return request({
url: `/api/followup-configs/${id}`,
method: 'delete'
})
}
// 获取复聊话术列表
export const ApiFollowupScripts = (data: any) => {
return request({
url: `/api/followup-scripts?config_id=${data.config_id || ''}&day_number=${data.day_number || ''}`,
method: 'get'
})
}
// 创建复聊话术
export const ApiFollowupScriptsAdd = (data: any) => {
const formData = new FormData()
formData.append('config_id', data.config_id)
formData.append('day_number', data.day_number)
formData.append('order', data.order)
formData.append('content', data.content)
return request({
url: `/api/followup-scripts`,
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 更新复聊话术
export const ApiFollowupScriptsEditor = (data: any) => {
const formData = new FormData()
formData.append('content', data.content)
formData.append('order', data.order)
return request({
url: `/api/followup-scripts/${data.id}`,
method: 'put',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 删除复聊话术
export const ApiFollowupScriptsDelete = (id: string) => {
return request({
url: `/api/followup-scripts/${id}`,
method: 'delete'
})
}

View File

@@ -343,6 +343,25 @@ export const constantRoutes: RouteRecordRaw[] = [
}
}
]
},
{
path: '/reconciliation',
name: 'Reconciliation',
component: Layout,
meta: {
title: '复聊管理',
icon: 'setting'
},
children: [
{
path: 'reconciliationManagement',
name: 'ReconciliationManagement',
component: () => import('@/views/ReconciliationManagement/index.vue'),
meta: {
title: '复聊管理'
}
}
]
}
// 注册平台登记
// {

View File

@@ -0,0 +1,118 @@
<template>
<div class="pre-registration-form">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="auto"
label-position="top"
>
<el-form-item v-if="!newData?.id" label="配置名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入" />
<!-- <el-select v-model="formData.task_type" placeholder="请选择">-->
<!-- <el-option label="检查登录" value="check_login" />-->
<!-- <el-option label="招聘" value="boss_recruit" />-->
<!-- </el-select>-->
</el-form-item>
<el-form-item v-if="!newData?.id" label="岗位类型" prop="position">
<el-input v-model="formData.position" placeholder="请输入" />
</el-form-item>
<el-form-item label="复聊间隔天数" prop="followup_days">
<el-input v-model="formData.followup_days" placeholder="请输入" />
</el-form-item>
<el-form-item label="是否启用" prop="is_active">
<el-switch v-model="formData.is_active" />
</el-form-item>
</el-form>
</div>
</template>
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { deepCloneByJSON } from '@/utils/auxiliaryFunction'
const props = defineProps({
newData: {
type: Object,
default: () => ({})
}
})
const formRef = ref()
// 表单数据
const formData = reactive<any>({
name: '',
position: '',
followup_days: '',
is_active: false
})
const formRules = reactive<any>({
name: [{ required: true, message: '请输入', trigger: 'blur' }],
position: [{ required: true, message: '请输入', trigger: 'blur' }],
followup_days: [{ required: true, message: '请输入', trigger: 'blur' }],
is_active: [{ required: true, message: '请输入', trigger: 'blur' }]
})
onMounted(() => {
setFormData(props.newData)
})
const getForm = () => {
return formData
}
const setFormData = (data: any) => {
if (data && Object.keys(data).length > 0) {
const data1 = deepCloneByJSON(data)
Object.assign(formData, data1)
}
}
const submit = (): Promise<boolean> => {
return new Promise((resolve, reject) => {
formRef.value?.validate((valid: boolean) => {
if (valid) {
resolve(true)
} else {
ElMessage.error('请完善必填信息')
reject(false)
}
})
})
}
defineExpose({
submit,
getForm
})
</script>
<style scoped lang="scss">
.pre-registration-form {
width: 100%;
padding-right: 20px;
overflow: hidden;
overflow-y: auto;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.3);
border-radius: 3px;
}
&::-webkit-scrollbar-thumb:hover {
background: rgba(0, 0, 0, 0.5);
}
}
.section {
display: flex;
flex-direction: column;
gap: 20px;
}
</style>

View File

@@ -0,0 +1,242 @@
<template>
<div class="app-container">
<h3>复聊配置</h3>
<el-card shadow="hover" class="data-table">
<div class="data-table__toolbar">
<div class="data-table__toolbar--actions">
<el-button type="success" icon="plus" @click="handleOpenDialog()">新增</el-button>
</div>
</div>
<el-table
ref="dataTableRef"
v-loading="loading"
:data="roleList"
highlight-current-row
row-key="id"
border
class="data-table__content"
:expanded-row-keys="expandedRowKeys"
@expand-change="handleExpandChange"
>
<el-table-column type="expand">
<template #default="scope">
<RevisedConversationScript
v-if="expandedRowKeys.includes(scope.row.id)"
:config-id="scope.row.id"
></RevisedConversationScript>
</template>
</el-table-column>
<el-table-column label="配置名称" prop="name" />
<el-table-column label="岗位类型" prop="position" />
<el-table-column label="复聊间隔" prop="followup_days" />
<el-table-column label="启用状态" prop="is_active">
<template #default="scope">
<el-switch v-model="scope.row.is_active" disabled />
</template>
</el-table-column>
<el-table-column label="创建时间" prop="created_at">
<template #default="scope">
{{ formatISOToDateTime(scope.row?.created_at || '') }}
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="220">
<template #default="scope">
<el-button
type="primary"
size="small"
link
icon="edit"
@click="handleOpenDialog(scope.row)"
>
编辑
</el-button>
<el-button
type="primary"
size="small"
link
icon="edit"
@click="handleExpandTask(scope.row.id)"
>
展开话术
</el-button>
<el-button
type="danger"
size="small"
link
icon="delete"
@click="onUserDeleteDepartment(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-if="total > 0"
v-model:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="fetchData"
/>
</el-card>
</div>
</template>
<script setup lang="ts">
import { RolePageVO } from '@/api/system/role-api'
import { functionDialogBox } from '@/utils/functionDialogBox'
import ReconfigurationSettingsForm from './components/ReconfigurationSettingsForm.vue'
import {
ApiFollowupConfigs,
ApiFollowupConfigsAdd,
ApiFollowupConfigsDelete,
ApiFollowupConfigsEditor
} from '@/api/ReconciliationManagement'
import { formatISOToDateTime } from '@/utils/auxiliaryFunction'
import RevisedConversationScript from '../RevisedConversationScript/index.vue'
defineOptions({
name: 'Role',
inheritAttrs: false
})
const queryFormRef = ref()
const dataTableRef = ref()
const loading = ref(false)
const total = ref(0)
const expandedRowKeys = ref<string[]>([])
const queryParams = reactive<any>({
pageNum: 1,
pageSize: 10,
times: [],
seal_type: '',
CaseNumber: ''
})
// 表格数据
const roleList = ref<RolePageVO[]>()
// 弹窗
const dialog = reactive({
title: '',
visible: false
})
// 获取数据
function fetchData() {
loading.value = true
ApiFollowupConfigs()
.then((res: any) => {
roleList.value = res.data
// total.value = res.data.total
})
.finally(() => {
loading.value = false
})
}
// 查询(重置页码后获取数据)
function handleQuery() {
queryParams.pageNum = 1
fetchData()
}
// 重置查询
function handleResetQuery() {
if (queryFormRef.value) queryFormRef.value.resetFields()
queryParams.pageNum = 1
fetchData()
}
// 打开角色弹窗
function handleOpenDialog(data: any = null) {
dialog.visible = true
if (data) {
functionDialogBox(
ReconfigurationSettingsForm,
{
newData: data
},
{
title: '编辑复聊配置',
width: '900',
ok(value: any) {
handleSubmit({ id: data.id, ...value })
}
}
)
} else {
functionDialogBox(
ReconfigurationSettingsForm,
{},
{
title: '创建复聊配置',
width: '900',
ok(value: any) {
handleSubmit(value)
}
}
)
}
}
// 提交角色表单
function handleSubmit(data: any) {
loading.value = true
const roleId = data.id
if (roleId) {
ApiFollowupConfigsEditor(data)
.then(() => {
ElMessage.success('修改成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
} else {
ApiFollowupConfigsAdd(data)
.then(() => {
ElMessage.success('新增成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
}
}
const onUserDeleteDepartment = (id: string) => {
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(
() => {
loading.value = true
ApiFollowupConfigsDelete(id)
.then(() => {
ElMessage.success('删除成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
},
() => {
ElMessage.info('已取消删除')
}
)
}
function handleExpandChange(row: any, expandedRows: any[]) {
expandedRowKeys.value = expandedRows.map((item) => item.id)
}
const handleExpandTask = (rowId: string) => {
// 找到对应的行数据
const targetRow = roleList.value?.find((item) => item.id === rowId)
if (targetRow && dataTableRef.value) {
dataTableRef.value.toggleRowExpansion(targetRow)
}
}
onMounted(() => {
handleQuery()
})
</script>

View File

@@ -0,0 +1,104 @@
<template>
<div class="pre-registration-form">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="auto"
label-position="top"
>
<el-form-item label="排序" prop="order">
<el-input v-model="formData.order" placeholder="请输入" />
</el-form-item>
<el-form-item label="话术内容" prop="content">
<el-input v-model="formData.content" type="textarea" placeholder="请输入" />
</el-form-item>
</el-form>
</div>
</template>
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { deepCloneByJSON } from '@/utils/auxiliaryFunction'
const props = defineProps({
newData: {
type: Object,
default: () => ({})
}
})
const formRef = ref()
// 表单数据
const formData = reactive<any>({
order: '',
content: ''
})
const formRules = reactive<any>({
order: [{ required: true, message: '请输入', trigger: 'blur' }],
content: [{ required: true, message: '请输入', trigger: 'blur' }]
})
onMounted(() => {
setFormData(props.newData)
})
const getForm = () => {
return formData
}
const setFormData = (data: any) => {
if (data && Object.keys(data).length > 0) {
const data1 = deepCloneByJSON(data)
Object.assign(formData, data1)
}
}
const submit = (): Promise<boolean> => {
return new Promise((resolve, reject) => {
formRef.value?.validate((valid: boolean) => {
if (valid) {
resolve(true)
} else {
ElMessage.error('请完善必填信息')
reject(false)
}
})
})
}
defineExpose({
submit,
getForm
})
</script>
<style scoped lang="scss">
.pre-registration-form {
width: 100%;
padding-right: 20px;
overflow: hidden;
overflow-y: auto;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.3);
border-radius: 3px;
}
&::-webkit-scrollbar-thumb:hover {
background: rgba(0, 0, 0, 0.5);
}
}
.section {
display: flex;
flex-direction: column;
gap: 20px;
}
</style>

View File

@@ -0,0 +1,232 @@
<template>
<div class="app-container">
<h3>复聊话术</h3>
<el-card shadow="hover" class="data-table">
<div class="data-table__toolbar">
<div class="data-table__toolbar--actions">
<el-button type="success" icon="plus" @click="handleOpenDialog()">新增</el-button>
</div>
<div class="data-table__toolbar--actions">
<el-select
v-model="queryParams.day_number"
placeholder="请选择"
style="width: 100px"
@change="handleQuery()"
>
<el-option v-for="item in 5" :key="item" :label="`第${item}天`" :value="item">
{{ `${item}` }}
</el-option>
</el-select>
</div>
</div>
<el-table
ref="dataTableRef"
v-loading="loading"
:data="roleList"
highlight-current-row
border
class="data-table__content"
@selection-change="handleSelectionChange"
>
<el-table-column label="第几天" prop="day_number">
<template #default="scope">{{ scope.row?.day_number }}</template>
</el-table-column>
<el-table-column label="排序" prop="order" />
<el-table-column label="话术内容" prop="content" />
<el-table-column label="创建时间" prop="created_at">
<template #default="scope">
{{ formatISOToDateTime(scope.row?.created_at || '') }}
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="140">
<template #default="scope">
<el-button
type="primary"
size="small"
link
icon="edit"
@click="handleOpenDialog(scope.row)"
>
编辑
</el-button>
<el-button
type="danger"
size="small"
link
icon="delete"
@click="onUserDeleteDepartment(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-if="total > 0"
v-model:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="fetchData"
/>
</el-card>
</div>
</template>
<script setup lang="ts">
import { RolePageVO } from '@/api/system/role-api'
import { functionDialogBox } from '@/utils/functionDialogBox'
import RevisedConversationScriptForm from './components/RevisedConversationScriptForm.vue'
import {
ApiFollowupScripts,
ApiFollowupScriptsAdd,
ApiFollowupScriptsDelete,
ApiFollowupScriptsEditor
} from '@/api/ReconciliationManagement'
import { formatISOToDateTime } from '@/utils/auxiliaryFunction'
const props = defineProps({
configId: {
type: String,
default: ''
}
})
defineOptions({
name: 'Role',
inheritAttrs: false
})
const queryFormRef = ref()
const loading = ref(false)
const ids = ref<number[]>([])
const total = ref(0)
const queryParams = reactive<any>({
pageNum: 1,
pageSize: 10,
day_number: 1
})
// 表格数据
const roleList = ref<RolePageVO[]>()
// 弹窗
const dialog = reactive({
title: '',
visible: false
})
// 获取数据
function fetchData() {
loading.value = true
ApiFollowupScripts({
config_id: props.configId,
day_number: queryParams.day_number
})
.then((res: any) => {
roleList.value = res.data
// total.value = res.data.total
})
.finally(() => {
loading.value = false
})
}
// 查询(重置页码后获取数据)
function handleQuery() {
queryParams.pageNum = 1
fetchData()
}
// 重置查询
function handleResetQuery() {
if (queryFormRef.value) queryFormRef.value.resetFields()
queryParams.pageNum = 1
fetchData()
}
// 行复选框选中
function handleSelectionChange(selection: any) {
ids.value = selection.map((item: any) => item.id)
}
// 打开角色弹窗
function handleOpenDialog(data: any = null) {
dialog.visible = true
if (data) {
functionDialogBox(
RevisedConversationScriptForm,
{
newData: data
},
{
title: '编辑复聊话术',
width: '900',
ok(value: any) {
handleSubmit({ id: data.id, ...value })
}
}
)
} else {
functionDialogBox(
RevisedConversationScriptForm,
{},
{
title: '创建复聊话术',
width: '900',
ok(value: any) {
handleSubmit({ ...value, config_id: props.configId, day_number: queryParams.day_number })
}
}
)
}
}
// 提交角色表单
function handleSubmit(data: any) {
loading.value = true
const roleId = data.id
if (roleId) {
ApiFollowupScriptsEditor(data)
.then(() => {
ElMessage.success('修改成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
} else {
ApiFollowupScriptsAdd(data)
.then(() => {
ElMessage.success('新增成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
}
}
const onUserDeleteDepartment = (id: string) => {
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(
() => {
loading.value = true
ApiFollowupScriptsDelete(id)
.then(() => {
ElMessage.success('删除成功')
handleResetQuery()
})
.finally(() => (loading.value = false))
},
() => {
ElMessage.info('已取消删除')
}
)
}
onMounted(() => {
handleQuery()
})
</script>

View File

@@ -0,0 +1,11 @@
<template>
<div class="app-container">
<ReconfigurationSettings></ReconfigurationSettings>
<!-- <RevisedConversationScript></RevisedConversationScript>-->
</div>
</template>
<script setup lang="ts">
import ReconfigurationSettings from './components/ReconfigurationSettings/index.vue'
// import RevisedConversationScript from './components/RevisedConversationScript/index.vue'
</script>