|
|
@ -1,5 +1,17 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { Modal as AModal, EditModeInj, IsFormInj, ReadonlyInj, computed, inject, ref, useVModel, watch } from '#imports' |
|
|
|
import { |
|
|
|
|
|
|
|
Modal as AModal, |
|
|
|
|
|
|
|
ActiveCellInj, |
|
|
|
|
|
|
|
EditModeInj, |
|
|
|
|
|
|
|
IsFormInj, |
|
|
|
|
|
|
|
ReadonlyInj, |
|
|
|
|
|
|
|
computed, |
|
|
|
|
|
|
|
inject, |
|
|
|
|
|
|
|
ref, |
|
|
|
|
|
|
|
useSelectedCellKeyupListener, |
|
|
|
|
|
|
|
useVModel, |
|
|
|
|
|
|
|
watch, |
|
|
|
|
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue: string | Record<string, any> | undefined |
|
|
|
modelValue: string | Record<string, any> | undefined |
|
|
@ -15,6 +27,8 @@ const emits = defineEmits<Emits>() |
|
|
|
|
|
|
|
|
|
|
|
const editEnabled = inject(EditModeInj, ref(false)) |
|
|
|
const editEnabled = inject(EditModeInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const active = inject(ActiveCellInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
const isForm = inject(IsFormInj, ref(false)) |
|
|
|
const isForm = inject(IsFormInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
const readonly = inject(ReadonlyInj) |
|
|
|
const readonly = inject(ReadonlyInj) |
|
|
@ -89,6 +103,22 @@ watch(editEnabled, () => { |
|
|
|
|
|
|
|
|
|
|
|
localValue.value = vModel.value |
|
|
|
localValue.value = vModel.value |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useSelectedCellKeyupListener(active, (e) => { |
|
|
|
|
|
|
|
switch (e.key) { |
|
|
|
|
|
|
|
case 'Enter': |
|
|
|
|
|
|
|
e.stopPropagation() |
|
|
|
|
|
|
|
if (e.shiftKey) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (editEnabled.value) { |
|
|
|
|
|
|
|
onSave() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
editEnabled.value = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|