新增羊只,转群功能完善
This commit is contained in:
@@ -143,21 +143,24 @@ const rules = {
|
||||
};
|
||||
|
||||
|
||||
//表单验证
|
||||
//表单验证 提交表单数据
|
||||
const submitForm = () => {
|
||||
formRef.value.validate((valid) => {
|
||||
console.log('表单验证结果:', valid);
|
||||
if (valid) {
|
||||
addSheep(form.value)
|
||||
addSheep(form.value) // 调用 API 方法,addSheep 应已在 @/api/sheep/sheep.js 中定义
|
||||
.then(response => {
|
||||
console.log('后端响应:', response);
|
||||
if (response.code === 200) {
|
||||
alert('新增成功');
|
||||
resetForm();
|
||||
// 可以在这里添加刷新列表的逻辑,例如调用 list 方法
|
||||
} else {
|
||||
alert(response.msg || '新增失败');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('新增失败:', error);
|
||||
alert('新增失败,请稍后重试');
|
||||
});
|
||||
} else {
|
||||
alert('请填写所有必填字段');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user