<!-- Description: 新装设备-保存成功 Author: 李亚光 Date: 2025-02-24 --> <script lang="ts" setup name="H5DeviceAddSuccess"> import AMap from '@/components/map/index.vue' const $route = useRoute() const detailInfo = ref<any>({}) detailInfo.value = JSON.parse($route.query.row as string) // 返回首页 const $router = useRouter() const backHome = () => { $router.replace({ name: 'Home' }) } // 计算地图区域高度 const scrollHeight = ref(0) const calcHeight = () => { // 公共头部高度40 // 边距安全 30 // 底部按钮 const exportBtnHeight = document.getElementById('export-btn')?.offsetHeight || 0 // 头部 const searchHeaderHeight = document.getElementById('base-info')?.offsetHeight || 0 const headerHeight = document.getElementById('header')?.offsetHeight || 0 scrollHeight.value = window.innerHeight - 40 - exportBtnHeight - searchHeaderHeight - 30 - headerHeight - 15 // console.log('scrollHeight', scrollHeight.value) } window.addEventListener('resize', () => { calcHeight() }) function resizePage() { setTimeout(() => { const resize = new Event('resize') window.dispatchEvent(resize) }) } const showMap = ref(false) onMounted(() => { calcHeight() resizePage() setTimeout(() => { showMap.value = true }, 500); }) const mapRef = ref() const completeMap = () => { mapRef.value.map.setCenter([detailInfo.value.lng, detailInfo.value.lat]) mapRef.value.map.setZoom(16) mapRef.value.addMarker({ position: [detailInfo.value.lng, detailInfo.value.lat], content: '', label: '', }) resizePage() } const resetMap = () => { mapRef.value.map.setCenter([detailInfo.value.lng, detailInfo.value.lat]) mapRef.value.map.setZoom(16) resizePage() } // 继续新装设备 const addDevice = () => { $router.replace({ name: 'DeviceAdd' }) } </script> <template> <div class="container"> <div id="header" class="header"> <div class="icon"></div> <div class="tips">设备信息添加成功</div> </div> <div class="info-container"> <!-- 基本信息 --> <div id="base-info" class="search-info"> <div class="cell"> <div class="title">产品</div> <!-- <div class="value">{{ detailInfo.productName }}</div> --> <div class="value"><van-text-ellipsis :rows="1" :content="detailInfo.productName" expand-text="展开" collapse-text="收起" /> </div> </div> <div class="cell"> <div class="title">设备编号</div> <div class="value">{{ detailInfo.devcode }}</div> </div> <div class="cell"> <div class="title">安装位置</div> <div class="value">{{ detailInfo.tagNumber }}</div> </div> <div class="cell"> <div class="title">详细位置</div> <!-- <div class="value">{{ detailInfo.position }} </div> --> <div class="value"><van-text-ellipsis :rows="1" :content="detailInfo.position" expand-text="展开" collapse-text="收起" /> </div> </div> <div class="cell"> <div class="title">安装日期</div> <div class="value">{{ detailInfo.installDate }}</div> </div> <div class="cell"> <div class="title">操作人</div> <div class="value">{{ detailInfo.userName }}</div> </div> </div> <div class="map" :style="{ width: '96%', margin: '0 auto', height: scrollHeight + 'px', marginTop: '5px', borderRadius: '10px', overflow: 'hidden', position: 'relative' }"> <a-map v-if="showMap" ref="mapRef" style="width: 100%;height: 100%;" @complete="completeMap" :zoom="15" /> <div class="reset-icon" @click="resetMap"> <div class="icon"></div> </div> </div> </div> <div id="export-btn" class="export-btn"> <el-button type="primary" style="width: 48%;" @click="backHome">返回首页</el-button> <el-button type="primary" style="width: 48%;" @click="addDevice">继续新装</el-button> </div> </div> </template> <style lang="scss" scoped> .header { display: flex; justify-content: center; align-items: center; margin-top: 10px; .icon { background: url("@/assets/images/success.png") no-repeat center center / cover; width: 45px; height: 45px; } .tips { font-size: 20px; font-weight: 400; margin-left: 10px; } } .reset-icon { width: 40px; height: 40px; position: absolute; z-index: 2; bottom: 10px; right: 16px; border-radius: 6px; display: flex; justify-content: center; flex-direction: column; align-items: center; box-shadow: 0px 0px 12px rgba(0, 0, 0, .12); background-color: #fff; .icon { width: 30px; height: 30px; background: url('@/assets/icons/icon-location_current.svg') no-repeat center center / cover; } } .info-container { width: 100%; height: calc(100vh - 40px); overflow: hidden; color: #444; .search-info { background-color: #fff; width: 96%; margin: 0 auto; margin-top: 1vh; border-radius: 6px; padding: 4px; padding-top: 0.8rem; padding-bottom: 0.8rem; padding-left: 0.8rem; font-size: 1.1rem; .cell { display: flex; justify-content: space-between; padding-top: 6px; padding-bottom: 6px; padding-right: 14px; align-items: center; .value { color: #888; width: 80%; text-align: right; font-size: 1rem; vertical-align: middle; // display: flex; // flex-direction: column; // justify-content: center; display: flex; align-items: center; justify-content: flex-end; .location { display: inline-block; width: 22px; height: 22px; background: url('@/assets/icons/icon-location.svg') no-repeat center center / cover; vertical-align: middle; margin-left: 8px; } } .title { width: 20%; white-space: nowrap; font-weight: 500; } // .title, // .value { // white-space: nowrap; // overflow: hidden; // text-overflow: ellipsis; // } } } .search-result { background-color: #fff; width: 96%; margin: 0 auto; margin-top: 1vh; border-radius: 6px; padding: 4px; padding-left: 0.6rem; .title { display: flex; font-size: 1.1rem; .symbol { width: 4px; height: 22px; background-color: #0d76d4; border-radius: 4px; margin-right: 8px; } } .top-border { border-top: 1px solid #e4e7ed; // margin-top: 8px; } .result-item { .cell { display: flex; justify-content: space-between; padding-top: 6px; padding-bottom: 6px; padding-right: 18px; align-items: center; .value { color: #888; width: 80%; text-align: right; font-size: 1rem; vertical-align: middle; // display: flex; // flex-direction: column; // justify-content: center; display: flex; align-items: center; justify-content: flex-end; } .title { width: 20%; white-space: nowrap; } } } } } .export-btn { position: absolute; width: 96%; bottom: 1vh; display: flex; justify-content: space-around; // margin: 0 auto; left: 50%; transform: translateX(-50%); ::v-deep(.el-button) { font-size: 18px; } } </style>