fix:修改 表达式输入框 选择后根据光标位置插入 ,修改部分国际化
This commit is contained in:
@@ -1156,7 +1156,7 @@ const cn = {
|
||||
},
|
||||
module: {
|
||||
module: '模块',
|
||||
moduleName: '模块名称',
|
||||
moduleName: '名称',
|
||||
editModule: '编辑模块',
|
||||
description: '描述',
|
||||
createModule: '新增模块',
|
||||
|
||||
@@ -94,18 +94,18 @@ export default {
|
||||
prop: 'id',
|
||||
show: true,
|
||||
width: 110,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('overall.name'),
|
||||
prop: 'name',
|
||||
show: true,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.manageIp'),
|
||||
prop: 'manageIp',
|
||||
show: true,
|
||||
width: 120,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('overall.parent'),
|
||||
prop: 'parent',
|
||||
@@ -116,49 +116,49 @@ export default {
|
||||
prop: 'type',
|
||||
show: true,
|
||||
width: 140,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.state'),
|
||||
prop: 'state',
|
||||
show: true,
|
||||
width: 80,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('overall.dc'),
|
||||
prop: 'dc',
|
||||
show: true,
|
||||
width: 110,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.cabinet'),
|
||||
prop: 'cabinet',
|
||||
show: true,
|
||||
width: 110,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.alertNum'),
|
||||
prop: 'alertNum',
|
||||
show: true,
|
||||
width: 140,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.endpointNum2'),
|
||||
prop: 'endpointNum',
|
||||
show: true,
|
||||
width: 140,
|
||||
sortable:'custom'
|
||||
width: 160,
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.brand'),
|
||||
prop: 'brand',
|
||||
show: true,
|
||||
width: 120,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: this.$t('asset.model'),
|
||||
prop: 'model',
|
||||
show: true,
|
||||
width: 110,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
}, {
|
||||
label: 'SN',
|
||||
prop: 'sn',
|
||||
|
||||
@@ -133,10 +133,10 @@ export default {
|
||||
prop: 'type',
|
||||
show: true
|
||||
}, {
|
||||
label: this.$t('project.project.project'),
|
||||
label: this.$t('project.project.projectName'),
|
||||
prop: 'project',
|
||||
show: true,
|
||||
sortable:'custom'
|
||||
sortable: 'custom'
|
||||
},
|
||||
{
|
||||
label: this.$t('project.endpoint.asset'),
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<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}"
|
||||
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="appendMsg" class="append-msg error"><span>{{appendMsg}}</span></div>
|
||||
</div>
|
||||
@@ -69,7 +69,7 @@
|
||||
<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>-->
|
||||
<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="appendMsg"><span>{{appendMsg}}</span></div>
|
||||
</div>
|
||||
@@ -286,7 +286,8 @@ export default {
|
||||
},
|
||||
metricChange: function (value) {
|
||||
if (!value) return
|
||||
this.expressionList[this.index] = value
|
||||
// this.expressionList[this.index] = value
|
||||
this.insertText(value)
|
||||
// this.$refs.editor.setContent(value)
|
||||
this.dropDownVisible = false
|
||||
this.$emit('change', value)
|
||||
@@ -392,7 +393,8 @@ export default {
|
||||
if (this.tempBox.vars.length == 0) {
|
||||
this.tempBoxShow = false
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
@@ -400,7 +402,8 @@ export default {
|
||||
this.$post('/expression/tmpl/render', params).then(res => {
|
||||
if (res.code === 200) {
|
||||
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)
|
||||
}
|
||||
})
|
||||
@@ -491,8 +494,25 @@ export default {
|
||||
},
|
||||
tempBoxClose () {
|
||||
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(){
|
||||
this.appendMsg
|
||||
} */
|
||||
|
||||
Reference in New Issue
Block a user