ModalSelectIcon.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <a-modal
  3. v-model:visible="showModal"
  4. :align-center="false"
  5. top="15vh"
  6. @cancel="handleCancel"
  7. @before-ok="handleBeforeOk"
  8. >
  9. <template #title>替换图标</template>
  10. <div class="section">
  11. <div class="labels">全部图标</div>
  12. <div class="icons">
  13. <div
  14. class="icon-border"
  15. v-for="icon in icons"
  16. :key="icon.icon"
  17. :class="{ 'icon-border-active': icon.id === target_icon }"
  18. @click="changeItem(icon.id)"
  19. >
  20. <img class="icon" :src="getIconIntelligent(icon.name)" alt="" />
  21. </div>
  22. </div>
  23. </div>
  24. </a-modal>
  25. </template>
  26. <script setup>
  27. import { ref, computed } from 'vue';
  28. import { getIconIntelligent } from '../common/icon-map.js';
  29. const props = defineProps({
  30. show_select_icon: {
  31. type: Boolean,
  32. default: false
  33. }
  34. });
  35. const icons = ref([
  36. {
  37. id: 1,
  38. name: 'intellFrame1'
  39. },
  40. {
  41. id: 2,
  42. name: 'intellFrame2'
  43. },
  44. {
  45. id: 3,
  46. name: 'intellFrame3'
  47. },
  48. {
  49. id: 4,
  50. name: 'intellFrame4'
  51. },
  52. {
  53. id: 5,
  54. name: 'intellFrame5'
  55. },
  56. {
  57. id: 6,
  58. name: 'intellFrame6'
  59. }
  60. ]);
  61. const target_icon = ref(icons.value[0].id);
  62. const emit = defineEmits(['update:show_model_item', 'sendIcon']);
  63. const showModal = computed(() => props.show_select_icon);
  64. const changeItem = (id) => {
  65. target_icon.value = id;
  66. };
  67. const handleBeforeOk = (done) => {
  68. emit('sendIcon', icons.value.filter((icon) => icon.id === target_icon.value)[0].name);
  69. emit('update:show_select_icon', false);
  70. done();
  71. };
  72. const handleCancel = () => {
  73. emit('update:show_select_icon', false);
  74. };
  75. </script>
  76. <style scoped lang="css">
  77. .section {
  78. height: 200px;
  79. padding: 0 20px;
  80. }
  81. .icons {
  82. display: flex;
  83. flex-wrap: wrap;
  84. gap: 10px;
  85. margin-top: 10px;
  86. }
  87. .icons .icon-border {
  88. /* width: 50px;
  89. height: 50px; */
  90. padding: 5px 10px;
  91. cursor: pointer;
  92. }
  93. .icon-border:hover {
  94. border: 1px solid var(--color-neutral-4);
  95. border-radius: 5px;
  96. }
  97. .icon-border .icon {
  98. width: 44px;
  99. height: 44px;
  100. }
  101. .icon-border-active {
  102. border: 1px solid var(--color-neutral-4);
  103. border-radius: 5px;
  104. }
  105. .arco-input-wrapper {
  106. height: 32px;
  107. background-color: var(--color-neutral-3);
  108. }
  109. </style>