# useChooseDialog 选择对话框

基于 useDialog 实现的选择对话框，集成 EpSearchListPage 组件，支持单选和多选。

## 基本用法

```vue
<template>
  <el-button @click="handleChoose">选择用户</el-button>
</template>

<script setup lang="tsx">
import { useChooseDialog } from 'el-plus'

const ChooseDialog = useChooseDialog({
  title: '选择用户',
  multiple: false, // 单选模式
  dialogProps: {
    destroyOnClose: true, // 关闭时销毁对话框内容
  },
  formItemList: [
    { prop: 'name', label: '姓名' },
  ],
  columns: [
    { prop: 'name', label: '姓名' },
    { prop: 'dept', label: '部门' },
  ],
  api: getUserList, // 列表接口
})

const handleChoose = async () => {
  try {
    const selection = await ChooseDialog.open()
    console.log('选中', selection)
  } catch (e) {
    console.log('取消')
  }
}
</script>
```

## Options

| 属性 | 说明 | 类型 | 默认值 |
|------|------|------|--------|
| title | 对话框标题 | `string` | - |
| dialogProps | 对话框属性，继承自 useDialog | `DialogOptions` | - |
| multiple | 是否多选 | `boolean` | `false` |
| formItemList | 搜索表单项配置，参考 [EpForm](./form.md) | `FormItemProps[]` | - |
| columns | 表格列配置，参考 [EpTable](./table.md) | `TableColumn[]` | - |
| api | 列表数据接口 | `(params) => Promise` | - |
| formData | 搜索表单数据 | `object` | - |
| formProps | 表单属性，参考 [EpForm](./form.md) | `FormProps` | `{ col: 3 }` |
| tableProps | 表格属性，参考 [EpTable](./table.md) | `TableProps` | `{ height: 300 }` |

## 多选模式

```tsx
const ChooseDialog = useChooseDialog({
  title: '选择用户',
  multiple: true, // 多选模式
  formItemList: [
    { prop: 'name', label: '姓名' },
  ],
  columns: [
    { prop: 'name', label: '姓名' },
    { prop: 'dept', label: '部门' },
  ],
  api: getUserList,
})
```

多选模式下，底部会显示已选数量，确认后返回选中的行数据数组。

## 单选模式

```tsx
const ChooseDialog = useChooseDialog({
  title: '选择用户',
  multiple: false, // 单选模式（默认）
  columns: [
    { prop: 'name', label: '姓名' },
  ],
  api: getUserList,
})
```

单选模式下，点击行即可选中并关闭对话框，返回选中的行数据对象。

## 自定义表格高度

```tsx
const ChooseDialog = useChooseDialog({
  title: '选择用户',
  tableProps: {
    height: 500, // 自定义表格高度
  },
  columns: [...],
  api: getUserList,
})
```

## 返回值

- **单选模式**: 返回选中的行数据对象
- **多选模式**: 返回选中的行数据数组

## 方法

| 方法 | 说明 | 类型 |
|------|------|------|
| open | 打开对话框并返回 Promise | `() => Promise<Selection>` |
| open | 打开对话框 | `() => void` |
| close | 关闭对话框 | `() => void` |
