Browse Source

fix(nc-gui): field validation issue

pull/7664/head
Ramesh Mane 7 months ago
parent
commit
c61dbcf57c
  1. 20
      packages/nc-gui/components/smartsheet/Form.vue

20
packages/nc-gui/components/smartsheet/Form.vue

@ -62,7 +62,7 @@ const { $api, $e } = useNuxtApp()
const { isUIAllowed } = useRoles()
let formState = reactive({})
let formState = reactive<Record<string, any>>({})
const secondsRemain = ref(0)
@ -158,8 +158,9 @@ async function submitForm() {
}
async function clearForm() {
formState = {}
formState = reactive<Record<string, any>>({})
state.value = {}
await formRef.value.clearValidate()
reloadEventHook.trigger()
}
@ -428,6 +429,20 @@ watch(view, (nextView) => {
}
})
watch([formState, state.value], async () => {
for (const virtualField in state.value) {
if (!formState[virtualField]) {
formState[virtualField] = state.value[virtualField]
}
}
try {
await formRef.value?.validateFields([...Object.keys(formState)])
} catch (e: any) {
e.errorFields.map((f: Record<string, any>) => console.error(f.errors.join(',')))
}
})
watch(activeRow, (newValue) => {
if (newValue) {
document
@ -892,7 +907,6 @@ useEventListener(
<div class="flex justify-between items-center mt-6 !px-8 !lg:px-12">
<NcButton
html-type="reset"
type="secondary"
size="small"
:disabled="!isUIAllowed('dataInsert')"

Loading…
Cancel
Save