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

88 lines
1.8 KiB
Vue
Raw Normal View History

2021-03-03 15:06:52 +08:00
<template>
2021-05-26 11:00:41 +08:00
<el-col ref="container" style="width: 100%;height:100%">
2021-03-03 17:38:41 +08:00
<span>{{ table.name }}</span>
<ux-grid
ref="plxTable"
2021-03-03 17:38:41 +08:00
size="mini"
style="width: 100%;"
:height="height"
:checkbox-config="{highlight: true}"
2021-03-16 11:55:22 +08:00
:width-resize="true"
2021-03-03 17:38:41 +08:00
>
<ux-table-column
2021-03-03 17:38:41 +08:00
v-for="field in fields"
2021-05-11 12:40:12 +08:00
:key="field.dataeaseName"
2021-03-03 17:38:41 +08:00
min-width="200px"
2021-05-11 12:40:12 +08:00
:field="field.dataeaseName"
:title="field.name"
:resizable="true"
2021-03-03 17:38:41 +08:00
/>
</ux-grid>
<span style="font-size: 12px;">{{ $t('chart.preview_100_data') }}</span>
2021-03-03 17:38:41 +08:00
</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: {
table: {
type: Object,
required: true
}
2021-03-03 15:06:52 +08:00
},
data() {
return {
fields: [],
data: [],
2021-05-26 11:00:41 +08:00
height: 'auto'
2021-03-03 15:06:52 +08:00
}
},
2021-03-03 17:38:41 +08:00
watch: {
table() {
this.initData()
}
},
2021-03-03 15:06:52 +08:00
mounted() {
2021-05-26 11:00:41 +08:00
// window.onresize = () => {
// return (() => {
// this.height = window.innerHeight / 3
// })()
// }
// this.height = window.innerHeight / 3
this.initData()
2021-03-03 15:06:52 +08:00
},
methods: {
initData() {
2021-03-03 17:38:41 +08:00
this.resetData()
2021-03-03 15:06:52 +08:00
if (this.table.id) {
this.table.row = 100
post('/dataset/table/getPreviewData/1/100', this.table).then(response => {
2021-03-03 17:38:41 +08:00
this.fields = response.data.fields
this.data = response.data.data
const datas = this.data
2021-05-26 11:00:41 +08:00
if (response.data.status === 'warnning') {
this.$warning(response.data.msg, 3000)
2021-05-25 17:48:29 +08:00
}
2021-05-26 11:00:41 +08:00
if (response.data.status === 'error') {
this.$error(response.data.msg, 3000)
2021-05-25 17:48:29 +08:00
}
this.$refs.plxTable.reloadData(datas)
2021-03-03 17:38:41 +08:00
})
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>