import { getIn } from 'herculex/dist/utils/manipulate';

const reload = {
  btnText: '刷新',
  handleName: 'onReloadHandle',
};

Component({
  props: {
    className: '',
    type: '',
    errMsg: '',
    operations: [],
    onReloadHandle() {},
  },
  data: {
    defaultErrMsg: '抱歉，系统繁忙，请稍后再试',
    operations: [reload],
  },
  didMount() {
  },
  didUpdate() {
  },
  methods: {
    onTapBtn(e) {
      const handleName = getIn(e, ['currentTarget', 'dataset', 'value']);
      const cb = this.props[handleName] || this[handleName];
      cb && cb.call(this);
    },
    onReloadHandle() {
      const { onReloadHandle } = this.props;
      onReloadHandle && onReloadHandle();
    },
  },
});
