| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- export default {
- data() {
- return {}
- },
- methods: {
- handleKeyDown(event, scope, type) {
- // ↑
- if (event.keyCode === 38) {
- if (type === 'select') {
- return;
- }
- if (scope.$index > 0) {
- this.changeFocus(scope.$index - 1, scope.column.property);
- }
- }
- // ↓
- if (event.keyCode === 40) {
- if (type === 'select') {
- return;
- }
- if (scope.$index < this.addList.length) {
- this.changeFocus(scope.$index + 1, scope.column.property);
- }
- }
- // ->
- if (event.keyCode === 39) {
- if (type === 'select') {
- let refName = 'r' + scope.$index + scope.column.property
- this.$refs[refName].blur();
- }
- let y = this.labelArr.indexOf(scope.column.property)
- if (y > -1) {
- this.changeFocus(scope.$index, this.labelArr[y + 1]);
- }
- }
- // <-
- if (event.keyCode === 37) {
- if (type === 'select') {
- let refName = 'r' + scope.$index + scope.column.property
- this.$refs[refName].blur();
- }
- let y = this.labelArr.indexOf(scope.column.property)
- if (y < this.labelArr.length) {
- this.changeFocus(scope.$index, this.labelArr[y - 1]);
- }
- }
- },
- changeFocus(row, columnProperty) {
- let refName = 'r' + row + columnProperty
- this.$nextTick(() => {
- let ref = this.$refs[refName];
- if (ref) ref.focus();
- });
- },
- }
- }
|