fix: 修改 topology 編輯時 metrics 无法点击语句中间的问题

This commit is contained in:
zhangyu
2022-09-08 10:16:19 +08:00
parent 889ddca357
commit a3cf8e1f90
2 changed files with 48 additions and 43 deletions

View File

@@ -1,7 +1,6 @@
<template>
<div class="props-box" :loading="loading">
<!--所有属性-->
<keep-alive>
<el-tabs v-model="tab" type="card" v-if="selection.pen" @tab-click="tabClick">
<el-tab-pane :label="$t('project.topology.data')" name="1">
<el-form v-model="selection.pen.data" class="pens-data" label-position="top">
@@ -45,6 +44,7 @@
<el-row v-for="(item,index) in selection.pen.data.expressArr" :key="index" class="element-item form-row-item"
style="">
<promql-input
v-if="selection.pen"
:from-father-data="true"
:isTopo="true"
:metricOptionsParent="metricOptions"
@@ -223,6 +223,7 @@
class="element-item form-row-item form-row-item-border"
style="width: 100%; border-radius: 2px; padding-right: 60px;">
<promql-input
v-if="selection.pen"
:from-father-data="true"
:isTopo="true"
:metricOptionsParent="metricOptions"
@@ -716,53 +717,52 @@
</div>
</div>
<!-- <div class="props-pen-item">-->
<!-- <div>{{ $t('project.topology.textOffsetX') }}</div>-->
<!-- <div class="p10 pl0">-->
<!-- <el-input-number-->
<!-- @focus="inputFocus"-->
<!-- @blur="inputBlur"-->
<!-- :precision="0"-->
<!-- controls-position="right"-->
<!-- size="small" name="x"-->
<!-- class="input"-->
<!-- v-model.number="selection.pen.textLeft"-->
<!-- :readonly="readonly"-->
<!-- required-->
<!-- @change="onChange()"></el-input-number>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="props-pen-item">-->
<!-- <div>{{ $t('project.topology.textOffsetX') }}</div>-->
<!-- <div class="p10 pl0">-->
<!-- <el-input-number-->
<!-- @focus="inputFocus"-->
<!-- @blur="inputBlur"-->
<!-- :precision="0"-->
<!-- controls-position="right"-->
<!-- size="small" name="x"-->
<!-- class="input"-->
<!-- v-model.number="selection.pen.textLeft"-->
<!-- :readonly="readonly"-->
<!-- required-->
<!-- @change="onChange()"></el-input-number>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="props-pen-item">-->
<!-- <div>{{ $t('project.topology.textOffsetY') }}</div>-->
<!-- <div class="p10 pl0">-->
<!-- <el-input-number-->
<!-- @focus="inputFocus"-->
<!-- @blur="inputBlur"-->
<!-- :precision="0"-->
<!-- controls-position="right"-->
<!-- size="small" name="x"-->
<!-- class="input"-->
<!-- v-model.number="selection.pen.textTop"-->
<!-- :readonly="readonly"-->
<!-- required-->
<!-- @change="onChange()"></el-input-number>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="props-pen-item">-->
<!-- <div>{{ $t('project.topology.textOffsetY') }}</div>-->
<!-- <div class="p10 pl0">-->
<!-- <el-input-number-->
<!-- @focus="inputFocus"-->
<!-- @blur="inputBlur"-->
<!-- :precision="0"-->
<!-- controls-position="right"-->
<!-- size="small" name="x"-->
<!-- class="input"-->
<!-- v-model.number="selection.pen.textTop"-->
<!-- :readonly="readonly"-->
<!-- required-->
<!-- @change="onChange()"></el-input-number>-->
<!-- </div>-->
<!-- </div>-->
</div>
</el-collapse-item>
</el-collapse>
</el-tab-pane>
</el-tabs>
</keep-alive>
<!--选中多个-->
<keep-alive>
<div v-if="selection.pens" class="">
<el-collapse v-model="activeNames">
<!--对齐方式-->
<el-collapse-item :title="$t('project.topology.align')" name="1" v-if="selection.pens">
<label class="hover pointer mr10 iconLabel" v-for="item in nodesAlign" :title="item.desc">
<label class="hover pointer mr10 iconLabel" v-for="item in nodesAlign" :title="item.desc" :key="item.value">
<i :class="['iconfont','iconfontSize16',`icon-align-${item.value}`]"
@click="onNodesAlign(item.value)"></i>
</label>

View File

@@ -514,7 +514,8 @@ export default {
projectOption: [],
filterSilence: '',
tempBoxId: {},
loading: false
loading: false,
firstInit: true
}
},
computed: {
@@ -697,6 +698,9 @@ export default {
}
},
newChange (val) {
if (this.firstInit && this.isTopo) {
return
}
if (val) {
this.oldcCodeLength = val.length
this.codeMirrorValue[this.index] = val
@@ -1154,7 +1158,7 @@ export default {
immediate: true,
handler (n, o) {
this.codeMirrorValue[this.index] = n[this.index]
if (this.isTopo) {
if (this.isTopo && this.firstInit) {
setTimeout(() => {
const text = this.newView.state.doc.toString()
this.newView.dispatch(
@@ -1162,6 +1166,7 @@ export default {
changes: { from: 0, to: text.length, insert: this.codeMirrorValue[this.index] }
})
)
this.firstInit = false
}, 200)
}
}