Files
electron-4/src/renderer/src/views/components/propertyBox/TerrainExcavation.vue

105 lines
2.8 KiB
Vue
Raw Normal View History

2025-09-10 10:31:32 +08:00
<template>
2025-09-05 18:28:31 +08:00
<Dialog ref="baseDialog" title="地形开挖" left="180px" top="100px" :closeCallback="closeCallBack">
<template #content>
<span class="custom-divider"></span>
<div class="div-item">
<div class="row">
<div class="col">
<span class="label" style="flex: 0 0 70px">挖掘高度</span>
<div class="input-number input-number-unit-1">
<input
class="input"
type="number"
id="height"
title=""
min="0"
max="5000000"
v-model="height"
@input="heightInput"
@change="changeHeight"
/>
<span class="unit">m</span>
<span class="arrow"></span>
</div>
</div>
</div>
</div>
<span class="custom-divider"></span>
<div class="div-item">
<div class="row">
<div class="col">
<span class="label">绘制开挖区域</span>
<button class="start-excavation" @click="draw">
<svg class="icon-edit"><use xlink:href="#yj-icon-edit"></use></svg>绘制
</button>
</div>
<div class="col">
<span class="label">清除开挖区域</span>
<button class="clean-excavation" @click="clear">
<svg class="icon-close"><use xlink:href="#yj-icon-close"></use></svg>清除
</button>
</div>
</div>
</div>
</template>
<template #footer>
2025-09-10 10:31:32 +08:00
<button @click="close">关闭</button>
2025-09-05 18:28:31 +08:00
</template>
</Dialog>
</template>
<script setup lang="ts">
2025-10-15 14:23:47 +08:00
import { ref, reactive, onBeforeUnmount } from 'vue'
2025-09-05 18:28:31 +08:00
import { inject } from 'vue'
import Dialog from '@/components/dialog/baseDialog.vue'
2025-09-05 19:45:46 +08:00
const baseDialog: any = ref(null)
const eventBus: any = inject('bus')
2025-09-05 18:28:31 +08:00
var height: any = ref(10)
var excavation: any = reactive([])
eventBus.on('terrainExcavationDialog', () => {
baseDialog.value?.open()
2025-09-10 10:31:32 +08:00
excavation = new (window as any).YJ.Analysis.TerrainExcavation(window.earth, { height: 10 })
2025-09-05 18:28:31 +08:00
})
2025-10-15 14:23:47 +08:00
const open = () => {
baseDialog.value?.open()
excavation = new (window as any).YJ.Analysis.TerrainExcavation(window.earth, { height: 10 })
}
2025-09-05 18:28:31 +08:00
const changeHeight = () => {
excavation.height = height.value
}
const heightInput = () => {
2025-10-15 14:23:47 +08:00
let dom: any = document.getElementById('height')
2025-09-05 18:28:31 +08:00
if (height.value < dom.min * 1) {
height.value = dom.min * 1
} else if (height.value > dom.max * 1) {
height.value = dom.max * 1
}
}
2025-09-10 10:31:32 +08:00
const closeCallBack = (e) => {
height.value = 10
}
2025-10-15 14:23:47 +08:00
onBeforeUnmount(() => {
closeCallBack('')
})
2025-09-05 18:28:31 +08:00
const close = (e) => {
baseDialog.value?.close()
}
const draw = (e) => {
excavation.startCreate()
}
const clear = (e) => {
excavation.clear()
}
2025-10-15 14:23:47 +08:00
defineExpose({
open
})
2025-09-05 18:28:31 +08:00
</script>
2025-09-10 10:31:32 +08:00
<style scoped lang="scss"></style>