fix: 预览数据 滚动条问题修复

This commit is contained in:
dataeaseShu 2022-09-22 11:25:31 +08:00
parent bfc6c323a7
commit dd5ce34902
6 changed files with 45 additions and 23 deletions

View File

@ -281,7 +281,7 @@ export default {
const that = this const that = this
setTimeout(function() { setTimeout(function() {
const currentHeight = document.documentElement.clientHeight const currentHeight = document.documentElement.clientHeight
that.height = currentHeight - 195 - 54 that.height = currentHeight - 56 - 64 - 75 - 32 - 24 - 16 - 10
}, 10) }, 10)
}, },
setActiveName({ name, datasourceId, enableCheck }) { setActiveName({ name, datasourceId, enableCheck }) {

View File

@ -312,7 +312,7 @@ export default {
const that = this const that = this
setTimeout(function () { setTimeout(function () {
const currentHeight = document.documentElement.clientHeight const currentHeight = document.documentElement.clientHeight
that.height = currentHeight - 195 - 54 that.height = currentHeight - 56 - 64 - 75 - 32 - 24 - 16 - 10
}, 10) }, 10)
}, },
setActiveName({ name, datasourceId, enableCheck }) { setActiveName({ name, datasourceId, enableCheck }) {

View File

@ -371,7 +371,7 @@ import 'codemirror/addon/hint/sql-hint'
import 'codemirror/addon/hint/show-hint' import 'codemirror/addon/hint/show-hint'
import { engineMode } from '@/api/system/engine' import { engineMode } from '@/api/system/engine'
import msgCfm from '@/components/msgCfm/index' import msgCfm from '@/components/msgCfm/index'
import _ from 'lodash'
export default { export default {
name: 'AddSQL', name: 'AddSQL',
components: { codemirror }, components: { codemirror },
@ -488,6 +488,11 @@ export default {
handler: function () { handler: function () {
this.initTableInfo() this.initTableInfo()
} }
},
sqlHeight: {
handler: function () {
this.calHeight()
}
} }
}, },
mounted() { mounted() {
@ -560,14 +565,11 @@ export default {
this.tableData = response.data this.tableData = response.data
}) })
}, },
calHeight() { calHeight: _.debounce(function() {
const that = this const sqlHeight = Math.max(this.sqlHeight, 248)
setTimeout(function () { const currentHeight = document.documentElement.clientHeight
const currentHeight = document.documentElement.clientHeight this.height = currentHeight - sqlHeight - 56 - 54 - 36 - 64
that.height = }, 200),
currentHeight - 56 - 30 - 26 - 25 - 43 - 160 - 10 - 37 - 20 - 10 - 16
}, 10)
},
initDataSource() { initDataSource() {
listDatasource().then((response) => { listDatasource().then((response) => {
this.options = response.data.filter((item) => item.type !== 'api') this.options = response.data.filter((item) => item.type !== 'api')
@ -636,7 +638,7 @@ export default {
return return
} }
this.parseVariable() this.parseVariable()
this.loading = true; this.loading = true
const table = { const table = {
id: this.param.tableId, id: this.param.tableId,
name: this.param.name, name: this.param.name,
@ -651,12 +653,14 @@ export default {
isBase64Encryption: true isBase64Encryption: true
}) })
} }
post('/dataset/table/update', table).then((response) => { post('/dataset/table/update', table)
this.openMessageSuccess('deDataset.set_saved_successfully') .then((response) => {
this.cancel() this.openMessageSuccess('deDataset.set_saved_successfully')
}).finally(() => { this.cancel()
this.loading = false; })
}) .finally(() => {
this.loading = false
})
}, },
cancel() { cancel() {

View File

@ -41,7 +41,7 @@
}}</span> }}</span>
<span @mousedown="mousedownDrag" class="drag"></span> <span @mousedown="mousedownDrag" class="drag"></span>
</div> </div>
<union-preview :table="previewTable" :dataset="dataset" /> <union-preview :unionHeight="unionHeight" :table="previewTable" :dataset="dataset" />
</div> </div>
<!--选择数据集--> <!--选择数据集-->
<el-drawer <el-drawer

View File

@ -4,7 +4,7 @@
ref="plxTable" ref="plxTable"
size="mini" size="mini"
style="width: 100%" style="width: 100%"
height="100%" :height="height"
:checkbox-config="{ highlight: true }" :checkbox-config="{ highlight: true }"
:width-resize="true" :width-resize="true"
> >
@ -22,6 +22,7 @@
<script> <script>
import { post } from '@/api/dataset/dataset' import { post } from '@/api/dataset/dataset'
import _ from 'lodash'
export default { export default {
name: 'UnionPreview', name: 'UnionPreview',
@ -33,11 +34,15 @@ export default {
dataset: { dataset: {
type: Array, type: Array,
required: true required: true
} },
unionHeight: {
type: Number,
default: 298
},
}, },
data() { data() {
return { return {
height: 'auto', height: 200,
fields: [], fields: [],
data: [] data: []
} }
@ -45,12 +50,26 @@ export default {
watch: { watch: {
table: function () { table: function () {
this.initPreview() this.initPreview()
},
unionHeight: {
handler: function () {
this.calHeight()
}
} }
}, },
mounted() { mounted() {
this.initPreview() this.initPreview()
this.calHeight()
window.onresize = () => {
this.calHeight()
}
}, },
methods: { methods: {
calHeight: _.debounce(function() {
const unionHeight = Math.max(this.unionHeight, 298)
const currentHeight = document.documentElement.clientHeight
this.height = currentHeight - unionHeight - 56 - 54 - 36
}, 200),
initPreview() { initPreview() {
if (this.dataset && this.dataset.length > 0) { if (this.dataset && this.dataset.length > 0) {
post('/dataset/table/unionPreview', this.table).then((response) => { post('/dataset/table/unionPreview', this.table).then((response) => {

View File

@ -529,7 +529,6 @@ export default {
}, },
activated() { activated() {
const dataset = this.$refs.datasetTreeRef?.getCurrentNode() const dataset = this.$refs.datasetTreeRef?.getCurrentNode()
if (!dataset) return
queryAuthModel({ modelType: 'dataset' }, true).then((res) => { queryAuthModel({ modelType: 'dataset' }, true).then((res) => {
localStorage.setItem('dataset-tree', JSON.stringify(res.data)) localStorage.setItem('dataset-tree', JSON.stringify(res.data))
this.tData = res.data this.tData = res.data