import * as API from 'api/virtual/products';

export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      default() {
        return null;
      }
    }
  },
  watch: {
    show(bool) {
      this.my_show = bool;
      if (bool) {
        this.list = [];
        this.index();
      }
    }
  },
  data() {
    return {
      loading: false,
      my_show: false,
      list: []
    };
  },
  methods: {
    index() {
      let params = {
        type: this.data.type,
        company_id: this.data.company_id,
        package_id: this.data.package_id
      };

      this.loading = true;
      API.history(params).then(res => {
        this.loading = false;
        if (res.code === 0) {
          this.list = res.data;
        }
      });
    },
    visibleChange(bool) {
      this.$emit('update:show', bool);
    }

  }
};
