Browse Source

fix(nc-gui): field validation issue

pull/7664/head
Ramesh Mane 9 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() const { isUIAllowed } = useRoles()
let formState = reactive({}) let formState = reactive<Record<string, any>>({})
const secondsRemain = ref(0) const secondsRemain = ref(0)
@ -158,8 +158,9 @@ async function submitForm() {
} }
async function clearForm() { async function clearForm() {
formState = {} formState = reactive<Record<string, any>>({})
state.value = {} state.value = {}
await formRef.value.clearValidate()
reloadEventHook.trigger() 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) => { watch(activeRow, (newValue) => {
if (newValue) { if (newValue) {
document document
@ -892,7 +907,6 @@ useEventListener(
<div class="flex justify-between items-center mt-6 !px-8 !lg:px-12"> <div class="flex justify-between items-center mt-6 !px-8 !lg:px-12">
<NcButton <NcButton
html-type="reset"
type="secondary" type="secondary"
size="small" size="small"
:disabled="!isUIAllowed('dataInsert')" :disabled="!isUIAllowed('dataInsert')"

Loading…
Cancel
Save