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

81 lines
1.5 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>
<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"
:key="field.originName"
min-width="200px"
:field="field.originName"
:title="field.name"
:resizable="true"
2021-03-03 17:38:41 +08:00
/>
</ux-grid>
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: [],
height: 500
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() {
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) {
2021-04-02 11:39:24 +08:00
this.table.row = 10
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
const datas = this.data
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>