<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useVModel } from "@vueuse/core";
import { httpBusinessTypes } from "/@/api/netOrderEnter/netOrderEntry";

import { useTask } from "/@/hooks/core"

const props = defineProps<{
  modelValue?: string;
  disabled?: boolean;
}>();

const emit = defineEmits(['change']);

const value = useVModel(props, "modelValue");
const list = ref<any[]>([])

const businessTypeTask = useTask({ initialData: [] })

onMounted(async () => businessTypeTask.run(httpBusinessTypes({ size: 10000 })));

defineExpose({ initalData: data => {} });
</script>

<template>
  <ElSelect style="width: 100%" v-model="value" :disabled="disabled" :loading="businessTypeTask.loading" @change="(val) => emit('change',val)" clearable>
    <ElOption 
      v-for="opt in businessTypeTask.data" 
      :key="opt.id"
      :value="opt.id"
      :label="opt.company_type"
      :disabled="String(opt.status) === '0'"
   />
  </ElSelect>
</template>
