mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 17:54:30 +08:00
migrate map sheet to composition API and typescript
This commit is contained in:
@@ -56,7 +56,7 @@ const finalMapStyle = computed<Record<string, unknown>>(() => {
|
|||||||
return styles;
|
return styles;
|
||||||
});
|
});
|
||||||
|
|
||||||
function init() {
|
function initMapView() {
|
||||||
let isFirstInit = false;
|
let isFirstInit = false;
|
||||||
let centerChanged = false;
|
let centerChanged = false;
|
||||||
|
|
||||||
@@ -112,6 +112,6 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
init
|
initMapView
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -30,39 +30,48 @@
|
|||||||
</f7-sheet>
|
</f7-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
export default {
|
import { computed, useTemplateRef } from 'vue';
|
||||||
props: [
|
import type MapView from '@/components/common/MapView.vue';
|
||||||
'modelValue',
|
|
||||||
'show'
|
import type { MapPosition } from '@/lib/map/base.ts';
|
||||||
],
|
|
||||||
emits: [
|
const props = defineProps<{
|
||||||
'update:modelValue',
|
modelValue?: MapPosition;
|
||||||
'update:show'
|
show: boolean;
|
||||||
],
|
}>();
|
||||||
computed: {
|
|
||||||
geoLocation: {
|
const emit = defineEmits<{
|
||||||
get: function () {
|
(e: 'update:modelValue', value: MapPosition | undefined): void,
|
||||||
return this.modelValue;
|
(e: 'update:show', value: boolean): void
|
||||||
},
|
}>();
|
||||||
set: function (value) {
|
|
||||||
this.$emit('update:modelValue', value);
|
const map = useTemplateRef<MapView>('map');
|
||||||
}
|
|
||||||
}
|
const geoLocation = computed<MapPosition | undefined>({
|
||||||
|
get: () => {
|
||||||
|
return props.modelValue;
|
||||||
},
|
},
|
||||||
methods: {
|
set: value => {
|
||||||
save() {
|
emit('update:modelValue', value);
|
||||||
this.$emit('update:show', false);
|
}
|
||||||
},
|
});
|
||||||
onSheetOpen() {
|
|
||||||
this.$refs.map.init();
|
function save() {
|
||||||
},
|
emit('update:show', false);
|
||||||
onSheetClosed() {
|
}
|
||||||
this.close();
|
|
||||||
},
|
function close() {
|
||||||
close() {
|
emit('update:show', false);
|
||||||
this.$emit('update:show', false);
|
}
|
||||||
}
|
|
||||||
|
function onSheetOpen() {
|
||||||
|
if (map.value) {
|
||||||
|
map.value.initMapView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onSheetClosed() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ export default {
|
|||||||
if (newValue === 'map') {
|
if (newValue === 'map') {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.$refs.map) {
|
if (this.$refs.map) {
|
||||||
this.$refs.map.init();
|
this.$refs.map.initMapView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user