import { getContentHeight } from '../../../utils';
const tabHeight = 44;
const filterH = '88rpx';
Component({
  props: {
    className: '',
    showAll: true,
    hasFilter: true,
    onFilter: () => null,
    onAutoFilter: () => null,
    showInpatient: true,
    typeOptions: [{
      value: 'normal',
      label: '普通号'
    }, {
      value: 'expert',
      label: '专家号'
    }],

    /* 就诊人Id */
    patientId: '',
    statusOptions: [],
    defaultName: '全部类型'
  },
  data: {
    filters: {
      type: '',
      cardNum: '',
      endTime: '',
      startTime: ''
    },
    contentHeight: `calc(${getContentHeight() - tabHeight}px - ${filterH})`
  },

  didMount() {
    if (!this.props.hasFilter) {
      this.setData({
        contentHeight: `${getContentHeight() - tabHeight}px`
      });
    }
  },

  methods: {
    onFilterChange(item) {
      const {
        filters
      } = this.data;
      const _filters = { ...filters,
        ...item
      };
      this.props.onFilter(_filters);
      this.setData({
        filters: _filters
      });
    },

    onAutoFilterHandel(res) {
      const {
        bindCardNum = '',
        medicCards = []
      } = res;
      this.setData({
        'filters.cardNum': bindCardNum,
        medicCards
      });
      this.props.onAutoFilter(res);
    }

  }
});