@lingxiteam/ebe-utils 0.0.25 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/constants.js +0 -1
- package/es/index.js +57 -38
- package/es/node/move.d.ts +1 -0
- package/es/node/move.js +7 -4
- package/es/requestQueue.d.ts +9 -0
- package/es/requestQueue.js +59 -0
- package/lib/h5public/src/components/common/PreviewFile/index.tsx +3 -7
- package/lib/h5public/src/components/factory/package.json +1 -1
- package/lib/h5public/src/components/factory/src/BlockSelect/components/CheckBox/index.tsx +14 -4
- package/lib/h5public/src/components/factory/src/BlockSelect/components/Icon/index.tsx +4 -4
- package/lib/h5public/src/components/factory/src/BlockSelect/index.tsx +13 -21
- package/lib/h5public/src/components/factory/src/Button/index.tsx +1 -0
- package/lib/h5public/src/components/factory/src/Card/index.less +11 -24
- package/lib/h5public/src/components/factory/src/Card/index.tsx +61 -22
- package/lib/h5public/src/components/factory/src/DGroup/index.less +7 -3
- package/lib/h5public/src/components/factory/src/DformFile/FormFile.tsx +17 -4
- package/lib/h5public/src/components/factory/src/DformFile/assets/closeIcon.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/default.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/fileName.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/img.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/js.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/pdf.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/ppt.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/txt.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/word.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/xls.png +0 -0
- package/lib/h5public/src/components/factory/src/DformFile/assets/zip.png +0 -0
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/YieldMethod.ts +33 -0
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.less +41 -5
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.tsx +18 -3
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/useDynamicDataContainer.ts +14 -1
- package/lib/h5public/src/components/factory/src/DynamicList/index.tsx +4 -2
- package/lib/h5public/src/components/factory/src/DynamicTable/Table.tsx +3 -1
- package/lib/h5public/src/components/factory/src/Image/BasicImage/index.tsx +36 -1
- package/lib/h5public/src/components/factory/src/StackColumn/loader.tsx +1 -1
- package/lib/h5public/src/components/factory/src/StaticTabs/index.tsx +1 -1
- package/lib/h5public/src/components/factory/src/VerificationCode/index.tsx +14 -3
- package/lib/h5public/src/components/factory/src/VideoPlayer/loader.ts +1 -1
- package/lib/h5public/src/components/factory/src/utils/CustomModule.tsx +3 -0
- package/lib/h5public/src/components/factory/src/utils/hooks/useFormItem.ts +3 -0
- package/lib/h5public/src/hooks/usePageForm.ts +29 -3
- package/lib/h5public/src/utils/native.ts +94 -0
- package/lib/h5public/yarn.lock +19383 -0
- package/lib/node/move.d.ts +1 -0
- package/lib/node/move.js +6 -3
- package/lib/pcpublic/src/components/common/PreviewFile/index.tsx +8 -0
- package/lib/pcpublic/src/components/common/PreviewFile/utils.ts +45 -0
- package/lib/pcpublic/src/components/pcfactory/package.json +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/CollapsePanel/index.tsx +6 -4
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/YieldMethod.ts +33 -0
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/index.tsx +18 -3
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts +14 -1
- package/lib/pcpublic/src/components/pcfactory/src/Img/index.tsx +34 -2
- package/lib/pcpublic/src/components/pcfactory/src/LoopList/index.tsx +9 -4
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +8 -1
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/index.tsx +39 -13
- package/lib/pcpublic/src/components/pcfactory/src/SuperSelect/ComSelect.tsx +22 -14
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +12 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +54 -12
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +516 -485
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +40 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +3 -34
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +30 -3
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +37 -13
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +15 -4
- package/lib/pcpublic/src/components/pcfactory/src/Tabs/index.tsx +2 -0
- package/lib/pcpublic/src/components/pcfactory/src/Tag/index.tsx +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +13 -2
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/FormGroup.less +8 -4
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Icon.less +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/StdUpload.less +3 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +15 -0
- package/lib/pcpublic/src/hooks/usePageForm.ts +4 -3
- package/lib/pcpublic/src/utils/exportCustomData/index.tsx +723 -0
- package/lib/pcpublic/src/utils/exportCustomData/tool.ts +399 -0
- package/lib/pcpublic/src/utils/messageApi.ts +25 -20
- package/lib/pcpublic/yarn.lock +11441 -0
- package/lib/public/src/components/ProgressComp/index.tsx +4 -14
- package/lib/public/src/hooks/useBaseDataSource.ts +2 -1
- package/lib/public/src/hooks/useExportCustomDataFile.ts +4 -0
- package/lib/public/src/services/api/engine.ts +19 -0
- package/lib/public/src/services/api/index.ts +12 -0
- package/lib/public/src/utils/Context/context.tsx +1 -0
- package/lib/public/src/utils/cmd.ts +455 -0
- package/lib/public/src/utils/historytool.ts +3 -0
- package/lib/public/src/utils/lcdpBaseApi.ts +2 -2
- package/lib/public/src/utils/platform/utils/fileUtils.ts +12 -11
- package/lib/public/src/utils/polyfills.ts +4 -0
- package/lib/public/src/utils/popoverUtils.ts +56 -0
- package/lib/public/src/utils/service/baseRequest.ts +8 -8
- package/lib/public/src/utils/service/urlHelper.ts +2 -0
- package/lib/public/src/utils/useComponentHoc.ts +6 -3
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { antPrefix } from '@/components/pcfactory/src/variables';
|
|
2
2
|
import { CloseCircleFilled } from '@ant-design/icons';
|
|
3
|
-
import { LocaleFunction } from '@lingxiteam/types';
|
|
4
3
|
import {
|
|
5
4
|
Button,
|
|
6
5
|
ConfigProvider,
|
|
@@ -21,13 +20,9 @@ const openProgressMsg = (
|
|
|
21
20
|
fileName: string,
|
|
22
21
|
percentComplete: number,
|
|
23
22
|
text: string,
|
|
24
|
-
{ getLocale = (k, p) => p ?? '' }: { getLocale: LocaleFunction },
|
|
25
23
|
) => {
|
|
26
24
|
message.loading({
|
|
27
|
-
icon:
|
|
28
|
-
fileName,
|
|
29
|
-
text,
|
|
30
|
-
}),
|
|
25
|
+
icon: `${fileName} 正在${text}:`,
|
|
31
26
|
content: openProgress(percentComplete),
|
|
32
27
|
key,
|
|
33
28
|
duration: 0,
|
|
@@ -66,12 +61,10 @@ const showProgressNotification = (config: {
|
|
|
66
61
|
type?: 'error' | 'success' | 'process';
|
|
67
62
|
btn: (onCancel: () => void) => any;
|
|
68
63
|
loadingText?: string;
|
|
69
|
-
getLocale: LocaleFunction;
|
|
70
64
|
}) => {
|
|
71
|
-
const getLocale = config.getLocale ?? ((k?: string, l?: string) => l ?? '');
|
|
72
65
|
const {
|
|
73
66
|
key,
|
|
74
|
-
title =
|
|
67
|
+
title = '导出',
|
|
75
68
|
percent,
|
|
76
69
|
onCancel,
|
|
77
70
|
message,
|
|
@@ -93,17 +86,14 @@ const showProgressNotification = (config: {
|
|
|
93
86
|
<ConfigProvider prefixCls={antPrefix} locale={zhCN}>
|
|
94
87
|
<Popconfirm
|
|
95
88
|
placement="bottomRight"
|
|
96
|
-
title={
|
|
97
|
-
'ProgressComp.cancelMessage',
|
|
98
|
-
'取消将无法获得下载结果,请确认是否需要取消',
|
|
99
|
-
)}
|
|
89
|
+
title={'取消将无法获得下载结果,请确认是否需要取消'}
|
|
100
90
|
onConfirm={() => {
|
|
101
91
|
onCancel?.();
|
|
102
92
|
notification?.close(key);
|
|
103
93
|
}}
|
|
104
94
|
overlayClassName="ProgressComp-confirm"
|
|
105
95
|
>
|
|
106
|
-
<Button>{
|
|
96
|
+
<Button>{'取消'}</Button>
|
|
107
97
|
</Popconfirm>
|
|
108
98
|
</ConfigProvider>
|
|
109
99
|
);
|
|
@@ -118,7 +118,8 @@ const useBaseDataSource = <T extends BaseDataSourceType>(
|
|
|
118
118
|
} else if (operateType === ARRAY_OPERATE_TYPE.DELETE) {
|
|
119
119
|
ArrayUtil.remove(data, path, predicate);
|
|
120
120
|
} else if (operateType === ARRAY_OPERATE_TYPE.REPLACE) {
|
|
121
|
-
|
|
121
|
+
// 如果是数组,变化的值是一个 undefined 则应给一个空数组
|
|
122
|
+
ArrayUtil.replace(data, path, value || []);
|
|
122
123
|
} else if (operateType === ARRAY_OPERATE_TYPE.UPDATE) {
|
|
123
124
|
ArrayUtil.update(
|
|
124
125
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APPID } from '@/constants';
|
|
1
2
|
import { api } from '@/services/api';
|
|
2
3
|
import { SERVICE_SOURCE } from '@/services/type';
|
|
3
4
|
import { handleParseGroups } from '@/utils/engine-utils/exportCustomUtils';
|
|
@@ -474,6 +475,7 @@ const useExportCustomDataFile = ({
|
|
|
474
475
|
req = api
|
|
475
476
|
.getSqlQueryColumnsList({
|
|
476
477
|
serviceCodes: selectedKeyMap[type].join(','),
|
|
478
|
+
appId: APPID,
|
|
477
479
|
})
|
|
478
480
|
.then((res: any) => {
|
|
479
481
|
const m: any = {};
|
|
@@ -486,6 +488,7 @@ const useExportCustomDataFile = ({
|
|
|
486
488
|
req = api
|
|
487
489
|
.queryBusiObjectRowColumnsList({
|
|
488
490
|
busiObjectIds: selectedKeyMap[type].join(','),
|
|
491
|
+
appId: APPID,
|
|
489
492
|
})
|
|
490
493
|
.then((res: any) => {
|
|
491
494
|
const m: any = {};
|
|
@@ -498,6 +501,7 @@ const useExportCustomDataFile = ({
|
|
|
498
501
|
req = api
|
|
499
502
|
.queryServiceResponseColumnsList({
|
|
500
503
|
serviceVersionIds: (selectedKeyMap[type] || []).join(','),
|
|
504
|
+
appId: APPID,
|
|
501
505
|
})
|
|
502
506
|
.then((res: any) => {
|
|
503
507
|
const m: any = {};
|
|
@@ -23,6 +23,12 @@ interface ApiType {
|
|
|
23
23
|
importInsts: string;
|
|
24
24
|
// 获取导出进度
|
|
25
25
|
getImportExportApply: HTTPMehodFn;
|
|
26
|
+
// 根据 serviceCodes 获取内部服务字段
|
|
27
|
+
getSqlQueryColumnsList: HTTPMehodFn;
|
|
28
|
+
// 根据 busiObjectIds 获取业务对象字段
|
|
29
|
+
queryBusiObjectRowColumnsList: HTTPMehodFn;
|
|
30
|
+
// 获取服务编排出参字段
|
|
31
|
+
queryServiceResponseColumnsList: HTTPMehodFn;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
const api: ApiType = {
|
|
@@ -54,6 +60,19 @@ const api: ApiType = {
|
|
|
54
60
|
// 获取导出进度
|
|
55
61
|
getImportExportApply: (params, appCtx) =>
|
|
56
62
|
urlHelper.get('app/object/getImportExportApply', params, appCtx),
|
|
63
|
+
// 根据 serviceCodes 获取内部服务字段
|
|
64
|
+
getSqlQueryColumnsList: (params, appCtx) =>
|
|
65
|
+
urlHelper.get('app/sql/getSqlQueryColumnsList', params, appCtx),
|
|
66
|
+
// 根据 busiObjectIds 获取业务对象字段
|
|
67
|
+
queryBusiObjectRowColumnsList: (params, appCtx) =>
|
|
68
|
+
urlHelper.get('app/object/queryBusiObjectRowColumnsList', params, appCtx),
|
|
69
|
+
// 获取服务编排出参字段
|
|
70
|
+
queryServiceResponseColumnsList: (params, appCtx) =>
|
|
71
|
+
urlHelper.get(
|
|
72
|
+
'app/orchestrationService/queryServiceResponseColumnsList',
|
|
73
|
+
params,
|
|
74
|
+
appCtx,
|
|
75
|
+
),
|
|
57
76
|
};
|
|
58
77
|
|
|
59
78
|
export default api;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import security from '@/utils/Security';
|
|
2
|
+
import http, { DataType, RequestOptions } from '@/utils/service/baseRequest';
|
|
2
3
|
import serviceApi from '@/utils/service/commonFetch';
|
|
3
4
|
import resolveApiPath from '@/utils/service/resolveApiPath';
|
|
4
5
|
import urlHelper from '../../utils/service/urlHelper';
|
|
@@ -6,6 +7,17 @@ import batchInsert from './batchInsert';
|
|
|
6
7
|
import { getAppFileUrlByFileCode } from './getAppFileUrlByFileCode';
|
|
7
8
|
|
|
8
9
|
export const api = {
|
|
10
|
+
http: {
|
|
11
|
+
get: (url: string, params: DataType, options?: RequestOptions) =>
|
|
12
|
+
http.get(url, {}, params, options),
|
|
13
|
+
post: (url: string, params: DataType, options?: RequestOptions) =>
|
|
14
|
+
http.post(url, {}, params, options),
|
|
15
|
+
put: (url: string, params: DataType = {}, options?: RequestOptions) =>
|
|
16
|
+
http.put(url, {}, params, options),
|
|
17
|
+
delete: (url: string, params: DataType = {}, options?: RequestOptions) =>
|
|
18
|
+
http.delete(url, {}, params, options),
|
|
19
|
+
},
|
|
20
|
+
downFieldPrefix: () => resolveApiPath(`app/file/download?fileId=`),
|
|
9
21
|
batchInsert,
|
|
10
22
|
resolveApiPath,
|
|
11
23
|
getAppFileUrlByFileCode,
|
|
@@ -19,9 +19,464 @@ export const checkIsContains = (contents: any, containContent: any) => {
|
|
|
19
19
|
}
|
|
20
20
|
return String(contents).indexOf(containContent) !== -1;
|
|
21
21
|
};
|
|
22
|
+
|
|
22
23
|
const numberregex = /\d+/g;
|
|
23
24
|
export const safeNumber = (str: string | number) => {
|
|
24
25
|
return typeof str === 'string' && numberregex.test(str) && !isNaN(Number(str))
|
|
25
26
|
? Number(str)
|
|
26
27
|
: str;
|
|
27
28
|
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 复制文本
|
|
32
|
+
* @param text 复制内容
|
|
33
|
+
*/
|
|
34
|
+
export const copyText = (text: string) => {
|
|
35
|
+
return new Promise<void>((resolve, reject) => {
|
|
36
|
+
const textarea = document.createElement('textarea');
|
|
37
|
+
textarea.value = text;
|
|
38
|
+
textarea.setAttribute('readonly', 'readonly');
|
|
39
|
+
document.body.appendChild(textarea);
|
|
40
|
+
textarea.select();
|
|
41
|
+
if (document.execCommand('copy')) {
|
|
42
|
+
document.execCommand('copy');
|
|
43
|
+
resolve();
|
|
44
|
+
} else {
|
|
45
|
+
reject();
|
|
46
|
+
}
|
|
47
|
+
document.body.removeChild(textarea);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface commonFunc {
|
|
52
|
+
(...args: any): any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 初始化百度地图
|
|
56
|
+
const initBaiduMap = (mapKey: string) =>
|
|
57
|
+
new Promise((resolve, reject) => {
|
|
58
|
+
if (typeof (window as any).BMap !== 'undefined') {
|
|
59
|
+
resolve((window as any).BMap);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
(window as any).onBMapCallback = () => {
|
|
63
|
+
// console.log('百度地图脚本初始化成功');
|
|
64
|
+
resolve((window as any).BMap);
|
|
65
|
+
};
|
|
66
|
+
// 将地图注册的信息插入到document中
|
|
67
|
+
const url = `https://api.map.baidu.com/api?v=3.0&ak=${mapKey}&callback=onBMapCallback`;
|
|
68
|
+
const mapScript = document.createElement('script');
|
|
69
|
+
mapScript.type = 'text/javascript';
|
|
70
|
+
mapScript.src = url;
|
|
71
|
+
mapScript.onerror = reject;
|
|
72
|
+
const [head] = document.getElementsByTagName('head') as any;
|
|
73
|
+
head.appendChild(mapScript);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const pointBaiduTranslate: commonFunc = (
|
|
77
|
+
convertor,
|
|
78
|
+
ggPoint,
|
|
79
|
+
successCallBack,
|
|
80
|
+
errorCallBask,
|
|
81
|
+
address,
|
|
82
|
+
{ getLocale },
|
|
83
|
+
) => {
|
|
84
|
+
convertor.translate([ggPoint], 5, 3, (data: any) => {
|
|
85
|
+
// console.log('转换后的坐标', data);
|
|
86
|
+
if (data.status === 0) {
|
|
87
|
+
successCallBack([data.points[0], address]);
|
|
88
|
+
} else {
|
|
89
|
+
errorCallBask(getLocale('sysAction.location.transformfail'));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const getBaiduCurrentLocation: commonFunc = (
|
|
95
|
+
geolocation,
|
|
96
|
+
geocoder,
|
|
97
|
+
locationAddress,
|
|
98
|
+
type,
|
|
99
|
+
convertor,
|
|
100
|
+
successCallBack,
|
|
101
|
+
errorCallBask,
|
|
102
|
+
timer,
|
|
103
|
+
{ getLocale },
|
|
104
|
+
) => {
|
|
105
|
+
geolocation.getCurrentPosition(
|
|
106
|
+
(r: any) => {
|
|
107
|
+
console.log(geolocation.getStatus());
|
|
108
|
+
console.log((window as any).BMAP_STATUS_SUCCESS);
|
|
109
|
+
if (geolocation.getStatus() === (window as any).BMAP_STATUS_SUCCESS) {
|
|
110
|
+
// console.log('获取定位:', r);
|
|
111
|
+
// 获取详细地址
|
|
112
|
+
if (locationAddress && locationAddress !== '') {
|
|
113
|
+
geocoder.getLocation(r.point, (address: any) => {
|
|
114
|
+
// console.log('定位地址:', address.address);
|
|
115
|
+
switch (type) {
|
|
116
|
+
case 'WGS84': // 大地坐标系 法律规定不支持转换
|
|
117
|
+
// pointTranslate(convertor, r.point, successCallBack, errorCallBask, r.address);
|
|
118
|
+
successCallBack([r.point, address]);
|
|
119
|
+
break;
|
|
120
|
+
case 'GCJ02': // 火星坐标系
|
|
121
|
+
pointBaiduTranslate(
|
|
122
|
+
convertor,
|
|
123
|
+
r.point,
|
|
124
|
+
successCallBack,
|
|
125
|
+
errorCallBask,
|
|
126
|
+
address,
|
|
127
|
+
{ getLocale },
|
|
128
|
+
);
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
// 默认百度坐标系
|
|
132
|
+
successCallBack([r.point, address]);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
switch (type) {
|
|
138
|
+
case 'WGS84': // 大地坐标系 法律规定不支持转换
|
|
139
|
+
// pointTranslate(convertor, r.point, successCallBack, errorCallBask, r.address);
|
|
140
|
+
successCallBack([r.point, r.address]);
|
|
141
|
+
break;
|
|
142
|
+
case 'GCJ02': // 火星坐标系
|
|
143
|
+
pointBaiduTranslate(
|
|
144
|
+
convertor,
|
|
145
|
+
r.point,
|
|
146
|
+
successCallBack,
|
|
147
|
+
errorCallBask,
|
|
148
|
+
r.address,
|
|
149
|
+
{ getLocale },
|
|
150
|
+
);
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
// 默认百度坐标系
|
|
154
|
+
successCallBack([r.point, r.address]);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
// console.log('定位失败:', r);
|
|
160
|
+
clearInterval(timer);
|
|
161
|
+
errorCallBask(getLocale('sysAction.localtion.fail'));
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{ enableHighAccuracy: true, maximumAge: 0, SDKLocation: true },
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const getBaiduLocation: commonFunc = (
|
|
169
|
+
always,
|
|
170
|
+
type,
|
|
171
|
+
locationAddress,
|
|
172
|
+
successCallBack,
|
|
173
|
+
errorCallBask,
|
|
174
|
+
{ getLocale },
|
|
175
|
+
) => {
|
|
176
|
+
const geolocation = new (window as any).BMap.Geolocation();
|
|
177
|
+
const convertor = new (window as any).BMap.Convertor();
|
|
178
|
+
const geocoder = new (window as any).BMap.Geocoder();
|
|
179
|
+
|
|
180
|
+
// /**
|
|
181
|
+
// * 开启辅助定位
|
|
182
|
+
// */
|
|
183
|
+
// geolocation?.enableSDKLocation();
|
|
184
|
+
getBaiduCurrentLocation(
|
|
185
|
+
geolocation,
|
|
186
|
+
geocoder,
|
|
187
|
+
locationAddress,
|
|
188
|
+
type,
|
|
189
|
+
convertor,
|
|
190
|
+
successCallBack,
|
|
191
|
+
errorCallBask,
|
|
192
|
+
null,
|
|
193
|
+
{ getLocale },
|
|
194
|
+
);
|
|
195
|
+
if (always && always !== '') {
|
|
196
|
+
// 持续定位 默认定位60次,间隔15秒
|
|
197
|
+
let times = 0;
|
|
198
|
+
const timer = setInterval(() => {
|
|
199
|
+
if (times > 60) {
|
|
200
|
+
clearInterval(timer);
|
|
201
|
+
}
|
|
202
|
+
times += 1;
|
|
203
|
+
getBaiduCurrentLocation(
|
|
204
|
+
geolocation,
|
|
205
|
+
geocoder,
|
|
206
|
+
locationAddress,
|
|
207
|
+
type,
|
|
208
|
+
convertor,
|
|
209
|
+
successCallBack,
|
|
210
|
+
errorCallBask,
|
|
211
|
+
timer,
|
|
212
|
+
{ getLocale },
|
|
213
|
+
);
|
|
214
|
+
}, 15000);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// 初始化高德地图
|
|
219
|
+
const initGaoDeMap = (securityKey: string | null, mapKey: string) =>
|
|
220
|
+
new Promise((resolve, reject) => {
|
|
221
|
+
if (typeof (window as any).AMap !== 'undefined') {
|
|
222
|
+
resolve((window as any).AMap);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
(window as any)._AMapSecurityConfig = {
|
|
226
|
+
securityJsCode: securityKey || '',
|
|
227
|
+
};
|
|
228
|
+
(window as any).onAMapLoaded = () => {
|
|
229
|
+
resolve((window as any).AMap);
|
|
230
|
+
};
|
|
231
|
+
// 将地图注册的信息插入到document中
|
|
232
|
+
const url = `https://webapi.amap.com/maps?v=2.0&key=${mapKey}&callback=onAMapLoaded`;
|
|
233
|
+
const mapScript = document.createElement('script');
|
|
234
|
+
mapScript.type = 'text/javascript';
|
|
235
|
+
mapScript.src = url;
|
|
236
|
+
mapScript.onerror = reject;
|
|
237
|
+
const [head] = document.getElementsByTagName('head') as any;
|
|
238
|
+
head.appendChild(mapScript);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const pointTranslate: commonFunc = (
|
|
242
|
+
ggPoint,
|
|
243
|
+
successCallBack,
|
|
244
|
+
errorCallBask,
|
|
245
|
+
address,
|
|
246
|
+
{ getLocale },
|
|
247
|
+
) => {
|
|
248
|
+
// 高德转百度坐标
|
|
249
|
+
const xPI = (3.14159265358979324 * 3000.0) / 180.0;
|
|
250
|
+
const bdLng = Number(ggPoint.KL || ggPoint.lng);
|
|
251
|
+
const bdLat = Number(ggPoint.kT || ggPoint.lat);
|
|
252
|
+
const z =
|
|
253
|
+
Math.sqrt(bdLng * bdLng + bdLat * bdLat) + 0.00002 * Math.sin(bdLat * xPI);
|
|
254
|
+
const theTa = Math.atan2(bdLat, bdLng) + 0.000003 * Math.cos(bdLng * xPI);
|
|
255
|
+
const lng = z * Math.cos(theTa) + 0.0065;
|
|
256
|
+
const lat = z * Math.sin(theTa) + 0.006;
|
|
257
|
+
if (lng && lat) {
|
|
258
|
+
successCallBack([{ lng, lat }, address]);
|
|
259
|
+
} else {
|
|
260
|
+
errorCallBask(getLocale('sysAction.location.transformfail'));
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const getCurrentLocation: commonFunc = (
|
|
265
|
+
geolocation,
|
|
266
|
+
locationAddress,
|
|
267
|
+
type,
|
|
268
|
+
successCallBack,
|
|
269
|
+
errorCallBask,
|
|
270
|
+
timer,
|
|
271
|
+
{ getLocale },
|
|
272
|
+
) => {
|
|
273
|
+
geolocation.getCurrentPosition((status: string, r: any) => {
|
|
274
|
+
if (status === 'complete') {
|
|
275
|
+
// console.log('获取定位:', r, status);
|
|
276
|
+
// 获取详细地址
|
|
277
|
+
if (locationAddress && locationAddress !== '') {
|
|
278
|
+
(window as any).AMap.plugin('AMap.Geocoder', () => {
|
|
279
|
+
const geocoder = new (window as any).AMap.Geocoder({});
|
|
280
|
+
geocoder.getAddress(
|
|
281
|
+
{
|
|
282
|
+
lng: r.position.KL || r.position.lng,
|
|
283
|
+
lat: r.position.kT || r.position.lat,
|
|
284
|
+
noAutofix: false,
|
|
285
|
+
},
|
|
286
|
+
(status: string, result: any) => {
|
|
287
|
+
let address = '获取详细地址失败';
|
|
288
|
+
if (status === 'complete' && result.regeocode) {
|
|
289
|
+
address = result.regeocode.formattedAddress;
|
|
290
|
+
} else {
|
|
291
|
+
address = `${address}: ${result}`;
|
|
292
|
+
}
|
|
293
|
+
switch (type) {
|
|
294
|
+
case 'WGS84': // 大地坐标系 法律规定不支持转换
|
|
295
|
+
// pointTranslate(convertor, r.point, successCallBack, errorCallBask, r.address);
|
|
296
|
+
successCallBack([r.position, address]);
|
|
297
|
+
break;
|
|
298
|
+
case 'GCJ02': // 火星坐标系
|
|
299
|
+
successCallBack([r.position, address]);
|
|
300
|
+
break;
|
|
301
|
+
default:
|
|
302
|
+
// 默认百度坐标系
|
|
303
|
+
pointTranslate(
|
|
304
|
+
r.position,
|
|
305
|
+
successCallBack,
|
|
306
|
+
errorCallBask,
|
|
307
|
+
address,
|
|
308
|
+
{ getLocale },
|
|
309
|
+
);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
switch (type) {
|
|
317
|
+
case 'WGS84': // 大地坐标系 法律规定不支持转换
|
|
318
|
+
// pointTranslate(convertor, r.point, successCallBack, errorCallBask, r.address);
|
|
319
|
+
successCallBack([r.position, '']);
|
|
320
|
+
break;
|
|
321
|
+
case 'GCJ02': // 火星坐标系
|
|
322
|
+
successCallBack([r.position, '']);
|
|
323
|
+
break;
|
|
324
|
+
default:
|
|
325
|
+
// 默认百度坐标系
|
|
326
|
+
pointTranslate(r.position, successCallBack, errorCallBask, '', {
|
|
327
|
+
getLocale,
|
|
328
|
+
});
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
// console.log('高德定位失败:', r);
|
|
334
|
+
clearInterval(timer);
|
|
335
|
+
errorCallBask(`${getLocale('sysAction.location.fail')}:${status}${r}`);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const getGaoDeLocation: commonFunc = (
|
|
341
|
+
always,
|
|
342
|
+
type,
|
|
343
|
+
locationAddress,
|
|
344
|
+
successCallBack,
|
|
345
|
+
errorCallBask,
|
|
346
|
+
{ getLocale },
|
|
347
|
+
) => {
|
|
348
|
+
(window as any).AMap.plugin('AMap.Geolocation', () => {
|
|
349
|
+
const geolocation = new (window as any).AMap.Geolocation({
|
|
350
|
+
timeout: 10000,
|
|
351
|
+
enableHighAccuracy: true,
|
|
352
|
+
});
|
|
353
|
+
// const convertor = new (window as any).AMap.Convertor();
|
|
354
|
+
getCurrentLocation(
|
|
355
|
+
geolocation,
|
|
356
|
+
locationAddress,
|
|
357
|
+
type,
|
|
358
|
+
successCallBack,
|
|
359
|
+
errorCallBask,
|
|
360
|
+
null,
|
|
361
|
+
{ getLocale },
|
|
362
|
+
);
|
|
363
|
+
if (always && always !== '') {
|
|
364
|
+
// 持续定位 默认定位60次,间隔15秒
|
|
365
|
+
let times = 0;
|
|
366
|
+
const timer = setInterval(() => {
|
|
367
|
+
if (times > 60) {
|
|
368
|
+
clearInterval(timer);
|
|
369
|
+
}
|
|
370
|
+
times += 1;
|
|
371
|
+
getCurrentLocation(
|
|
372
|
+
geolocation,
|
|
373
|
+
locationAddress,
|
|
374
|
+
type,
|
|
375
|
+
successCallBack,
|
|
376
|
+
errorCallBask,
|
|
377
|
+
timer,
|
|
378
|
+
{ getLocale },
|
|
379
|
+
);
|
|
380
|
+
}, 15000);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// export default {
|
|
386
|
+
// initBaiduMap,
|
|
387
|
+
// getBaiduLocation,
|
|
388
|
+
// };
|
|
389
|
+
interface LocalLocationParams {
|
|
390
|
+
mapKey: string;
|
|
391
|
+
mapType: string;
|
|
392
|
+
securityKey?: string;
|
|
393
|
+
locationAlways: boolean;
|
|
394
|
+
locationOutputType: string;
|
|
395
|
+
locationAddress: boolean;
|
|
396
|
+
}
|
|
397
|
+
interface LocalLocation {
|
|
398
|
+
longitude: string;
|
|
399
|
+
latitude: string;
|
|
400
|
+
locationInformation: string;
|
|
401
|
+
}
|
|
402
|
+
export const getLocalLocation = ({
|
|
403
|
+
securityKey = '',
|
|
404
|
+
mapType,
|
|
405
|
+
mapKey,
|
|
406
|
+
locationAlways,
|
|
407
|
+
locationOutputType,
|
|
408
|
+
locationAddress,
|
|
409
|
+
}: LocalLocationParams) => {
|
|
410
|
+
return new Promise<LocalLocation>((resolve, reject) => {
|
|
411
|
+
if (mapType === 'baidu') {
|
|
412
|
+
initBaiduMap(mapKey)
|
|
413
|
+
.then(() => {
|
|
414
|
+
// 百度地图注册成功
|
|
415
|
+
getBaiduLocation(
|
|
416
|
+
locationAlways,
|
|
417
|
+
locationOutputType,
|
|
418
|
+
locationAddress,
|
|
419
|
+
(opt: any) => {
|
|
420
|
+
// console.log('定位成功:', opt);
|
|
421
|
+
const [position] = opt;
|
|
422
|
+
const localLocation = {
|
|
423
|
+
longitude: position.lng,
|
|
424
|
+
latitude: position.lat,
|
|
425
|
+
locationInformation: '',
|
|
426
|
+
};
|
|
427
|
+
if (locationAddress) {
|
|
428
|
+
const address = opt[1];
|
|
429
|
+
localLocation.locationInformation = address;
|
|
430
|
+
}
|
|
431
|
+
resolve(localLocation);
|
|
432
|
+
},
|
|
433
|
+
(err: any) => {
|
|
434
|
+
reject(err);
|
|
435
|
+
// console.log('定位失败:', err);
|
|
436
|
+
},
|
|
437
|
+
// FIXME: getLocale
|
|
438
|
+
{ getLocale: (a: any) => a },
|
|
439
|
+
);
|
|
440
|
+
})
|
|
441
|
+
.catch((err) => {
|
|
442
|
+
reject(err);
|
|
443
|
+
// 地图注册失败
|
|
444
|
+
// console.log('---注册失败:', err);
|
|
445
|
+
});
|
|
446
|
+
} else {
|
|
447
|
+
initGaoDeMap(securityKey, mapKey)
|
|
448
|
+
.then(() => {
|
|
449
|
+
getGaoDeLocation(
|
|
450
|
+
locationAlways,
|
|
451
|
+
locationOutputType,
|
|
452
|
+
locationAddress,
|
|
453
|
+
(opt: any) => {
|
|
454
|
+
// console.log('定位成功:', opt);
|
|
455
|
+
const [position] = opt;
|
|
456
|
+
const localLocation = {
|
|
457
|
+
longitude: position.KL || position.lng,
|
|
458
|
+
latitude: position.kT || position.lat,
|
|
459
|
+
locationInformation: '',
|
|
460
|
+
};
|
|
461
|
+
if (locationAddress) {
|
|
462
|
+
const address = opt[1];
|
|
463
|
+
localLocation.locationInformation = address;
|
|
464
|
+
}
|
|
465
|
+
resolve(localLocation);
|
|
466
|
+
},
|
|
467
|
+
(err: any) => {
|
|
468
|
+
// console.log('定位失败:', err);
|
|
469
|
+
reject(err);
|
|
470
|
+
},
|
|
471
|
+
// FIXME: getLocale
|
|
472
|
+
{ getLocale: (a: any) => a },
|
|
473
|
+
);
|
|
474
|
+
})
|
|
475
|
+
.catch((err) => {
|
|
476
|
+
reject(err);
|
|
477
|
+
// 地图注册失败
|
|
478
|
+
// console.log('---注册失败:', err);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ModalManagerHooks } from '@lingxiteam/types';
|
|
3
3
|
import copy from 'copy-to-clipboard';
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import PopoverUtils from './popoverUtils';
|
|
5
6
|
import api from './service/commonFetch';
|
|
6
|
-
// import PopoverUtils from '@/utils/popoverUtils';
|
|
7
7
|
// import { Interceptor } from "../request";
|
|
8
8
|
// import type { InterceptorType } from "../request";
|
|
9
9
|
// import browserCompatible from './browserCompatible';
|
|
@@ -50,7 +50,7 @@ class LcdpBaseApi {
|
|
|
50
50
|
/**
|
|
51
51
|
* 收集页面popover引用
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
PopoverManager: PopoverUtils.getInstance(),
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
// 调用接口合集
|