<!--
 * @Author: lixg lixg@dongwu-inc.com
 * @Date: 2022-12-14 15:46:36
 * @LastEditors: lixg lixg@dongwu-inc.com
 * @LastEditTime: 2022-12-14 15:47:46
 * @FilePath: /fe-manage/src/components/project/TrainClass.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<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;
});

const emit = defineEmits({});

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

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