Ben Lin
2024-07-24 50111114eb8254fe4d6fc15e9781f2c47e3db74a
src/views/components/GeneralTree.vue
@@ -4,7 +4,7 @@
 * @version: 
 * @Date: 2024-06-19 11:07:21
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-19 23:09:39
 * @LastEditTime: 2024-07-23 21:29:52
-->
<template>
  <div class="m-4 mr-0 overflow-hidden bg-white">
@@ -20,38 +20,49 @@
      :fieldNames="fieldNames"
      @select="handleSelect"
      @handleAdd="handleAdd"
      @unselect="UnSelect"
      :beforeRightClick="props.beforeRightClick"
    />
  </div>
</template>
<script lang="ts" setup>
  import { onMounted, ref } from 'vue';
  import { FieldNames, TigerTree, TreeItem } from '/@/components/TigerTree'
  import { ContextMenuItem, ContextMenuOptions, FieldNames, TigerTree, TreeItem } from '/@/components/TigerTree';
  import { EventDataNode } from 'ant-design-vue/lib/tree';
  defineOptions({ name: 'CustTree' });
  const emit = defineEmits(['select', 'handleAdd']);
  const emit = defineEmits(['select', 'handleAdd', 'UnSelect']);
  const props = defineProps({
    title: {
      // type: [Function, String] as PropType<string | ((data) => string)>,
      type: String,
    },
    treeData: {
      type:  Array as PropType<TreeItem[]>,
      type: Array as PropType<TreeItem[]>,
    },
    createIcon: {
      type: Function as PropType<(params: Recordable<any>) => string>,
    },
    add: {type: Boolean,},
    fieldNames: {type: Object as PropType<FieldNames>},
    add: { type: Boolean },
    fieldNames: { type: Object as PropType<FieldNames> },
    beforeRightClick: {
      type: Function as PropType<(...arg: any) => ContextMenuItem[] | ContextMenuOptions>,
      default: undefined,
    },
  });
  function handleSelect(keys) {
    emit('select', keys[0]);
  function handleSelect(keys, e) {
    emit('select', keys[0], e);
  }
  function handleAdd() {
    emit('handleAdd');
  }
  function UnSelect(node) {
    emit('UnSelect', node);
  }
  onMounted(() => {});
</script>