优化代码结构
This commit is contained in:
@@ -10,7 +10,7 @@ export function getaccountList(data: object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加客服账号
|
//添加客服账号
|
||||||
export function getaccountAdd(data: object) {
|
export function addAccount(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/customer/service/account/add',
|
url: '/customerService/customer/service/account/add',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -28,7 +28,7 @@ export function updatestate(data: object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新账号
|
//更新账号
|
||||||
export function updateaccount(data: object) {
|
export function updateAccount(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/customer/service/account/update',
|
url: '/customerService/customer/service/account/update',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import request, { newService } from '/@/utils/request';
|
import request, { newService } from '/@/utils/request';
|
||||||
|
|
||||||
//添加产品
|
//添加产品
|
||||||
export function getproductAdd(data: object) {
|
export function addProduct(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/product/add',
|
url: '/customerService/product/add',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ export function getDataList(data: object) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出数据
|
// 导出报表
|
||||||
export function exportProduct(data: object) {
|
export function exportReport(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/data/statistics/export',
|
url: '/customerService/data/statistics/export',
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ export function getscriptList(data: object) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取话术列表
|
//增加话术
|
||||||
export function getscriptAdd(data: object) {
|
export function addScript(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/speechcraft/add',
|
url: '/customerService/speechcraft/add',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -19,7 +19,7 @@ export function getscriptAdd(data: object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//删除话术列表
|
//删除话术列表
|
||||||
export function deletescript(data: object) {
|
export function deleteScript(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/speechcraft/delete',
|
url: '/customerService/speechcraft/delete',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -28,7 +28,7 @@ export function deletescript(data: object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新话术列表
|
//更新话术列表
|
||||||
export function updatescript(data: object) {
|
export function updateScript(data: object) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/customerService/speechcraft/update',
|
url: '/customerService/speechcraft/update',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const service: AxiosInstance = axios.create({
|
|||||||
|
|
||||||
// 配置新建第二个 axios 实例(新功能服务)
|
// 配置新建第二个 axios 实例(新功能服务)
|
||||||
const newService: AxiosInstance = axios.create({
|
const newService: AxiosInstance = axios.create({
|
||||||
baseURL: 'http://192.168.3.95:8000/',
|
// baseURL: 'http://192.168.3.95:8000/',
|
||||||
// baseURL: 'http://192.168.3.49:8000/',
|
baseURL: 'http://192.168.3.49:8000/',
|
||||||
timeout: 50000,
|
timeout: 50000,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
paramsSerializer: {
|
paramsSerializer: {
|
||||||
@@ -133,7 +133,7 @@ const responseErrorHandler = (error: any) => {
|
|||||||
|
|
||||||
if (!error.response) {
|
if (!error.response) {
|
||||||
if (error.message === 'Network Error') {
|
if (error.message === 'Network Error') {
|
||||||
ElMessage.error('网络连接错误,请检查网络设置');
|
// ElMessage.error('网络连接错误,请检查网络设置');
|
||||||
} else {
|
} else {
|
||||||
// ElMessage.error('网络异常,请检查连接');
|
// ElMessage.error('网络异常,请检查连接');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="system-edit-role-container">
|
<div class="account-edit-dialog">
|
||||||
<el-dialog :title="(formData.id ? '修改' : '添加') + '客服账号'" v-model="isShowDialog" width="769px">
|
<el-dialog :title="(formData.id ? '修改' : '添加') + '客服账号'" v-model="isShowDialog" width="769px">
|
||||||
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
||||||
<el-row :gutter="35">
|
<el-row :gutter="35">
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, toRefs, nextTick } from 'vue';
|
import { ref, reactive, toRefs, nextTick } from 'vue';
|
||||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||||
import { getaccountAdd, updateaccount } from '/@/api/customerService/account';
|
import { addAccount, updateAccount } from '/@/api/customerService/account';
|
||||||
|
|
||||||
interface DialogFormData {
|
interface DialogFormData {
|
||||||
id?: string;
|
id?: string;
|
||||||
@@ -50,7 +50,7 @@ interface DialogFormData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'getRoleList'): void;
|
(e: 'refresh'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@@ -127,23 +127,17 @@ const onSubmit = async () => {
|
|||||||
state.loading = true;
|
state.loading = true;
|
||||||
|
|
||||||
if (state.formData.id) {
|
if (state.formData.id) {
|
||||||
// 修改操作 - 不包含状态字段
|
// 修改操作
|
||||||
const updateData = {
|
await updateAccount(state.formData);
|
||||||
id: state.formData.id,
|
|
||||||
customerServiceId: state.formData.customerServiceId,
|
|
||||||
platform: state.formData.platform,
|
|
||||||
// 注意:修改时不传递status,状态通过单独的开关控制\
|
|
||||||
};
|
|
||||||
await updateaccount(updateData);
|
|
||||||
ElMessage.success('修改成功');
|
ElMessage.success('修改成功');
|
||||||
} else {
|
} else {
|
||||||
// 新增操作
|
// 新增操作
|
||||||
await getaccountAdd(state.formData);
|
await addAccount(state.formData);
|
||||||
ElMessage.success('添加成功');
|
ElMessage.success('添加成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
emit('getRoleList');
|
emit('refresh');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('操作失败:', error);
|
console.error('操作失败:', error);
|
||||||
ElMessage.error(state.formData.id ? '修改失败' : '添加失败');
|
ElMessage.error(state.formData.id ? '修改失败' : '添加失败');
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
<EditAccount ref="editRoleRef" @getRoleList="getList" />
|
<EditAccount ref="editRoleRef" @refresh="getList" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
import { ref, reactive, onMounted } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||||
import EditAccount from './component/editAccount.vue';
|
import EditAccount from './component/editAccount.vue';
|
||||||
import { getaccountAdd, getaccountList, updatestate } from '/@/api/customerService/account';
|
import { addAccount, getaccountList, updatestate } from '/@/api/customerService/account';
|
||||||
|
|
||||||
// 定义类型接口
|
// 定义类型接口
|
||||||
interface TableDataItem {
|
interface TableDataItem {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="system-edit-role-container">
|
<div class="product-edit-dialog">
|
||||||
<el-dialog :title="(formData.id === 0 ? '添加' : '修改') + '产品'" v-model="isShowDialog" width="1000px">
|
<el-dialog :title="(formData.id === 0 ? '添加' : '修改') + '产品'" v-model="isShowDialog" width="1000px">
|
||||||
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
||||||
<el-row :gutter="35">
|
<el-row :gutter="35">
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, toRefs, nextTick } from 'vue';
|
import { ref, reactive, toRefs, nextTick } from 'vue';
|
||||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||||
import { getproductAdd, updateProduct } from '/@/api/customerService/product';
|
import { addProduct, updateProduct } from '/@/api/customerService/product';
|
||||||
import Editor from '/@/components/editor/index.vue';
|
import Editor from '/@/components/editor/index.vue';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,9 +61,9 @@ interface ComponentState {
|
|||||||
// 定义组件事件
|
// 定义组件事件
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
/**
|
/**
|
||||||
* 获取产品列表事件 - 用于刷新父组件列表
|
* 刷新产品列表事件
|
||||||
*/
|
*/
|
||||||
(e: 'getRoleList'): void;
|
(e: 'refresh'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 响应式状态
|
// 响应式状态
|
||||||
@@ -173,10 +173,8 @@ const onSubmit = async () => {
|
|||||||
// 根据ID判断是新增还是修改
|
// 根据ID判断是新增还是修改
|
||||||
if (state.formData.id === 0) {
|
if (state.formData.id === 0) {
|
||||||
// 新增产品
|
// 新增产品
|
||||||
|
await addProduct(state.formData);
|
||||||
await getproductAdd(state.formData).then((res) => {
|
ElMessage.success('产品添加成功');
|
||||||
ElMessage.success('产品添加成功');
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// 修改产品
|
// 修改产品
|
||||||
await updateProduct(state.formData);
|
await updateProduct(state.formData);
|
||||||
@@ -185,7 +183,7 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
// 关闭对话框并刷新列表
|
// 关闭对话框并刷新列表
|
||||||
closeDialog();
|
closeDialog();
|
||||||
emit('getRoleList');
|
emit('refresh');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('提交失败:', error);
|
console.error('提交失败:', error);
|
||||||
ElMessage.error(state.formData.id === 0 ? '添加失败' : '修改失败');
|
ElMessage.error(state.formData.id === 0 ? '添加失败' : '修改失败');
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="导出产品数据" v-model="isShowDialog" width="450px" align-center>
|
<div class="product-export-dialog">
|
||||||
<div class="export-content">
|
<el-dialog title="导出产品数据" v-model="isShowDialog" width="450px" align-center>
|
||||||
<div class="export-icon">
|
<div class="export-content">
|
||||||
<el-icon class="icon-download"><Download /></el-icon>
|
<div class="export-icon">
|
||||||
|
<el-icon class="icon-download"><Download /></el-icon>
|
||||||
|
</div>
|
||||||
|
<p class="export-text">确定要导出产品数据吗?</p>
|
||||||
|
<p class="export-tip">导出的文件将包含所有产品信息</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="export-text">确定要导出产品数据吗?</p>
|
<template #footer>
|
||||||
<p class="export-tip">导出的文件将包含所有产品信息</p>
|
<div class="dialog-footer">
|
||||||
</div>
|
<el-button @click="isShowDialog = false">取消</el-button>
|
||||||
<template #footer>
|
<el-button type="primary" @click="handleExport" :loading="loading">
|
||||||
<div class="dialog-footer">
|
<el-icon><Download /></el-icon>
|
||||||
<el-button @click="isShowDialog = false">取消</el-button>
|
导出
|
||||||
<el-button type="primary" @click="handleExport" :loading="loading">
|
</el-button>
|
||||||
<el-icon><Download /></el-icon>
|
</div>
|
||||||
导出
|
</template>
|
||||||
</el-button>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ import { saveAs } from 'file-saver';
|
|||||||
import { importProduct } from '/@/api/customerService/product';
|
import { importProduct } from '/@/api/customerService/product';
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'getRoleList'): void;
|
(e: 'refresh'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 响应式状态
|
// 响应式状态
|
||||||
@@ -279,8 +279,7 @@ const handleCustomUpload = async (file: File) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElMessage.success(`导入完成!失败记录:${resultData.failCount || 0}条`);
|
ElMessage.success(`导入完成!失败记录:${resultData.failCount || 0}条`);
|
||||||
emit('getRoleList');
|
emit('refresh');
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (isShowDialog.value) {
|
if (isShowDialog.value) {
|
||||||
isShowDialog.value = false;
|
isShowDialog.value = false;
|
||||||
|
|||||||
@@ -87,10 +87,10 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 编辑对话框组件 -->
|
<!-- 编辑对话框组件 -->
|
||||||
<EditRole ref="editRoleRef" @getRoleList="getProductList" />
|
<EditRole ref="editRoleRef" @refresh="getProductList" />
|
||||||
|
|
||||||
<!-- 导入导出对话框组件 -->
|
<!-- 导入导出对话框组件 -->
|
||||||
<ImportDialog ref="importDialogRef" @getRoleList="getProductList" />
|
<ImportDialog ref="importDialogRef" @refresh="getProductList" />
|
||||||
<ExportDialog ref="exportDialogRef" />
|
<ExportDialog ref="exportDialogRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="导出产品数据" v-model="isShowDialog" width="450px" align-center>
|
<el-dialog title="导出报表数据" v-model="isShowDialog" width="450px" align-center>
|
||||||
<div class="export-content">
|
<div class="report-export-content">
|
||||||
<div class="export-icon">
|
<div class="export-icon">
|
||||||
<el-icon class="icon-download"><Download /></el-icon>
|
<el-icon class="icon-download"><Download /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
<p class="export-text">确定要导出产品数据吗?</p>
|
<p class="export-text">确定要导出报表数据吗?</p>
|
||||||
<p class="export-tip">导出的文件将包含所有产品信息</p>
|
<p class="export-tip">导出的文件将包含所有报表信息</p>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { Download } from '@element-plus/icons-vue';
|
import { Download } from '@element-plus/icons-vue';
|
||||||
import { exportProduct } from '/@/api/customerService/report';
|
import { exportReport } from '/@/api/customerService/report';
|
||||||
|
|
||||||
const isShowDialog = ref(false);
|
const isShowDialog = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -46,8 +46,8 @@ const handleExport = async () => {
|
|||||||
params.name = exportName.value;
|
params.name = exportName.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用导出接口 - 根据API文档,这里应该返回JSON
|
// 调用导出接口
|
||||||
const response = await exportProduct(params);
|
const response = await exportReport(params);
|
||||||
|
|
||||||
console.log('导出响应:', response);
|
console.log('导出响应:', response);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="system-edit-role-container">
|
<div class="script-edit-dialog">
|
||||||
<el-dialog title="" v-model="isShowDialog" width="769px" @close="onDialogClose">
|
<el-dialog title="" v-model="isShowDialog" width="769px" @close="onDialogClose">
|
||||||
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
||||||
<el-row :gutter="35">
|
<el-row :gutter="35">
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
import { ref, reactive, toRefs, nextTick } from 'vue';
|
import { ref, reactive, toRefs, nextTick } from 'vue';
|
||||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||||
import Editor from '/@/components/editor/index.vue';
|
import Editor from '/@/components/editor/index.vue';
|
||||||
import { getscriptAdd, updatescript } from '/@/api/customerService/script';
|
import { addScript, updateScript } from '/@/api/customerService/script';
|
||||||
|
|
||||||
// 定义类型接口
|
// 定义类型接口
|
||||||
interface DialogRow {
|
interface DialogRow {
|
||||||
@@ -45,7 +45,7 @@ interface DialogRow {
|
|||||||
|
|
||||||
// 定义事件
|
// 定义事件
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'success'): void;
|
(e: 'refresh'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
@@ -149,18 +149,17 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
if (state.formData.id === 0) {
|
if (state.formData.id === 0) {
|
||||||
// 新增模式
|
// 新增模式
|
||||||
console.log(state.formData.content, '话术内容');
|
await addScript(state.formData);
|
||||||
await getscriptAdd(state.formData);
|
|
||||||
ElMessage.success('添加成功');
|
ElMessage.success('添加成功');
|
||||||
} else {
|
} else {
|
||||||
// 编辑模式
|
// 编辑模式
|
||||||
await updatescript(state.formData);
|
await updateScript(state.formData);
|
||||||
ElMessage.success('修改成功');
|
ElMessage.success('修改成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭对话框并刷新列表
|
// 关闭对话框并刷新列表
|
||||||
state.isShowDialog = false;
|
state.isShowDialog = false;
|
||||||
emit('success');
|
emit('refresh');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('提交失败:', error);
|
console.error('提交失败:', error);
|
||||||
ElMessage.error('操作失败');
|
ElMessage.error('操作失败');
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 编辑组件 -->
|
<!-- 编辑组件 -->
|
||||||
<EditRole ref="editRoleRef" @success="handleSuccess" />
|
<EditRole ref="editRoleRef" @refresh="loadTableData" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ import { ElMessageBox, ElMessage } from 'element-plus';
|
|||||||
import { FolderAdd, EditPen, DeleteFilled } from '@element-plus/icons-vue';
|
import { FolderAdd, EditPen, DeleteFilled } from '@element-plus/icons-vue';
|
||||||
import EditRole from './component/editRole.vue';
|
import EditRole from './component/editRole.vue';
|
||||||
import Pagination from '/@/components/pagination/index.vue';
|
import Pagination from '/@/components/pagination/index.vue';
|
||||||
import { getscriptList, deletescript } from '/@/api/customerService/script';
|
import { getscriptList, deleteScript } from '/@/api/customerService/script';
|
||||||
|
|
||||||
// ==================== 类型定义 ====================
|
// ==================== 类型定义 ====================
|
||||||
interface ScriptItem {
|
interface ScriptItem {
|
||||||
@@ -230,7 +230,7 @@ const handleDelete = async (row: ScriptItem) => {
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
});
|
});
|
||||||
|
|
||||||
await deletescript({ id: row.id });
|
await deleteScript({ id: row.id });
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
|
|
||||||
// 重新加载数据
|
// 重新加载数据
|
||||||
|
|||||||
Reference in New Issue
Block a user