dataease/frontend/src/views/dataset/common/DatasetTableData.vue

69 lines
1.1 KiB
Vue
Raw Normal View History

2021-03-03 15:06:52 +08:00
<template>
2021-03-03 17:38:41 +08:00
<el-col>
<span>{{ table.name }}</span>
<el-table
size="mini"
:data="data"
height="40vh"
border
style="width: 100%;margin-top: 6px;"
>
<el-table-column
v-for="field in fields"
:key="field.originName"
min-width="200px"
:prop="field.originName"
:label="field.name"
/>
</el-table>
</el-col>
2021-03-03 15:06:52 +08:00
</template>
<script>
import { post } from '@/api/dataset/dataset'
2021-03-03 15:06:52 +08:00
export default {
2021-03-03 17:38:41 +08:00
name: 'DatasetTableData',
2021-03-03 15:06:52 +08:00
props: {
2021-03-03 18:20:59 +08:00
// eslint-disable-next-line vue/require-default-prop
2021-03-03 15:06:52 +08:00
table: Object
},
data() {
return {
fields: [],
data: []
}
},
2021-03-03 17:38:41 +08:00
watch: {
table() {
this.initData()
}
},
2021-03-03 15:06:52 +08:00
created() {
2021-03-03 17:38:41 +08:00
this.initData()
2021-03-03 15:06:52 +08:00
},
mounted() {
},
methods: {
initData() {
2021-03-03 17:38:41 +08:00
this.resetData()
2021-03-03 15:06:52 +08:00
if (this.table.id) {
post('/dataset/table/getPreviewData', this.table).then(response => {
2021-03-03 17:38:41 +08:00
this.fields = response.data.fields
this.data = response.data.data
})
2021-03-03 15:06:52 +08:00
}
},
resetData() {
2021-03-03 17:38:41 +08:00
this.fields = []
this.data = []
2021-03-03 15:06:52 +08:00
}
}
}
</script>
<style scoped>
</style>