diff --git a/src/GeolocationEditor/mb-editor/location-editor.js b/src/GeolocationEditor/mb-editor/location-editor.js index 16f6f4fb..ed424f50 100644 --- a/src/GeolocationEditor/mb-editor/location-editor.js +++ b/src/GeolocationEditor/mb-editor/location-editor.js @@ -6,6 +6,7 @@ import List from '../../List'; import MobileFullScreenPage from '../../MobileFullScreenPage'; import { getLocale } from '../../lang'; import ObjectUtils from '../../utils/object-utils'; +import { DISTRICT_COMPAT_MAP } from 'dtable-utils'; const { Header, Body } = MobileFullScreenPage; @@ -17,7 +18,11 @@ const LocationEditor = ({ onToggle, onCommit, }) => { - let initValue = [oldValue?.province || '', oldValue?.city || '', oldValue?.district || '']; + let district = oldValue?.district || ''; + if (DISTRICT_COMPAT_MAP[district]) { + district = DISTRICT_COMPAT_MAP[district]; + } + let initValue = [oldValue?.province || '', oldValue?.city || '', district]; if (isShowDetails) { initValue.push(oldValue?.detail || ''); } @@ -31,7 +36,7 @@ const LocationEditor = ({ locations.current = data; setLoading(false); }); - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const onValueChange = useCallback((newValue) => { diff --git a/src/GeolocationEditor/pc-editor/location-editor.js b/src/GeolocationEditor/pc-editor/location-editor.js index 8cf634ae..0f086131 100644 --- a/src/GeolocationEditor/pc-editor/location-editor.js +++ b/src/GeolocationEditor/pc-editor/location-editor.js @@ -8,6 +8,7 @@ import { KeyCodes } from '../../constants'; import Loading from '../../Loading'; import parseGeolocation from './parse-geolocation'; import { getLocale } from '../../lang'; +import { DISTRICT_COMPAT_MAP } from 'dtable-utils'; const propTypes = { isShowDetails: PropTypes.bool, @@ -26,7 +27,7 @@ class LocationEditor extends Component { this.locations = {}; this.state = { isShowSelector: false, - location: `${this.value.province || ''}${this.value.city || ''}${this.value.district || ''}`, + location: `${this.value.province || ''}${this.value.city || ''}${DISTRICT_COMPAT_MAP[this.value.district] || this.value.district || ''}`, selectedProvince: null, selectedCity: null, selectedCounty: null, @@ -73,8 +74,13 @@ class LocationEditor extends Component { return { selectedProvince, selectedCity: null, selectedCounty: null, selectedItem: 'city' }; } + let districtName = value.district || ''; + if (DISTRICT_COMPAT_MAP[districtName]) { + districtName = DISTRICT_COMPAT_MAP[districtName]; + } + let selectedCounty = selectedCity.children.find((county) => { - return value.district && value.district.length > 0 && county.name.includes(value.district); + return districtName && districtName.length > 0 && county.name.includes(districtName); }); if (!selectedCounty) { @@ -267,23 +273,23 @@ class LocationEditor extends Component { )} {this.props.isShowDetails && -