Component({
  props: {
    item: {},
    lastCache: {},
    onTapItem: () => null,
    onTapOpen: () => null
  },
  data: {
    open: false,
    style: ''
  },

  didMount() {},

  methods: {
    async onOpen() {
      const {
        item
      } = this.props;
      const {
        hasChildren
      } = item;
      const isOpen = !this.data.open;
      if (!hasChildren) return this.onTapItemProxy(item);
      const items = (await this.props.onTapOpen(item)) || [];
      const style = `height:${isOpen ? items.length * 100 : 0}rpx`;
      this.setData({
        open: isOpen,
        style
      });
    },

    onTapItem({
      target
    }) {
      const {
        item
      } = target.dataset;
      this.onTapItemProxy(item);
    },

    onTapItemProxy(item) {
      return this.props.onTapItem(item);
    }

  }
});