2021-03-03 15:06:52 +08:00
|
|
|
<template>
|
2021-03-03 17:38:41 +08:00
|
|
|
<el-col>
|
|
|
|
<span>{{ table.name }}</span>
|
2021-03-15 15:51:34 +08:00
|
|
|
<ux-grid
|
|
|
|
ref="plxTable"
|
2021-03-03 17:38:41 +08:00
|
|
|
size="mini"
|
2021-03-15 15:51:34 +08:00
|
|
|
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
|
|
|
>
|
2021-03-15 15:51:34 +08:00
|
|
|
<ux-table-column
|
2021-03-03 17:38:41 +08:00
|
|
|
v-for="field in fields"
|
|
|
|
:key="field.originName"
|
|
|
|
min-width="200px"
|
2021-03-15 15:51:34 +08:00
|
|
|
:field="field.originName"
|
|
|
|
:title="field.name"
|
|
|
|
:resizable="true"
|
2021-03-03 17:38:41 +08:00
|
|
|
/>
|
2021-03-15 15:51:34 +08:00
|
|
|
</ux-grid>
|
2021-03-03 17:38:41 +08:00
|
|
|
</el-col>
|
2021-03-03 15:06:52 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-03-03 18:35:51 +08:00
|
|
|
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-15 15:51:34 +08:00
|
|
|
table: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fields: [],
|
2021-03-15 15:51:34 +08:00
|
|
|
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() {
|
2021-03-15 15:51:34 +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) {
|
2021-04-02 11:39:24 +08:00
|
|
|
this.table.row = 10
|
2021-03-03 18:35:51 +08:00
|
|
|
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-15 15:51:34 +08:00
|
|
|
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>
|