import { MapIcon } from '@vtx/map-icon';
import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
var BaseService = {
  useBaseDetail: function useBaseDetail(id) {
    var _info$geometryInfo, _info$geometryInfo2, _lngLats$split, _lngLats$split2, _lngLats$split3, _info$geometryInfo3;
    var _useRequest = useRequest(function () {
        return request.get('/cloud/zykh-reborn/orderTask/get', {
          data: {
            id: id,
            coordType: 'wgs84'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data,
      loading = _useRequest.loading;
    var info = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    var baseInfo = [{
      label: '问题来源',
      key: 'problemFromStr',
      value: info === null || info === void 0 ? void 0 : info.problemFromStr
    }, {
      label: '大类',
      key: 'parentCategoryName',
      value: info === null || info === void 0 ? void 0 : info.parentCategoryName
    }, {
      label: '问题分类',
      key: 'problemCategoryName',
      value: info === null || info === void 0 ? void 0 : info.problemCategoryName
    }, {
      label: '考核对象',
      key: 'checkResourceName',
      value: info === null || info === void 0 ? void 0 : info.checkResourceName
    }, {
      label: '上报人员',
      key: 'reportStaffName',
      value: info === null || info === void 0 ? void 0 : info.reportStaffName
    }, {
      label: '上报时间',
      key: 'reportDateTimeStr',
      value: info === null || info === void 0 ? void 0 : info.reportDateTimeStr
    }, {
      label: '截止时间',
      key: 'endDateTimeStr',
      value: info === null || info === void 0 ? void 0 : info.endDateTimeStr
    }, {
      label: '标段',
      key: 'tenderName',
      value: info === null || info === void 0 ? void 0 : info.tenderName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName,
      width: '100%'
    }, {
      label: '问题描述',
      key: 'memo',
      value: info === null || info === void 0 ? void 0 : info.memo,
      width: '100%'
    }, {
      label: '问题照片',
      key: 'photos',
      value: info === null || info === void 0 ? void 0 : info.photos,
      componentType: 'IMAGE',
      width: '100%'
    }, {
      label: '问题位置',
      key: 'address',
      value: info === null || info === void 0 ? void 0 : info.address,
      width: '100%'
    }];
    var type = info === null || info === void 0 || (_info$geometryInfo = info.geometryInfo) === null || _info$geometryInfo === void 0 ? void 0 : _info$geometryInfo.type;
    var lngLats = info === null || info === void 0 || (_info$geometryInfo2 = info.geometryInfo) === null || _info$geometryInfo2 === void 0 ? void 0 : _info$geometryInfo2.lngLats;
    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(',');
    return {
      info: info,
      baseInfo: baseInfo,
      center: center,
      loading: loading,
      geometryType: type,
      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: 'GD',
        type: info === null || info === void 0 || (_info$geometryInfo3 = info.geometryInfo) === null || _info$geometryInfo3 === void 0 ? void 0 : _info$geometryInfo3.type,
        url: new MapIcon.CommonIcon({
          canvasIcon: 'GD',
          color: '#119FFB'
        }).getImgUrl()
      }] : [],
      mapPolygons: type !== 'point' ? [{
        id: info === null || info === void 0 ? void 0 : info.id,
        rings: lngLats,
        type: type
      }] : []
    };
  },
  useGetRecord: function useGetRecord(orderTaskNo) {
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/zykh-reborn/orderProcessLog/list', {
          data: {
            orderTaskNo: orderTaskNo
          }
        });
      }, {
        ready: !!orderTaskNo,
        refreshDeps: [orderTaskNo]
      }),
      data = _useRequest2.data;
    return (data === null || data === void 0 ? void 0 : data.data) || [];
  }
};
export { BaseService };