feat: 新增 添加时 计算最后元素的位置
This commit is contained in:
@@ -134,8 +134,8 @@ export function getLayoutPosition (arr) {
|
|||||||
})
|
})
|
||||||
let maxX = 0
|
let maxX = 0
|
||||||
lastItem.forEach(last => {
|
lastItem.forEach(last => {
|
||||||
if (maxX < last.x) {
|
if (maxX < last.x + last.span) {
|
||||||
maxX = last.x
|
maxX = last.x + last.span
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import VueGridLayout from 'vue-grid-layout'
|
import VueGridLayout from 'vue-grid-layout'
|
||||||
import { fromRoute } from '@/components/common/js/constants'
|
import { fromRoute } from '@/components/common/js/constants'
|
||||||
import { getGroupHeight } from './chart/tools'
|
import { getGroupHeight, getLayoutPosition } from './chart/tools'
|
||||||
import panelChart from '@/components/chart/panelChart'
|
import panelChart from '@/components/chart/panelChart'
|
||||||
import bus from '@/libs/bus'
|
import bus from '@/libs/bus'
|
||||||
import groupData from '@/components/chart/tempGroup'
|
import groupData from '@/components/chart/tempGroup'
|
||||||
@@ -264,8 +264,11 @@ export default {
|
|||||||
charts: charts
|
charts: charts
|
||||||
}
|
}
|
||||||
// console.log(this.copyDataList)
|
// console.log(this.copyDataList)
|
||||||
this.$put('/visual/panel/chart/weights', params)
|
this.$put('/visual/panel/chart/weights', params).then(() => {
|
||||||
}, 200)
|
const position = getLayoutPosition(this.copyDataList)
|
||||||
|
this.$store.commit('setChartLastPosition', position)
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -286,6 +289,8 @@ export default {
|
|||||||
this.firstInit = true
|
this.firstInit = true
|
||||||
this.gridLayoutLoading = true
|
this.gridLayoutLoading = true
|
||||||
this.noData = !n || n.length < 1
|
this.noData = !n || n.length < 1
|
||||||
|
const position = getLayoutPosition(n)
|
||||||
|
this.$store.commit('setChartLastPosition', position)
|
||||||
const tempList = n.map(item => {
|
const tempList = n.map(item => {
|
||||||
let param = ''
|
let param = ''
|
||||||
let height = ''
|
let height = ''
|
||||||
@@ -327,7 +332,7 @@ export default {
|
|||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.firstInit = false
|
this.firstInit = false
|
||||||
},200)
|
}, 200)
|
||||||
this.gridLayoutLoading = false
|
this.gridLayoutLoading = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,7 +468,7 @@
|
|||||||
<div class='mapping-display'>Title</div>
|
<div class='mapping-display'>Title</div>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item :prop="'param.columns.' + index + '.title'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" style="flex: 1">
|
<el-form-item :prop="'param.columns.' + index + '.title'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" style="flex: 1">
|
||||||
<el-input size="small" v-model="item.title" placeholder="regx" @change="change"></el-input>
|
<el-input size="small" v-model="item.title" @change="change"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div>
|
<div>
|
||||||
<div class='mapping-display'>Unit</div>
|
<div class='mapping-display'>Unit</div>
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ export default {
|
|||||||
systemChartConfig,
|
systemChartConfig,
|
||||||
otherChartConfig
|
otherChartConfig
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
chartLastPosition () {
|
||||||
|
return this.$store.getters.getChartLastPosition
|
||||||
|
}
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
fromRoute,
|
fromRoute,
|
||||||
@@ -169,6 +174,10 @@ export default {
|
|||||||
if (!params.groupId) {
|
if (!params.groupId) {
|
||||||
params.groupId = 0
|
params.groupId = 0
|
||||||
}
|
}
|
||||||
|
if (!params.x || !params.y) {
|
||||||
|
params.x = this.chartLastPosition.x + params.span > 12 ? 0 : this.chartLastPosition.x
|
||||||
|
params.y = this.chartLastPosition.y + 12
|
||||||
|
}
|
||||||
delete params.panel
|
delete params.panel
|
||||||
if (params.type === 'table') {
|
if (params.type === 'table') {
|
||||||
delete params.param.tags
|
delete params.param.tags
|
||||||
|
|||||||
@@ -247,7 +247,7 @@
|
|||||||
<div class='mapping-display'>Title</div>
|
<div class='mapping-display'>Title</div>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item :prop="'param.columns.' + index + '.title'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" style="flex: 1">
|
<el-form-item :prop="'param.columns.' + index + '.title'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" style="flex: 1">
|
||||||
<el-input size="small" v-model="item.title" placeholder="regx" @change="change"></el-input>
|
<el-input size="small" v-model="item.title" @change="change"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div>
|
<div>
|
||||||
<div class='mapping-display'>Unit</div>
|
<div class='mapping-display'>Unit</div>
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ const panel = {
|
|||||||
headerH: 0.5,
|
headerH: 0.5,
|
||||||
headerHPadding: 0.5,
|
headerHPadding: 0.5,
|
||||||
rowHeight: 150,
|
rowHeight: 150,
|
||||||
chartListId: ''
|
chartListId: '',
|
||||||
|
chartLastPosition: {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setShowRightBox (state, flag) {
|
setShowRightBox (state, flag) {
|
||||||
@@ -34,6 +38,9 @@ const panel = {
|
|||||||
setPanelNowTimeType (state, nowTimeType) {
|
setPanelNowTimeType (state, nowTimeType) {
|
||||||
state.nowTimeType = nowTimeType
|
state.nowTimeType = nowTimeType
|
||||||
},
|
},
|
||||||
|
setChartLastPosition (state, position) {
|
||||||
|
state.chartLastPosition = position
|
||||||
|
},
|
||||||
setHeaderH (state, h) {
|
setHeaderH (state, h) {
|
||||||
state.headerH = h.headerH
|
state.headerH = h.headerH
|
||||||
state.headerHPadding = h.headerHPadding
|
state.headerHPadding = h.headerHPadding
|
||||||
@@ -81,6 +88,9 @@ const panel = {
|
|||||||
getRowHeight (state) {
|
getRowHeight (state) {
|
||||||
return state.rowHeight
|
return state.rowHeight
|
||||||
},
|
},
|
||||||
|
getChartLastPosition (state, position) {
|
||||||
|
return state.chartLastPosition
|
||||||
|
},
|
||||||
getChartListId (state, id) {
|
getChartListId (state, id) {
|
||||||
return state.chartListId
|
return state.chartListId
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user