<script lang="ts" setup>
import ADropTable from '@/components/a-drop-table/ADropTable.vue'
import DriverApi from '@/pages/cst/driver/driver-api.ts'

const props = defineProps<{
  orgId?: string,
}>()
const model = defineModel({type: String})

const dropTableColumns = [
  {
    label: '司机姓名',
    prop: 'driverName',
  },
  {
    label: '手机号',
    prop: 'phone',
  },
]

const dropTableLoader = (param: DriverTypes.SearchDriverParam) => {
  if (props.orgId == null) return Promise.resolve({
    current: 1,
    size: 10,
    total: 0,
    records: [] as any[],
  } as G.PageResult<DriverTypes.SearchDriverResult>)
  param.orgId = props.orgId
  return DriverApi.paging(param).then(res => res.data)
}

</script>

<template>
  <ADropTable v-model="model"
    :columns="dropTableColumns"
    :loader="dropTableLoader"
    display-field="driverName"
    placeholder="请选择司机"/>
</template>
