Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <a-select v-model:value="selectValue" @change="handleChange" :placeholder="placeholder" label-in-value>
  3. <a-select-option v-for="item in listOptions" :key="item.id" :value="item.id" :label="item.name">{{item.name}}</a-select-option>
  4. </a-select>
  5. </template>
  6. <script lang="ts" setup>
  7. import { ref, onMounted, defineProps, watch, defineEmits } from 'vue';
  8. import { GetDictTree } from '@/apis/models';
  9. const props = defineProps(['dict', 'placeholder', 'select_content']);
  10. let listOptions = ref([]);
  11. let selectValue = ref<Number>(0);
  12. let placeholder = ref<String>(props.placeholder);
  13. watch(() => [props.dict, props.select_content],
  14. (newVal) => {
  15. GetDictTree({
  16. code: newVal[0]
  17. }).then((res:object) => {
  18. listOptions.value = res.data.dicts
  19. })
  20. selectValue.value = newVal[1] == 0 ? props.placeholder : newVal[1];
  21. }, { immediate: true })
  22. onMounted(() => {
  23. GetDictTree({
  24. code: props.dict
  25. }).then((res:object) => {
  26. listOptions.value = res.data.dicts
  27. })
  28. })
  29. const emit = defineEmits();
  30. const handleChange = (val) => {
  31. emit('saveSelect', { val: val });
  32. }
  33. </script>
  34. <style>
  35. </style>