<template>
  <a-select
      v-model:value="id"
      :options="options"
      style="width: 100%"
      placeholder="请选择分类"
      :disabled="disabled"
  />
</template>
<script>
import {onMounted, reactive, toRefs, watch} from "vue";
import {useStore} from "vuex";

export default {
  name: "TrainClass",

  props: {
    modelValue: {
      type: Number,
    },
    disabled: {
      type: Boolean,
      default: false
    },
  },
  setup(props, ctx) {
    const store = useStore();

    const state = reactive({
      options: [],
      id: props.modelValue
    });
    watch(state.id, () => {
      ctx.emit('update:modelValue', state.id)
    })
    onMounted(() => {
      state.options = store.state.projectSys.map(e => ({value: parseInt(e.dictCode), label: e.dictName}))
    })
    return {
      ...toRefs(state),
    };
  },
};
</script>
