adtec-core-package 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Create by丁盼
3
+ * 说明: v-keydown
4
+ * 创建时间: 2024/12/12 15:51
5
+ * 修改时间: 2024/12/12 15:51
6
+ */
7
+ import { useEventBus } from '@vueuse/core'
8
+ const vKeydown = {
9
+ beforeMount: (el: HTMLElement) => {
10
+ el.addEventListener('keydown', (e) => {
11
+ if (e.key === 'Tab') {
12
+ const el = e.target as HTMLElement
13
+ if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
14
+ //查找上级DIV 节点 取消编辑
15
+ let b = true
16
+ let i = 0
17
+ let parent: any = el
18
+ while (b) {
19
+ parent = parent.parentElement
20
+ if (parent.className.indexOf('el-table-column-edit') > -1) {
21
+ b = false
22
+ } else {
23
+ i++
24
+ if (i > 5) {
25
+ b = false
26
+ }
27
+ }
28
+ }
29
+ const bus = useEventBus<string>(parent.id)
30
+ bus.emit()
31
+ //寻找下一个编辑的单元格
32
+ //找到el-table__cell' 节点
33
+ b = true
34
+ i = 0
35
+ while (b) {
36
+ parent = parent.parentElement
37
+ if (parent.className.indexOf('el-table__cell') > -1) {
38
+ b = false
39
+ } else {
40
+ i++
41
+ if (i > 5) {
42
+ b = false
43
+ }
44
+ }
45
+ }
46
+ b = true
47
+ i = 0
48
+ while (b) {
49
+ if (parent.nextElementSibling) {
50
+ const input = parent.nextElementSibling.getElementsByClassName('el-table-column-edit')
51
+ if (input.length > 0) {
52
+ setTimeout(() => {
53
+ input[0].click()
54
+ }, 10)
55
+ b = false
56
+ e.stopPropagation()
57
+ return false
58
+ } else {
59
+ parent = parent.nextElementSibling
60
+ i++
61
+ if (i > 5) {
62
+ b = false
63
+ }
64
+ }
65
+ } else {
66
+ b = false
67
+ }
68
+ }
69
+ //如果当前行结束判断下一行数据
70
+ const tr = parent.parentNode.nextElementSibling
71
+ try {
72
+ for (let j = 0; j < tr.children.length; j++) {
73
+ const input = tr.children[j].getElementsByClassName('el-table-column-edit')
74
+ if (input.length > 0) {
75
+ setTimeout(() => {
76
+ input[0].click()
77
+ e.stopPropagation()
78
+ }, 10)
79
+ break
80
+ }
81
+ }
82
+ } catch {
83
+ /* empty */
84
+ }
85
+ }
86
+ }
87
+ })
88
+ },
89
+ unmounted: (el: HTMLElement) => {
90
+ el.removeEventListener('keydown', () => {})
91
+ },
92
+ }
93
+ export default vKeydown
@@ -11,6 +11,8 @@ import ElTitle from '../components/Title/ElTitle.vue'
11
11
  import ElIcons from '../components/icon/ElIcons.vue'
12
12
  import ElIconBtn from '../components/icon/ElIconBtn.vue'
13
13
  import ElIconSearch from '../components/Search/ElIconSearch.vue'
14
+ import ElTableColumnEdit from '../components/Table/ElTableColumnEdit.vue'
15
+ import vKeydown from '../directives/vKeydown'
14
16
  //@ts-ignore
15
17
  export const globalMixin = {
16
18
  components: {
@@ -21,5 +23,9 @@ export const globalMixin = {
21
23
  ElIcons,
22
24
  ElIconBtn,
23
25
  ElIconSearch,
26
+ ElTableColumnEdit
24
27
  },
28
+ directives:{
29
+ "keydown":vKeydown
30
+ }
25
31
  }