|
@@ -997,9 +997,20 @@ export default {
|
|
|
console.log(error, 'eeee');
|
|
|
});
|
|
|
},
|
|
|
+ // 点击获取光标位置进行字段插入
|
|
|
handleGetChangeAll(item, field) {
|
|
|
let node = document.getElementById(field);
|
|
|
- this.configForm.adName += '-{{' + item + '}}-';
|
|
|
+ let startPos = node.selectionStart; // input 第0个字符到选中的字符
|
|
|
+ let endPos = node.selectionEnd; // 选中的字符到最后的字符
|
|
|
+ let txt = node.value;
|
|
|
+ if (startPos === 0 || endPos === 0) {
|
|
|
+ this.configForm.adName += '-{{' + item + '}}-';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.configForm.adName = txt.substring(0, startPos) + '-{{' + item + '}}-' + txt.substring(endPos);
|
|
|
+ node.selectionStart = startPos + item.length + 6;
|
|
|
+ node.selectionEnd = startPos + item.length + 6;
|
|
|
+ }
|
|
|
node.focus();
|
|
|
node.blur();
|
|
|
},
|