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

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

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

const value = useVModel(props, "modelValue");
const RemoteSelectRef = ref<InstanceType<typeof RemoteSelect> | null>(null);

onMounted(() => {
  value.value && (RemoteSelectRef.value as any).initalData(value.value);
});

defineExpose({
  initalData: data => (RemoteSelectRef.value as any).initalData(data)
});
</script>

<template>
  <RemoteSelect
    v-model="value"
    ref="RemoteSelectRef"
    style="width: 100%"
    :api="httpBrandlist"
    requset-prop="brand_name"
    response-label-prop="brand_name"
    response-val-prop="id"
    @item-change="emits('change')"
    @clear="emits('change')"
  />
</template>
