优化代码结构
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="system-edit-role-container">
|
||||
<div class="script-edit-dialog">
|
||||
<el-dialog title="" v-model="isShowDialog" width="769px" @close="onDialogClose">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" size="default" label-width="90px">
|
||||
<el-row :gutter="35">
|
||||
@@ -32,7 +32,7 @@
|
||||
import { ref, reactive, toRefs, nextTick } from 'vue';
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||
import Editor from '/@/components/editor/index.vue';
|
||||
import { getscriptAdd, updatescript } from '/@/api/customerService/script';
|
||||
import { addScript, updateScript } from '/@/api/customerService/script';
|
||||
|
||||
// 定义类型接口
|
||||
interface DialogRow {
|
||||
@@ -45,7 +45,7 @@ interface DialogRow {
|
||||
|
||||
// 定义事件
|
||||
const emit = defineEmits<{
|
||||
(e: 'success'): void;
|
||||
(e: 'refresh'): void;
|
||||
}>();
|
||||
|
||||
// 响应式数据
|
||||
@@ -149,18 +149,17 @@ const onSubmit = async () => {
|
||||
|
||||
if (state.formData.id === 0) {
|
||||
// 新增模式
|
||||
console.log(state.formData.content, '话术内容');
|
||||
await getscriptAdd(state.formData);
|
||||
await addScript(state.formData);
|
||||
ElMessage.success('添加成功');
|
||||
} else {
|
||||
// 编辑模式
|
||||
await updatescript(state.formData);
|
||||
await updateScript(state.formData);
|
||||
ElMessage.success('修改成功');
|
||||
}
|
||||
|
||||
// 关闭对话框并刷新列表
|
||||
state.isShowDialog = false;
|
||||
emit('success');
|
||||
emit('refresh');
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error);
|
||||
ElMessage.error('操作失败');
|
||||
|
||||
Reference in New Issue
Block a user