|
|
@@ -55,6 +55,17 @@
|
|
|
<ActivityIndicator :size="64" />
|
|
|
</FlexCol>
|
|
|
|
|
|
+ <NButton
|
|
|
+ :innerStyle="{
|
|
|
+ position: 'absolute',
|
|
|
+ bottom: '20rpx',
|
|
|
+ left: '20rpx',
|
|
|
+ zIndex: 100,
|
|
|
+ backgroundColor: '#ffffff',
|
|
|
+ }"
|
|
|
+ icon="search"
|
|
|
+ @click="showSearch"
|
|
|
+ />
|
|
|
<SimpleDropDownPicker
|
|
|
v-if="!isEmptyRegion"
|
|
|
class="light-map-region-picker"
|
|
|
@@ -74,6 +85,17 @@
|
|
|
icon="navigation"
|
|
|
@click="emit('getCurrentLonlat')"
|
|
|
/>
|
|
|
+ <Dialog
|
|
|
+ v-model:show="searchDialogShow"
|
|
|
+ title="搜索村社"
|
|
|
+ showCancel
|
|
|
+ :maskClosable="false"
|
|
|
+ :onConfirm="searchConfirm"
|
|
|
+ >
|
|
|
+ <template #content>
|
|
|
+ <Field v-model="searchKeyword" placeholder="请输入村社名称进行搜索" />
|
|
|
+ </template>
|
|
|
+ </Dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -93,12 +115,23 @@ import Icon from '@/components/basic/Icon.vue';
|
|
|
import ActivityIndicator from '@/components/basic/ActivityIndicator.vue';
|
|
|
import type { MapMarker } from '@/types/Map';
|
|
|
import MapApi from '@/api/map/MapApi';
|
|
|
+import Dialog from '@/components/dialog/Dialog.vue';
|
|
|
+import Field from '@/components/form/Field.vue';
|
|
|
+import { toast } from '@/components/dialog/CommonRoot';
|
|
|
|
|
|
const instance = getCurrentInstance();
|
|
|
const mapCtx = uni.createMapContext('prevMap', instance);
|
|
|
+
|
|
|
const selectedRegion = ref<number>();
|
|
|
const nextNeedAutoFocus = ref(false);
|
|
|
const villageData = new Map<number, VillageListItem>();
|
|
|
+
|
|
|
+const ready = ref(false);
|
|
|
+const hasResItems = ref(false);
|
|
|
+
|
|
|
+const searchDialogShow = ref(false);
|
|
|
+const searchKeyword = ref('');
|
|
|
+
|
|
|
const emit = defineEmits([
|
|
|
'getCurrentLonlat',
|
|
|
'update:isLightMode',
|
|
|
@@ -107,8 +140,6 @@ const emit = defineEmits([
|
|
|
'regionChanged',
|
|
|
'lightVillage',
|
|
|
]);
|
|
|
-const ready = ref(false);
|
|
|
-const hasResItems = ref(false);
|
|
|
|
|
|
const props = defineProps<{
|
|
|
lonlat?: { longitude: number, latitude: number } | undefined;
|
|
|
@@ -134,7 +165,12 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
|
|
|
if (!selectedRegion.value)
|
|
|
return [];
|
|
|
await waitTimeOut(200);
|
|
|
- const res = (await LightVillageApi.getVillageList(undefined, selectedRegion.value, undefined, 1, 1000)).list;
|
|
|
+ const res = (await LightVillageApi.getVillageList({
|
|
|
+ region: selectedRegion.value,
|
|
|
+ keyword: searchKeyword.value.trim() || undefined,
|
|
|
+ page: 1,
|
|
|
+ pageSize: 1000
|
|
|
+ })).list;
|
|
|
hasResItems.value = res.length > 0;
|
|
|
const list = res.map((p, i) => {
|
|
|
villageData.set(p.id, p);
|
|
|
@@ -193,7 +229,7 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
|
|
|
|
|
|
if (nextNeedAutoFocus.value) {
|
|
|
|
|
|
- if (res.length > 20) {
|
|
|
+ if (res.length > 0) {
|
|
|
setTimeout(() => {
|
|
|
mapCtx.includePoints({
|
|
|
points: list.map(p => {
|
|
|
@@ -263,6 +299,19 @@ function setCurrentRegion(regionName: string) {
|
|
|
mapLoader.reload();
|
|
|
}
|
|
|
|
|
|
+function showSearch() {
|
|
|
+ searchDialogShow.value = true;
|
|
|
+ searchKeyword.value = '';
|
|
|
+}
|
|
|
+async function searchConfirm() {
|
|
|
+ searchDialogShow.value = false;
|
|
|
+ if (searchKeyword.value.trim() === '') {
|
|
|
+ toast('请输入搜索关键词');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await mapLoader.reload();
|
|
|
+}
|
|
|
+
|
|
|
watch(() => props.city, async (newVal) => {
|
|
|
await regionLoader.reload();
|
|
|
setCurrentRegion(newVal || '');
|