@etsoo/smarterp-core 1.1.2 → 1.1.4
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/lib/cjs/PublicApi.js +27 -2
- package/lib/cjs/components/index.d.ts +1 -0
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/components/public/AddressTiplist.d.ts +12 -0
- package/lib/cjs/components/public/AddressTiplist.js +24 -0
- package/lib/cjs/rq/public/PlaceQueryRQ.d.ts +19 -1
- package/lib/cjs/rq/public/PlaceQueryRQ.js +13 -0
- package/lib/mjs/PublicApi.js +27 -2
- package/lib/mjs/components/index.d.ts +1 -0
- package/lib/mjs/components/index.js +1 -0
- package/lib/mjs/components/public/AddressTiplist.d.ts +12 -0
- package/lib/mjs/components/public/AddressTiplist.js +21 -0
- package/lib/mjs/rq/public/PlaceQueryRQ.d.ts +19 -1
- package/lib/mjs/rq/public/PlaceQueryRQ.js +13 -0
- package/package.json +6 -6
- package/src/PublicApi.ts +41 -3
- package/src/components/index.ts +1 -0
- package/src/components/public/AddressTiplist.tsx +56 -0
- package/src/rq/public/PlaceQueryRQ.ts +22 -1
package/lib/cjs/PublicApi.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PublicApi = void 0;
|
|
4
4
|
const shared_1 = require("@etsoo/shared");
|
|
5
|
+
const PlaceQueryRQ_1 = require("./rq/public/PlaceQueryRQ");
|
|
5
6
|
const appscript_1 = require("@etsoo/appscript");
|
|
6
7
|
const unitPrefix = "unit";
|
|
7
8
|
/**
|
|
@@ -154,8 +155,32 @@ class PublicApi extends appscript_1.BaseApi {
|
|
|
154
155
|
* @param payload Payload
|
|
155
156
|
* @returns Result
|
|
156
157
|
*/
|
|
157
|
-
queryPlace(rq, payload) {
|
|
158
|
-
|
|
158
|
+
async queryPlace(rq, payload) {
|
|
159
|
+
// For simplified Chinese, or CN region, use China map
|
|
160
|
+
if (rq.provider === null &&
|
|
161
|
+
(rq.language === "zh-Hans" ||
|
|
162
|
+
rq.language === "zh-CN" ||
|
|
163
|
+
rq.region === "CN")) {
|
|
164
|
+
// Amap first
|
|
165
|
+
const amapRq = {
|
|
166
|
+
...rq,
|
|
167
|
+
region: undefined,
|
|
168
|
+
provider: PlaceQueryRQ_1.ApiProvider.Amap
|
|
169
|
+
};
|
|
170
|
+
const amapResult = await this.api.post("Public/QueryPlace", amapRq, payload);
|
|
171
|
+
if (amapResult && amapResult.length > 0)
|
|
172
|
+
return amapResult;
|
|
173
|
+
// Baidu
|
|
174
|
+
const baiduRq = {
|
|
175
|
+
...rq,
|
|
176
|
+
region: undefined,
|
|
177
|
+
provider: PlaceQueryRQ_1.ApiProvider.Baidu
|
|
178
|
+
};
|
|
179
|
+
const baiduResult = await this.api.post("Public/QueryPlace", baiduRq, payload);
|
|
180
|
+
if (baiduResult && baiduResult.length > 0)
|
|
181
|
+
return baiduResult;
|
|
182
|
+
}
|
|
183
|
+
return await this.api.post("Public/QueryPlace", rq, payload);
|
|
159
184
|
}
|
|
160
185
|
/**
|
|
161
186
|
* Read member invitation
|
|
@@ -9,6 +9,7 @@ export * from "./app/UserRoleList";
|
|
|
9
9
|
export * from "./org/ButtonApiServices";
|
|
10
10
|
export * from "./org/OrgSwitchPopover";
|
|
11
11
|
export * from "./org/OrgTiplist";
|
|
12
|
+
export * from "./public/AddressTiplist";
|
|
12
13
|
export * from "./public/ButtonCultures";
|
|
13
14
|
export * from "./public/ButtonCurrencies";
|
|
14
15
|
export * from "./public/ButtonRadioRegions";
|
|
@@ -29,6 +29,7 @@ __exportStar(require("./org/ButtonApiServices"), exports);
|
|
|
29
29
|
__exportStar(require("./org/OrgSwitchPopover"), exports);
|
|
30
30
|
__exportStar(require("./org/OrgTiplist"), exports);
|
|
31
31
|
// public
|
|
32
|
+
__exportStar(require("./public/AddressTiplist"), exports);
|
|
32
33
|
__exportStar(require("./public/ButtonCultures"), exports);
|
|
33
34
|
__exportStar(require("./public/ButtonCurrencies"), exports);
|
|
34
35
|
__exportStar(require("./public/ButtonRadioRegions"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TiplistProps } from "@etsoo/materialui";
|
|
2
|
+
import { PlaceCommon } from "../../dto/public/PlaceCommon";
|
|
3
|
+
/**
|
|
4
|
+
* Address tiplist component props
|
|
5
|
+
*/
|
|
6
|
+
export type AddressTiplistProps = Omit<TiplistProps<PlaceCommon, "placeId">, "idField" | "loadData" | "name" | "label"> & Partial<Pick<TiplistProps<PlaceCommon, "placeId">, "name" | "label">> & {};
|
|
7
|
+
/**
|
|
8
|
+
* Address tiplist component
|
|
9
|
+
* @param props Properties
|
|
10
|
+
* @returns Component
|
|
11
|
+
*/
|
|
12
|
+
export declare function AddressTiplist(props: AddressTiplistProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddressTiplist = AddressTiplist;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const materialui_1 = require("@etsoo/materialui");
|
|
6
|
+
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
7
|
+
/**
|
|
8
|
+
* Address tiplist component
|
|
9
|
+
* @param props Properties
|
|
10
|
+
* @returns Component
|
|
11
|
+
*/
|
|
12
|
+
function AddressTiplist(props) {
|
|
13
|
+
// App
|
|
14
|
+
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
15
|
+
// Destruct
|
|
16
|
+
const { fullWidth = true, getOptionLabel = (option) => `${option.name} - ${option.formattedAddress} (${option.postalCode})`, name = "address", label = app.get("address") ?? "Address", maxItems = 10, ...rest } = props;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(materialui_1.Tiplist, { fullWidth: fullWidth, getOptionLabel: getOptionLabel, idField: "placeId", label: label, loadData: (keyword, _, maxItems) => keyword
|
|
18
|
+
? app.core.publicApi.queryPlace({
|
|
19
|
+
language: app.culture,
|
|
20
|
+
query: keyword,
|
|
21
|
+
pageSize: maxItems
|
|
22
|
+
}, { showLoading: false })
|
|
23
|
+
: Promise.resolve([]), name: name, ...rest }));
|
|
24
|
+
}
|
|
@@ -12,8 +12,21 @@ export declare enum ApiOutput {
|
|
|
12
12
|
* 接口供应商
|
|
13
13
|
*/
|
|
14
14
|
export declare enum ApiProvider {
|
|
15
|
+
/**
|
|
16
|
+
* Google Maps
|
|
17
|
+
* 谷歌地图
|
|
18
|
+
*/
|
|
15
19
|
Google = 0,
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Baidu Maps
|
|
22
|
+
* 百度地图
|
|
23
|
+
*/
|
|
24
|
+
Baidu = 1,
|
|
25
|
+
/**
|
|
26
|
+
* Amap
|
|
27
|
+
* 高德地图
|
|
28
|
+
*/
|
|
29
|
+
Amap = 2
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Place query request
|
|
@@ -55,4 +68,9 @@ export type PlaceQueryRQ = {
|
|
|
55
68
|
* 方圆距离,单位为米
|
|
56
69
|
*/
|
|
57
70
|
radius?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Page size, 1 - 20 suggested
|
|
73
|
+
* 每页记录数,建议1-20
|
|
74
|
+
*/
|
|
75
|
+
pageSize?: number;
|
|
58
76
|
};
|
|
@@ -16,6 +16,19 @@ var ApiOutput;
|
|
|
16
16
|
*/
|
|
17
17
|
var ApiProvider;
|
|
18
18
|
(function (ApiProvider) {
|
|
19
|
+
/**
|
|
20
|
+
* Google Maps
|
|
21
|
+
* 谷歌地图
|
|
22
|
+
*/
|
|
19
23
|
ApiProvider[ApiProvider["Google"] = 0] = "Google";
|
|
24
|
+
/**
|
|
25
|
+
* Baidu Maps
|
|
26
|
+
* 百度地图
|
|
27
|
+
*/
|
|
20
28
|
ApiProvider[ApiProvider["Baidu"] = 1] = "Baidu";
|
|
29
|
+
/**
|
|
30
|
+
* Amap
|
|
31
|
+
* 高德地图
|
|
32
|
+
*/
|
|
33
|
+
ApiProvider[ApiProvider["Amap"] = 2] = "Amap";
|
|
21
34
|
})(ApiProvider || (exports.ApiProvider = ApiProvider = {}));
|
package/lib/mjs/PublicApi.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from "@etsoo/shared";
|
|
2
|
+
import { ApiProvider } from "./rq/public/PlaceQueryRQ";
|
|
2
3
|
import { BaseApi, ProductUnit, RepeatOption } from "@etsoo/appscript";
|
|
3
4
|
const unitPrefix = "unit";
|
|
4
5
|
/**
|
|
@@ -151,8 +152,32 @@ export class PublicApi extends BaseApi {
|
|
|
151
152
|
* @param payload Payload
|
|
152
153
|
* @returns Result
|
|
153
154
|
*/
|
|
154
|
-
queryPlace(rq, payload) {
|
|
155
|
-
|
|
155
|
+
async queryPlace(rq, payload) {
|
|
156
|
+
// For simplified Chinese, or CN region, use China map
|
|
157
|
+
if (rq.provider === null &&
|
|
158
|
+
(rq.language === "zh-Hans" ||
|
|
159
|
+
rq.language === "zh-CN" ||
|
|
160
|
+
rq.region === "CN")) {
|
|
161
|
+
// Amap first
|
|
162
|
+
const amapRq = {
|
|
163
|
+
...rq,
|
|
164
|
+
region: undefined,
|
|
165
|
+
provider: ApiProvider.Amap
|
|
166
|
+
};
|
|
167
|
+
const amapResult = await this.api.post("Public/QueryPlace", amapRq, payload);
|
|
168
|
+
if (amapResult && amapResult.length > 0)
|
|
169
|
+
return amapResult;
|
|
170
|
+
// Baidu
|
|
171
|
+
const baiduRq = {
|
|
172
|
+
...rq,
|
|
173
|
+
region: undefined,
|
|
174
|
+
provider: ApiProvider.Baidu
|
|
175
|
+
};
|
|
176
|
+
const baiduResult = await this.api.post("Public/QueryPlace", baiduRq, payload);
|
|
177
|
+
if (baiduResult && baiduResult.length > 0)
|
|
178
|
+
return baiduResult;
|
|
179
|
+
}
|
|
180
|
+
return await this.api.post("Public/QueryPlace", rq, payload);
|
|
156
181
|
}
|
|
157
182
|
/**
|
|
158
183
|
* Read member invitation
|
|
@@ -9,6 +9,7 @@ export * from "./app/UserRoleList";
|
|
|
9
9
|
export * from "./org/ButtonApiServices";
|
|
10
10
|
export * from "./org/OrgSwitchPopover";
|
|
11
11
|
export * from "./org/OrgTiplist";
|
|
12
|
+
export * from "./public/AddressTiplist";
|
|
12
13
|
export * from "./public/ButtonCultures";
|
|
13
14
|
export * from "./public/ButtonCurrencies";
|
|
14
15
|
export * from "./public/ButtonRadioRegions";
|
|
@@ -13,6 +13,7 @@ export * from "./org/ButtonApiServices";
|
|
|
13
13
|
export * from "./org/OrgSwitchPopover";
|
|
14
14
|
export * from "./org/OrgTiplist";
|
|
15
15
|
// public
|
|
16
|
+
export * from "./public/AddressTiplist";
|
|
16
17
|
export * from "./public/ButtonCultures";
|
|
17
18
|
export * from "./public/ButtonCurrencies";
|
|
18
19
|
export * from "./public/ButtonRadioRegions";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TiplistProps } from "@etsoo/materialui";
|
|
2
|
+
import { PlaceCommon } from "../../dto/public/PlaceCommon";
|
|
3
|
+
/**
|
|
4
|
+
* Address tiplist component props
|
|
5
|
+
*/
|
|
6
|
+
export type AddressTiplistProps = Omit<TiplistProps<PlaceCommon, "placeId">, "idField" | "loadData" | "name" | "label"> & Partial<Pick<TiplistProps<PlaceCommon, "placeId">, "name" | "label">> & {};
|
|
7
|
+
/**
|
|
8
|
+
* Address tiplist component
|
|
9
|
+
* @param props Properties
|
|
10
|
+
* @returns Component
|
|
11
|
+
*/
|
|
12
|
+
export declare function AddressTiplist(props: AddressTiplistProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tiplist } from "@etsoo/materialui";
|
|
3
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
4
|
+
/**
|
|
5
|
+
* Address tiplist component
|
|
6
|
+
* @param props Properties
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function AddressTiplist(props) {
|
|
10
|
+
// App
|
|
11
|
+
const app = useRequiredAppContext();
|
|
12
|
+
// Destruct
|
|
13
|
+
const { fullWidth = true, getOptionLabel = (option) => `${option.name} - ${option.formattedAddress} (${option.postalCode})`, name = "address", label = app.get("address") ?? "Address", maxItems = 10, ...rest } = props;
|
|
14
|
+
return (_jsx(Tiplist, { fullWidth: fullWidth, getOptionLabel: getOptionLabel, idField: "placeId", label: label, loadData: (keyword, _, maxItems) => keyword
|
|
15
|
+
? app.core.publicApi.queryPlace({
|
|
16
|
+
language: app.culture,
|
|
17
|
+
query: keyword,
|
|
18
|
+
pageSize: maxItems
|
|
19
|
+
}, { showLoading: false })
|
|
20
|
+
: Promise.resolve([]), name: name, ...rest }));
|
|
21
|
+
}
|
|
@@ -12,8 +12,21 @@ export declare enum ApiOutput {
|
|
|
12
12
|
* 接口供应商
|
|
13
13
|
*/
|
|
14
14
|
export declare enum ApiProvider {
|
|
15
|
+
/**
|
|
16
|
+
* Google Maps
|
|
17
|
+
* 谷歌地图
|
|
18
|
+
*/
|
|
15
19
|
Google = 0,
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Baidu Maps
|
|
22
|
+
* 百度地图
|
|
23
|
+
*/
|
|
24
|
+
Baidu = 1,
|
|
25
|
+
/**
|
|
26
|
+
* Amap
|
|
27
|
+
* 高德地图
|
|
28
|
+
*/
|
|
29
|
+
Amap = 2
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Place query request
|
|
@@ -55,4 +68,9 @@ export type PlaceQueryRQ = {
|
|
|
55
68
|
* 方圆距离,单位为米
|
|
56
69
|
*/
|
|
57
70
|
radius?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Page size, 1 - 20 suggested
|
|
73
|
+
* 每页记录数,建议1-20
|
|
74
|
+
*/
|
|
75
|
+
pageSize?: number;
|
|
58
76
|
};
|
|
@@ -13,6 +13,19 @@ export var ApiOutput;
|
|
|
13
13
|
*/
|
|
14
14
|
export var ApiProvider;
|
|
15
15
|
(function (ApiProvider) {
|
|
16
|
+
/**
|
|
17
|
+
* Google Maps
|
|
18
|
+
* 谷歌地图
|
|
19
|
+
*/
|
|
16
20
|
ApiProvider[ApiProvider["Google"] = 0] = "Google";
|
|
21
|
+
/**
|
|
22
|
+
* Baidu Maps
|
|
23
|
+
* 百度地图
|
|
24
|
+
*/
|
|
17
25
|
ApiProvider[ApiProvider["Baidu"] = 1] = "Baidu";
|
|
26
|
+
/**
|
|
27
|
+
* Amap
|
|
28
|
+
* 高德地图
|
|
29
|
+
*/
|
|
30
|
+
ApiProvider[ApiProvider["Amap"] = 2] = "Amap";
|
|
18
31
|
})(ApiProvider || (ApiProvider = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/smarterp-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "TypeScript APIs for SmartERP Core",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"@vitejs/plugin-react": "^5.1.2",
|
|
51
51
|
"jsdom": "^27.3.0",
|
|
52
52
|
"typescript": "^5.9.3",
|
|
53
|
-
"vitest": "^4.0.
|
|
53
|
+
"vitest": "^4.0.16"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@etsoo/appscript": "^1.6.49",
|
|
57
|
-
"@etsoo/materialui": "^1.5.
|
|
58
|
-
"@etsoo/react": "^1.8.
|
|
57
|
+
"@etsoo/materialui": "^1.5.92",
|
|
58
|
+
"@etsoo/react": "^1.8.65",
|
|
59
59
|
"@etsoo/shared": "^1.2.80",
|
|
60
60
|
"@etsoo/toolpad": "^1.0.42",
|
|
61
61
|
"@mui/material": "^7.3.6",
|
|
62
62
|
"ajv": "^8.17.1",
|
|
63
63
|
"ajv-formats": "^3.0.1",
|
|
64
|
-
"react": "^19.2.
|
|
65
|
-
"react-dom": "^19.2.
|
|
64
|
+
"react": "^19.2.3",
|
|
65
|
+
"react-dom": "^19.2.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/PublicApi.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { PinyinRQ } from "./rq/public/PinyinRQ";
|
|
|
4
4
|
import { CreateBarcodeRQ } from "./rq/public/CreateBarcodeRQ";
|
|
5
5
|
import { CurrencyItem } from "./dto/public/CurrencyItem";
|
|
6
6
|
import { RegionData } from "./dto/public/RegionData";
|
|
7
|
-
import { PlaceQueryRQ } from "./rq/public/PlaceQueryRQ";
|
|
7
|
+
import { ApiProvider, PlaceQueryRQ } from "./rq/public/PlaceQueryRQ";
|
|
8
8
|
import { PlaceCommon } from "./dto/public/PlaceCommon";
|
|
9
9
|
import {
|
|
10
10
|
BaseApi,
|
|
@@ -192,8 +192,46 @@ export class PublicApi extends BaseApi {
|
|
|
192
192
|
* @param payload Payload
|
|
193
193
|
* @returns Result
|
|
194
194
|
*/
|
|
195
|
-
queryPlace(rq: PlaceQueryRQ, payload?: IApiPayload<PlaceCommon[]>) {
|
|
196
|
-
|
|
195
|
+
async queryPlace(rq: PlaceQueryRQ, payload?: IApiPayload<PlaceCommon[]>) {
|
|
196
|
+
// For simplified Chinese, or CN region, use China map
|
|
197
|
+
if (
|
|
198
|
+
rq.provider === null &&
|
|
199
|
+
(rq.language === "zh-Hans" ||
|
|
200
|
+
rq.language === "zh-CN" ||
|
|
201
|
+
rq.region === "CN")
|
|
202
|
+
) {
|
|
203
|
+
// Amap first
|
|
204
|
+
const amapRq: PlaceQueryRQ = {
|
|
205
|
+
...rq,
|
|
206
|
+
region: undefined,
|
|
207
|
+
provider: ApiProvider.Amap
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const amapResult = await this.api.post(
|
|
211
|
+
"Public/QueryPlace",
|
|
212
|
+
amapRq,
|
|
213
|
+
payload
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
if (amapResult && amapResult.length > 0) return amapResult;
|
|
217
|
+
|
|
218
|
+
// Baidu
|
|
219
|
+
const baiduRq: PlaceQueryRQ = {
|
|
220
|
+
...rq,
|
|
221
|
+
region: undefined,
|
|
222
|
+
provider: ApiProvider.Baidu
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const baiduResult = await this.api.post(
|
|
226
|
+
"Public/QueryPlace",
|
|
227
|
+
baiduRq,
|
|
228
|
+
payload
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
if (baiduResult && baiduResult.length > 0) return baiduResult;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return await this.api.post("Public/QueryPlace", rq, payload);
|
|
197
235
|
}
|
|
198
236
|
|
|
199
237
|
/**
|
package/src/components/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./org/OrgSwitchPopover";
|
|
|
16
16
|
export * from "./org/OrgTiplist";
|
|
17
17
|
|
|
18
18
|
// public
|
|
19
|
+
export * from "./public/AddressTiplist";
|
|
19
20
|
export * from "./public/ButtonCultures";
|
|
20
21
|
export * from "./public/ButtonCurrencies";
|
|
21
22
|
export * from "./public/ButtonRadioRegions";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Tiplist, TiplistProps } from "@etsoo/materialui";
|
|
2
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
3
|
+
import { PlaceCommon } from "../../dto/public/PlaceCommon";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Address tiplist component props
|
|
7
|
+
*/
|
|
8
|
+
export type AddressTiplistProps = Omit<
|
|
9
|
+
TiplistProps<PlaceCommon, "placeId">,
|
|
10
|
+
"idField" | "loadData" | "name" | "label"
|
|
11
|
+
> &
|
|
12
|
+
Partial<Pick<TiplistProps<PlaceCommon, "placeId">, "name" | "label">> & {};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Address tiplist component
|
|
16
|
+
* @param props Properties
|
|
17
|
+
* @returns Component
|
|
18
|
+
*/
|
|
19
|
+
export function AddressTiplist(props: AddressTiplistProps) {
|
|
20
|
+
// App
|
|
21
|
+
const app = useRequiredAppContext();
|
|
22
|
+
|
|
23
|
+
// Destruct
|
|
24
|
+
const {
|
|
25
|
+
fullWidth = true,
|
|
26
|
+
getOptionLabel = (option) =>
|
|
27
|
+
`${option.name} - ${option.formattedAddress} (${option.postalCode})`,
|
|
28
|
+
name = "address",
|
|
29
|
+
label = app.get("address") ?? "Address",
|
|
30
|
+
maxItems = 10,
|
|
31
|
+
...rest
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Tiplist<PlaceCommon>
|
|
36
|
+
fullWidth={fullWidth}
|
|
37
|
+
getOptionLabel={getOptionLabel}
|
|
38
|
+
idField="placeId"
|
|
39
|
+
label={label}
|
|
40
|
+
loadData={(keyword, _, maxItems) =>
|
|
41
|
+
keyword
|
|
42
|
+
? app.core.publicApi.queryPlace(
|
|
43
|
+
{
|
|
44
|
+
language: app.culture,
|
|
45
|
+
query: keyword,
|
|
46
|
+
pageSize: maxItems
|
|
47
|
+
},
|
|
48
|
+
{ showLoading: false }
|
|
49
|
+
)
|
|
50
|
+
: Promise.resolve([])
|
|
51
|
+
}
|
|
52
|
+
name={name}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -14,8 +14,23 @@ export enum ApiOutput {
|
|
|
14
14
|
* 接口供应商
|
|
15
15
|
*/
|
|
16
16
|
export enum ApiProvider {
|
|
17
|
+
/**
|
|
18
|
+
* Google Maps
|
|
19
|
+
* 谷歌地图
|
|
20
|
+
*/
|
|
17
21
|
Google,
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Baidu Maps
|
|
25
|
+
* 百度地图
|
|
26
|
+
*/
|
|
27
|
+
Baidu,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Amap
|
|
31
|
+
* 高德地图
|
|
32
|
+
*/
|
|
33
|
+
Amap
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
/**
|
|
@@ -64,4 +79,10 @@ export type PlaceQueryRQ = {
|
|
|
64
79
|
* 方圆距离,单位为米
|
|
65
80
|
*/
|
|
66
81
|
radius?: number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Page size, 1 - 20 suggested
|
|
85
|
+
* 每页记录数,建议1-20
|
|
86
|
+
*/
|
|
87
|
+
pageSize?: number;
|
|
67
88
|
};
|