You need to sign in before continuing.

Commit c05b85a697f85cf3ae2824a71e80c6998a689188

Authored by qianbao
1 parent c47c6979

上下左右键移动问题处理

src/views/bigscreenDesigner/designer/index.vue
... ... @@ -509,8 +509,16 @@ export default {
509 509 // 判断是否按住shift键,是就把pin赋值为true
510 510 if (code.keyCode === 16 && code.shiftKey) {
511 511 this.shiftEnt = true;
  512 + }else if (
  513 + code.keyCode === 37 ||
  514 + code.keyCode === 38 ||
  515 + code.keyCode === 39 ||
  516 + code.keyCode === 40
  517 + ) {
  518 + //上下左右移动
  519 + this.dragWidgetMoveByKey(code,this.widgetIndex);
512 520 }
513   - }, 500, true),
  521 + }, 10, true),
514 522 handleKeyUp: debounce(function(code) {
515 523 // 判断是否松开shift键,是就把pin赋值为false
516 524 if (code.keyCode === 16) {
... ... @@ -1144,6 +1152,24 @@ export default {
1144 1152 entryDelete(index){
1145 1153 this.widgets.splice(index, 1);
1146 1154 },
  1155 + //根据上下左右键移动(因为子组件直接切换焦点事件问题,这里弥补不点大屏直接切组件移动)
  1156 + dragWidgetMoveByKey(code,widgetIndex){
  1157 + const position = this.widgets[widgetIndex].value.position;
  1158 + const temp=3;
  1159 + if(code.keyCode==40 || code.key=='ArrowDown'){
  1160 + position.top = position.top+temp;
  1161 + this.$refs.widgets[widgetIndex].$refs.draggable.setTop(position);
  1162 + }if(code.keyCode==38 || code.key=='ArrowUp'){
  1163 + position.top = position.top-temp;
  1164 + this.$refs.widgets[widgetIndex].$refs.draggable.setTop(position);
  1165 + }if(code.keyCode==37 || code.key=='ArrowLeft'){
  1166 + position.left = position.left-temp;
  1167 + this.$refs.widgets[widgetIndex].$refs.draggable.setLeft(position);
  1168 + }if(code.keyCode==39 || code.key=='ArrowRight'){
  1169 + position.left = position.left+temp;
  1170 + this.$refs.widgets[widgetIndex].$refs.draggable.setLeft(position);
  1171 + }
  1172 + },
1147 1173 //输入ctrl+c
1148 1174 entryCopy(index){
1149 1175 const obj = this.deepClone(this.widgets[index]);
... ...