import { queryList } from './service';
import history from '../../utils/history';
Component({
  props: {},
  methods: {
    onFilterHandel(filters) {
      this.filters = this.restData(filters);
      this.flatRef.refresh();
    },

    restData(filters) {
      const rest = {};
      Object.keys(filters).forEach(key => {
        const value = filters[key];
        if (value) rest[key] = value;
      });
      return rest;
    },

    saveRef(ref) {
      this.flatRef = ref;
    },

    onService() {
      const params = {
        cardNum: '',
        ...this.filters
      };
      return queryList(params).then(list => ({
        // expired：已过号，queuing：排队中，ringing：叫号中， completed：已完成
        list,
        pagination: {
          total: list.length
        }
      }));
    },

    toH5(e) {
      const {
        url
      } = e.target.dataset;
      history.toH5(url);
    }

  }
});