@gm-pc/business 1.25.0 → 1.25.1-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gm-pc/business",
3
- "version": "1.25.0",
3
+ "version": "1.25.1-beta.1",
4
4
  "description": "观麦科技业务组件库",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-pc#readme",
@@ -28,8 +28,8 @@
28
28
  "dependencies": {
29
29
  "@gm-common/hooks": "^2.10.0",
30
30
  "@gm-common/tool": "^2.10.0",
31
- "@gm-pc/react": "^1.25.0",
32
- "@gm-pc/table-x": "^1.25.0"
31
+ "@gm-pc/react": "^1.25.1-beta.1",
32
+ "@gm-pc/table-x": "^1.25.1-beta.1"
33
33
  },
34
- "gitHead": "807f3c85b9645ce15d6ee00818c04aea936a5880"
34
+ "gitHead": "5dd0c3577285d50f79d819477ca636ab6839d276"
35
35
  }
@@ -1,30 +1,31 @@
1
- import React, { FC } from 'react'
2
- import { DataAddressNameProps } from './types'
3
- import { MapId_City, MapId_District, MapId_Street } from 'gm_api/src/enterprise/pc'
4
-
5
- const DataAddressName: FC<DataAddressNameProps> = ({
6
- address: { city_id, district_id, street_id },
7
- }) => {
8
- return (
9
- <>
10
- {city_id && (
11
- <>
12
- <MapId_City
13
- id={city_id}
14
- getName={(item) => item.local_name}
15
- getResponseData={(response) => response.cities}
16
- />
17
- /
18
- </>
19
- )}
20
- {district_id && (
21
- <>
22
- <MapId_District id={district_id} getName={(item) => item.local_name} />/
23
- </>
24
- )}
25
- {street_id && <MapId_Street id={street_id} getName={(item) => item.local_name} />}
26
- </>
27
- )
28
- }
29
-
30
- export default DataAddressName
1
+ import React, { FC } from 'react'
2
+ import { DataAddressNameProps } from './types'
3
+ import { MapId_City, MapId_District, MapId_Street } from 'gm_api/src/enterprise/pc'
4
+
5
+ const DataAddressName: FC<DataAddressNameProps> = ({
6
+ address: { city_id, district_id, street_id },
7
+ }) => {
8
+ return (
9
+ <>
10
+ {city_id && (
11
+ <>
12
+ <MapId_City
13
+ id={city_id}
14
+ getName={(item) => item.local_name}
15
+ getResponseData={(response) => response.cities}
16
+ />
17
+ {(district_id || street_id) && '/'}
18
+ </>
19
+ )}
20
+ {district_id && (
21
+ <>
22
+ <MapId_District id={district_id} getName={(item) => item.local_name} />
23
+ {street_id && '/'}
24
+ </>
25
+ )}
26
+ {street_id && <MapId_Street id={street_id} getName={(item) => item.local_name} />}
27
+ </>
28
+ )
29
+ }
30
+
31
+ export default DataAddressName
@@ -1,81 +1,85 @@
1
- import _ from 'lodash'
2
- import { ListCity, ListDistrict, ListStreet, District } from 'gm_api/src/enterprise'
3
- import { CityItem, DistrictItem } from './types'
4
-
5
- async function fetchCityDistrictStreetTree(params: {
6
- city_ids: string[]
7
- }): Promise<CityItem[]> {
8
- const { city_ids } = params
9
-
10
- const [cityRes, districtRes] = await Promise.all([
11
- ListCity({
12
- city_ids,
13
- }),
14
- ListDistrict({
15
- city_ids,
16
- }),
17
- ])
18
-
19
- const cityDistrictTree: CityItem[] = []
20
- const cityMap: { [key: string]: CityItem } = {}
21
- const districtMap: { [key: string]: DistrictItem } = {}
22
-
23
- _.each(cityRes.response.cities, (city) => {
24
- const cityItem = {
25
- value: city.city_id,
26
- text: city.local_name,
27
- // children: [], // 不一定有下一级
28
- original: city,
29
- }
30
- cityDistrictTree.push(cityItem)
31
- cityMap[city.city_id] = cityItem
32
- })
33
-
34
- _.each(districtRes.response.districts, (district) => {
35
- const districtItem = {
36
- original: district,
37
- value: district.district_id,
38
- text: district.local_name,
39
- // children: [], // 不一定有下一级
40
- }
41
- districtMap[district.district_id] = districtItem
42
-
43
- const p = cityMap[district.city_id]
44
- if (p) {
45
- if (Array.isArray(p.children)) {
46
- p.children.push(districtItem)
47
- } else {
48
- p.children = [districtItem]
49
- }
50
- }
51
- })
52
-
53
- const district_ids = _.map(
54
- districtRes.response.districts,
55
- (district: District) => district.district_id
56
- )
57
- const streetRes = await ListStreet({
58
- district_ids,
59
- })
60
-
61
- _.each(streetRes.response.streets, (street) => {
62
- const streetItem = {
63
- original: street,
64
- value: street.street_id,
65
- text: street.local_name,
66
- }
67
-
68
- const p = districtMap[street.district_id]
69
- if (p) {
70
- if (Array.isArray(p.children)) {
71
- p.children.push(streetItem)
72
- } else {
73
- p.children = [streetItem]
74
- }
75
- }
76
- })
77
-
78
- return cityDistrictTree
79
- }
80
-
81
- export { fetchCityDistrictStreetTree }
1
+ import _ from 'lodash'
2
+ import { ListCity, ListDistrict, ListStreet, District } from 'gm_api/src/enterprise'
3
+ import { CityItem, DistrictItem } from './types'
4
+
5
+ async function fetchCityDistrictStreetTree(params: {
6
+ city_ids: string[]
7
+ }): Promise<CityItem[]> {
8
+ const { city_ids } = params
9
+
10
+ const [cityRes, districtRes] = await Promise.all([
11
+ ListCity({
12
+ city_ids,
13
+ }),
14
+ ListDistrict({
15
+ city_ids,
16
+ }),
17
+ ])
18
+
19
+ const cityDistrictTree: CityItem[] = []
20
+ const cityMap: { [key: string]: CityItem } = {}
21
+ const districtMap: { [key: string]: DistrictItem } = {}
22
+
23
+ _.each(cityRes.response.cities, (city) => {
24
+ const cityItem = {
25
+ value: city.city_id,
26
+ text: city.local_name,
27
+ // children: [], // 不一定有下一级
28
+ original: city,
29
+ }
30
+ cityDistrictTree.push(cityItem)
31
+ cityMap[city.city_id] = cityItem
32
+ })
33
+
34
+ _.each(districtRes.response.districts, (district) => {
35
+ const districtItem = {
36
+ original: district,
37
+ value: district.district_id,
38
+ text: district.local_name,
39
+ // children: [], // 不一定有下一级
40
+ }
41
+ districtMap[district.district_id] = districtItem
42
+
43
+ const p = cityMap[district.city_id]
44
+ if (p) {
45
+ if (Array.isArray(p.children)) {
46
+ p.children.push(districtItem)
47
+ } else {
48
+ p.children = [districtItem]
49
+ }
50
+ }
51
+ })
52
+
53
+ const district_ids = _.map(
54
+ districtRes.response.districts,
55
+ (district: District) => district.district_id
56
+ )
57
+
58
+ // 空数组会报错阻塞后续执行,后端不改,所以判断一下
59
+ if (!district_ids.length) return cityDistrictTree
60
+
61
+ const streetRes = await ListStreet({
62
+ district_ids,
63
+ })
64
+
65
+ _.each(streetRes.response.streets, (street) => {
66
+ const streetItem = {
67
+ original: street,
68
+ value: street.street_id,
69
+ text: street.local_name,
70
+ }
71
+
72
+ const p = districtMap[street.district_id]
73
+ if (p) {
74
+ if (Array.isArray(p.children)) {
75
+ p.children.push(streetItem)
76
+ } else {
77
+ p.children = [streetItem]
78
+ }
79
+ }
80
+ })
81
+
82
+ return cityDistrictTree
83
+ }
84
+
85
+ export { fetchCityDistrictStreetTree }