|
|
@@ -35,68 +35,14 @@
|
|
|
</table-list>
|
|
|
|
|
|
<!-- 预览对话框 -->
|
|
|
- <m-dialog :visible.sync="previewDialog.show" title="数据预览" :footer="false" max-width="90%">
|
|
|
- <div v-if="previewDialog.data.product" class="mb-4">
|
|
|
- <v-card outlined>
|
|
|
- <v-card-text>
|
|
|
- <div class="d-flex align-center mb-2">
|
|
|
- <span class="text-h6 mr-3">{{ previewDialog.data.product.product_name }}</span>
|
|
|
- <v-chip small>{{ previewDialog.data.total_count }} 条记录</v-chip>
|
|
|
- </div>
|
|
|
- <div class="text-body-2">
|
|
|
- <span class="mr-4">目标表: {{ previewDialog.data.product.target_schema }}.{{ previewDialog.data.product.target_table }}</span>
|
|
|
- <span>列数: {{ previewDialog.data.product.column_count }}</span>
|
|
|
- </div>
|
|
|
- </v-card-text>
|
|
|
- </v-card>
|
|
|
- <v-alert v-if="previewDialog.data.error" type="warning" dense class="ma-3">{{ previewDialog.data.error }}</v-alert>
|
|
|
- </div>
|
|
|
- <div v-loading="previewDialog.loading" style="max-height: 600px; overflow-y: auto;">
|
|
|
- <v-simple-table v-if="previewDialog.data.columns && previewDialog.data.columns.length" fixed-header dense>
|
|
|
- <template v-slot:default>
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th v-for="col in previewDialog.data.columns" :key="col.name" class="text-left">
|
|
|
- <div>
|
|
|
- <div>{{ col.name }}</div>
|
|
|
- <small style="color: #909399; font-weight: normal;">{{ col.type }}</small>
|
|
|
- </div>
|
|
|
- </th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr v-for="(row, index) in previewDialog.data.data" :key="index">
|
|
|
- <td v-for="col in previewDialog.data.columns" :key="col.name">
|
|
|
- {{ row[col.name] }}
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </template>
|
|
|
- </v-simple-table>
|
|
|
- <div v-else class="text-center pa-10 text--secondary">
|
|
|
- 暂无数据
|
|
|
- </div>
|
|
|
- <div class="text-end text--secondary">
|
|
|
- <span>已加载 {{ previewDialog.data.preview_count || 0 }} / {{ previewDialog.data.total_count || 0 }} 条</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <template #footer>
|
|
|
- <v-divider></v-divider>
|
|
|
- <v-card-actions>
|
|
|
- <v-spacer></v-spacer>
|
|
|
- <v-btn
|
|
|
- v-if="previewDialog.data.preview_count < previewDialog.data.total_count && previewDialog.limit < 1000"
|
|
|
- text
|
|
|
- color="primary"
|
|
|
- @click="handleLoadMore"
|
|
|
- >
|
|
|
- 加载更多
|
|
|
- </v-btn>
|
|
|
- <v-btn v-if="previewDialog.data.product" text color="success" @click="handleDownloadFromPreview">下载Excel</v-btn>
|
|
|
- <v-btn text @click="previewDialog.show = false">关闭</v-btn>
|
|
|
- </v-card-actions>
|
|
|
- </template>
|
|
|
- </m-dialog>
|
|
|
+ <preview-dialog
|
|
|
+ :visible.sync="previewDialog.show"
|
|
|
+ :loading="previewDialog.loading"
|
|
|
+ :preview-data="previewDialog.data"
|
|
|
+ :limit="previewDialog.limit"
|
|
|
+ @load-more="handleLoadMore"
|
|
|
+ @download="handleDownloadFromPreview"
|
|
|
+ />
|
|
|
|
|
|
<!-- 注册对话框 -->
|
|
|
<m-dialog :visible.sync="registerDialog.show" :title="registerDialog.isEdit ? '编辑数据产品' : '新增数据产品'" @submit="handleRegisterSubmit">
|
|
|
@@ -110,6 +56,7 @@ import MFilter from '@/components/Filter'
|
|
|
import TableList from '@/components/List/table'
|
|
|
import MDialog from '@/components/Dialog'
|
|
|
import RegisterForm from './components/RegisterForm'
|
|
|
+import PreviewDialog from './components/PreviewDialog'
|
|
|
import { api } from '@/api/dataService'
|
|
|
import { formatDate } from '@/utils/date'
|
|
|
|
|
|
@@ -119,7 +66,8 @@ export default {
|
|
|
MFilter,
|
|
|
TableList,
|
|
|
MDialog,
|
|
|
- RegisterForm
|
|
|
+ RegisterForm,
|
|
|
+ PreviewDialog
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
@@ -274,8 +222,7 @@ export default {
|
|
|
const response = await api.downloadExcel(item.id, 200)
|
|
|
|
|
|
// 响应拦截器已处理错误情况,这里response格式为 { data: blob, name: filename }
|
|
|
- const filename = response.name || `${item.product_name_en}_${new Date().toISOString().slice(0, 10).replace(/-/g, '')}.xlsx`
|
|
|
-
|
|
|
+ const filename = `${item.product_name || item.product_name_en}_${new Date().toISOString().slice(0, 10).replace(/-/g, '')}.xlsx`
|
|
|
// 创建下载链接
|
|
|
const blob = new Blob([response.data], {
|
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|