|
@@ -41,11 +41,19 @@ let quantityEditObj = {
|
|
|
},
|
|
|
onCellDoubleClick:function (e,info) {
|
|
|
if(quantityEditObj.datas[info.row]){
|
|
|
- let oldVal = $("#quantityEXPValue").val();
|
|
|
- $("#quantityEXPValue").val(oldVal+quantityEditObj.datas[info.row].code);
|
|
|
$("#quantityEXPValue").focus();
|
|
|
+ quantityEditObj.setToQuantityEXP(quantityEditObj.datas[info.row].code);
|
|
|
+ quantityEditObj.spread.focus(false);
|
|
|
}
|
|
|
},
|
|
|
+ setToQuantityEXP:function (value) {
|
|
|
+ let oldVal = $("#quantityEXPValue").val();
|
|
|
+ let startIndex = getCursor($("#quantityEXPValue")[0]);//取光标位置
|
|
|
+ let strartString = oldVal.substring(0,startIndex);
|
|
|
+ let endString = oldVal.substring(startIndex);
|
|
|
+ $("#quantityEXPValue").val(strartString+value+endString);
|
|
|
+ setCursor($("#quantityEXPValue")[0],startIndex+value.length);//设置回光标位置
|
|
|
+ },
|
|
|
getQuantityEditCellType:function () {
|
|
|
var ns = GC.Spread.Sheets;
|
|
|
function QuantityEditCellType() {
|
|
@@ -248,14 +256,15 @@ let quantityEditObj = {
|
|
|
};
|
|
|
$(function(){
|
|
|
$('#quantityEXPEdit').on('shown.bs.modal', function (e) {
|
|
|
+ projectObj.mainSpread.focus(false);
|
|
|
quantityEditObj.initSpread();
|
|
|
+ $("#quantityEXPValue").focus();
|
|
|
});
|
|
|
|
|
|
$('#operation_p').children("button").bind('click',function (){
|
|
|
- let oldVal = $("#quantityEXPValue").val();
|
|
|
- $("#quantityEXPValue").val(oldVal+$(this).text());
|
|
|
+ quantityEditObj.setToQuantityEXP($(this).text());
|
|
|
$("#quantityEXPValue").focus();
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
$("#quantityEditConf").bind('click',function () {
|
|
|
let selected = projectObj.project.mainTree.selected;
|
|
@@ -264,6 +273,37 @@ $(function(){
|
|
|
$("#quantityEXPEdit").modal('hide');
|
|
|
}
|
|
|
})
|
|
|
+ $('#quantityEXPEdit').bind('keypress', function (event) {
|
|
|
+ if(event.keyCode === 13){
|
|
|
+ $("#quantityEditConf").click();
|
|
|
+ event.preventDefault();
|
|
|
+ }
|
|
|
|
|
|
+ });
|
|
|
|
|
|
});
|
|
|
+
|
|
|
+function getCursor(elem) {
|
|
|
+ //IE 9 ,10,其他浏览器
|
|
|
+ if (elem.selectionStart !== undefined) {
|
|
|
+ return elem.selectionStart;
|
|
|
+ } else { //IE 6,7,8
|
|
|
+ var range = document.selection.createRange();
|
|
|
+ range.moveStart("character", -elem.value.length);
|
|
|
+ var len = range.text.length;
|
|
|
+ return len;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function setCursor(elem, index) {
|
|
|
+ //IE 9 ,10,其他浏览器
|
|
|
+ if (elem.selectionStart !== undefined) {
|
|
|
+ elem.selectionStart = index;
|
|
|
+ elem.selectionEnd = index;
|
|
|
+ } else { //IE 6,7,8
|
|
|
+ var range = elem.createTextRange();
|
|
|
+ range.moveStart("character", -elem.value.length); //左边界移动到起点
|
|
|
+ range.move("character", index); //光标放到index位置
|
|
|
+ range.select();
|
|
|
+ }
|
|
|
+}
|