<template>
  <a-select
    placeholder="分析状态"
    allowClear
    :disabled="props.disabled"
    :value="valueStr"
    style="width: 120px"
    @change="handleChange"
  >
    <a-select-option
      v-for="(item, index) in PROJECT_STATUS"
      :key="index"
      :value="item.code"
    >
      {{ item.name }}
    </a-select-option>
  </a-select>
</template>

<script setup lang="ts">
import { PROJECT_STATUS } from "@/constants/constants";
import { computed } from "vue";

const props = withDefaults(
  defineProps<{
    value?: string;
    disabled?: boolean;
  }>(),
  {
    value: undefined,
    disabled: false,
  }
);
const emit = defineEmits(["update:value"]);

const valueStr = computed(() => {
  let res: undefined | string = props.value ?? undefined;
  return res as undefined | string;
});

function handleChange(v: undefined | string) {
  emit("update:value", v);
}
</script>
