af-mobile-client-vue3 1.2.4 → 1.2.5
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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { FormInstance } from 'vant'
|
|
3
3
|
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
4
4
|
import { addOrModifyEntity } from '@af-mobile-client-vue3/services/api/common'
|
|
5
|
+
import XOlMap from '@af-mobile-client-vue3/components/data/XOlMap/index.vue'
|
|
5
6
|
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
6
7
|
import {
|
|
7
8
|
showFailToast,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
CellGroup as VanCellGroup,
|
|
11
12
|
Form as VanForm,
|
|
12
13
|
} from 'vant'
|
|
13
|
-
import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
|
|
14
|
+
import { computed, defineEmits, defineProps, nextTick, onBeforeMount, reactive, ref, watch } from 'vue'
|
|
14
15
|
|
|
15
16
|
interface FormItem {
|
|
16
17
|
addOrEdit: string
|
|
@@ -74,6 +75,37 @@ const resolvedSubmitButton = computed(() => {
|
|
|
74
75
|
return props.submitButton
|
|
75
76
|
})
|
|
76
77
|
|
|
78
|
+
const previewMapRef = ref(null)
|
|
79
|
+
// 假设你只预览第一个 addressSearch 类型的经纬度
|
|
80
|
+
const previewLonLatKey = computed(() => {
|
|
81
|
+
const item = realJsonData.value.find(i => i.type === 'addressSearch')
|
|
82
|
+
return item ? `${item.model}_lon_lat` : null
|
|
83
|
+
})
|
|
84
|
+
const previewMapPoint = computed(() => {
|
|
85
|
+
const val = form.value[previewLonLatKey.value]
|
|
86
|
+
if (val && typeof val === 'string' && val.includes(',')) {
|
|
87
|
+
const [lon, lat] = val.split(',').map(Number)
|
|
88
|
+
if (!Number.isNaN(lon) && !Number.isNaN(lat)) {
|
|
89
|
+
return [lon, lat]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// 地图初始化逻辑
|
|
96
|
+
const previewMapInited = ref(false)
|
|
97
|
+
watch(previewMapPoint, async (val) => {
|
|
98
|
+
await nextTick()
|
|
99
|
+
if (val && previewMapRef.value) {
|
|
100
|
+
if (!previewMapInited.value) {
|
|
101
|
+
await previewMapRef.value.init({ center: val, zoom: 16, isPreview: true })
|
|
102
|
+
previewMapInited.value = true
|
|
103
|
+
}
|
|
104
|
+
previewMapRef.value.setCenter(val, true)
|
|
105
|
+
previewMapRef.value.updateLocationMarker(val)
|
|
106
|
+
}
|
|
107
|
+
}, { immediate: true })
|
|
108
|
+
|
|
77
109
|
onBeforeMount(() => {
|
|
78
110
|
if (!props.configName && props.groupFormItems) {
|
|
79
111
|
if (props.groupFormItems && props.groupFormItems.tableName) {
|
|
@@ -266,6 +298,15 @@ defineExpose({ init, form, formGroupName, validate })
|
|
|
266
298
|
@set-form="setForm"
|
|
267
299
|
/>
|
|
268
300
|
</VanCellGroup>
|
|
301
|
+
<!-- 地图预览,统一放在表单项下方,只在有经纬度时显示 -->
|
|
302
|
+
<div v-if="previewMapPoint" style="height: 200px; margin-top: 12px; position: relative;">
|
|
303
|
+
<XOlMap
|
|
304
|
+
ref="previewMapRef"
|
|
305
|
+
:center="previewMapPoint"
|
|
306
|
+
:style="{ height: '100%' }"
|
|
307
|
+
/>
|
|
308
|
+
<div class="map-mask" />
|
|
309
|
+
</div>
|
|
269
310
|
</div>
|
|
270
311
|
<div v-if="resolvedSubmitButton && props.mode !== '预览'" class="form-footer-fixed">
|
|
271
312
|
<VanButton class="action-btn" round block type="primary" native-type="submit">
|
|
@@ -298,4 +339,14 @@ defineExpose({ init, form, formGroupName, validate })
|
|
|
298
339
|
border-radius: 10px;
|
|
299
340
|
}
|
|
300
341
|
}
|
|
342
|
+
.map-mask {
|
|
343
|
+
position: absolute;
|
|
344
|
+
left: 0;
|
|
345
|
+
top: 0;
|
|
346
|
+
width: 100%;
|
|
347
|
+
height: 100%;
|
|
348
|
+
pointer-events: all;
|
|
349
|
+
background: transparent;
|
|
350
|
+
z-index: 10;
|
|
351
|
+
}
|
|
301
352
|
</style>
|
|
@@ -48,6 +48,8 @@ const mapParams = ref<InitParams>({})
|
|
|
48
48
|
|
|
49
49
|
/** 地图容器引用 */
|
|
50
50
|
const mapRef = ref<HTMLDivElement>()
|
|
51
|
+
/** 是否为预览模式 */
|
|
52
|
+
const preview = ref(false)
|
|
51
53
|
/** 地图实例 */
|
|
52
54
|
let map: Map | null = null
|
|
53
55
|
/** 当前底图类型 */
|
|
@@ -104,13 +106,17 @@ function createLocationLayer(): VectorLayer<VectorSource> {
|
|
|
104
106
|
* 更新位置图标
|
|
105
107
|
*/
|
|
106
108
|
function updateLocationMarker(center: [number, number]): void {
|
|
107
|
-
if (!map
|
|
109
|
+
if (!map) {
|
|
108
110
|
return
|
|
109
|
-
|
|
111
|
+
}
|
|
112
|
+
if (!locationLayer) {
|
|
113
|
+
locationLayer = createLocationLayer()
|
|
114
|
+
map?.addLayer(locationLayer)
|
|
115
|
+
}
|
|
110
116
|
const source = locationLayer.getSource()
|
|
111
|
-
if (!source)
|
|
117
|
+
if (!source) {
|
|
112
118
|
return
|
|
113
|
-
|
|
119
|
+
}
|
|
114
120
|
// 清除现有图标
|
|
115
121
|
source.clear()
|
|
116
122
|
|
|
@@ -330,8 +336,10 @@ function init(params: InitParams = {}): Promise<void> {
|
|
|
330
336
|
zoom = 10,
|
|
331
337
|
maxZoom = 18,
|
|
332
338
|
minZoom = 4,
|
|
339
|
+
isPreview = false,
|
|
333
340
|
} = params
|
|
334
|
-
|
|
341
|
+
// 设置预览模式
|
|
342
|
+
preview.value = isPreview
|
|
335
343
|
try {
|
|
336
344
|
getConfigByName('webConfig', (res) => {
|
|
337
345
|
const tianDiTuKey = res.tianDiTuKey || 'c16876b28898637c0a1a68b3fa410504'
|
|
@@ -1031,6 +1039,7 @@ function handleToggleTrackLayer(track: TrackData): void {
|
|
|
1031
1039
|
|
|
1032
1040
|
// 暴露方法给父组件
|
|
1033
1041
|
defineExpose({
|
|
1042
|
+
updateLocationMarker,
|
|
1034
1043
|
init,
|
|
1035
1044
|
getMap,
|
|
1036
1045
|
setCenter,
|
|
@@ -1071,8 +1080,7 @@ onUnmounted(() => {
|
|
|
1071
1080
|
<template>
|
|
1072
1081
|
<div class="map-wrapper">
|
|
1073
1082
|
<div ref="mapRef" class="ol-map" />
|
|
1074
|
-
|
|
1075
|
-
<div class="location-button">
|
|
1083
|
+
<div v-if="!preview" class="location-button">
|
|
1076
1084
|
<Button size="small" square @click="handleLocation">
|
|
1077
1085
|
<img
|
|
1078
1086
|
src="@af-mobile-client-vue3/assets/img/component/location.png"
|
|
@@ -1183,7 +1191,7 @@ onUnmounted(() => {
|
|
|
1183
1191
|
.ol-map {
|
|
1184
1192
|
width: 100%;
|
|
1185
1193
|
height: 100%;
|
|
1186
|
-
min-height:
|
|
1194
|
+
min-height: 200px;
|
|
1187
1195
|
touch-action: none;
|
|
1188
1196
|
|
|
1189
1197
|
&:active {
|
|
@@ -14,7 +14,7 @@ export interface PhoneLocationStatus {
|
|
|
14
14
|
status: string
|
|
15
15
|
|
|
16
16
|
data: {
|
|
17
|
-
location: string
|
|
17
|
+
location: string
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -30,6 +30,8 @@ export interface InitParams {
|
|
|
30
30
|
minZoom?: number
|
|
31
31
|
/** 是否开启地址选择模式 */
|
|
32
32
|
enableLocationPicker?: boolean
|
|
33
|
+
/** 是否为预览模式(预览时不显示定位按钮) */
|
|
34
|
+
isPreview?: boolean
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/** 点位数据接口 */
|