update: 模板保存添加必填校验

This commit is contained in:
zhuoqinglian
2026-06-17 10:36:02 +08:00
parent 164eb5481c
commit 7849e6b030
@@ -78,7 +78,7 @@
@confirm="handleDialogConfirm"
@cancel="dialogVisible = false"
>
<el-form ref="dialogForm" :model="form" label-width="100px">
<el-form ref="dialogForm" :model="form" :rules="formRules" label-width="100px">
<el-form-item :label="$t('templateQuickConfig.agentSettings.agentName')" prop="agentName">
<el-input
v-model="form.agentName"
@@ -155,6 +155,14 @@ export default {
sort: 0,
model: { ...DEFAULT_MODEL_CONFIG }
},
formRules: {
agentName: [
{ required: true, message: "请输入助手昵称", trigger: "blur" }
],
systemPrompt: [
{ required: true, message: "请输入角色介绍", trigger: "blur" }
]
},
originalForm: null
};
},
@@ -263,20 +271,23 @@ export default {
});
},
handleDialogConfirm() {
const configData = {
id: this.form.id || "",
agentCode: this.form.agentCode,
agentName: this.form.agentName,
systemPrompt: this.form.systemPrompt,
sort: this.form.sort,
functions: [],
...this.form.model
};
this.$refs.dialogForm.validate((valid) => {
if (!valid) return;
this.confirmLoading = true;
const apiCall = this.form.id
? agentApi.updateAgentTemplate
: agentApi.addAgentTemplate;
const configData = {
id: this.form.id || "",
agentCode: this.form.agentCode,
agentName: this.form.agentName,
systemPrompt: this.form.systemPrompt,
sort: this.form.sort,
functions: [],
...this.form.model
};
this.confirmLoading = true;
const apiCall = this.form.id
? agentApi.updateAgentTemplate
: agentApi.addAgentTemplate;
apiCall(configData, (res) => {
this.confirmLoading = false;
@@ -297,6 +308,7 @@ export default {
this.confirmLoading = false;
this.$message.error(this.$t("common.networkError"));
});
});
},
deleteTemplate(row) {
this.$confirm(