From 1731e29ef418bb3b89cd6d514988893f8a870bf7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 31 Jan 2026 17:13:05 +0800
Subject: [PATCH] feat: 地形
---
/dev/null | 569 -----------------------------------------------
applications/task-work-order/env/.env | 2
applications/task-work-order/src/utils/cesium/publicCesium.js | 80 ++---
applications/task-work-order/src/router/views/index.js | 25 --
applications/task-work-order/env/.env.development | 2
applications/task-work-order/src/main.js | 2
6 files changed, 36 insertions(+), 644 deletions(-)
diff --git a/applications/task-work-order/env/.env b/applications/task-work-order/env/.env
index b91a161..5894dcc 100644
--- a/applications/task-work-order/env/.env
+++ b/applications/task-work-order/env/.env
@@ -21,3 +21,5 @@
# 预览地址 previewURL
VITE_APP_PREVIEW_URL=http://192.168.1.204:8012
+
+VITE_APP_TERRAIN_URL=https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_c_uas/
diff --git a/applications/task-work-order/env/.env.development b/applications/task-work-order/env/.env.development
index ed8d14a..15492be 100644
--- a/applications/task-work-order/env/.env.development
+++ b/applications/task-work-order/env/.env.development
@@ -31,8 +31,6 @@
# 航线文件地址
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/minio/cloud-bucket
-# 图片存放地址
-VITE_APP_TERRAIN_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_terrain/
# 行政区划存放地址
VITE_APP_REGION_URL = https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_region
# 算法仓库图片地址
diff --git a/applications/task-work-order/src/components/PlaybackVideo/PlaybackVideo.vue b/applications/task-work-order/src/components/PlaybackVideo/PlaybackVideo.vue
deleted file mode 100644
index 9cabfa2..0000000
--- a/applications/task-work-order/src/components/PlaybackVideo/PlaybackVideo.vue
+++ /dev/null
@@ -1,141 +0,0 @@
-<template>
- <el-dialog
- class="work-dialog-video playback-dialog"
- v-model="isShow"
- append-to-body
- :close-on-click-modal="false"
- :destroy-on-close="true"
- :show-close="false"
- >
- <template #header>
- <div class="title">视频回放</div>
-
- <div class="close" @click="isShow = false"></div>
- </template>
-
- <div v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.7)">
- <div class="mpa-container">
- <MapContainer ref="mapContainerEle" />
- </div>
-
- <div class="video-player-container">
- <VideoPlayer ref="videoPlayerEle" />
- </div>
-
- <div v-show="photoEleShow" class="photo-list-container">
- <PhotoList ref="photoListEle" />
- </div>
- </div>
- </el-dialog>
-</template>
-
-<script setup>
-import PhotoList from '@/components/PlaybackVideo/components/PhotoList.vue'
-import VideoPlayer from '@/components/PlaybackVideo/components/VideoPlayer.vue'
-import MapContainer from '@/components/PlaybackVideo/components/MapContainer.vue'
-import { getWaylinejobLiveRecordPage, findFlightLogInfoByJobId, aiImagesPage } from '@/api/playback/'
-const isShow = defineModel('show', {
- type: Boolean,
- default: true,
-})
-
-const detailData = defineModel('detailData', {
- type: Object,
- default: () => ({}),
-})
-
-const props = defineProps(['detailsData'])
-
-const loading = ref(true)
-const photoEleShow = ref(false)
-
-const positionData = ref(null)
-const attachmentData = ref(null)
-
-const mapContainerEle = ref(null)
-const videoPlayerEle = ref(null)
-const photoListEle = ref(null)
-
-const jobId = inject('jobId')
-
-provide('videoData', detailData)
-provide('positionData', positionData)
-provide('attachmentData', attachmentData)
-
-watch(isShow, newVal => {
- if (newVal) {
- init()
- }
-})
-
-const init = async () => {
- loading.value = true
- await nextTick()
-
- Promise.all([
- findFlightLogInfoByJobId({ jobId: jobId.value }),
- aiImagesPage({ size: 30, current: 1 }, { size: 30, current: 1, wayLineJobId: jobId.value, resultTypes: [0, 2] }),
- ]).then(([positionDetails, attachmentDetails]) => {
- let arr = positionDetails.data.data.filter(item => {
- return item.create_time >= detailData.value.start_time && item.create_time <= detailData.value.end_time
- })
-
- positionData.value = arr.sort((a, b) => a.create_time - b.create_time)
-
- attachmentData.value =
- attachmentDetails.data.data.records
- .filter(item => {
- return (
- item.metadata.createdTime >= detailData.value.start_time &&
- item.metadata.createdTime <= detailData.value.end_time
- )
- })
- .map(item => ({
- ...item,
- metadata: {
- ...item.metadata,
- createdTime: item.metadata.createdTime,
- },
- })) || []
-
- photoEleShow.value = attachmentData.value.length > 0
-
- videoPlayerEle.value.init(detailData.value, attachmentData.value)
- mapContainerEle.value.init(positionData.value, props.detailsData, props.taskData)
- photoListEle.value.init(detailData.value, attachmentData.value)
-
- loading.value = false
- })
-}
-</script>
-
-<style lang="scss" scoped>
-.mpa-container {
- position: absolute;
- top: 58px;
- left: 10px;
- width: 338px;
- height: 206px;
- z-index: 1;
- border-radius: 8px;
- overflow: hidden;
-}
-
-.video-player-container {
- width: 100%;
- height: 100%;
-}
-
-.photo-list-container {
- position: absolute;
- top: 58px;
- right: 10px;
- width: 338px;
- height: calc(100% - 116px);
- z-index: 1;
- border-radius: 8px;
- background: rgba(2, 2, 2, 0.6);
- overflow: hidden;
- backdrop-filter: blur(13.7px);
-}
-</style>
diff --git a/applications/task-work-order/src/components/PlaybackVideo/components/MapContainer.vue b/applications/task-work-order/src/components/PlaybackVideo/components/MapContainer.vue
deleted file mode 100644
index 621394c..0000000
--- a/applications/task-work-order/src/components/PlaybackVideo/components/MapContainer.vue
+++ /dev/null
@@ -1,227 +0,0 @@
-<template>
- <div class="work-cesium map-box" id="map">
- <PlanarRouteLineList
- :curRouteLineData="curRouteLineData"
- @routeLineListClick="routeLineListClick"
- :customClass="'airline-list'"
- />
- </div>
-</template>
-
-<script setup>
-import _ from 'lodash'
-import { useRouteLine } from '@/hooks/useRouteLine/useRouteLine.js'
-// import { getWaylineSplitApi } from '@/api/routePlan'
-
-import PlanarRouteLineList from '@/components/PlanarRouteLineList/PlanarRouteLineList.vue'
-
-import { flyVisual } from '@ztzf/utils'
-
-import * as Cesium from 'cesium'
-import { PublicCesium } from '@/utils/cesium/publicCesium'
-import { ArrowLineMaterialProperty } from '@/utils/cesium/Material'
-import aircraftGltf from '@/assets/gltf/aircraft.gltf'
-import EventBus from '@/utils/eventBus'
-
-// 加载航线hook
-const {
- curRouteLineData,
- routeLineListClick,
- initViewer,
- renderPreviewLine,
- removePreviewLine,
- resetCurRouteLineData,
- renderDroneRouteLine,
-} = useRouteLine()
-
-let viewer = null
-let publicCesiumInstance = null
-
-const initMap = () => {
- publicCesiumInstance = new PublicCesium({
- dom: 'map',
- terrain: true,
- flatMode: false,
- layerMode: 4,
- contour: true,
- })
-
- viewer = publicCesiumInstance.getViewer()
- viewer.scene.globe.depthTestAgainstTerrain = true
-
- initViewer(viewer)
-}
-
-// 绘制线和飞行
-const drawLine = async detailsData => {
- detailsData.way_lines.forEach(async item => {
- // if (item.is_split) {
- // getWaylineSplitApi(item.workspace_id).then(async res => {
- // // 大航线拆分
- // let result = res.data.data
- // littleFileLine.value = result.wayline_file_list
- // let bigPolygonList = await renderPreviewLine(
- // import.meta.env.VITE_APP_AIRLINE_URL + result.object_key,
- // result.wayline_type,
- // result.wayline_file_list
- // )
- // emit('wayLineFileSelected', bigPolygonList)
- // })
- // } else {
- await renderPreviewLine(item.url, item.wayline_type)
- // }
- })
-}
-
-let arrowLineMaterialProperty = new ArrowLineMaterialProperty({
- color: new Cesium.Color(128 / 255, 215 / 255, 255 / 255, 1),
- directionColor: new Cesium.Color(1, 1, 1, 1),
- outlineColor: new Cesium.Color(1, 1, 1, 1),
- outlineWidth: 0,
- speed: 5,
-})
-
-let droneEntity = null
-let planarRouteEntity = null
-let sampledPosition
-
-const initPlanarRoute = data => {
- flyVisual({ positionsData: data.map(i => [i.longitude, i.latitude, i.height]), viewer, multiple: 3.2 })
-
- if (planarRouteEntity) {
- viewer.entities.remove(planarRouteEntity)
- planarRouteEntity = null
- }
-
- planarRouteEntity = viewer.entities.add({
- polyline: {
- width: 4,
- positions: data.map(i =>
- Cesium.Cartesian3.fromDegrees(Number(i.longitude), Number(i.latitude), Number(i.height))
- ),
- material: arrowLineMaterialProperty,
- clampToGround: false,
- },
- })
-}
-
-let startJulian = null
-let endJulian = null
-
-const init = async (positionData, detailsData) => {
- await nextTick()
-
- if (!viewer) initMap()
-
- resetCurRouteLineData()
- removePreviewLine()
-
- drawLine(detailsData)
-
- // initPlanarRoute(positionData)
-
- // sampledPosition = new Cesium.SampledPositionProperty()
- // positionData.forEach(item => {
- // const time = toJulianDate(item.create_time)
- // const pos = Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude, item.height)
- // sampledPosition.addSample(time, pos)
- // })
-
- // // 3️⃣ 设置 Clock
- // startJulian = toJulianDate(positionData[0].create_time)
- // endJulian = toJulianDate(positionData[positionData.length - 1].create_time)
- // viewer.clock.startTime = startJulian.clone()
- // viewer.clock.stopTime = endJulian.clone()
- // viewer.clock.currentTime = startJulian.clone()
- // viewer.clock.multiplier = 1
- // viewer.clock.shouldAnimate = false
- // viewer.clock.clockRange = Cesium.ClockRange.CLAMPED
-
- // if (droneEntity) {
- // viewer.entities.remove(droneEntity)
- // droneEntity = null
- // }
-
- // droneEntity = viewer.entities.add({
- // availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({ start: startJulian, stop: endJulian })]),
- // position: sampledPosition,
- // model: {
- // uri: aircraftGltf, //注意entitits.add方式加载gltf文件时,这里是uri,不是url,并且这种方式只能加载.glb格式的文件
- // scale: 1, //缩放比例
- // minimumPixelSize: 64, //最小像素大小,可以避免太小看不见
- // maximumScale: 128,
- // },
- // })
-}
-
-// ========== 播放/暂停/倍速/重播 控制 ==========
-const mapAnimationPlay = () => {
- if (!viewer) return
- viewer.clock.shouldAnimate = true
-}
-
-const mapAnimationPause = () => {
- if (!viewer) return
- viewer.clock.shouldAnimate = false
-}
-
-const mapAnimationSetSpeed = speed => {
- if (!viewer) return
- viewer.clock.multiplier = speed
-}
-
-const mapAnimationReplay = () => {
- if (!viewer) return
- viewer.clock.currentTime = startJulian.clone()
- viewer.clock.shouldAnimate = true
-}
-
-// 传入一个时间,跳转到该时间点
-const mapAnimationSetCurrentTime = time => {
- if (!viewer) return
- // 支持传入 Date 或毫秒数
- let julian = toJulianDate(time)
-
- viewer.clock.currentTime = julian
- // 如果希望暂停时也能直接跳过去:强制暂停后更新
- // viewer.clock.shouldAnimate = false
-}
-
-// 转换函数:毫秒 → JulianDate
-function toJulianDate(ms) {
- return Cesium.JulianDate.fromDate(new Date(ms))
-}
-
-onMounted(() => {
- // EventBus.on('mapAnimationPlay', mapAnimationPlay)
- // EventBus.on('mapAnimationPause', mapAnimationPause)
- // EventBus.on('mapAnimationSetSpeed', mapAnimationSetSpeed)
- // EventBus.on('mapAnimationReplay', mapAnimationReplay)
- // EventBus.on('mapAnimationSetCurrentTime', mapAnimationSetCurrentTime)
-})
-
-onBeforeUnmount(() => {
- droneEntity && viewer.entities.remove(droneEntity)
- droneEntity = null
- viewer?.entities?.removeAll()
- publicCesiumInstance?.viewerDestroy()
- publicCesiumInstance = null
- viewer = null
- // EventBus.off('mapAnimationPlay', mapAnimationPlay)
- // EventBus.off('mapAnimationPause', mapAnimationPause)
- // EventBus.off('mapAnimationSetSpeed', mapAnimationSetSpeed)
- // EventBus.off('mapAnimationReplay', mapAnimationReplay)
- // EventBus.off('mapAnimationSetCurrentTime', mapAnimationSetCurrentTime)
-})
-
-defineExpose({
- init,
-})
-</script>
-
-<style lang="scss" scoped>
-.map-box {
- width: 100%;
- height: 100%;
-}
-</style>
diff --git a/applications/task-work-order/src/components/PlaybackVideo/components/PhotoList.vue b/applications/task-work-order/src/components/PlaybackVideo/components/PhotoList.vue
deleted file mode 100644
index 4b1eefc..0000000
--- a/applications/task-work-order/src/components/PlaybackVideo/components/PhotoList.vue
+++ /dev/null
@@ -1,187 +0,0 @@
-<template>
- <div class="photo-container">
- <div class="photo-statistics">
- <div class="label">事件照片</div>
- <div class="num">{{ eventsPhotoArr.length }}</div>
- </div>
- <div class="photo-statistics">
- <div class="label">照片总数</div>
- <div class="num">{{ allPhotoArr.length }}</div>
- </div>
- <div class="list-box">
- <div class="item" v-for="(item, ind) in allPhotoArr" :key="ind">
- <el-image
- style="width: 100%; height: 100%"
- :src="item.smallUrl"
- :preview-src-list="[item.showUrl]"
- fit="cover"
- preview-teleported
- ></el-image>
-
- <div class="bottom-box">
- <div class="time">{{ item.metadata.createdTime }}</div>
-
- <div
- class="status"
- :class="EVENT_STATUS_CLASSES[item.status]"
- v-if="EVENT_STATUS_CLASSES[item.status]"
- >
- {{ EVENT_STATUS_LABELS[item.status] }}
- </div>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script setup>
-import { getShowImg, getSmallImg } from '@/utils/util'
-import { EVENT_STATUS_LABELS, EVENT_STATUS_CLASSES } from '@ztzf/constants'
-
-const eventsPhotoArr = ref([])
-const allPhotoArr = ref([])
-
-const init = async (vData, pData) => {
- await nextTick()
-
- allPhotoArr.value = pData.map(item => ({
- ...item,
- showUrl: getShowImg(item.link),
- smallUrl: getSmallImg(item.link),
- metadata: {
- ...item.metadata,
- createdTime: formatTimeDiff(item.metadata.createdTime, vData.start_time),
- },
- }))
- eventsPhotoArr.value = pData.filter(item => item.resultType === 2) || []
-}
-
-defineExpose({
- init,
-})
-
-function formatTimeDiff(timestamp1, timestamp2) {
- // 计算差值(毫秒)
- const diffMs = Math.abs(timestamp1 - timestamp2)
-
- // 转换为秒
- const totalSeconds = Math.floor(diffMs / 1000)
-
- // 计算小时、分钟、秒
- const hours = Math.floor(totalSeconds / 3600)
- const minutes = Math.floor((totalSeconds % 3600) / 60)
- const seconds = totalSeconds % 60
-
- // 格式化为两位数
- const pad = num => num.toString().padStart(2, '0')
-
- // 根据是否有小时决定格式
- if (hours > 0) {
- return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`
- } else {
- return `${pad(minutes)}:${pad(seconds)}`
- }
-}
-</script>
-
-<style lang="scss" scoped>
-.photo-container {
- padding: 0 16px 16px;
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- color: #fff;
- font-family: Source Han Sans CN, Source Han Sans CN;
- font-weight: 400;
- font-size: 14px;
- font-style: normal;
- text-transform: none;
-
- .photo-statistics {
- display: flex;
- align-items: center;
- justify-content: space-between;
- line-height: 44px;
- border-bottom: 1px solid rgba(255, 255, 255, 0.11);
- padding: 0 30px; // 添加内边距让内容有间距
- box-sizing: border-box; // 确保边框包含在宽度内
- border-radius: 4px; // 添加圆角让边框更明显
- background: rgba(0, 0, 0, 0.3); // 添加背景色让边框更清晰
-
- .num {
- color: #ff974d;
- }
- }
-
- .list-box {
- margin-top: 16px;
- height: 0;
- flex: 1;
- overflow: hidden;
- overflow-y: auto;
-
- .item {
- margin-top: 10px;
- position: relative;
- width: 100%;
- height: 190px;
- background: #ff974d;
- border-radius: 8px 8px 8px 8px;
- overflow: hidden;
-
- &:first-child {
- margin-top: 0;
- }
-
- .bottom-box {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12px;
- position: absolute;
- bottom: 0;
- width: 100%;
- height: 32px;
- width: 305px;
- background: rgba(20, 18, 18, 0.8);
- border-radius: 0 0 8px 8px;
-
- .status {
- padding: 0 8px;
- line-height: 24px;
- border-radius: 4px 4px 4px 4px;
- font-family: Source Han Sans CN, Source Han Sans CN;
- font-weight: 400;
- font-size: 14px;
- color: #ffffff;
- text-align: center;
- font-style: normal;
- text-transform: none;
- }
-
- // 待处理
- .pending {
- background: #ff7411;
- }
- // 待审核
- .reviewed {
- background: #ff472f;
- }
- // 处理中
- .processing {
- background: #ffff61;
- }
- // 已完成
- .done {
- background: #06d957;
- }
- // 已完结
- .ended {
- background: #06d957;
- }
- }
- }
- }
-}
-</style>
diff --git a/applications/task-work-order/src/components/PlaybackVideo/components/VideoPlayer.vue b/applications/task-work-order/src/components/PlaybackVideo/components/VideoPlayer.vue
deleted file mode 100644
index 1e2a700..0000000
--- a/applications/task-work-order/src/components/PlaybackVideo/components/VideoPlayer.vue
+++ /dev/null
@@ -1,170 +0,0 @@
-<template>
- <video ref="videoEle" class="video-js video-container"></video>
-</template>
-
-<script setup>
-// import videoSrc from '@/assets/mp4/DJI_20250917140642_0001_V.mp4'
-import { inputEmits } from 'element-plus'
-import videojs from 'video.js'
-import zhCN from 'video.js/dist/lang/zh-CN.json'
-// 添加中文语言支持
-videojs.addLanguage('zh-CN', zhCN)
-import 'videojs-markers'
-import EventBus from '@/utils/eventBus'
-
-const videoEle = ref(null)
-
-let player = null
-
-const videoData = inject('videoData')
-
-const init = async (vData, pData) => {
- await nextTick()
-
- if (!player) {
- player = videojs(videoEle.value, {
- html5: {
- preload: 'auto', // 可选值:'auto', 'metadata', 'none'
- },
- controls: true, // 启用默认控件
- playbackRates: [0.5, 1, 1.5, 2],
- })
- }
-
- player.src(vData.play_url)
-
- player.on('play', play)
-
- player.on('pause', pause)
-
- player.on('ratechange', ratechange)
-
- player.on('error', error)
-
- player.controlBar.playToggle.on('click', click)
-
- player.on('seeked', seeked)
-
- console.log(pData, vData, 1)
-
- pData.length > 0 &&
- player.markers({
- showTime: false,
- showTooltips: true,
- markerStyle: {
- 'width': '6px',
- 'background-color': 'red',
- },
- markerTip: {
- display: false,
- },
- onMarkerClick: marker => {
- console.log(`点击了标记:${marker.text}`)
- },
- onMarkerReached: marker => {
- console.log(`到达标记:${marker.text}`)
- },
-
- markers: pData.map((item, ind) => {
- let className = 'ended'
-
- switch (item.status) {
- case 0:
- className = 'pending'
- break
-
- case 2:
- className = 'reviewed'
- break
-
- case 3:
- className = 'processing'
- break
-
- case 4:
- className = 'done'
- break
-
- case 5:
- className = 'ended'
- break
-
- default:
- className = 'noneEvent'
- break
- }
-
- return {
- time: getTimestampDiffInSeconds(item.metadata.createdTime, vData.start_time), // 标记时间,单位为秒
- class: className,
- }
- }),
- })
-}
-
-function play() {
- console.log('播放按钮被点击')
- // EventBus.emit('mapAnimationPlay')
-}
-
-function pause() {
- console.log('暂停按钮被点击')
- // EventBus.emit('mapAnimationPause')
-}
-
-function ratechange() {
- console.log('播放速率已改变,当前速率: ' + player.playbackRate())
- // EventBus.emit('mapAnimationSetSpeed', player.playbackRate())
-}
-
-let retryCount = 0
-const maxRetries = 3
-function error() {
- if (player.error().code === 2 && retryCount < maxRetries) {
- retryCount++
- console.log(`尝试重新加载 (${retryCount}/${maxRetries})`)
- setTimeout(() => player.src(player.currentSrc()), 2000)
- }
-}
-
-function click() {
- if (player.hasClass('vjs-ended')) {
- console.log('重播按钮被点击')
- // 执行重播相关操作
- // EventBus.emit('mapAnimationReplay')
- }
-}
-
-function seeked() {
- const time = player.currentTime() * 1000 + videoData.value.videoStartTime
-
- // EventBus.emit('mapAnimationSetCurrentTime', time)
-}
-
-onBeforeUnmount(() => {
- if (player) {
- player.dispose()
- }
-})
-
-defineExpose({
- init,
-})
-
-function getTimestampDiffInSeconds(timestamp1, timestamp2) {
- // 计算两个时间戳的绝对差值(毫秒)
- const diffInMilliseconds = Math.abs(timestamp1 - timestamp2)
-
- // 将毫秒转换为秒
- const diffInSeconds = diffInMilliseconds / 1000
-
- return diffInSeconds
-}
-</script>
-
-<style lang="scss" scoped>
-.video-container {
- width: 100%;
- height: 100%;
-}
-</style>
diff --git a/applications/task-work-order/src/components/map-container/mapContainer.vue b/applications/task-work-order/src/components/map-container/mapContainer.vue
deleted file mode 100644
index c9c6ae3..0000000
--- a/applications/task-work-order/src/components/map-container/mapContainer.vue
+++ /dev/null
@@ -1,172 +0,0 @@
-<!--
- * @Author: shuishen 1109946754@qq.com
- * @Date: 2024-10-25 15:07:51
- * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2025-04-28 11:34:40
- * @FilePath: \drone-command\src\components\map-container\mapContainer.vue
- * @Description:
- *
- * Copyright (c) 2024 by shuishen, All Rights Reserved.
--->
-<template>
- <div class="map-container">
- <div class="viewer-container command-cesium" id="viewer-container">
- <div class="content">
- <slot name="content"></slot>
- </div>
-
- <PlanarRouteLineList
- :curRouteLineData="curRouteLineData"
- @routeLineListClick="routeLineListClick"
- />
- </div>
- </div>
-</template>
-
-<script setup>
-import PlanarRouteLineList from '@/components/PlanarRouteLineList/PlanarRouteLineList.vue';
-
-import * as Cesium from 'cesium';
-import { Cartesian3, Terrain, Viewer } from 'cesium';
-import { PublicCesium } from '@/utils/cesium/publicCesium';
-import ImageTrailMaterial from '@/utils/cesium/ImageTrailMaterial';
-import { flyVisual } from '@ztzf/utils';
-import * as turf from '@turf/turf';
-
-import { nextTick, onBeforeUnmount, onMounted, onUnmounted } from 'vue';
-import { read } from 'xlsx';
-
-import startPng from '@/assets/map_images/Startingpointicon.png';
-import endPng from '@/assets/map_images/EndPointicon.png';
-import rwqfdImg from '@/assets/images/task/arrow-right-blue.png';
-import newNumPoint from '@/assets/images/task/custom-point.png';
-
-import { useRouteLine } from '@/hooks/useRouteLine/useRouteLine.js';
-const viewInstance = shallowRef(null);
-// 加载航线hook
-const { curRouteLineData, routeLineListClick, initViewer, renderPreviewLine } = useRouteLine();
-
-let publicCesiumInstance = null;
-let viewer = null;
-
-const { VITE_APP_BASE } = import.meta.env;
-// import * as Cesium from 'cesium'
-// import 'cesium/Build/Cesium/Widgets/widgets.css'
-const isViewerReady = ref(false);
-const { rowDetails } = defineProps({
- rowDetails: {
- type: Object,
- default: () => ({}),
- },
-});
-
-async function initMap() {
- if (viewer) return;
- publicCesiumInstance = new PublicCesium({ dom: 'viewer-container', layerMode: 4 });
- viewer = publicCesiumInstance.getViewer();
- viewInstance.value = publicCesiumInstance;
- initViewer(viewer);
- isViewerReady.value = true;
-}
-
-/**
- * 初始化标注添加
- * @param type 类型
- * @param data 数据
- */
-const initAddEntity = (type, data) => {
- watch(
- () => isViewerReady.value,
- ready => {
- if (ready) {
- viewer.entities.removeAll();
- if (type === 'initPosition') {
- viewInstance.value?.flyToContour();
- } else {
- type === 'point' ? addPoint(data) : addPolyline(data);
- }
- }
- },
- { deep: true, immediate: true } // 初始化时立即执行
- );
-};
-
-/**
- * 添加点标注
- * @param data 数据 数据格式 [lng, lat]
- */
-function addPoint(data) {
- const [lng, lat] = data;
-
- if (!lng || !lat) return;
-
- viewer.entities.add({
- position: Cartesian3.fromDegrees(lng, lat),
- point: {
- pixelSize: 10,
- color: Cesium.Color.BLUE,
- outlineColor: Cesium.Color.WHITE,
- outlineWidth: 2,
- },
- });
-
- // 定位到点位
- const points = [[lng, lat]]; // 确保格式为二维数组
- flyVisual({ positionsData: points, viewer, multiple: 10 });
-}
-
-/**
- * 添加点标注
- * @param data 数据 数据格式 [[lng, lat], [lng, lat], [lng, lat]]
- */
-async function addPolyline(data) {
- await renderPreviewLine(data.url, data.type, data.cb, data.infos);
-}
-
-const getViewer = () => viewer;
-
-onMounted(() => {
- nextTick(() => {
- initMap();
- });
-});
-
-onBeforeUnmount(() => {
- var cesiumContainer = document.getElementById('viewer-container');
- if (cesiumContainer) {
- cesiumContainer.remove(); // 移除与地图相关的DOM元素
- }
-
- viewer.entities.removeAll();
- publicCesiumInstance.viewerDestroy();
- viewer = null;
-});
-
-defineExpose({
- initAddEntity,
- getViewer
-});
-</script>
-
-<script>
-export default {
- name: 'MapContainer',
-};
-</script>
-
-<style lang="scss" scoped>
-.map-container {
- position: relative;
- width: 100% !important;
- height: 100% !important;
- overflow: hidden;
-}
-
-.viewer-container {
- position: absolute;
- top: 0%;
- left: 0%;
- width: 100%;
- height: 100%;
-}
-</style>
diff --git a/applications/task-work-order/src/main.js b/applications/task-work-order/src/main.js
index 9d21ed1..04bc6a0 100644
--- a/applications/task-work-order/src/main.js
+++ b/applications/task-work-order/src/main.js
@@ -50,7 +50,6 @@
// 业务组件
import tenantPackage from './views/system/tenantpackage.vue'
// 地图依赖
-import mapContainer from './components/map-container/mapContainer.vue'
import * as DC from '@dvgis/dc-sdk'
import '@dvgis/dc-sdk/dist/dc.min.css'
@@ -102,7 +101,6 @@
app.component('thirdRegister', thirdRegister)
app.component('flowDesign', flowDesign)
app.component('tenantPackage', tenantPackage)
-app.component('mapContainer', mapContainer)
app.config.globalProperties.$dayjs = dayjs
app.config.globalProperties.website = website
diff --git a/applications/task-work-order/src/router/views/index.js b/applications/task-work-order/src/router/views/index.js
index de30ead..c18c3c3 100644
--- a/applications/task-work-order/src/router/views/index.js
+++ b/applications/task-work-order/src/router/views/index.js
@@ -134,29 +134,4 @@
},
],
},
-
- {
- path: '/resource',
- component: Layout,
- redirect: '/resource/patchManagement',
- children: [
- {
- path: 'patchManagement',
- name: '图斑管理',
- meta: {
- i18n: 'info',
- },
- component: () => import(/* webpackChunkName: "views" */ '@/views/resource/patchManagement.vue'),
- },
-
- {
- path: 'patchTypeManagement',
- name: '图斑类型管理',
- meta: {
- i18n: 'info',
- },
- component: () => import(/* webpackChunkName: "views" */ '@/views/resource/patchTypeManagement.vue'),
- },
- ],
- },
]
diff --git a/applications/task-work-order/src/utils/cesium/publicCesium.js b/applications/task-work-order/src/utils/cesium/publicCesium.js
index 830c3f0..f457a70 100644
--- a/applications/task-work-order/src/utils/cesium/publicCesium.js
+++ b/applications/task-work-order/src/utils/cesium/publicCesium.js
@@ -146,52 +146,7 @@
this.viewer?.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) // 禁用双击
- if (terrain) {
- try {
- const noTerrainMechanism = ['1962779164650135554']
- if (noTerrainMechanism.includes(store.state.user.userInfo?.deptId)) {
- // 使用Cesium World Terrain
- Cesium.createWorldTerrainAsync({
- requestWaterMask: false, // 请求水域效果
- requestVertexNormals: true // 请求光照和地形法线
- }).then(terrainProvider => {
- this.viewer.terrainProvider = terrainProvider
- terrainLoadCallback?.()
- })
- } else {
- /*// 正则:第一位非0,第二位任意数字,后10位都是0
- const re = /^[1-9]\d0{10}$/
-
- let result = null
-
- // 1️⃣先判断 areaCode
- if (re.test(store.state.user.userInfo.detail.areaCode)) {
- result = store.state.user.userInfo.detail.areaCode.slice(0, 6)
- } else {
- // 2️⃣如果不满足,从 ancestors 里找
- const matchedItems = store.state.user.userInfo.detail.ancestors
- .split(',')
- .filter(item => re.test(item)) // 过滤出符合条件的
-
- // 取第一个符合条件的前6位(可以改成 last one 看需求)
- if (matchedItems.length > 0) {
- result = matchedItems[0].slice(0, 6)
- }
- }
-
- // 使用公司地形
- Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}${result}`, {
- requestVertexNormals: true, // 启用地形法线增强立体感
- requestWaterMask: true, // 启用水体遮罩效果
- }).then(terrainProvider => {
- this.viewer.terrainProvider = terrainProvider
- terrainLoadCallback?.()
- })*/
- }
- } catch (error) {
- console.error('地形加载失败:', error)
- }
- }
+ this.setTerrainVisible(terrain, terrainLoadCallback)
this.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 4500000
this.switchLayers(layerMode)
@@ -205,6 +160,39 @@
this.viewer.resolutionScale = dpr // 设置分辨率缩放比例
}
}
+ async ensureTerrainProvider () {
+ if (this.terrainProvider) return this.terrainProvider
+ if (this.terrainLoading) return this.terrainLoading
+ this.terrainLoading = Cesium.CesiumTerrainProvider.fromUrl(
+ `${import.meta.env.VITE_APP_TERRAIN_URL}ja_terrain`,
+ {
+ requestVertexNormals: true, // 启用地形法线增强立体感
+ requestWaterMask: true, // 启用水体遮罩效果
+ }
+ ).then(provider => {
+ this.terrainProvider = provider
+ return provider
+ })
+ return this.terrainLoading
+ }
+
+ async setTerrainVisible (visible, terrainLoadCallback) {
+ if (!this.viewer) return
+ if (!visible) {
+ this.viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider()
+ this.terrainEnabled = false
+ return
+ }
+ try {
+ const provider = await this.ensureTerrainProvider()
+ if (!this.viewer) return
+ this.viewer.terrainProvider = provider
+ this.terrainEnabled = true
+ terrainLoadCallback?.()
+ } catch (error) {
+ this.terrainEnabled = false
+ }
+ }
getViewer () {
return this.viewer
diff --git a/applications/task-work-order/src/views/resource/components/spotDetails.vue b/applications/task-work-order/src/views/resource/components/spotDetails.vue
deleted file mode 100644
index 63b2c0d..0000000
--- a/applications/task-work-order/src/views/resource/components/spotDetails.vue
+++ /dev/null
@@ -1,955 +0,0 @@
-<template>
- <el-dialog
- class="spotDialog work-dialog-mange"
- :title="props.title"
- v-model="uploadPatchDialog"
- width="78%"
- align-center
-
- >
- <div class="container">
- <!-- 信息展示区 -->
- <div class="infoBox">
- <div class="itemBoxLeft">
- <div v-for="(item, index) in infoList" :key="index" class="itemCon">
- <div class="itemBox">
- <div class="itemTitle">
- <span
- v-if="
- props.title === '图斑编辑' &&
- (item.name === '文件名称' || item.name === '图斑类型')
- "
- style="color: red"
- >*</span
- >{{ item.name }}:
- </div>
- <div class="itemContent">
- <template v-if="props.title === '图斑编辑' && item.editable">
- <template v-if="item.name === '图斑类型'">
- <el-select
- v-model="item.value"
- placeholder="请选择图斑类型"
- style="width: 102%"
-
- >
- <el-option
- v-for="opt in spotTypeOptions"
- :key="opt.value"
- :label="opt.label"
- :value="opt.value"
- />
- </el-select>
- </template>
- <template v-else-if="item.name === '文件名称'">
- <el-input style="width: 102%" v-model="item.value" />
- </template>
- </template>
- <template v-else>
- <div class="itemValue" :class="{ 'error-text': item.name === '异常图斑数量' }">
- {{ item.value }}
- </div>
- </template>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 地图和表格容器 -->
- <div class="map-container">
- <!-- 图斑列表 -->
- <div class="table-overlay">
- <div class="table-content">
- <div class="tabname">图斑列表</div>
- <div class="tabBoxLoading"
- v-loading="tableLoading"
- element-loading-text="加载中..."
- element-loading-background="rgba(0, 0, 0, 0.1)"
- >
- <el-table
- v-if="tableData.length > 0"
-
- ref="polygonTableEle"
- highlight-current-row
- :row-class-name="tableRowClassName"
- :data="tableData"
- @row-click="handleLocationPolygon"
-
- >
- <el-table-column type="index" align="center" :width="pxToRemNum(30)" label="序号">
- <template #default="{ $index }">
- {{ ($index + 1).toString().padStart(2, '0') }}
- </template>
- </el-table-column>
- <el-table-column prop="dkbh" align="center" label="图斑名称" show-overflow-tooltip />
- <el-table-column prop="is_exception" :width="pxToRemNum(50)" align="center" label="图斑状态">
- <template #default="scope">
- <span>{{ scope.row.is_exception === 2 ? '异常' : '正常' }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" v-if="props.title === '图斑编辑'">
- <template #default="scope">
- <!-- <span class="operationspan" @click="handleDelete(scope.row)">删除</span> -->
- <el-button icon="el-icon-delete" link @click="handleDelete(scope.row)"></el-button>
- <!-- <span
- class="operationspan"
- v-if="scope.row.is_exception == 2"
- @click.stop="handleSelectionChange(scope.row)"
- >
- {{ isEditing && selectionIds === scope.row.id ? '取消编辑' : '编辑' }}
- </span> -->
- <template v-if="scope.row.is_exception == 2">
- <el-button
- v-if="!isEditing || selectionIds !== scope.row.id"
- icon="el-icon-edit"
- link
- @click.stop="handleSelectionChange(scope.row)"
- />
- <el-button
- v-else
- icon="el-icon-circle-close"
- link
- @click.stop="handleSelectionChange(scope.row)"
-
- />
- </template>
- </template>
- </el-table-column>
- </el-table>
- </div>
-
- </div>
- </div>
- <!--绘制按钮-->
-
- <DrawPolygon
- ref="drawPolygonRef"
- v-if="isEditing"
- @upDateDrawState="handleUpDateDrawState"
-
- />
- <!-- 完成/取消 -->
- <div class="btnGroups" v-if="props.title === '图斑编辑'">
- <img @click="handleSave" src="@/assets/images/home/territory/savebtn.png" alt="" />
- <img @click="handleCancel" src="@/assets/images/home/territory/cancelbtn.png" alt="" />
- </div>
- <!-- 地图 -->
- <div id="spotMap" v-loading="loading" element-loading-text="加载中..." element-loading-background="rgba(0, 0, 0, 0.7)" class="work-cesium" v-show="uploadPatchDialog"></div>
- </div>
- </div>
- </el-dialog>
-</template>
-
-<script setup>
-import { flyVisual } from '@ztzf/utils'
-import { pxToRem, pxToRemNum } from '@/utils/rem'
-import DrawPolygon from '@/views/resource/components/DrawPolygon.vue';
-import { ElMessage, ElMessageBox } from 'element-plus';
-import { findAreaName } from '@/utils/areaUtils';
-import {
- patchEditApi,
- tableMapListApi,
- deletePatches,
- AlltableMapListApi,
- spotManagementTableApi,
-} from '@/api/patchManagement/index';
-import { getCenterPoint } from '@/utils/cesium/mapUtil.js';
-
-import * as Cesium from 'cesium';
-import { PublicCesium } from '@/utils/cesium/publicCesium';
-import { ref, watch, onBeforeUnmount, onMounted } from 'vue';
-// 标记地图是否初始化完成
-const isMapReady = ref(false);
-const uploadPatchDialog = defineModel('show');
-const props = defineProps(['title', 'detailid', 'detailList', 'spotTypeOption', 'regionalData']);
-const polygonTableEle = ref(null);
-let publicCesiumInstance = null;
-let viewer = null;
-const viewInstance = shallowRef(null);
-const homeViewer = shallowRef(null);
-let tbJwdList = [];
-const loading = ref(true);
-const tableLoading = ref(true);
-const tableData = ref([]);
-const AlltableData = ref([]);
-let total = ref(0);
-const refreshonload = inject('searchReset');
-const initialFileName = ref('');
-const initialSpotTypeId = ref('');
-const initialSpotTypeLabel = ref('');
-const spotManagementData = ref(null);
-const isEditing = ref(false);
-const drawPolygonRef = ref(null);
-// 记录上一次点击高亮
-let lastHighlightRow = null;
-// 功能按钮区域相关:编辑图斑等
-const funButtonEle = ref(null);
-const isBoxSelect = ref(false);
-const isDrawPolygon = ref(false);
-// 选中了哪些图斑
-const selectionIds = ref(null);
-const selectionList = ref([]);
-// 当前在编辑状态的异常图斑
-let curCustomPolygon = null;
-let lastEntity = null;
-// 表格隔行变色
-const tableRowClassName = ({ rowIndex }) => {
- return rowIndex % 2 === 1 ? 'oddNumberRow' : 'even-row';
-};
-const spotTypeOptions = ref([]);
-const infoList = ref([
- { name: '文件名称', value: '', field: 'file_name', editable: true },
- { name: '图斑类型', value: '', field: 'lot_type_id', editable: true },
- { name: '图斑数量', value: '', field: 'patches_num', editable: false },
- { name: '异常图斑数量', value: '', field: 'exception_num', editable: false },
- { name: '行政区划', value: '', field: 'areaName', editable: false },
- { name: '数据来源', value: '', field: 'dataFrom', editable: false },
- { name: '创建时间', value: '', field: 'create_time', editable: false },
- { name: '创建人', value: '', field: 'user_name', editable: false },
-]);
-watch(
- () => props.spotTypeOption,
- newOptions => {
- if (newOptions) {
- spotTypeOptions.value = newOptions.map(opt => ({
- label: opt.label,
- value: opt.value,
- }));
- }
- },
- { immediate: true }
-);
-watch(
- () => spotManagementData.value,
- newVal => {
- if (newVal) updateInfoList(newVal);
- },
- { immediate: true }
-);
-
-// 图斑编辑详情
-const getspotManagementTableApi = () => {
- spotManagementTableApi({ id: props.detailid }).then(res => {
- spotManagementData.value = {
- ...res.data.data.records[0],
- dataFrom: res.data.data.records[0].date_from === 0 ? '本地上传' : '国土调查云',
- areaName: findAreaName(res.data.data.records[0].area_code, props.regionalData, true),
- };
- });
-};
-
-// 将 lot_type_id 转换为对应的 label
-const getPatchTypeLabel = lotTypeId => {
- const option = spotTypeOptions.value.find(opt => opt.value === String(lotTypeId));
- return option ? option.label : '';
-};
-const updateInfoList = detailData => {
- if (!detailData) return;
- if (initialFileName.value === '' || initialSpotTypeId.value === '') {
- initialFileName.value = detailData.file_name || '';
- initialSpotTypeId.value = detailData.lot_type_id || '';
- initialSpotTypeLabel.value =
- detailData.patches_type_desc || getPatchTypeLabel(detailData.lot_type_id);
- }
- infoList.value = infoList.value.map(item => {
- const value = detailData[item.field] ?? item.value;
- if (item.name === '图斑类型') {
- return {
- ...item,
- value: detailData.patches_type_desc || getPatchTypeLabel(detailData.lot_type_id),
- originalValue: detailData.lot_type_id,
- };
- }
- return { ...item, value };
- });
-};
-const params = ref({
- page: 1,
- pageSize: 10,
-});
-const isInit = ref(true);
-// 图斑管理表格
-const getTableList = () => {
- tableLoading.value = true;
- const requestParams = {
- patchesInfoId: props.detailid,
- };
- AlltableMapListApi(requestParams).then(res => {
- tableData.value = res.data.data?.map(item => ({
- ...item,
- dkfw: item.sdfw && item.is_exception == 1 ? item.sdfw : item.dkfw,
- }));
- total.value = res.data.data.total || res.data.data.length;
- tbJwdList = [];
- viewer?.entities.removeAll();
- if (!tableData.value) {
- viewInstance.value?.flyToContour();
- } else {
- entitiesAddSpot();
- }
- }).finally(() => {
- tableLoading.value = false;
- });
-};
-
-
-
-// 地图
-const initMap = () => {
- if (!document.getElementById('spotMap') || isMapReady.value) return;
-
- publicCesiumInstance = new PublicCesium({
- dom: 'spotMap',
- flatMode: false,
- terrain: true,
- layerMode: 4,
- contour: false,
- });
-
- homeViewer.value = publicCesiumInstance.getViewer();
- viewer = publicCesiumInstance.getViewer();
- viewInstance.value = publicCesiumInstance;
- viewer.scene.globe.depthTestAgainstTerrain = true;
- viewInstance.value.switchContour(true);
-
- // 确保 readyPromise 存在
- if (viewer.readyPromise) {
- viewer.readyPromise.then(() => {
- isMapReady.value = true;
- getTableList();
- }).catch((error) => {
- console.error('地图加载失败:', error);
- ElMessage.error('地图加载失败,请刷新重试');
- });
- } else {
-
- // 如果没有 readyPromise
- setTimeout(() => {
- isMapReady.value = true;
- getTableList();
- }, 1000);
- }
-};
-
-
-// 仅弹框初始化时执行的定位逻辑
-const initMapLocation = () => {
- if (tbJwdList.length === 0 || !homeViewer.value) return;
-
- // 计算所有图斑的包围球(用于初始化定位)
- const allPositions = tbJwdList.flatMap(item =>
- Cesium.Cartesian3.fromDegreesArray(item.grouped)
- );
- const boundingSphere = Cesium.BoundingSphere.fromPoints(allPositions);
-
- // 初始化定位(仅执行一次)
- homeViewer.value.camera.flyToBoundingSphere(boundingSphere, {
- duration: 0,
- offset: new Cesium.HeadingPitchRange(
- Cesium.Math.toRadians(0),
- Cesium.Math.toRadians(-90)
- ),
- });
-};
-// 初始化所有图斑
-const entitiesAddSpot = () => {
-if (!isMapReady.value || !viewer) return;
- viewer?.entities.removeAll();
- tbJwdList = []; // 重置经纬度列表
-
- tableData.value.forEach(item => {
- const numbersWithCommas = item.dkfw.match(/\d+(\.\d+)?/g);
- if (!numbersWithCommas) return;
-
- const grouped = numbersWithCommas.map(Number);
- tbJwdList.push({ ...item, grouped }); // 存储经纬度用于后续操作
-
- // 绘制图斑(保留原有逻辑,仅移除定位相关代码)
- const fillColor = item.is_exception === 2
- ? Cesium.Color.RED.withAlpha(0.5)
- : Cesium.Color.YELLOW.withAlpha(0.5);
- const outlineColor = item.is_exception === 2
- ? Cesium.Color.RED
- : Cesium.Color.YELLOW;
-
- homeViewer.value?.entities?.add({
- id: `polygon_dk${item.id}`,
- customType: 'pattern_spot_polygon',
- customInfo: item,
- polygon: {
- hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(grouped)),
- material: fillColor,
- outline: true,
- outlineColor: outlineColor,
- outlineWidth: 2,
- clampToGround: true,
- outlineDepthFailColor: outlineColor,
- },
- polyline: {
- positions: Cesium.Cartesian3.fromDegreesArray(grouped),
- width: 2,
- material: outlineColor,
- clampToGround: true,
- },
- zIndex: 99,
- });
- });
-
- // 仅在初始化阶段执行定位(关键:通过isInit控制)
- if (isInit.value) {
- initMapLocation();
- isInit.value = false; // 初始化完成,后续不再执行定位
- }
-
- // 保留图斑点击高亮事件(原有逻辑不变)
- viewInstance.value?.removeLeftClickEvent('spotHighlighting');
- viewInstance.value?.addLeftClickEvent(null, spotHighlighting, 'spotHighlighting');
-};
-
-// 高亮当前选中图斑,并定位
-const getEntityByDataId = dataId => {
- if (!homeViewer.value) return null;
- const entityId = `polygon_dk${dataId}`;
- return homeViewer.value.entities.getById(entityId);
-};
-const handleLocationPolygon = data => {
- if (!data) return;
-
- // 取消任何现有的绘制状态(与编辑取消逻辑一致)
- if (isEditing.value) {
- isEditing.value = false;
- handleUpDateDrawState(false);
- selectionIds.value = null;
- selectionList.value = [];
- }
-
- const targetEntity = getEntityByDataId(data.id);
- if (targetEntity) {
- updateMapSpotInfo(targetEntity);
- // 同步表格选中状态
- const clickTableID = tableData.value.findIndex(i => i.id === data.id);
- const rows = polygonTableEle?.value.$el.querySelectorAll('.el-table__body tr');
- const targetRow = rows[clickTableID];
-
- nextTick(() => {
- const table = polygonTableEle?.value;
- if (table && targetRow) {
- table.setCurrentRow(tableData.value[clickTableID]);
- targetRow.scrollIntoView({ behavior: 'smooth', block: 'center' });
- }
- });
- }
-};
-
-// 鼠标触发点击图斑高亮 pick:可以获取当前图斑数据
-function spotHighlighting(click, pick, viewer) {
- let entities = viewer?.scene
- .drillPick(click.position)
- .filter(item => item.id)
- .map(i => i.id)
- .filter(i => i._customType === 'pattern_spot_polygon');
- if (!pick || !(pick.id?.customType == 'pattern_spot_polygon')) return;
- const nowEntity = entities?.[0];
- const nowData = nowEntity.customInfo;
- const clickTableID = tableData.value.findIndex(i => i.id === nowData.id);
- const rows = polygonTableEle?.value.$el.querySelectorAll('.el-table__body tr');
- const targetRow = rows[clickTableID];
-
- nextTick(() => {
- const table = polygonTableEle?.value;
- if (!table || !targetRow) return;
- // 表格滚动到中间位置
- targetRow.scrollIntoView({ behavior: 'smooth', block: 'center' });
- // 同步表格选中状态
- table.setCurrentRow(tableData.value[clickTableID]);
- });
-
- updateMapSpotInfo(nowEntity);
-}
-function updateMapSpotInfo(nowEntity) {
- const nowData = nowEntity.customInfo;
- if (!nowEntity) return;
- if (nowEntity.customInfo.id === lastEntity?.customInfo.id) return;
- nowEntity.polygon.material = Cesium.Color.RED.withAlpha(0);
- nowEntity.polyline.material = Cesium.Color.RED;
- if (lastEntity) {
- const lastData = lastEntity.customInfo;
- const originalFillColor =
- lastData.is_exception === 2
- ? Cesium.Color.RED.withAlpha(0.5)
- : Cesium.Color.YELLOW.withAlpha(0.5);
- const originalOutlineColor =
- lastData.is_exception == 2 ? Cesium.Color.RED : Cesium.Color.YELLOW;
- lastEntity.polygon.material = originalFillColor;
- lastEntity.polygon.outlineColor = originalOutlineColor;
- lastEntity.polyline.material = originalOutlineColor;
- }
- lastEntity = nowEntity;
- const numbersWithCommas = nowData.dkfw.match(/\d+(\.\d+)?/g);
- if (numbersWithCommas) {
-
- const positionsData = [];
- for (let i = 0; i < numbersWithCommas.length; i += 2) {
- const lon = Number(numbersWithCommas[i]);
- const lat = Number(numbersWithCommas[i + 1]);
- positionsData.push([lon, lat, 10]);
- }
- flyVisual({
- positionsData: positionsData,
- viewer: homeViewer.value,
- multiple: 15,
-
- });
- }
-}
-// 清空选中的数据
-const clearSelect = () => {
- lastHighlightRow = null;
- selectionList.value = [];
- viewer?.entities.removeAll();
-};
-// 编辑
-
-const handleSelectionChange = row => {
- // 如果是同一个图斑且正在编辑,则取消编辑
- if (selectionIds.value === row.id && isEditing.value) {
- isEditing.value = false;
- handleUpDateDrawState(false);
- selectionIds.value = null;
- selectionList.value = [];
- return;
- }
-
- // 定位到选中的图斑
- handleLocationPolygon(row);
-
- // 仅异常图斑可编辑
- if (row.is_exception !== 2) {
- ElMessage.warning('仅异常图斑支持编辑绘制');
- return;
- }
-
- // 设置编辑状态
- selectionIds.value = row.id;
- selectionList.value = row;
- isEditing.value = true;
- handleUpDateDrawState(true);
-};
-const handleUpDateDrawState = show => {
- isEditing.value = show; // 同步编辑状态
- if (!show) {
- // 绘制关闭时,清空选中的编辑行
- selectionIds.value = null;
- selectionList.value = [];
- }
-};
-// 删除
-const handleDelete = (row) => {
- ElMessageBox.confirm('确认删除当前行图斑?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- }).then(() => {
- deletePatches({ ids: row.id }).then(res => {
- if (res.data.code !== 0) return ElMessage.warning('删除失败');
- ElMessage.success('删除成功');
- tableData.value = tableData.value.filter(item => item.id !== row.id);
- //从地图上移除对应的图斑实体
- const entityId = `polygon_dk${row.id}`;
- viewer?.entities.removeById(entityId);
- const exceptionCountItem = infoList.value.find(item => item.name === '异常图斑数量');
- if (exceptionCountItem && row.is_exception === 2) {
- exceptionCountItem.value = Math.max(0, parseInt(exceptionCountItem.value) - 1);
- }
- const totalCountItem = infoList.value.find(item => item.name === '图斑数量');
- if (totalCountItem) {
- totalCountItem.value = Math.max(0, parseInt(totalCountItem.value) - 1);
- }
-
- // 清除选中状态
- if (selectionIds.value === row.id) {
- selectionIds.value = null;
- selectionList.value = [];
- isEditing.value = false;
- handleUpDateDrawState(false);
- }
-
- });
- });
-};
-
-// 保存
-const handleSave = () => {
- const fileNameItem = infoList.value.find(item => item.name === '文件名称');
- const patchTypeItem = infoList.value.find(item => item.name === '图斑类型');
- let lotTypeId;
- // 检查value是否为数字类型(包括字符串形式的数字)
- const isValueNumber =
- !isNaN(Number(patchTypeItem.value)) &&
- patchTypeItem.value !== '' &&
- patchTypeItem.value !== null &&
- patchTypeItem.value !== undefined;
- if (isValueNumber) {
- // 转换为数字类型
- lotTypeId = Number(patchTypeItem.value);
- } else {
- // 使用原始值
- lotTypeId = patchTypeItem.originalValue;
- }
- // 构建请求参数
- const updateParams = {
- file_name: fileNameItem.value,
- lot_type_id: lotTypeId,
- type: lotTypeId,
- id: props.detailList.id,
- };
- patchEditApi(updateParams).then(res => {
- ElMessage.success(res.data.data);
- refreshonload();
- uploadPatchDialog.value = false;
- });
-};
-// 取消
-const handleCancel = () => {
- const fileNameItem = infoList.value.find(item => item.name === '文件名称');
- const spotTypeItem = infoList.value.find(item => item.name === '图斑类型');
- if (fileNameItem) {
- fileNameItem.value = initialFileName.value;
- }
- if (spotTypeItem) {
- spotTypeItem.value = initialSpotTypeLabel.value;
- spotTypeItem.originalValue = initialSpotTypeId.value;
- }
- if (isEditing.value) {
- isEditing.value = false;
- handleUpDateDrawState(false);
- }
- clearSelect();
- isDrawPolygon.value = false; // 关闭地图绘制状态
- uploadPatchDialog.value = false;
-};
-provide('selectionIds', selectionIds);
-provide('homeViewer', homeViewer);
-provide('viewInstance', viewInstance);
-provide('clearSelect', clearSelect);
-provide('getTableList', getTableList);
-// 销毁
-const destroyMap = () => {
- if (viewer) {
- viewer.destroy();
- viewer = null;
- }
- publicCesiumInstance = null;
-};
-
-
-watch(uploadPatchDialog, newVal => {
- if (newVal) {
- isInit.value = true;
- isMapReady.value = false;
- setTimeout(() => {
- initMap();
- getspotManagementTableApi();
- }, 0);
- } else {
- tableLoading.value = false;
- tableData.value = [];
- isEditing.value = false;
- handleUpDateDrawState(false);
- destroyMap();
- isInit.value = false;
- clearSelect();
- isMapReady.value = false;
- }
- refreshonload();
-});
-onMounted(() => {});
-onBeforeUnmount(() => {
- destroyMap();
-});
-</script>
-
-<style scoped lang="scss">
-:global(.spotDialog .el-dialog__header span) {
- padding-left: 16px !important;
- display: inline-block;
-}
-:global(.spotDialog .el-dialog__header) .el-dialog__title {
- font-family: 'Source Han Sans CN' !important;
- font-weight: bold !important;
- font-size: 16px !important;
- color: #363636 !important;
-}
-:global(.spotDialog .el-dialog__body) {
- padding: 2rem 2rem 0 !important;
-
- }
-.container {
- display: flex;
- flex-direction: column;
- height: 100%;
- padding: 10px 20px 23px 20px;
-}
-
-.infoBox {
- display: flex;
- justify-content: space-between;
- margin-bottom: 16px;
- border: 1px solid;
- border: 1px solid #e8e8e8;
- border-radius: 4px;
- background: #fff;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
-
- .itemBoxLeft {
- flex: 1;
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- row-gap: 0;
- padding: 0;
- font-size: 14px;
- }
-
- .itemCon {
- border-bottom: 1px solid #e8e8e8;
-
- &:nth-child(2n) {
- .itemBox {
- border-right: none;
- }
- }
-
- &:nth-last-child(-n + 2) {
- border-bottom: none;
- }
- }
-
- .itemBox {
- display: flex;
- align-items: center;
- height: 33px;
- padding: 0 10px;
- border-right: 1px solid #e8e8e8;
- border-bottom: none;
-
- .itemTitle {
- width: 202px;
- font-family: Source Han Sans CN, Source Han Sans CN;
- font-weight: 400;
- font-size: 14px;
- color: #383838;
- text-align: right;
- background: #fafafa;
- height: 100%;
- line-height: 33px;
- padding-right: 10px;
- margin: 0 -10px 0 -10px;
- border-right: 1px solid #e8e8e8;
- }
-
- .itemContent {
- flex: 1;
- padding-left: 10px;
- .itemValue {
- padding-left: 6px;
- color: #7b7b7b;
- }
- .error-text {
- color: #ff0a0a;
- }
- }
- }
-}
-
-.map-container {
- position: relative;
- height: 620px;
- width: 100%;
-}
-.table-overlay {
- position: absolute;
- top: 0;
- left: 0;
- height: 99%;
- z-index: 99;
- width: 277px;
- overflow: hidden;
- background: rgba(0, 0, 0, 0.8);
-
- border-radius: 8px 8px 8px 8px;
- padding: 6px 10px 0 10px;
- display: flex;
- flex-direction: column;
-}
-
-.table-content {
- width: 100%;
- display: flex;
- flex-direction: column;
- height: 99%;
- .tabname {
- font-family: Source Han Sans CN, Source Han Sans CN;
- font-weight: bold;
- font-size: 14px;
- color: #ffffff;
- }
-
- // 表格样式
- :deep(.el-table) {
- // 清除表格内部横线和竖线
- &::before,
- &::after,
- .el-table__inner-wrapper::before,
- .el-table__inner-wrapper::after {
- background-color: transparent !important;
- // display: none !important; // 彻底隐藏伪元素边框
- }
- .el-table__header-wrapper th {
- border: none !important;
- }
- --el-table-bg-color: transparent !important;
- --el-table-tr-bg-color: transparent !important;
-
- --el-table-row-hover-bg-color: rgba(30, 58, 138, 0.5) !important;
- --el-table-current-row-bg-color: rgba(30, 58, 138, 0.7) !important;
- color: #fff !important;
- .cell {
- padding: 0px !important;
- font-size: 12px !important;
- }
- // 隔行变色
- .even-row {
- background-color: rgba(255, 255, 255, 0.17) !important;
- }
- .oddNumberRow {
- background-color: rgba(255, 255, 255, 0.08) !important;
- }
-
- // 表头样式
- .el-table__header {
- th {
- background: rgba(51, 51, 51, 0.32) !important;
- font-family: Source Han Sans CN;
- font-weight: 500;
- font-size: 14px;
- color: #ffffff;
- .cell {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
-
- // 表格主体
- .el-table__body {
- tr:hover > td {
- background-color: rgba(64, 158, 255,0.3) !important;
- }
-
- td {
- border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
- }
- }
-
- // 选中行
- .current-row td {
-
- background-color: rgba(64, 158, 255,0.3) !important;
- }
- }
- :deep(.el-table__body) {
- tr {
- height: 46px;
- }
- td {
- padding: 8px 0;
- }
- }
- .operationspan {
- cursor: pointer;
- color: #409eff;
- }
- .operationspan:first-child {
- margin-right: 5px;
- }
-
- // 分页
- :deep(.pagination-container) {
- background: transparent !important;
- }
- :deep(.el-pagination) {
- .btn-prev,
- .btn-next {
- padding: 5px 6px;
- }
- }
- :deep(.el-pager li) {
- margin: 0 0.1rem;
- background: rgba(34, 34, 34, 0.9) !important;
- box-shadow: 0px 4px 72px 0px rgba(0, 0, 0, 0.25) !important;
- border-radius: 8px 8px 8px 8px !important;
-
- font-family: Source Han Sans CN, Source Han Sans CN;
- font-weight: 400;
- font-size: 14px;
- color: #ededed !important;
- }
- :deep(.el-pager li.is-active) {
- border: 1px solid rgba(255, 255, 255, 0.99) !important;
- }
- :deep(.el-pagination button) {
- background: rgba(34, 34, 34, 0.9) !important;
- color: #ededed !important;
- border-radius: 8px 8px 8px 8px !important;
- }
- .pagination-container {
- margin-top: auto;
- padding: 8px 5px !important;
- background: white;
- display: flex;
- justify-content: center;
- height: auto; // 取消固定高度20px,避免内容被截断
- margin: 24px 0 14px 0;
- width: 100%;
- box-sizing: border-box;
- }
-}
-:deep(.el-tooltip__popper) {
- z-index: 9999 !important;
- max-width: 300px;
-}
-.tabBoxLoading {
-height: 100%;
-
-}
-
-.el-table {
-height: 98%;
-overflow: auto;
-
-}
-.btnGroups {
- position: absolute;
- bottom: 49px;
- left: 50%;
- transform: translate(-50%);
- img {
- width: 125px;
- height: 45px;
- cursor: pointer;
- }
-}
-.btnGroups img:first-child {
- margin-right: 21px;
-}
-#spotMap {
- height: 100%;
- width: 100%;
-}
-.el-button {
- padding: 0;
- color: #fff;
- width: 17px;
-}
-</style>
diff --git a/applications/task-work-order/src/views/resource/patchManagement.vue b/applications/task-work-order/src/views/resource/patchManagement.vue
deleted file mode 100644
index 7927989..0000000
--- a/applications/task-work-order/src/views/resource/patchManagement.vue
+++ /dev/null
@@ -1,569 +0,0 @@
-<template>
- <basic-container>
- <avue-crud
- :option="option"
- :table-loading="loading"
- :data="data"
- v-model:page="page"
- :permission="permissionList"
- v-model="form"
- ref="crud"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @row-del="rowDel"
- :before-open="beforeOpen"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- >
- <template #menu-left>
- <el-button type="primary" icon="el-icon-upload" @click="handleDebug"> 上传图斑 </el-button>
- <el-button type="primary" icon="el-icon-setting" @click="goTypeManagement">
- 类型管理
- </el-button>
- <el-button type="success" icon="el-icon-download" @click="downloadPatch"> 导出 </el-button>
- </template>
-
- <template #menu="scope">
- <el-button type="primary" text icon="el-icon-view" @click="uploadPatch(scope.row, 'detail')"
- >详情
- </el-button>
- <el-button type="primary" text icon="el-icon-edit" @click="uploadPatch(scope.row, 'edit')"
- >编辑
- </el-button>
- <el-button :disabled="scope.row.patches_type_desc==='综合类'" type="primary" text icon="el-icon-delete" @click="rowDel(scope.row)"
- >删除
- </el-button>
- </template>
- </avue-crud>
-
- <el-dialog title="上传图斑" class="work-dialog-mange" append-to-body align-center v-model="box" width="550px">
- <el-form
- ref="ruleFormRef"
- style="max-width: 600px"
- :model="ruleForm"
- :rules="rules"
- label-width="auto"
- >
- <el-form-item label="文件名称" prop="name">
- <el-input v-model="ruleForm.name" />
- </el-form-item>
- <el-form-item label="图斑类型" prop="region">
- <el-select v-model="ruleForm.region" placeholder="请选择图斑类型">
- <el-option
- v-for="item in allspotTypeOption"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item class="center-align">
- <el-upload
- action="#"
- :show-file-list="false"
- :before-upload="e => uploadFlightFile(e, '1')"
- accept=".kmz, .kml, .zip"
- >
- <el-button type="primary"> 图斑上传 </el-button>
- </el-upload>
- </el-form-item>
- <el-form-item class="center-align">
- <span>注:仅支持gis平台导出的zip压缩文件</span>
- </el-form-item>
- </el-form>
- </el-dialog>
- <!-- 图斑详情 -->
- <SpotDetails
- v-model:show="uploadPatchDialog"
- :title="spotDetailsTitle"
- :detailid="detailid"
- :detailList="detailList"
- :spotTypeOption="allspotTypeOption"
- :regionalData="regionalData"
- ></SpotDetails>
- </basic-container>
-</template>
-<script setup>
-import { findAreaName } from '@/utils/areaUtils';
-import {
- spotManagementTableApi,
- searchManagementApi,
- uploadManagementApi,
- tableMapListApi,
- exportExcel,
- patchDeleteApi,
- listOfSpotTypesApi,
-} from '@/api/patchManagement/index';
-import { getRegionTreeAll } from '@/api/job/task';
-import { ref, computed, watch } from 'vue';
-import { useStore } from 'vuex';
-import { useRouter } from 'vue-router';
-import { ElMessage, ElMessageBox } from 'element-plus';
-import { getListPage, getDetail, add, update, remove, enable, disable } from '@/api/resource/oss';
-import func from '@/utils/func';
-import patchDetails from '@/views/resource/components/patchDetails.vue';
-import SpotDetails from '@/views/resource/components/spotDetails.vue';
-const spotDetailsTitle = ref('');
-const detailList = ref('');
-const store = useStore();
-const router = useRouter();
-const ruleFormRef = ref(null);
-let deptTreeData = ref([]);
-const regionalScope = ref([]);
-const spotTypeOption = ref([]);
-const creatorOption = ref([]);
-const userAreaCode = computed(() => store.getters.userInfo.detail.areaCode);
-const ruleForm = reactive({
- name: '',
- region: '',
-});
-const rules = reactive({
- name: [{ required: true, message: '请输入', trigger: 'blur' }, { trigger: 'blur' }],
- region: [
- {
- required: true,
- message: '请选择',
- trigger: 'change',
- },
- ],
-});
-
-// ===== state =====
-const form = ref({});
-const query = ref({});
-const loading = ref(true);
-const box = ref(false);
-
-const page = ref({
- pageSize: 20,
- currentPage: 1,
- total: 0,
- lotTypeId: '',
- createUser: '',
- areaCode: '',
- fileName: '',
-});
-
-const selectionList = ref([]);
-const option = ref({
- emptyBtnText: '重置',
- emptyBtnIcon: 'el-icon-refresh',
- align: 'center',
- headerAlign: 'center',
- addBtn: false,
- tip: false,
- searchShow: true,
- searchGutter: 30,
- searchMenuPosition: 'left',
- searchMenuSpan: 4,
- border: true,
- index: true,
- indexLabel: '序号',
- indexWidth: 60,
- selection: true,
- grid: false,
- menuWidth: 240,
- labelWidth: 100,
- dialogWidth: 880,
- dialogClickModal: false,
- height: 'auto',
- calcHeight: 20,
- refreshBtn: false,
- gridBtn: false,
- searchShowBtn: false,
- columnBtn: false,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- column: [
- {
- label: '文件名称',
- prop: 'file_name',
- span: 24,
- search: true,
- overHidden: true,
- showOverflowTooltip: true,
- searchSpan: 4,
- rules: [{ required: true, message: '请输入文件名称', trigger: 'blur' }],
- },
- {
- label: '图斑类型',
- prop: 'patches_type_desc',
- span: 24,
- // searchLabelWidth: 100,
- search: true,
- searchSpan: 4,
- type: 'select',
- dicData: spotTypeOption,
- props: {
- label: 'label',
- value: 'value',
- },
- rules: [{ required: true, message: '请选择图斑类型', trigger: 'blur' }],
- },
- {
- label: '图斑数量',
- prop: 'patches_num',
- span: 24,
- rules: [{ required: true, message: '请输入图斑数量', trigger: 'blur' }],
- },
- {
- label: '异常图斑数量',
- prop: 'exception_num',
- span: 24,
- rules: [{ required: true, message: '请输入异常图斑数量', trigger: 'blur' }],
- },
- {
- label: '行政区划',
- prop: 'areaName',
- span: 24,
- width: 180,
- // searchLabelWidth: 100,
- search: true,
- searchSpan: 4,
- type: 'tree',
- dicData: deptTreeData,
- props: {
- label: 'name',
- value: 'id',
- children: 'childrens',
- },
- rules: [{ required: true, message: '请选择行政区划', trigger: 'blur' }],
- },
- {
- label: '数据来源',
- prop: 'dataFrom',
- span: 24,
- rules: [{ required: true, message: '请输入数据来源', trigger: 'blur' }],
- },
- {
- label: '创建时间',
- prop: 'create_time',
- span: 24,
- rules: [{ required: true, message: '请输入创建时间', trigger: 'blur' }],
- },
- {
- label: '创建人',
- prop: 'user_name',
- span: 24,
- // searchLabelWidth: 100,
- search: true,
- searchSpan: 4,
- type: 'select',
- dicData: creatorOption,
- props: {
- label: 'label',
- value: 'value',
- },
- rules: [{ required: true, message: '请输入创建人', trigger: 'blur' }],
- },
- ],
-});
-
-const data = ref([]);
-const crudRef = ref(null);
-const uploadPatchDialog = ref(null);
-const detailid = ref(null);
-// ===== computed =====
-const userInfo = computed(() => store.getters.userInfo);
-const permission = computed(() => store.getters.permission);
-const permissionList = computed(() => ({
- addBtn: !!permission.value.oss_add,
- viewBtn: !!permission.value.oss_view,
- delBtn: !!permission.value.oss_delete,
- editBtn: !!permission.value.oss_edit,
-}));
-
-const ids = computed(() => selectionList.value.map(ele => ele.id).join(','));
-// 获取行政区划
-const regionalData = ref([]);
-const requestDockInfo = () => {
- getRegionTreeAll({ parentCode: userAreaCode.value }).then(res => {
- const rawData = res.data.data ? [res.data.data] : [];
- regionalData.value = rawData;
- const filterTree = nodes => {
- return nodes.filter(node => {
- const nodeCodeStr = node.id.toString();
- const isMatched = regionalScope.value.some(
- code => nodeCodeStr.startsWith(code.toString()) || code.toString().startsWith(nodeCodeStr)
- );
-
- if (node.childrens && node.childrens.length) {
- node.childrens = filterTree(node.childrens);
- if (node.childrens.length) return true;
- }
-
- return isMatched;
- });
- };
- deptTreeData.value = filterTree(rawData);
- onLoad(page.value);
- });
-};
-// 获取搜索数据
-const getsearchManagementApi = () => {
- searchManagementApi().then(res => {
- const uniqueMap = new Map();
- res.data.data.lot_values.forEach(item => {
- const [key, value] = Object.entries(item)[0];
- if (!uniqueMap.has(key)) {
- uniqueMap.set(key, value);
- }
- });
- const creatorOptionuniqueMap = new Map();
- res.data.data.user_names.forEach(item => {
- const [key, value] = Object.entries(item)[0];
- if (!creatorOptionuniqueMap.has(key)) {
- creatorOptionuniqueMap.set(key, value);
- }
- });
- spotTypeOption.value = Array.from(uniqueMap).map(([key, value]) => ({
- label: value,
- value: key,
- }));
- creatorOption.value = Array.from(creatorOptionuniqueMap).map(([key, value]) => ({
- label: value,
- value: key,
- }));
- regionalScope.value = res.data.data.area_codes;
- requestDockInfo();
- });
-};
-const allspotTypeOption = ref([]);
-// 获取上传图斑类型
-const getlistOfSpotTypesApi = () => {
- const searchparams = {
- current: 1,
- size: 9999,
- };
- listOfSpotTypesApi(searchparams).then(res => {
- allspotTypeOption.value = res.data.data.records.map(item => ({
- label: item.patches_type,
- value: item.id,
- }));
- });
-};
-// ===== watch =====
-watch(
- () => form.value.category,
- () => {
- const category = func.toInt(form.value.category);
- option.value.column.forEach(item => {
- if (item.prop === 'appId') {
- item.display = category === 4;
- }
- });
- }
-);
-// ===== methods =====
-const rowSave = (row, done, loading) => {
- add(row).then(
- () => {
- onLoad(page.value);
- ElMessage.success('操作成功!');
- done();
- },
- error => {
- console.log(error);
- loading();
- }
- );
-};
-
-const rowUpdate = (row, index, done, loading) => {
- update(row).then(
- () => {
- onLoad(page.value);
- ElMessage.success('操作成功!');
- done();
- },
- error => {
- console.log(error);
- loading();
- }
- );
-};
-
-const rowDel = row => {
- ElMessageBox.confirm('确定将选择数据删除?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(() => patchDeleteApi(row.id)) // 直接传递ID
- .then(() => {
- onLoad(page.value);
- ElMessage.success('操作成功!');
- });
-};
-
-const searchReset = () => {
- page.value.areaCode = '';
- page.value.createUser = '';
- page.value.fileName = '';
- page.value.lotTypeId = '';
- page.value.currentPage = 1;
- page.value.pageSize = 20;
- onLoad(page.value);
-};
-
-const searchChange = (params, done) => {
- page.value.currentPage = 1;
- page.value.lotTypeId = params.patches_type_desc;
- page.value.createUser = params.user_name;
- page.value.fileName = params.file_name;
- page.value.areaCode = params.areaName;
- page.value.createUser = params.user_name;
- onLoad(page.value);
- done();
-};
-const selectionChange = list => {
- selectionList.value = list;
-};
-
-const selectionClear = () => {
- selectionList.value = [];
- crudRef.value?.toggleSelection();
-};
-
-const handleDebug = row => {
- box.value = true;
-};
-const beforeOpen = (done, type) => {
- // if (['edit', 'view'].includes(type)) {
- // getDetail(form.value.id).then(res => {
- // form.value = res.data.data
- // })
- // }
- done();
-};
-
-const currentChange = currentPage => {
- page.value.currentPage = currentPage;
-};
-
-const sizeChange = pageSize => {
- page.value.pageSize = pageSize;
-};
-
-const refreshChange = () => {
- onLoad(page.value);
-};
-
-const onLoad = (pageInfo, params = {}) => {
- const searchparams = {
- current: pageInfo.currentPage,
- size: pageInfo.pageSize,
- lotTypeId: pageInfo.lotTypeId,
- fileName: pageInfo.fileName,
- areaCode: pageInfo.areaCode,
- createUser: pageInfo.createUser,
- };
- loading.value = true;
- spotManagementTableApi(searchparams).then(res => {
- const d = res.data.data;
- page.value.total = d.total;
- data.value = d.records.map(i => ({
- ...i,
- dataFrom: i.date_from === 0 ? '本地上传' : '国土调查云',
- areaName: findAreaName(i.area_code, regionalData.value, true),
- }));
- loading.value = false;
- selectionClear();
- });
-};
-
-// 图斑详情/编辑
-const uploadPatch = (row, type = 'detail') => {
- detailid.value = row.id;
- uploadPatchDialog.value = true;
- spotDetailsTitle.value = type === 'detail' ? '图斑详情' : '图斑编辑';
- detailList.value = row;
-};
-
-// 跳转至图斑类型管理页面
-const goTypeManagement = () => {
- router.push({ path: '/resource/patchTypeManagement' });
-};
-
-// 下载图斑
-const downloadPatch = () => {
- if (!selectionList.value.length) {
- return ElMessage.warning('请选择需要导出的数据');
- }
- const a = selectionList.value.map(i => Number(i.id));
- exportExcel(a).then(res => {
- const elink = document.createElement('a');
- elink.download = new Date().getTime() + '.xls';
- elink.style.display = 'none';
- const blob = new Blob([res.data], {
- type: 'application/x-msdownload',
- });
- elink.href = URL.createObjectURL(blob);
- document.body.appendChild(elink);
- elink.click();
- document.body.removeChild(elink);
- loading.value = false;
- });
-};
-// 图斑上传
-const uploadFlightFile = async (file, t) => {
- loading.value = true;
- try {
- const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1);
- if (!['kmz', 'kml', 'zip'].includes(fileSuffix)) {
- ElMessage.error('请上传zip/kmz/kml格式的文件');
- return;
- }
- box.value = false;
- let data = new FormData();
- let type = t === '3' ? '' : t;
- const params = {
- file: file,
- fileName: ruleForm.name,
- LotTypeId: ruleForm.region,
- };
-
- Object.keys(params).forEach(key => {
- data.append(key, params[key]);
- });
-
- const res = await uploadManagementApi(data);
- if (res.data.code !== 0) {
- ElMessage.error('上传失败');
- return;
- }
-
- ElMessage.success('上传成功');
-
- // 重置表单
- ruleForm.name = '';
- ruleForm.region = '';
- if (ruleFormRef.value) {
- ruleFormRef.value.resetFields();
- }
-
- searchReset();
- } catch (error) {
- loading.value = false;
- } finally {
- loading.value = false;
- }
-};
-provide('searchReset', searchReset);
-onMounted(() => {
- getsearchManagementApi();
- getlistOfSpotTypesApi();
-});
-</script>
-
-<style scoped lang="scss">
-.center-align :deep(.el-form-item__content) {
- justify-content: center !important;
-}
-</style>
--
Gitblit v1.9.3