<template>
  <template v-if="tag">
    <div>{{ options?.find(e => e.value == id)?.label || '' }}</div>
  </template>
  <template v-else>
    <a-select
        :getPopupContainer="
                          (triggerNode) => {
                            return triggerNode.parentNode || document.body;
                          }
                        "
        v-model:value="id"
        :options="options"
        style="width: 100%"
        placeholder="请选择项目级别"
        @change="change"
        :disabled="disabled"
    />
  </template>
</template>
<script setup>
import {computed, defineEmits, defineProps} from "vue";
import {useStore} from "vuex";


const store = useStore();
const props = defineProps({
  value: String,
  disabled: String,
  tag: {
    type: Boolean,
    default: false
  }
})

const id = computed(() => {
  return props.value || null
})

const emit = defineEmits({})

const options = computed(()=>store.state.projectLevel.map(e => ({value: parseInt(e.dictCode), label: e.dictName})))


function change(key) {
  emit('update:value', key)
}
</script>
