import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
var BaseService = {
  useRepairMaintain: function useRepairMaintain(id, dateValue, endDate) {
    // 汇总
    var _useRequest = useRequest(function () {
        return request.get('/cloud/jcss-reborn/maintainRecord/getMaintainRecordStatisticsByFacilityId', {
          data: {
            facilityId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      rmSummaryRes = _useRequest.data;
    var rmSummary = (rmSummaryRes === null || rmSummaryRes === void 0 ? void 0 : rmSummaryRes.data) || {};

    //维保类型
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/jcss-reborn/maintainRecord/maintainRecordStatisticsByType', {
          data: {
            facilityId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      rmTypeRes = _useRequest2.data;
    var rmType = [];
    if (Array.isArray(rmTypeRes === null || rmTypeRes === void 0 ? void 0 : rmTypeRes.data)) {
      rmType = rmTypeRes.data.map(function (ele) {
        return {
          name: ele.typeName,
          value: ele.count
        };
      });
    }

    //月度趋势
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/jcss-reborn/maintainRecord/maintainRecordStatisticsByMonth', {
          data: {
            facilityId: id,
            startDate: dateValue,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, dateValue, endDate]
      }),
      rmMonthTrendRes = _useRequest3.data,
      loading = _useRequest3.loading;
    var rmMonthTrend = (rmMonthTrendRes === null || rmMonthTrendRes === void 0 ? void 0 : rmMonthTrendRes.data) || {
      legends: [],
      names: [],
      values: []
    };
    return {
      rmSummary: rmSummary,
      rmType: rmType,
      rmMonthTrend: rmMonthTrend,
      loading: loading
    };
  },
  useRmRecord: function useRmRecord(id, applyTimeBegin, applyTimeEnd, page, sort) {
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/jcss-reborn/maintainRecord/maintainAllPage', {
          data: {
            facilityIds: id,
            applyTimeBegin: applyTimeBegin,
            applyTimeEnd: applyTimeEnd,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, applyTimeBegin, applyTimeEnd, page, sort]
      }),
      rmRecordRes = _useRequest4.data;
    var rmRecord = (rmRecordRes === null || rmRecordRes === void 0 ? void 0 : rmRecordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      rmRecord: rmRecord
    };
  }
};
export { BaseService };