From 188cd2c31c875bdd117b6540675d116677548281 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 8 Aug 2022 16:08:08 +0800 Subject: [PATCH] feat(gui-v2): submit form --- .../nc-gui-v2/components/smartsheet/Form.vue | 150 ++++++++++-------- 1 file changed, 85 insertions(+), 65 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Form.vue b/packages/nc-gui-v2/components/smartsheet/Form.vue index 052725d9b4..f676dcf0dd 100644 --- a/packages/nc-gui-v2/components/smartsheet/Form.vue +++ b/packages/nc-gui-v2/components/smartsheet/Form.vue @@ -19,6 +19,8 @@ const toast = useToast() const state = useGlobal() +const formRef = ref() + const { $api, $e } = useNuxtApp() const { isUIAllowed } = useUIPermission() @@ -78,8 +80,14 @@ const formView = ref({}) function updateView() {} -function submitForm() { - // TODO: validation +async function submitForm() { + try { + await formRef.value?.validateFields() + } catch (e: any) { + e.errorFields.map((f: Record) => toast.error(f.errors.join(','))) + return + } + insertRow(formState) } @@ -334,7 +342,7 @@ watch( - +
@@ -362,74 +370,86 @@ watch( @click="updateView" /> - - - + +