This commit is contained in:
吴红兵
2026-03-07 01:34:48 +08:00
parent adc511cfdc
commit 94c3473958
1211 changed files with 599405 additions and 322105 deletions

View File

@@ -4,17 +4,17 @@
### 1. 入参 `BasicTableProps`
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `createdIsNeed` | `boolean` | **true** | 是否在 `onMounted` 时自动请求列表 |
| `isPage` | `boolean` | true | 是否分页 |
| `queryForm` | `any` | `{}` | 查询条件,会合并到请求参数 |
| `pageList` | `(...arg: any) => Promise<any>` | - | **必填**,分页接口方法 |
| `props` | `object` | `{ item: 'records', totalCount: 'total' }` | 列表/总数的数据路径 |
| `validate` | `Function` | - | 请求前校验,不通过则不请求 |
| `onLoaded` | `Function` | - | 请求成功、写入 `dataList` 后的回调 |
| `onCascaded` | `Function` | - | 级联回调 |
| `pagination` | `Pagination` | 见源码 | 分页配置 |
| 属性 | 类型 | 默认值 | 说明 |
| --------------- | ------------------------------- | ------------------------------------------ | ---------------------------------- |
| `createdIsNeed` | `boolean` | **true** | 是否在 `onMounted` 时自动请求列表 |
| `isPage` | `boolean` | true | 是否分页 |
| `queryForm` | `any` | `{}` | 查询条件,会合并到请求参数 |
| `pageList` | `(...arg: any) => Promise<any>` | - | **必填**,分页接口方法 |
| `props` | `object` | `{ item: 'records', totalCount: 'total' }` | 列表/总数的数据路径 |
| `validate` | `Function` | - | 请求前校验,不通过则不请求 |
| `onLoaded` | `Function` | - | 请求成功、写入 `dataList` 后的回调 |
| `onCascaded` | `Function` | - | 级联回调 |
| `pagination` | `Pagination` | 见源码 | 分页配置 |
### 2. 内部逻辑
@@ -27,12 +27,12 @@
```ts
{
getDataList, // (refresh?: any) => void默认重置到第 1 页再请求getDataList(false) 不重置页码
currentChangeHandle, // 页码变化时调用
sizeChangeHandle, // 每页条数变化时调用
sortChangeHandle, // 排序变化时调用(若表格支持 sortable="custom"
tableStyle, // { cellStyle, headerCellStyle }
downBlobFile // 下载文件
getDataList, // (refresh?: any) => void默认重置到第 1 页再请求getDataList(false) 不重置页码
currentChangeHandle, // 页码变化时调用
sizeChangeHandle, // 每页条数变化时调用
sortChangeHandle, // 排序变化时调用(若表格支持 sortable="custom"
tableStyle, // { cellStyle, headerCellStyle }
downBlobFile; // 下载文件
}
```
@@ -43,17 +43,17 @@
### 1. 定义 state 并传入 useTable
```ts
import { BasicTableProps, useTable } from '/@/hooks/table'
import { BasicTableProps, useTable } from '/@/hooks/table';
const search = reactive({ deptCode: '', realName: '', teacherNo: '' })
const search = reactive({ deptCode: '', realName: '', teacherNo: '' });
const state = reactive<BasicTableProps>({
queryForm: search, // 与 search-form 的 :model 同一对象
pageList: fetchList, // 或自定义方法合并额外参数
// createdIsNeed 不写则默认为 true首屏自动请求
})
queryForm: search, // 与 search-form 的 :model 同一对象
pageList: fetchList, // 或自定义方法合并额外参数
// createdIsNeed 不写则默认为 true首屏自动请求
});
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);
```
- **state 由调用方定义并传入**,不要在解构时期望 `useTable` 返回 `state`(源码未返回)。
@@ -78,18 +78,18 @@ const { getDataList, currentChangeHandle, sizeChangeHandle, tableStyle } = useTa
## 三、professionaltitlerelation/index.vue 检查结果
| 检查项 | 状态 | 说明 |
|--------|------|------|
| queryForm 使用 search | ✅ | 与 search-form 的 model 一致 |
| pageList 返回结构 | ✅ | 返回 `{ data: { records, total } }`,与默认 props 一致 |
| createdIsNeed | ✅ | 未配置即默认 true首屏由 useTable 自动请求 |
| onMounted 不重复请求 | ✅ | 仅 `loadDictData()`,未再调 getDataList |
| 表格绑定 state.dataList / state.loading | ✅ | 正确 |
| 分页绑定 state.pagination + currentChangeHandle/sizeChangeHandle | ✅ | 正确 |
| 查询 handleFilter → getDataList() | ✅ | 正确 |
| 重置 resetQuery → 清空 search + getDataList() | ✅ | 正确 |
| 删除/审核后 getDataList() | ✅ | 正确 |
| tableStyle 用于 el-table | ✅ | 正确 |
| 检查项 | 状态 | 说明 |
| ---------------------------------------------------------------- | ---- | ------------------------------------------------------ |
| queryForm 使用 search | ✅ | 与 search-form 的 model 一致 |
| pageList 返回结构 | ✅ | 返回 `{ data: { records, total } }`,与默认 props 一致 |
| createdIsNeed | ✅ | 未配置即默认 true首屏由 useTable 自动请求 |
| onMounted 不重复请求 | ✅ | 仅 `loadDictData()`,未再调 getDataList |
| 表格绑定 state.dataList / state.loading | ✅ | 正确 |
| 分页绑定 state.pagination + currentChangeHandle/sizeChangeHandle | ✅ | 正确 |
| 查询 handleFilter → getDataList() | ✅ | 正确 |
| 重置 resetQuery → 清空 search + getDataList() | ✅ | 正确 |
| 删除/审核后 getDataList() | ✅ | 正确 |
| tableStyle 用于 el-table | ✅ | 正确 |
**结论**:当前 `professionaltitlerelation/index.vue` 对 hooks/table 的使用符合上述规范,无需修改。