<template>
  <el-autocomplete :style="{width}" :model-value="modelValue" @update:modelValue="emitInput" :fetch-suggestions="querySearchAsync"></el-autocomplete>
</template>
<script>
import { ElAutocomplete } from 'element-plus'
import { formInputProps } from '../../form-input-props'
import { useFormInput } from '@cip/components/hooks/form-input'
console.log('加载 autocomplete')
export default {
  components: { ElAutocomplete },
  props: formInputProps,
  emits: ['update:modelValue'],
  setup (props, content) {
    const formInput = useFormInput(props, content)
    const querySearchAsync = async (query, cb) => {
      const options = await props.config.asyncOptions(query)
      cb(options)
    }
    return {
      ...formInput,
      querySearchAsync
    }
  }
}
</script>
