优化代码结构

This commit is contained in:
WUSIJIAN
2025-12-05 15:45:14 +08:00
parent e41884fc60
commit 134ea96340
14 changed files with 67 additions and 75 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="system-edit-role-container">
<div class="account-edit-dialog">
<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">
@@ -38,7 +38,7 @@
<script lang="ts" setup>
import { ref, reactive, toRefs, nextTick } from 'vue';
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 {
id?: string;
@@ -50,7 +50,7 @@ interface DialogFormData {
}
const emit = defineEmits<{
(e: 'getRoleList'): void;
(e: 'refresh'): void;
}>();
const state = reactive({
@@ -127,23 +127,17 @@ const onSubmit = async () => {
state.loading = true;
if (state.formData.id) {
// 修改操作 - 不包含状态字段
const updateData = {
id: state.formData.id,
customerServiceId: state.formData.customerServiceId,
platform: state.formData.platform,
// 注意修改时不传递status状态通过单独的开关控制\
};
await updateaccount(updateData);
// 修改操作
await updateAccount(state.formData);
ElMessage.success('修改成功');
} else {
// 新增操作
await getaccountAdd(state.formData);
await addAccount(state.formData);
ElMessage.success('添加成功');
}
closeDialog();
emit('getRoleList');
emit('refresh');
} catch (error) {
console.error('操作失败:', error);
ElMessage.error(state.formData.id ? '修改失败' : '添加失败');