This commit is contained in:
吴红兵
2026-03-03 21:39:22 +08:00
parent 6a1cc54c8b
commit 4ae5a63d97
3 changed files with 180 additions and 2 deletions

78
src/hooks/AGENTS.md Normal file
View File

@@ -0,0 +1,78 @@
# AGENTS.md - Vue Composables (hooks)
**Generated:** 2026-03-03
**Purpose:** Custom Vue 3 composables for data fetching and UI state
## Key Hooks
### useDict
Fetch dictionary data with automatic caching.
```typescript
const { dict } = useDict('sex', 'status', 'type');
// Access: dict.sex, dict.status, dict.type
// Automatically cached per type
```
### useTable
Table data management with pagination.
```typescript
const { tableData, loading, pagination, getData, resetQuery } = useTable({
pageList: fetchList, // API function
queryForm: reactive({ name: '' }) // Query params
});
// pagination: { current, size, total }
// getData(): refresh table
// resetQuery(): reset to defaults
```
### useMessage
Toast notifications.
```typescript
const { msgSuccess, msgError, msgWarning } = useMessage();
msgSuccess('操作成功');
msgError('操作失败');
```
### useMessageBox
Confirm/alert dialogs.
```typescript
const { msgBoxConfirm, msgBoxAlert } = useMessageBox();
// Confirm
await msgBoxConfirm('确定删除该记录?');
// Returns promise, resolves on confirm
// Alert
await msgBoxAlert('提示信息');
```
### useParam
Fetch system parameters.
```typescript
const { param } = useParam('SYSTEM_NAME');
// Access: param.SYSTEM_NAME
```
## Files
| File | Purpose |
|------|---------|
| useDict.ts | Dictionary data with caching |
| useTable.ts | Table + pagination state |
| useMessage.ts | Toast notifications |
| useMessageBox.ts | Confirm dialogs |
| useParam.ts | System parameters |
## Pattern
All hooks follow Vue 3 composition API pattern:
1. Accept reactive params
2. Return reactive state + methods
3. Handle loading/error states internally
4. Provide clean API surface

View File

@@ -173,13 +173,13 @@
:width="col.width"
:min-width="col.minWidth"
:show-overflow-tooltip="col.showOverflowTooltip !== false"
:align="col.align || 'center'>
:align="col.align || 'center'">
<template #header>
<el-icon v-if="col.icon"><component :is="col.icon" /></el-icon>
<span :style="{ marginLeft: col.icon ? '4px' : '0' }">{{ col.label }}</span>
</template>
<!-- 上传状态列特殊模板 -->
<template v-else-if="col.prop === 'uploadStatus'" #default="scope">
<template v-if="col.prop === 'uploadStatus'" #default="scope">
<el-tag
v-if="scope.row.unuploadCount === 0"
size="small"