sign.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <ui-group-option class="sign-tagging" :class="{active: selected}" @click="emit('select')">
  3. <div class="info">
  4. <img :src="getResource(getFileUrl(style.icon))" v-if="style">
  5. <div>
  6. <p>{{ tagging.title }}</p>
  7. <a @click.stop="$emit('flyPositions')">放置:{{ positions.length }}</a>
  8. </div>
  9. </div>
  10. <div class="actions" @click.stop>
  11. <ui-icon type="pin" ctrl />
  12. <ui-more
  13. :options="menus"
  14. style="margin-left: 20px"
  15. @click="(action: keyof typeof actions) => actions[action]()"
  16. />
  17. </div>
  18. </ui-group-option>
  19. </template>
  20. <script setup lang="ts">
  21. import { Tagging, getTaggingStyle, getTaggingPositions } from '@/store'
  22. import { getFileUrl } from '@/utils'
  23. import { computed } from 'vue';
  24. import { getResource } from '@/env'
  25. const props = defineProps<{ tagging: Tagging, selected?: boolean }>()
  26. const style = computed(() => getTaggingStyle(props.tagging.styleId))
  27. const positions = computed(() => getTaggingPositions(props.tagging))
  28. const emit = defineEmits<{
  29. (e: 'delete'): void
  30. (e: 'edit'): void
  31. (e: 'select'): void
  32. (e: 'flyPositions'): void
  33. }>()
  34. const menus = [
  35. { label: '编辑', value: 'edit' },
  36. { label: '删除', value: 'delete' },
  37. ]
  38. const actions = {
  39. edit: () => emit('edit'),
  40. delete: () => emit('delete')
  41. }
  42. </script>
  43. <style lang="scss" scoped src="./style.scss"></style>