import scroll from 'vue-seamless-scroll'
export default {
  components: {
    scroll
  },
  data () {
    return {
    };
  },
  props: {
    details: {
      type: Boolean,
      default: false
    },
    width: {
      type: [String, Number],
      default: '100%'
    },
    height: {
      type: [String, Number],
      default: '100'
    },
    bodyHeight: {
      type: [Number],
      default: 200
    },
    headers: {
      type: Array,
      default: function () {
        return ['表头1', '表头2', '表头3']
      }
    },
    data: {
      type: Array,
      default: function () {
        return [
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头1', '表头2', '表头3'],
          ['表头11', '表头22', '表头33']
        ]
      }
    },
    dataName: {
      type: Array,
      default: function () {
        return ['voucherSummary', 'bookDate', 'jieAmount', 'daiAmount']
      }
    }
  },
  computed: {
    dataLength: function () {
      return this.dataList.length;
    },
    bodyStyle: function () {
      return {
        height: this.bodyHeight + 'px',
      };
    },
    style: function () {
      return {
        height: this.height,
        width: this.width
      };
    },
    // 如果数据不足5条则不滚动
    swiperOption: function () {
      return {
        step: 0.4,
        limitMoveNum: 5,
        hoverStop: true,
        direction: 1,
        openWatch: true,
        singleHeight: 0,
        waitTime: 1000
      }
    }
  },
  created () {
  },
  methods: {
    handleClick(e) {
      // 获取最近携带 data-item 属性的元素
      const target = e.target.closest('[data-item]');
      if (!target) return;

      // 解析存储的数据
      const item = JSON.parse(target.dataset.item);
      console.log("点击项数据：", item);
      this.$emit('lineClick', item)
    }
  }
};
