签入版本
This commit is contained in:
@@ -195,7 +195,7 @@ public function export(): JsonResponse
|
||||
"code": 0,
|
||||
"ok": true,
|
||||
"msg": "导出成功",
|
||||
"data": "http://file.laravel13.elevue/temp/20261006/用户数据_20261006050143.xlsx"
|
||||
"data": "http://file.laravel13.naivevue/temp/20261006/用户数据_20261006050143.xlsx"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -328,32 +328,28 @@ public function export(array $params = []): string
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<el-upload
|
||||
:action="'/api/example/import'"
|
||||
:headers="{ Authorization: `Bearer ${token}` }"
|
||||
:on-success="handleImportSuccess"
|
||||
accept=".xls,.xlsx"
|
||||
>
|
||||
<el-button type="primary">导入</el-button>
|
||||
</el-upload>
|
||||
<!-- 导入按钮 + 导入弹窗(内置 n-upload 直传与模板下载,来自项目实际的 example 模块) -->
|
||||
<n-button @click="importVisible = true">导入</n-button>
|
||||
<fileUpload
|
||||
v-if="importVisible"
|
||||
v-model:visible="importVisible"
|
||||
api="/api/example/import"
|
||||
templateCode="example_import"
|
||||
dialogTitle="导入案例演示"
|
||||
@success="refreshTable()"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const handleImportSuccess = (response) => {
|
||||
if (response.code === 0) {
|
||||
const { count, errors } = response.data;
|
||||
if (errors.length === 0) {
|
||||
ElMessage.success(`成功导入 ${count} 条数据`);
|
||||
} else {
|
||||
ElMessage.warning(`成功 ${count} 条,失败 ${errors.length} 条`);
|
||||
// 可展开 errors 查看行号与原因
|
||||
}
|
||||
refreshTable();
|
||||
}
|
||||
};
|
||||
import { ref } from 'vue';
|
||||
import fileUpload from '@/components/importFile/index.vue';
|
||||
|
||||
const importVisible = ref(false);
|
||||
</script>
|
||||
```
|
||||
|
||||
导入结果由组件内 `useMessage` 统一反馈:全部成功提示 `成功导入 N 条数据`;存在失败时提示成功/失败条数,`errors` 中含行号与原因。
|
||||
|
||||
### 导出
|
||||
|
||||
```typescript
|
||||
|
||||
Reference in New Issue
Block a user