function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { MapIcon } from '@vtx/map-icon';
import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
var BaseService = {
  useBaseInfo: function useBaseInfo(id) {
    var _info$categoryDTO, _info$geometryInfo, _info$geometryInfo2, _lngLats$split, _info$geometryInfo3;
    var _useRequest = useRequest(function () {
        return request.get('/cloud/zykh-reborn/checkResource/get', {
          data: {
            id: id,
            coordType: 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var info = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    var baseInfo = [{
      label: '编码',
      key: 'code',
      value: info === null || info === void 0 ? void 0 : info.code
    }, {
      label: '名称',
      key: 'name',
      value: info === null || info === void 0 ? void 0 : info.name
    }, {
      label: '分类',
      key: 'categoryName',
      value: info === null || info === void 0 || (_info$categoryDTO = info.categoryDTO) === null || _info$categoryDTO === void 0 ? void 0 : _info$categoryDTO.name
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }, {
      label: '标段',
      key: 'tenderName',
      value: info === null || info === void 0 ? void 0 : info.tenderName
    }, {
      label: '管理单位',
      key: 'manageUnitName',
      value: info === null || info === void 0 ? void 0 : info.manageUnitName
    }, {
      label: '责任单位',
      key: 'responsibleUnitName',
      value: info === null || info === void 0 ? void 0 : info.responsibleUnitName
    }, {
      label: '责任人',
      key: 'responsibleStaffName',
      value: info === null || info === void 0 ? void 0 : info.responsibleStaffName
    }, {
      label: '责任人手机',
      key: 'responsibleStaffPhone',
      value: info === null || info === void 0 ? void 0 : info.responsibleStaffPhone
    }];
    var lngLats = info === null || info === void 0 || (_info$geometryInfo = info.geometryInfo) === null || _info$geometryInfo === void 0 ? void 0 : _info$geometryInfo.lngLats;
    var type = info === null || info === void 0 || (_info$geometryInfo2 = info.geometryInfo) === null || _info$geometryInfo2 === void 0 ? void 0 : _info$geometryInfo2.type;
    var center = type === 'point' ? lngLats === null || lngLats === void 0 ? void 0 : lngLats.split(',') : lngLats === null || lngLats === void 0 || (_lngLats$split = lngLats.split(';')) === null || _lngLats$split === void 0 ? void 0 : _lngLats$split[0].split(',');
    var results = {};
    if (lngLats) {
      var _lngLats$split2, _lngLats$split3;
      results = {
        mapPoints: type === 'point' ? [{
          lng: lngLats === null || lngLats === void 0 || (_lngLats$split2 = lngLats.split(',')) === null || _lngLats$split2 === void 0 ? void 0 : _lngLats$split2[0],
          lat: lngLats === null || lngLats === void 0 || (_lngLats$split3 = lngLats.split(',')) === null || _lngLats$split3 === void 0 ? void 0 : _lngLats$split3[1],
          icon: 'KH',
          type: type,
          url: new MapIcon.CommonIcon({
            canvasIcon: 'KH',
            color: '#119FFB'
          }).getImgUrl()
        }] : [],
        type: type,
        mapPolygons: type !== 'point' ? [{
          id: info === null || info === void 0 ? void 0 : info.id,
          rings: lngLats
        }] : []
      };
    }
    return _objectSpread({
      baseInfo: baseInfo,
      lngLats: (info === null || info === void 0 || (_info$geometryInfo3 = info.geometryInfo) === null || _info$geometryInfo3 === void 0 ? void 0 : _info$geometryInfo3.lngLats) || '',
      info: baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data,
      center: center
    }, results);
  },
  useKhInfo: function useKhInfo(id, startDate, endDate, checkActivityCode) {
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/zykh-reborn/kanban/resourceInfo', {
          data: {
            resourceId: id,
            coordType: 'wgs84',
            startDate: startDate,
            endDate: endDate,
            checkActivityCode: checkActivityCode
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id, startDate, endDate, checkActivityCode]
      }),
      res = _useRequest2.data;
    return {
      khRes: (res === null || res === void 0 ? void 0 : res.data) || {}
    };
  },
  useGetQuestions: function useGetQuestions(id, startDate, endDate) {
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/zykh-reborn/kanban/monthRuleRankList', {
          data: {
            resourceId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id, startDate, endDate]
      }),
      res = _useRequest3.data;
    return {
      questions: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  },
  use7month: function use7month(id, startDate, endDate) {
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/zykh-reborn/kanban/monthPointList', {
          data: {
            resourceId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id, startDate, endDate]
      }),
      res = _useRequest4.data,
      loading = _useRequest4.loading;
    return {
      monthData: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  }
};
var ReocrdService = {
  useRecordInfo: function useRecordInfo(id, startDate, endDate, checkActivityCode, page, sort) {
    var _useRequest5 = useRequest(function () {
        return request.get('/cloud/zykh-reborn/kanban/recordRulePage', {
          data: {
            resourceId: id,
            startDate: startDate,
            endDate: endDate,
            checkActivityCode: checkActivityCode,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, checkActivityCode, page, sort]
      }),
      recordRes = _useRequest5.data,
      loading = _useRequest5.loading;
    var records = (recordRes === null || recordRes === void 0 ? void 0 : recordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      records: records,
      loading: loading
    };
  }
};
export { BaseService, ReocrdService };