LabelSelected.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div class="label-select">
  3. <a-input v-model="searchText" :placeholder="$t('management.search')" style="width: 100%" @input="handleSearch">
  4. <template #prefix>
  5. <icon-search />
  6. </template>
  7. </a-input>
  8. <a-checkbox-group v-model="checkedList" direction="vertical" @change="handleToAdd">
  9. <a-checkbox v-for="item in label_list" :key="item.labelId" :value="item.labelId">{{ item.labelName }}</a-checkbox>
  10. </a-checkbox-group>
  11. <a-empty v-if="!label_list.length"></a-empty>
  12. <div class="footer">
  13. <div class="label-manage" @click="toManageTags"><icon-tags /> 管理标签</div>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref, computed, watch } from 'vue';
  19. import { funcDebounce } from '../../utils/utils';
  20. const props = defineProps({
  21. labels: {
  22. type: Array,
  23. default: () => []
  24. },
  25. addedLabels: {
  26. type: Array,
  27. default: () => []
  28. }
  29. });
  30. const emit = defineEmits(['openManageTags', 'toSearchLabels', 'addLabelToTarget']);
  31. const searchText = ref('');
  32. const checkedList = ref([...props.addedLabels.map((item) => item.labelId)]);
  33. const label_list = computed(() => props.labels);
  34. const handleSearch = funcDebounce(() => {
  35. emit('toSearchLabels', searchText.value);
  36. }, 300);
  37. const toManageTags = () => {
  38. emit('openManageTags');
  39. };
  40. const handleToAdd = (checkedList) => {
  41. emit('addLabelToTarget', checkedList);
  42. };
  43. </script>
  44. <style scoped lang="css">
  45. .footer {
  46. display: flex;
  47. border-top: 1px solid var(--color-neutral-4);
  48. }
  49. .footer .label-manage {
  50. margin-top: 10px;
  51. cursor: pointer;
  52. }
  53. .arco-input-wrapper {
  54. background-color: var(--color-neutral-2);
  55. }
  56. </style>