LabelSelected.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. <div class="footer">
  12. <div class="label-manage" @click="toManageTags"><icon-tags /> 管理标签</div>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ref, computed, watch } from 'vue';
  18. import { funcDebounce } from '../../utils/utils';
  19. const props = defineProps({
  20. labels: {
  21. type: Array,
  22. default: () => []
  23. },
  24. addedLabels: {
  25. type: Array,
  26. default: () => []
  27. }
  28. });
  29. const emit = defineEmits(['openManageTags', 'toSearchLabels', 'addLabelToTarget']);
  30. const searchText = ref('');
  31. const checkedList = ref([...props.addedLabels.map((item) => item.labelId)]);
  32. const label_list = computed(() => props.labels);
  33. const handleSearch = funcDebounce(() => {
  34. emit('toSearchLabels', searchText.value);
  35. }, 300);
  36. const toManageTags = () => {
  37. emit('openManageTags');
  38. };
  39. const handleToAdd = (checkedList) => {
  40. emit('addLabelToTarget', checkedList);
  41. };
  42. </script>
  43. <style scoped lang="css">
  44. .footer {
  45. display: flex;
  46. border-top: 1px solid var(--color-neutral-4);
  47. }
  48. .footer .label-manage {
  49. margin-top: 10px;
  50. cursor: pointer;
  51. }
  52. .arco-input-wrapper {
  53. background-color: var(--color-neutral-2);
  54. }
  55. </style>