<script lang="ts" setup>
import ADropTable from '@/components/a-drop-table/ADropTable.vue'
import GoodsApi from '@/pages/gds/goods/goods-api.ts'
import { bizType } from '@/pages/gds/goods-category/constants.ts'

const props = defineProps<{
  defaultBizType?: typeof bizType[number]['val']
  placeholder?: string
}>()

const model = defineModel<string | undefined | null>()
const dropTableColumns = [
  {
    label: '产品类型',
    prop: 'goodsCategoryName',
  },
  {
    label: '产品名称',
    prop: 'goodsName',
  },
]
const dropTableLoader = (param: GoodsTypes.SearchGoodsParam) => {
  param.bizType = props.defaultBizType
  return GoodsApi.paging(param).then(res => res.data)
}

</script>

<template>
  <ADropTable v-model="model"
    :columns="dropTableColumns"
    :loader="dropTableLoader"
    :placeholder="placeholder"
    display-field="goodsName"/>
</template>
