mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
update: 模板保存添加必填校验
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user