123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <div class="right-layout" @click.stop="selectChange(null)">
- <div class="right-content">
- <div class="tree-layout">
- <p class="sub-title">全部数据</p>
- <div class="poly-list">
- <template v-if="boardData.polygons.length > 0">
- <div
- v-for="item in boardData.polygons"
- class="poly-list-item"
- :class="{
- active: [
- boardStatus.lightPolygonId,
- boardStatus.editPolygonId,
- selectId,
- ].includes(item.id),
- }"
- @mouseenter="!selectId && (boardStatus.lightPolygonId = item.id)"
- @mouseleave="!selectId && (boardStatus.lightPolygonId = null)"
- @click.stop="!currentItem && selectChange(item.id)"
- >
- <div class="left">
- <span>{{ item.name ? item.name : "本体边界" + item.id }}</span>
- </div>
- <div
- class="right"
- @click.stop
- v-if="!boardStatus.editPolygonId && !queryMode"
- >
- <el-icon class="icon">
- <Delete @click="del(item.id)" />
- </el-icon>
- <el-icon class="icon">
- <Edit @click="handleShowEditModel(item)" />
- </el-icon>
- <el-icon class="icon">
- <Download @click="handleDownload(item)" />
- </el-icon>
- </div>
- </div>
- </template>
- <template v-else>
- <div class="empty">暂没数据</div>
- </template>
- </div>
- </div>
- </div>
- </div>
- <Teleport to="body" v-if="!queryMode">
- <div class="draw-global-icon" @click="cleanupEdit ? cleanupEdit() : enterEdit()">
- <el-icon size="36">
- <Check v-if="cleanupEdit" />
- <picpenIcon v-else />
- </el-icon>
- </div>
- <SingleInput
- v-if="selectItem"
- :visible="isShowPolyEditName"
- @update:visible="isShowPolyEditName = false"
- :value="selectItem.name || ''"
- :update-value="(name) => boardDataChange(() => (selectItem.name = name))"
- placeholder="请输入"
- title="修改边界名称"
- />
- </Teleport>
- </template>
- <script setup lang="ts">
- import { computed, onBeforeUnmount, ref, shallowRef, watch } from "vue";
- import type { PolyDataType } from "@/request/drawing.ts";
- import { Delete, Download, Edit, Check } from "@element-plus/icons-vue";
- import SingleInput from "@/components/single-input.vue";
- import { downloadPointsXLSL1 } from "@/util/pc4xlsl";
- import { boardData, scenePoints } from "@/store/scene";
- import { getWholeLinePolygonPoints } from "drawing-board";
- import { board, boardDataChange, mapManage, queryMode } from "./install";
- import { confirm } from "@/helper/message";
- import picpenIcon from "@/assets/pic_pen.svg";
- const boardStatus = board.polygon.status;
- const selectId = ref<string>();
- const selectChange = (id: string) => {
- if (currentItem.value) return;
- if (selectId.value === id) {
- boardStatus.lightPolygonId = null;
- selectId.value = null;
- } else {
- selectId.value = id;
- if (!selectItem.value) {
- selectChange(null);
- } else {
- boardStatus.lightPolygonId = selectItem.value.id;
- const points = getWholeLinePolygonPoints(boardData.value, selectItem.value.id);
- if (points.length) {
- const total = points.reduce((t, p) => [t[0] + p.x, t[1] + p.y], [0, 0]);
- mapManage.map
- .getView()
- .setCenter([total[0] / points.length, total[1] / points.length]);
- }
- }
- }
- };
- board.polygon.bus.on("activePolygonId", selectChange);
- const selectItem = computed(() =>
- boardData.value.polygons.find(({ id }) => id === selectId.value)
- );
- const currentItem = computed(() =>
- boardData.value.polygons.find(({ id }) => id === boardStatus.editPolygonId)
- );
- const cleanupEdit = shallowRef<() => void>();
- const enterEdit = () => {
- cleanupEdit.value && cleanupEdit.value();
- const quitEdit = board.polygon.editPolygon(selectId.value);
- let needUpdate = false;
- const stopWatch = watch(
- () => currentItem.value,
- () => (needUpdate = true),
- { deep: true }
- );
- cleanupEdit.value = () => {
- board.polygon.bus.off("penEndHandler", cleanupEdit.value);
- quitEdit();
- selectChange(null);
- stopWatch();
- needUpdate && boardDataChange();
- cleanupEdit.value = null;
- };
- board.polygon.bus.on("penEndHandler", cleanupEdit.value);
- };
- onBeforeUnmount(() => {
- cleanupEdit.value && cleanupEdit.value();
- board.polygon.status.lightPointId = null;
- });
- const isShowPolyEditName = ref(false);
- const handleShowEditModel = (item: PolyDataType) => {
- selectChange(item.id);
- isShowPolyEditName.value = true;
- };
- const del = async (id: string) => {
- if ((await confirm("确定要删除吗")) && !currentItem.value) {
- boardDataChange(() => board.polygon.removePolygon(id));
- }
- };
- const handleDownload = async (item: any) => {
- const polygonPoints: any[] = getWholeLinePolygonPoints(boardData.value, item.id);
- const points = polygonPoints.map((p) => {
- const pos = [p.x, p.y, 0];
- if (p.rtk) {
- const sPoint = scenePoints.value.find(({ id }) => id.toString() === p.title);
- if (sPoint) {
- pos[2] = sPoint.pos[2];
- }
- }
- return pos;
- });
- const dists = polygonPoints.map((p) => ({
- title: p.id,
- desc: p.title || p.id,
- }));
- await downloadPointsXLSL1(
- points,
- dists,
- `${item.name ? item.name : "本体边界" + item.id}`
- );
- };
- </script>
- <style lang="scss" scoped>
- .tree-item {
- display: flex;
- width: calc(100% - 50px);
- align-items: center;
- justify-content: space-between;
- .title {
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis; //文本溢出显示省略号
- white-space: nowrap; //文本不会换行
- }
- .oper {
- flex: none;
- }
- }
- .disable {
- pointer-events: all;
- }
- .tree-layout {
- p {
- color: #303133;
- font-size: 14px;
- }
- .sub-title {
- font-size: 14px;
- font-weight: bolder;
- margin-bottom: 30px;
- }
- }
- .right-layout {
- display: flex;
- height: 100%;
- flex-direction: column;
- font-size: 16px;
- .right-content {
- flex: 1;
- overflow-y: auto;
- }
- }
- .tree-layout .tree-scene-name {
- font-size: 10px;
- margin: 0;
- color: #999;
- }
- .poly-list {
- width: 100%;
- display: flex;
- flex-direction: column;
- font-size: 14px;
- user-select: none;
- .poly-list-item {
- cursor: pointer;
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10px;
- &.active {
- color: #409eff;
- }
- .icon {
- margin-left: 8px;
- font-size: 16px;
- color: #409eff;
- cursor: pointer;
- }
- }
- .empty {
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 13px;
- color: gray;
- padding-top: 40px;
- }
- }
- .draw-global-icon {
- width: 64px;
- height: 64px;
- background: #ffffff;
- border-radius: 50%;
- position: fixed;
- z-index: 1000;
- transform: translateX(calc(-1 * calc(50% - 300px)));
- left: calc(50% - 300px);
- top: 90%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- color: #409eff;
- }
- </style>
|