四零语境后端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
982 B

<template>
<div>
<BasicForm @register="registerForm" @submit="handleSubmit"/>
</div>
</template>
<script lang="ts" setup>
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../AppletCoursePage.data';
import { saveOrUpdate } from '../AppletCoursePage.api';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
const emit = defineEmits(['success']);
const [registerForm, { validate, resetFields }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: true,
actionColOptions: {
span: 24,
},
baseColProps: { span: 12 },
});
async function handleSubmit() {
try {
const values = await validate();
await saveOrUpdate(values, false);
createMessage.success('保存成功');
await resetFields();
emit('success');
} catch (error) {
createMessage.error('保存失败');
}
}
</script>