非空判断

This commit is contained in:
WUSIJIAN
2025-12-01 16:54:21 +08:00
parent 91ce6a597d
commit ad1acf29b8
2 changed files with 14 additions and 1 deletions

View File

@@ -164,6 +164,12 @@ const onSubmit = async () => {
return; return;
} }
// 额外验证话术内容
if (!state.formData.description || state.formData.description === '<p><br></p>' || state.formData.description.trim() === '<p><br></p>') {
ElMessage.warning('产品详情内容不能为空');
return;
}
// 根据ID判断是新增还是修改 // 根据ID判断是新增还是修改
if (state.formData.id === 0) { if (state.formData.id === 0) {
// 新增产品 // 新增产品

View File

@@ -10,7 +10,7 @@
</el-col> </el-col>
<!-- 富文本编辑器 --> <!-- 富文本编辑器 -->
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="产品详情" prop="content"> <el-form-item label="话术" prop="content">
<Editor v-model="formData.content" height="400px" :key="editorKey" placeholder="请输入产品详情" /> <Editor v-model="formData.content" height="400px" :key="editorKey" placeholder="请输入产品详情" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -133,10 +133,17 @@ const onSubmit = async () => {
const valid = await formRef.value.validate(); const valid = await formRef.value.validate();
if (!valid) return; if (!valid) return;
// 额外验证话术内容
if (!state.formData.content || state.formData.content === '<p><br></p>' || state.formData.content.trim() === '<p><br></p>') {
ElMessage.warning('话术内容不能为空');
return;
}
state.loading = true; state.loading = true;
if (state.formData.id === 0) { if (state.formData.id === 0) {
// 新增模式 // 新增模式
console.log(state.formData.content, '话术内容');
await getscriptAdd(state.formData); await getscriptAdd(state.formData);
ElMessage.success('添加成功'); ElMessage.success('添加成功');
} else { } else {