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 * as VtxMapIcon from '@vtx/map-icon';
console.log(VtxMapIcon, 'VtxMapIcon');
import { getUrlParam, getVtxToken, request } from '@vtx/utils';
import { useRequest } from 'ahooks';
import dayjs from 'dayjs';
var BaseService = {
  useBaseInfo: function useBaseInfo(id, coordType) {
    var _info$paramsDone, _numInfo$data, _numInfo$data2;
    var _useRequest = useRequest(function () {
        return request.get("/cloud/management/workElement/findbyid/".concat(id, ".read"), {
          extraHeader: {
            systemCode: getUrlParam('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByWorkElement', {
          data: {
            workElementId: id,
            needRealtimeInfo: true,
            date: dayjs().format('YYYY-MM-DD'),
            coordType: 'wgs84'
          },
          extraHeader: {
            systemCode: getUrlParam('systemCode')
          }
        });
      }, {
        ready: !!id && !!coordType,
        refreshDeps: [id, coordType]
      }),
      numInfo = _useRequest2.data;
    var info = baseInfoRes || {};
    var mapPolygons = info !== null && info !== void 0 && (_info$paramsDone = info.paramsDone) !== null && _info$paramsDone !== void 0 && _info$paramsDone.length ? [{
      id: 'polygon',
      rings: info === null || info === void 0 ? void 0 : info.paramsDone,
      config: {
        color: 'red',
        lineColor: 'red',
        lineWidth: 1
      }
    }] : [];
    var mapPoints = numInfo !== null && numInfo !== void 0 && (_numInfo$data = numInfo.data) !== null && _numInfo$data !== void 0 && (_numInfo$data = _numInfo$data.list) !== null && _numInfo$data !== void 0 && _numInfo$data.length ? numInfo.data.list.map(function (item) {
      var _mapInfoRes, _mapInfoRes2;
      return _objectSpread(_objectSpread({}, item), {}, {
        id: item.staffId,
        canShowLabel: true,
        labelClass: 'vtx-map-carCode',
        lng: item.lngDone,
        lat: item.latDone,
        layerType: 'staff',
        staffName: item.staffName,
        newType: item.icon ? 1 : item.statusCode === 'Normal' ? 2 : 3,
        url: item.icon ? "/cloudFile/common/downloadFile?id=".concat(item.icon, "&token=").concat(getVtxToken('token')) : isDark ? new MapIcon.CommonIcon2({
          canvasIcon: 'PERSONNEL',
          color: ((_mapInfoRes = mapInfoRes) === null || _mapInfoRes === void 0 || (_mapInfoRes = _mapInfoRes.data) === null || _mapInfoRes === void 0 ? void 0 : _mapInfoRes.statusCode) === 'Normal' ? '#119FFB' : '#999999'
        }).getImgUrl() : new MapIcon.CommonIcon({
          canvasIcon: 'PERSONNEL',
          color: ((_mapInfoRes2 = mapInfoRes) === null || _mapInfoRes2 === void 0 || (_mapInfoRes2 = _mapInfoRes2.data) === null || _mapInfoRes2 === void 0 ? void 0 : _mapInfoRes2.statusCode) === 'Normal' ? '#119FFB' : '#999999'
        }).getImgUrl(),
        config: {
          width: 30,
          height: 30,
          labelContent: item.staffName
        }
      });
    }) : [];
    var baseInfo = [{
      label: '编码',
      key: 'code',
      value: info === null || info === void 0 ? void 0 : info.code
    }, {
      label: '区域类型',
      key: 'workElementTypeName',
      value: info === null || info === void 0 ? void 0 : info.workElementTypeName
    }, {
      label: '所属机构',
      key: 'departmentName',
      value: info === null || info === void 0 ? void 0 : info.departmentName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }];
    return {
      baseInfo: baseInfo,
      numInfo: (numInfo === null || numInfo === void 0 || (_numInfo$data2 = numInfo.data) === null || _numInfo$data2 === void 0 ? void 0 : _numInfo$data2.realtime) || {},
      mapPolygons: mapPolygons,
      mapPoints: mapPoints
    };
  },
  // 今日作业
  useTodayWork: function useTodayWork(id, startDate, endDate, page) {
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/zyry-reborn/api/v101/attendanceRecord', {
          data: {
            matchWorkElementId: id,
            startTime: startDate,
            endTime: endDate,
            pageNo: page,
            pageSize: 20
          },
          extraHeader: {
            systemCode: getUrlParam('systemCode')
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, page]
      }),
      todayWorkRes = _useRequest3.data;
    return {
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || []
    };
  },
  useWorkInfo: function useWorkInfo(id, date) {
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByWorkElement', {
          data: {
            workElementId: id,
            date: date
          },
          extraHeader: {
            systemCode: getUrlParam('systemCode')
          }
        });
      }, {
        refreshDeps: [id, date]
      }),
      workInfoRes = _useRequest4.data;
    return {
      workInfoRes: (workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.data) || {}
    };
  },
  // 里程分析
  useMileAnalysis: function useMileAnalysis(staffId, startDate, endDate) {
    var _useRequest5 = useRequest(function () {
        return request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkMileageAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: getUrlParam('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      mileAnalysisRes = _useRequest5.data;
    return {
      mileAnalysisRes: (mileAnalysisRes === null || mileAnalysisRes === void 0 ? void 0 : mileAnalysisRes.data) || {}
    };
  }
};
export { BaseService };