|
@@ -1,4 +1,4 @@
|
|
|
-import { defineComponent, onMounted, reactive } from 'vue';
|
|
|
+import { defineComponent, onMounted, reactive, ref } from 'vue';
|
|
|
import styles from './index.module.less';
|
|
|
import MHeader from '@/components/m-header';
|
|
|
import { Area, Button, CellGroup, Field, Form, Popup, showToast } from 'vant';
|
|
@@ -133,19 +133,29 @@ export default defineComponent({
|
|
|
}
|
|
|
}, 1000);
|
|
|
};
|
|
|
- const handleSubmit = async () => {
|
|
|
+ const formRef = ref();
|
|
|
+ const handleSubmit = () => {
|
|
|
forms.name = forms.name.trim();
|
|
|
- if (!forms.code) {
|
|
|
- showToast('请输入验证码');
|
|
|
- return;
|
|
|
- }
|
|
|
- const res = await api_schoolSave({ ...forms });
|
|
|
- if (res?.code === 200) {
|
|
|
- if (res?.data?.id) {
|
|
|
- forms.id = res.data.id;
|
|
|
- }
|
|
|
- data.success = true;
|
|
|
- }
|
|
|
+ formRef.value
|
|
|
+ .validate()
|
|
|
+ .then(async () => {
|
|
|
+ if (!forms.code) {
|
|
|
+ showToast('请输入验证码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const res = await api_schoolSave({ ...forms });
|
|
|
+ if (res?.code === 200) {
|
|
|
+ if (res?.data?.id) {
|
|
|
+ forms.id = res.data.id;
|
|
|
+ }
|
|
|
+ data.success = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err: any) => {
|
|
|
+ console.log('🚀 ~ err:', err);
|
|
|
+ formRef.value.scrollToField(err[0].name);
|
|
|
+ });
|
|
|
+ return;
|
|
|
};
|
|
|
return () => (
|
|
|
<div class={styles.container}>
|
|
@@ -160,7 +170,7 @@ export default defineComponent({
|
|
|
|
|
|
<div class={styles.contentWrap}>
|
|
|
<div class={styles.content}>
|
|
|
- <Form onSubmit={() => handleSubmit()}>
|
|
|
+ <Form ref={formRef}>
|
|
|
<CellGroup class={styles.group}>
|
|
|
<img src={icon_school} class={styles.icon} />
|
|
|
<Field
|
|
@@ -192,6 +202,7 @@ export default defineComponent({
|
|
|
<Field
|
|
|
isLink
|
|
|
border
|
|
|
+ name="cityName"
|
|
|
label="所属城市"
|
|
|
placeholder="请选择"
|
|
|
readonly
|
|
@@ -199,7 +210,7 @@ export default defineComponent({
|
|
|
v-model={data.cityName}
|
|
|
onClick={() => {
|
|
|
if (browserInfo.ios && data.inputFouce < 2) {
|
|
|
- data.inputFouce++
|
|
|
+ data.inputFouce++;
|
|
|
setTimeout(() => {
|
|
|
data.showArea = true;
|
|
|
}, 700);
|
|
@@ -458,7 +469,11 @@ export default defineComponent({
|
|
|
</div>
|
|
|
</CellGroup>
|
|
|
|
|
|
- <Button class={styles.submit} round block native-type="submit">
|
|
|
+ <Button
|
|
|
+ class={styles.submit}
|
|
|
+ round
|
|
|
+ block
|
|
|
+ onClick={() => handleSubmit()}>
|
|
|
<img class={styles.submitIcon} src={icon_submit} />
|
|
|
</Button>
|
|
|
</Form>
|