|
|
@ -31,7 +31,6 @@ import { |
|
|
|
onClickOutside, |
|
|
|
onClickOutside, |
|
|
|
parseProp, |
|
|
|
parseProp, |
|
|
|
provide, |
|
|
|
provide, |
|
|
|
reactive, |
|
|
|
|
|
|
|
ref, |
|
|
|
ref, |
|
|
|
useDebounceFn, |
|
|
|
useDebounceFn, |
|
|
|
useEventListener, |
|
|
|
useEventListener, |
|
|
@ -82,7 +81,7 @@ const { getPossibleAttachmentSrc } = useAttachment() |
|
|
|
|
|
|
|
|
|
|
|
const formRef = ref() |
|
|
|
const formRef = ref() |
|
|
|
|
|
|
|
|
|
|
|
let formState = reactive<Record<string, any>>({}) |
|
|
|
const formState = ref<Record<string, any>>({}) |
|
|
|
|
|
|
|
|
|
|
|
const secondsRemain = ref(0) |
|
|
|
const secondsRemain = ref(0) |
|
|
|
|
|
|
|
|
|
|
@ -112,7 +111,7 @@ const { fields, showAll, hideAll } = useViewColumnsOrThrow() |
|
|
|
const { state, row } = useProvideSmartsheetRowStore( |
|
|
|
const { state, row } = useProvideSmartsheetRowStore( |
|
|
|
meta, |
|
|
|
meta, |
|
|
|
ref({ |
|
|
|
ref({ |
|
|
|
row: formState, |
|
|
|
row: formState.value, |
|
|
|
oldRow: {}, |
|
|
|
oldRow: {}, |
|
|
|
rowMeta: { new: true }, |
|
|
|
rowMeta: { new: true }, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -198,7 +197,7 @@ const updateView = useDebounceFn( |
|
|
|
const updatePreFillFormSearchParams = useDebounceFn(() => { |
|
|
|
const updatePreFillFormSearchParams = useDebounceFn(() => { |
|
|
|
if (isLocked.value || !isUIAllowed('dataInsert')) return |
|
|
|
if (isLocked.value || !isUIAllowed('dataInsert')) return |
|
|
|
|
|
|
|
|
|
|
|
const preFilledData = { ...formState, ...state.value } |
|
|
|
const preFilledData = { ...formState.value, ...state.value } |
|
|
|
|
|
|
|
|
|
|
|
const searchParams = new URLSearchParams() |
|
|
|
const searchParams = new URLSearchParams() |
|
|
|
|
|
|
|
|
|
|
@ -224,7 +223,7 @@ async function submitForm() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await insertRow({ |
|
|
|
await insertRow({ |
|
|
|
row: { ...formState, ...state.value }, |
|
|
|
row: { ...formState.value, ...state.value }, |
|
|
|
oldRow: {}, |
|
|
|
oldRow: {}, |
|
|
|
rowMeta: { new: true }, |
|
|
|
rowMeta: { new: true }, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -235,7 +234,7 @@ async function submitForm() { |
|
|
|
async function clearForm() { |
|
|
|
async function clearForm() { |
|
|
|
if (isLocked.value || !isUIAllowed('dataInsert')) return |
|
|
|
if (isLocked.value || !isUIAllowed('dataInsert')) return |
|
|
|
|
|
|
|
|
|
|
|
formState = reactive<Record<string, any>>({}) |
|
|
|
formState.value = {} |
|
|
|
state.value = {} |
|
|
|
state.value = {} |
|
|
|
await formRef.value?.clearValidate() |
|
|
|
await formRef.value?.clearValidate() |
|
|
|
reloadEventHook.trigger() |
|
|
|
reloadEventHook.trigger() |
|
|
@ -592,19 +591,25 @@ watch(view, (nextView) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
watch([formState, state.value], async () => { |
|
|
|
watch( |
|
|
|
|
|
|
|
[formState, state], |
|
|
|
|
|
|
|
async () => { |
|
|
|
for (const virtualField in state.value) { |
|
|
|
for (const virtualField in state.value) { |
|
|
|
if (!formState[virtualField]) { |
|
|
|
formState.value[virtualField] = state.value[virtualField] |
|
|
|
formState[virtualField] = state.value[virtualField] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updatePreFillFormSearchParams() |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
await formRef.value?.validateFields([...Object.keys(formState)]) |
|
|
|
await formRef.value?.validateFields([...Object.keys(formState.value)]) |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
e.errorFields.map((f: Record<string, any>) => console.error(f.errors.join(','))) |
|
|
|
e.errorFields.map((f: Record<string, any>) => console.error(f.errors.join(','))) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deep: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
watch(activeRow, (newValue) => { |
|
|
|
watch(activeRow, (newValue) => { |
|
|
|
if (newValue) { |
|
|
|
if (newValue) { |
|
|
@ -624,10 +629,6 @@ watch([focusLabel, activeRow], () => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
watch([formState, state], () => { |
|
|
|
|
|
|
|
updatePreFillFormSearchParams() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEventListener( |
|
|
|
useEventListener( |
|
|
|
formRef, |
|
|
|
formRef, |
|
|
|
'focusout', |
|
|
|
'focusout', |
|
|
|