sign.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <ui-group-option class="sign-tagging" :class="{active: selected}" @click="!disabledFly && emit('select')">
  3. <div class="info">
  4. <img :src="getResource(getFileUrl(tagging.images.length ? tagging.images[0] : style.icon))" v-if="style">
  5. <div>
  6. <p>{{ tagging.title }}</p>
  7. <span>放置:{{ positions.length }}</span>
  8. </div>
  9. </div>
  10. <div class="actions" @click.stop>
  11. <ui-icon type="pin1" ctrl @click.stop="$emit('fixed')" />
  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 { getFileUrl } from '@/utils'
  22. import { computed } from 'vue';
  23. import { getResource } from '@/env'
  24. import {
  25. getTaggingStyle,
  26. getTaggingPositions,
  27. getFuseModel,
  28. getFuseModelShowVariable
  29. } from '@/store'
  30. import type { Tagging } from '@/store'
  31. const props = defineProps<{ tagging: Tagging, selected?: boolean }>()
  32. const style = computed(() => getTaggingStyle(props.tagging.styleId))
  33. const positions = computed(() => getTaggingPositions(props.tagging))
  34. const disabledFly = computed(() =>
  35. positions.value
  36. .map(position => getFuseModel(position.modelId))
  37. .every(model => !model || !getFuseModelShowVariable(model).value)
  38. )
  39. const emit = defineEmits<{
  40. (e: 'delete'): void
  41. (e: 'edit'): void
  42. (e: 'select'): void
  43. (e: 'fixed'): void
  44. }>()
  45. const menus = [
  46. { label: '编辑', value: 'edit' },
  47. { label: '删除', value: 'delete' },
  48. ]
  49. const actions = {
  50. edit: () => emit('edit'),
  51. delete: () => emit('delete')
  52. }
  53. </script>
  54. <style lang="scss" scoped src="./style.scss"></style>