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

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

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

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

    (async function initialData() {
        const result = await httpCompanies({ size: 10000 })
        if (result.code == 0) {
            list.value = [...result.data.list]
        }
    })()
</script>

<template>
    <ElSelect 
        style="width: 100%" 
        v-model="value" :disabled="disabled" 
        @change="(val) => emit('change', val)" 
        clearable
    >
        <ElOption 
            v-for="opt in list" 
            :key="opt.company_license" 
            :value="opt.company_license" 
            :label="opt.company_name" 
        />
    </ElSelect>
</template>
