|
@@ -1,6 +1,6 @@
|
|
import {createApp} from "vue/dist/vue.esm-bundler.js";
|
|
import {createApp} from "vue/dist/vue.esm-bundler.js";
|
|
import {getTokenHeader} from '~src/api/request/header';
|
|
import {getTokenHeader} from '~src/api/request/header';
|
|
-import {toParse} from "vue-utils-plus";
|
|
|
|
|
|
+import {toParse, isArray} from "vue-utils-plus";
|
|
import HcTableFormUpload from "~com/plugins/table-form/hc-form-upload.vue"
|
|
import HcTableFormUpload from "~com/plugins/table-form/hc-form-upload.vue"
|
|
import HcFormSelectSearch from "~com/plugins/table-form/hc-form-select-search.vue"
|
|
import HcFormSelectSearch from "~com/plugins/table-form/hc-form-select-search.vue"
|
|
import HcFormCheckboxGroup from "~com/plugins/table-form/hc-form-checkbox-group.vue"
|
|
import HcFormCheckboxGroup from "~com/plugins/table-form/hc-form-checkbox-group.vue"
|
|
@@ -20,7 +20,9 @@ const components = {
|
|
|
|
|
|
//表单渲染
|
|
//表单渲染
|
|
export default class HTableForm {
|
|
export default class HTableForm {
|
|
|
|
+
|
|
static createForm({template, tableForm, appId, onRight, onBlur}) {
|
|
static createForm({template, tableForm, appId, onRight, onBlur}) {
|
|
|
|
+ const _this = this;
|
|
const app = createApp({
|
|
const app = createApp({
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -89,19 +91,19 @@ export default class HTableForm {
|
|
},
|
|
},
|
|
//键盘事件 上键
|
|
//键盘事件 上键
|
|
keyupShiftUp(event) {
|
|
keyupShiftUp(event) {
|
|
-
|
|
|
|
|
|
+ _this.setKeyupData(event, 'up', this.formData.keys)
|
|
},
|
|
},
|
|
//键盘事件 下键
|
|
//键盘事件 下键
|
|
keyupShiftDown(event) {
|
|
keyupShiftDown(event) {
|
|
-
|
|
|
|
|
|
+ _this.setKeyupData(event, 'down', this.formData.keys)
|
|
},
|
|
},
|
|
//键盘事件 左键
|
|
//键盘事件 左键
|
|
keyupShiftLeft(event) {
|
|
keyupShiftLeft(event) {
|
|
-
|
|
|
|
|
|
+ _this.setKeyupData(event, 'left', this.formData.keys)
|
|
},
|
|
},
|
|
//键盘事件 右键
|
|
//键盘事件 右键
|
|
keyupShiftRight(event) {
|
|
keyupShiftRight(event) {
|
|
-
|
|
|
|
|
|
+ _this.setKeyupData(event, 'right', this.formData.keys)
|
|
},
|
|
},
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -125,4 +127,91 @@ export default class HTableForm {
|
|
}
|
|
}
|
|
return data
|
|
return data
|
|
}
|
|
}
|
|
|
|
+ //计算上下左右快捷键的
|
|
|
|
+ static setKeyupData({target}, type, keys) {
|
|
|
|
+ const key = target.id
|
|
|
|
+ /*const keys = [
|
|
|
|
+ ['key_15__3_1', 'key_16__3_3'],
|
|
|
|
+ ['key_10__4_1', 'key_11__4_3'],
|
|
|
|
+ ['key_13__5_1'],
|
|
|
|
+ ['key_8__6_1'],
|
|
|
|
+ ['key_3__7_1'],
|
|
|
|
+ ['key_9__8_1'],
|
|
|
|
+ ['key_6__9_1'],
|
|
|
|
+ ['key_2__10_1', 'key_2__10_2'],
|
|
|
|
+ ['key_1__11_1', 'key_1__11_2'],
|
|
|
|
+ ['key_18__13_0'],
|
|
|
|
+ ['key_7__15_0'],
|
|
|
|
+ ['key_5__16_1', 'key__16_2'],
|
|
|
|
+ ['key_12__18_0'],
|
|
|
|
+ ['key_4__19_1', 'key_12__19_2'],
|
|
|
|
+ ['key_21__21_0'],
|
|
|
|
+ ['key_17__22_1', 'key_17__22_2'],
|
|
|
|
+ ]*/
|
|
|
|
+ //处理快捷键数据和事件
|
|
|
|
+ if (key && type && isArray(keys)) {
|
|
|
|
+ //计算当前的位置
|
|
|
|
+ let left = -1, top = -1;
|
|
|
|
+ for (let i = 0; i < keys.length; i++) {
|
|
|
|
+ if (isArray(keys[i])) {
|
|
|
|
+ const index = keys[i].findIndex(id => id === key)
|
|
|
|
+ if (index !== -1) {
|
|
|
|
+ left = index
|
|
|
|
+ top = i
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (type === 'up') {
|
|
|
|
+ //向上移动
|
|
|
|
+ if (top > 0) {
|
|
|
|
+ let keyId = '';
|
|
|
|
+ const tops = keys[top - 1]
|
|
|
|
+ const keyLength = tops.length -1;
|
|
|
|
+ if (keyLength < left) {
|
|
|
|
+ keyId = tops[keyLength]
|
|
|
|
+ } else {
|
|
|
|
+ keyId = tops[left]
|
|
|
|
+ }
|
|
|
|
+ if (keyId) {
|
|
|
|
+ document.getElementById(keyId).focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (type === 'down') {
|
|
|
|
+ //向下移动
|
|
|
|
+ const tops = keys.length - 1;
|
|
|
|
+ if (tops > top) {
|
|
|
|
+ let keyId = '';
|
|
|
|
+ const tops = keys[top + 1]
|
|
|
|
+ const keyLength = tops.length -1;
|
|
|
|
+ if (keyLength < left) {
|
|
|
|
+ keyId = tops[keyLength]
|
|
|
|
+ } else {
|
|
|
|
+ keyId = tops[left]
|
|
|
|
+ }
|
|
|
|
+ if (keyId) {
|
|
|
|
+ document.getElementById(keyId).focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (type === 'left') {
|
|
|
|
+ //向左移动
|
|
|
|
+ if (left > 0) {
|
|
|
|
+ const keyId = keys[top][left-1]
|
|
|
|
+ if (keyId) {
|
|
|
|
+ document.getElementById(keyId).focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (type === 'right') {
|
|
|
|
+ //向右移动
|
|
|
|
+ const lefts = keys[top]
|
|
|
|
+ const leftLength = lefts.length - 1;
|
|
|
|
+ if (leftLength > left) {
|
|
|
|
+ const keyId = lefts[left + 1]
|
|
|
|
+ if (keyId) {
|
|
|
|
+ document.getElementById(keyId).focus();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|