ModalSelectIcon.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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="icon.icon" alt="" />
  21. </div>
  22. </div>
  23. </div>
  24. </a-modal>
  25. </template>
  26. <script setup>
  27. import { ref, computed } from 'vue';
  28. import intellFrame1 from '../../assets/image/management/intellFrame1.png';
  29. import intellFrame2 from '../../assets/image/management/intellFrame2.png';
  30. import intellFrame3 from '../../assets/image/management/intellFrame3.png';
  31. import intellFrame4 from '../../assets/image/management/intellFrame4.png';
  32. import intellFrame5 from '../../assets/image/management/intellFrame5.png';
  33. import intellFrame6 from '../../assets/image/management/intellFrame6.png';
  34. const props = defineProps({
  35. show_select_icon: {
  36. type: Boolean,
  37. default: false
  38. }
  39. });
  40. const icons = ref([
  41. {
  42. id: 1,
  43. icon: intellFrame1
  44. },
  45. {
  46. id: 2,
  47. icon: intellFrame2
  48. },
  49. {
  50. id: 3,
  51. icon: intellFrame3
  52. },
  53. {
  54. id: 4,
  55. icon: intellFrame4
  56. },
  57. {
  58. id: 5,
  59. icon: intellFrame5
  60. },
  61. {
  62. id: 6,
  63. icon: intellFrame6
  64. }
  65. ]);
  66. const target_icon = ref(icons.value[0].id);
  67. const emit = defineEmits(['update:show_model_item', 'sendIcon']);
  68. const showModal = computed(() => props.show_select_icon);
  69. const changeItem = (id) => {
  70. target_icon.value = id;
  71. };
  72. const handleBeforeOk = (done) => {
  73. emit('sendIcon', icons.value.filter((icon) => icon.id === target_icon.value)[0].icon);
  74. emit('update:show_select_icon', false);
  75. done();
  76. };
  77. const handleCancel = () => {
  78. emit('update:show_select_icon', false);
  79. };
  80. </script>
  81. <style scoped lang="css">
  82. .section {
  83. height: 200px;
  84. padding: 0 20px;
  85. }
  86. .icons {
  87. display: flex;
  88. flex-wrap: wrap;
  89. gap: 10px;
  90. margin-top: 10px;
  91. }
  92. .icons .icon-border {
  93. /* width: 50px;
  94. height: 50px; */
  95. padding: 5px 10px;
  96. cursor: pointer;
  97. }
  98. .icon-border:hover {
  99. border: 1px solid var(--color-neutral-4);
  100. border-radius: 5px;
  101. }
  102. .icon-border .icon {
  103. width: 44px;
  104. height: 44px;
  105. }
  106. .icon-border-active {
  107. border: 1px solid var(--color-neutral-4);
  108. border-radius: 5px;
  109. }
  110. .arco-input-wrapper {
  111. height: 32px;
  112. background-color: var(--color-neutral-3);
  113. }
  114. </style>