干燥机配套车间生产管理系统/云平台服务端
baoshiwei
2024-05-27 fa3ac93010bea3805438ee3ab0a182bfbf7423da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * JVxeTable 键盘操作
 */
import type { VxeTablePropTypes } from 'vxe-table';
import type { JVxeTableProps } from '../types';
import { computed } from 'vue';
 
/**
 * JVxeTable 键盘操作
 *
 * @param props
 */
export function useKeyboardEdit(props: JVxeTableProps) {
  // 是否开启了键盘操作
  const enabledKeyboard = computed(() => props.keyboardEdit ?? false);
  // 重写 keyboardConfig
  const keyboardConfig: VxeTablePropTypes.KeyboardConfig = {
    editMethod({ row, column, $table }) {
      // 重写默认的覆盖式,改为追加式
      $table.setActiveCell(row, column);
      return true;
    },
  };
  // 键盘操作配置
  const keyboardEditConfig = computed(() => {
    return {
      mouseConfig: {
        selected: enabledKeyboard.value,
      },
      keyboardConfig,
    };
  });
 
  return {
    keyboardEditConfig,
  };
}