fix:修改 表达式输入框 选择后根据光标位置插入 ,修改部分国际化
This commit is contained in:
@@ -1156,7 +1156,7 @@ const cn = {
|
|||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
module: '模块',
|
module: '模块',
|
||||||
moduleName: '模块名称',
|
moduleName: '名称',
|
||||||
editModule: '编辑模块',
|
editModule: '编辑模块',
|
||||||
description: '描述',
|
description: '描述',
|
||||||
createModule: '新增模块',
|
createModule: '新增模块',
|
||||||
|
|||||||
@@ -94,18 +94,18 @@ export default {
|
|||||||
prop: 'id',
|
prop: 'id',
|
||||||
show: true,
|
show: true,
|
||||||
width: 110,
|
width: 110,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('overall.name'),
|
label: this.$t('overall.name'),
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
show: true,
|
show: true,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.manageIp'),
|
label: this.$t('asset.manageIp'),
|
||||||
prop: 'manageIp',
|
prop: 'manageIp',
|
||||||
show: true,
|
show: true,
|
||||||
width: 120,
|
width: 120,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('overall.parent'),
|
label: this.$t('overall.parent'),
|
||||||
prop: 'parent',
|
prop: 'parent',
|
||||||
@@ -116,49 +116,49 @@ export default {
|
|||||||
prop: 'type',
|
prop: 'type',
|
||||||
show: true,
|
show: true,
|
||||||
width: 140,
|
width: 140,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.state'),
|
label: this.$t('asset.state'),
|
||||||
prop: 'state',
|
prop: 'state',
|
||||||
show: true,
|
show: true,
|
||||||
width: 80,
|
width: 80,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('overall.dc'),
|
label: this.$t('overall.dc'),
|
||||||
prop: 'dc',
|
prop: 'dc',
|
||||||
show: true,
|
show: true,
|
||||||
width: 110,
|
width: 110,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.cabinet'),
|
label: this.$t('asset.cabinet'),
|
||||||
prop: 'cabinet',
|
prop: 'cabinet',
|
||||||
show: true,
|
show: true,
|
||||||
width: 110,
|
width: 110,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.alertNum'),
|
label: this.$t('asset.alertNum'),
|
||||||
prop: 'alertNum',
|
prop: 'alertNum',
|
||||||
show: true,
|
show: true,
|
||||||
width: 140,
|
width: 140,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.endpointNum2'),
|
label: this.$t('asset.endpointNum2'),
|
||||||
prop: 'endpointNum',
|
prop: 'endpointNum',
|
||||||
show: true,
|
show: true,
|
||||||
width: 140,
|
width: 160,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.brand'),
|
label: this.$t('asset.brand'),
|
||||||
prop: 'brand',
|
prop: 'brand',
|
||||||
show: true,
|
show: true,
|
||||||
width: 120,
|
width: 120,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('asset.model'),
|
label: this.$t('asset.model'),
|
||||||
prop: 'model',
|
prop: 'model',
|
||||||
show: true,
|
show: true,
|
||||||
width: 110,
|
width: 110,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
}, {
|
}, {
|
||||||
label: 'SN',
|
label: 'SN',
|
||||||
prop: 'sn',
|
prop: 'sn',
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ export default {
|
|||||||
prop: 'type',
|
prop: 'type',
|
||||||
show: true
|
show: true
|
||||||
}, {
|
}, {
|
||||||
label: this.$t('project.project.project'),
|
label: this.$t('project.project.projectName'),
|
||||||
prop: 'project',
|
prop: 'project',
|
||||||
show: true,
|
show: true,
|
||||||
sortable:'custom'
|
sortable: 'custom'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.$t('project.endpoint.asset'),
|
label: this.$t('project.endpoint.asset'),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<div v-if="plugins.indexOf('metric-input') > -1" class="input-box" @click="dropDownVisible=false">
|
<div v-if="plugins.indexOf('metric-input') > -1" class="input-box" @click="dropDownVisible=false">
|
||||||
<el-input :id="inputId" v-model="expressionList[index]" :autosize="{ minRows: 1, maxRows: 6}"
|
<el-input :id="inputId" v-model="expressionList[index]" :autosize="{ minRows: 1, maxRows: 6}"
|
||||||
class="not-fixed-height no-resize" type="textarea"
|
class="not-fixed-height no-resize" type="textarea"
|
||||||
@input="metricKeyDown" @keyup.enter.native="expressionChange"></el-input>
|
@input="metricKeyDown" @keyup.enter.native="expressionChange" ref="elInput"></el-input>
|
||||||
<div v-if="errorMsg" class="append-msg error"><span>{{errorMsg}}</span></div>
|
<div v-if="errorMsg" class="append-msg error"><span>{{errorMsg}}</span></div>
|
||||||
<div v-if="appendMsg" class="append-msg error"><span>{{appendMsg}}</span></div>
|
<div v-if="appendMsg" class="append-msg error"><span>{{appendMsg}}</span></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<div class="input-box" @click="dropDownVisible=false" v-if="plugins.indexOf('metric-input') > -1">
|
<div class="input-box" @click="dropDownVisible=false" v-if="plugins.indexOf('metric-input') > -1">
|
||||||
<!--<editor :styleType="styleType" :metric-list="metricStore" :historyParam="historyParam" v-model="expressionList[index]" ref="editor" @on-enter="expressionChange" @on-blur="expressionChange" ></editor>-->
|
<!--<editor :styleType="styleType" :metric-list="metricStore" :historyParam="historyParam" v-model="expressionList[index]" ref="editor" @on-enter="expressionChange" @on-blur="expressionChange" ></editor>-->
|
||||||
<el-input v-model="expressionList[index]" @change="metricChange" @input="metricKeyDown" type="textarea"
|
<el-input v-model="expressionList[index]" @change="metricChange" @input="metricKeyDown" type="textarea"
|
||||||
:autosize="{ minRows: 1, maxRows: 6}" class="not-fixed-height no-resize"></el-input>
|
:autosize="{ minRows: 1, maxRows: 6}" class="not-fixed-height no-resize" ref="elInput"></el-input>
|
||||||
<div class="append-msg error" v-if="errorMsg"><span>{{errorMsg}}</span></div>
|
<div class="append-msg error" v-if="errorMsg"><span>{{errorMsg}}</span></div>
|
||||||
<div class="append-msg error" v-if="appendMsg"><span>{{appendMsg}}</span></div>
|
<div class="append-msg error" v-if="appendMsg"><span>{{appendMsg}}</span></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -286,7 +286,8 @@ export default {
|
|||||||
},
|
},
|
||||||
metricChange: function (value) {
|
metricChange: function (value) {
|
||||||
if (!value) return
|
if (!value) return
|
||||||
this.expressionList[this.index] = value
|
// this.expressionList[this.index] = value
|
||||||
|
this.insertText(value)
|
||||||
// this.$refs.editor.setContent(value)
|
// this.$refs.editor.setContent(value)
|
||||||
this.dropDownVisible = false
|
this.dropDownVisible = false
|
||||||
this.$emit('change', value)
|
this.$emit('change', value)
|
||||||
@@ -392,7 +393,8 @@ export default {
|
|||||||
if (this.tempBox.vars.length == 0) {
|
if (this.tempBox.vars.length == 0) {
|
||||||
this.tempBoxShow = false
|
this.tempBoxShow = false
|
||||||
// eslint-disable-next-line vue/no-mutating-props
|
// eslint-disable-next-line vue/no-mutating-props
|
||||||
this.expressionList[this.index] = params.expression
|
// this.expressionList[this.index] = params.expression
|
||||||
|
this.insertText(params.expression)
|
||||||
this.$emit('change', params.expression)
|
this.$emit('change', params.expression)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -400,7 +402,8 @@ export default {
|
|||||||
this.$post('/expression/tmpl/render', params).then(res => {
|
this.$post('/expression/tmpl/render', params).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.tempBoxShow = false
|
this.tempBoxShow = false
|
||||||
this.expressionList[this.index] = res.data.expression
|
// this.expressionList[this.index] = res.data.expression
|
||||||
|
this.insertText(res.data.expression)
|
||||||
this.$emit('change', res.data.expression)
|
this.$emit('change', res.data.expression)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -491,8 +494,25 @@ export default {
|
|||||||
},
|
},
|
||||||
tempBoxClose () {
|
tempBoxClose () {
|
||||||
this.cascaderValue = ''
|
this.cascaderValue = ''
|
||||||
}
|
},
|
||||||
|
insertText (insertTxt) {
|
||||||
|
// 获取el-input中的input元素
|
||||||
|
const elInput = this.$refs.elInput.$el.firstElementChild
|
||||||
|
// 获取el-input的值
|
||||||
|
const txt = elInput.value
|
||||||
|
// 获取选区开始位置
|
||||||
|
const startPos = elInput.selectionStart
|
||||||
|
// 获取选区结束位置
|
||||||
|
const endPos = elInput.selectionEnd
|
||||||
|
if (startPos === undefined || endPos === undefined) return
|
||||||
|
|
||||||
|
// 将文本插入光标位置
|
||||||
|
this.expressionList[this.index] = txt.substring(0, startPos) + insertTxt + txt.substring(endPos)
|
||||||
|
// 将光标移至文本末尾
|
||||||
|
elInput.focus()
|
||||||
|
elInput.selectionStart = startPos + insertTxt.length
|
||||||
|
elInput.selectionEnd = startPos + insertTxt.length
|
||||||
|
}
|
||||||
/* setMsg:function(){
|
/* setMsg:function(){
|
||||||
this.appendMsg
|
this.appendMsg
|
||||||
} */
|
} */
|
||||||
|
|||||||
Reference in New Issue
Block a user