mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 09:33:55 +08:00
update: 模板保存添加必填校验
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
@confirm="handleDialogConfirm"
|
@confirm="handleDialogConfirm"
|
||||||
@cancel="dialogVisible = false"
|
@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-form-item :label="$t('templateQuickConfig.agentSettings.agentName')" prop="agentName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.agentName"
|
v-model="form.agentName"
|
||||||
@@ -155,6 +155,14 @@ export default {
|
|||||||
sort: 0,
|
sort: 0,
|
||||||
model: { ...DEFAULT_MODEL_CONFIG }
|
model: { ...DEFAULT_MODEL_CONFIG }
|
||||||
},
|
},
|
||||||
|
formRules: {
|
||||||
|
agentName: [
|
||||||
|
{ required: true, message: "请输入助手昵称", trigger: "blur" }
|
||||||
|
],
|
||||||
|
systemPrompt: [
|
||||||
|
{ required: true, message: "请输入角色介绍", trigger: "blur" }
|
||||||
|
]
|
||||||
|
},
|
||||||
originalForm: null
|
originalForm: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -263,20 +271,23 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleDialogConfirm() {
|
handleDialogConfirm() {
|
||||||
const configData = {
|
this.$refs.dialogForm.validate((valid) => {
|
||||||
id: this.form.id || "",
|
if (!valid) return;
|
||||||
agentCode: this.form.agentCode,
|
|
||||||
agentName: this.form.agentName,
|
|
||||||
systemPrompt: this.form.systemPrompt,
|
|
||||||
sort: this.form.sort,
|
|
||||||
functions: [],
|
|
||||||
...this.form.model
|
|
||||||
};
|
|
||||||
|
|
||||||
this.confirmLoading = true;
|
const configData = {
|
||||||
const apiCall = this.form.id
|
id: this.form.id || "",
|
||||||
? agentApi.updateAgentTemplate
|
agentCode: this.form.agentCode,
|
||||||
: agentApi.addAgentTemplate;
|
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) => {
|
apiCall(configData, (res) => {
|
||||||
this.confirmLoading = false;
|
this.confirmLoading = false;
|
||||||
@@ -297,6 +308,7 @@ export default {
|
|||||||
this.confirmLoading = false;
|
this.confirmLoading = false;
|
||||||
this.$message.error(this.$t("common.networkError"));
|
this.$message.error(this.$t("common.networkError"));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
deleteTemplate(row) {
|
deleteTemplate(row) {
|
||||||
this.$confirm(
|
this.$confirm(
|
||||||
|
|||||||
Reference in New Issue
Block a user