sign.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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>放置:{{ positions.length }}</a>
  8. </div>
  9. </div>
  10. <div class="actions" @click.stop>
  11. <ui-icon
  12. :class="{disabled: disabledFly}"
  13. type="pin"
  14. ctrl
  15. @click.stop="$emit('flyPositions')"
  16. />
  17. <ui-more
  18. :options="menus"
  19. style="margin-left: 20px"
  20. @click="(action: keyof typeof actions) => actions[action]()"
  21. />
  22. </div>
  23. </ui-group-option>
  24. </template>
  25. <script setup lang="ts">
  26. import { getFileUrl } from '@/utils'
  27. import { computed } from 'vue';
  28. import { getResource } from '@/env'
  29. import {
  30. getTaggingStyle,
  31. getTaggingPositions,
  32. getModel,
  33. getModelShowVariable
  34. } from '@/store'
  35. import type { Tagging } from '@/store'
  36. const props = defineProps<{ tagging: Tagging, selected?: boolean }>()
  37. const style = computed(() => getTaggingStyle(props.tagging.styleId))
  38. const positions = computed(() => getTaggingPositions(props.tagging))
  39. const disabledFly = computed(() =>
  40. positions.value
  41. .map(position => getModel(position.modelId))
  42. .every(model => !model || !getModelShowVariable(model).value)
  43. )
  44. const emit = defineEmits<{
  45. (e: 'delete'): void
  46. (e: 'edit'): void
  47. (e: 'select'): void
  48. (e: 'flyPositions'): void
  49. }>()
  50. const menus = [
  51. { label: '编辑', value: 'edit' },
  52. { label: '删除', value: 'delete' },
  53. ]
  54. const actions = {
  55. edit: () => emit('edit'),
  56. delete: () => emit('delete')
  57. }
  58. </script>
  59. <style lang="scss" scoped src="./style.scss"></style>