import { queryList } from '../utils/service';
import { navigateTo } from '../utils/index';
import monitor from '../utils/alipayLogger';
import { reportCmPV_YL } from '../utils/cloudMonitorHelper';
Component({
  didMount() {
    const {
      serviceCode
    } = getCurrentPages().pop().options;
    reportCmPV_YL({
      title: '报告查询',
      query: {
        serviceCode
      }
    });
  },

  methods: {
    toDetail(e) {
      const {
        recordId,
        status
      } = e.currentTarget.dataset.record;

      if (status === '未出报告') {
        my.showToast({
          type: 'none',
          content: '未出报告'
        });
        return;
      }

      navigateTo({
        url: `/pages/page-detail/index?queryId=${recordId}&type=report`
      });
    },

    onService({
      pageIndex,
      pageSize,
      ...other
    }) {
      monitor.api({
        api: '报告查询',
        success: true,
        c1: 'taSR_YL',
        time: 2000
      });
      return queryList({
        pageIndex,
        pageSize,
        ...other
      });
    }

  }
});