Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

select.vue 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <a-select v-model:value="selectValue" @change="handleChange" :placeholder="placeholder">
  3. <a-select-option v-for="item in listOptions" :key="item.id" :value="item.id">{{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. let listOptions = ref([]);
  10. let selectValue = ref('');
  11. let placeholder = ref('请选择');
  12. const props = defineProps(['dict', 'placeholder', 'select_content']);
  13. placeholder.value = props.placeholder
  14. watch(() => [props.dict, props.select_content],
  15. (newVal:string, oldVal:string) => {
  16. GetDictTree({
  17. code: newVal[0]
  18. }).then((res:object) => {
  19. listOptions.value = res.data.dicts
  20. })
  21. selectValue.value = newVal[1]
  22. })
  23. onMounted(() => {
  24. GetDictTree({
  25. code: props.dict
  26. }).then((res:object) => {
  27. listOptions.value = res.data.dicts
  28. })
  29. })
  30. const emit = defineEmits();
  31. const handleChange = (val) => {
  32. emit('saveSelect', { val: val });
  33. }
  34. </script>
  35. <style>
  36. </style>