map-right-poly.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="right-layout">
  3. <div class="right-content">
  4. <div class="tree-layout">
  5. <p class="sub-title">全部数据</p>
  6. <div class="poly-list">
  7. <template v-if="data.polygons.length > 0" v-for="item in data.polygons">
  8. <div class="poly-list-item">
  9. <div class="left">
  10. <span>{{ item.name ? item.name : "本体边界" + item.id }}</span>
  11. </div>
  12. <div class="right">
  13. <el-icon class="icon">
  14. <Delete @click="del(item.id)" />
  15. </el-icon>
  16. <el-icon class="icon">
  17. <Edit @click="handleShowEditModel(item)" />
  18. </el-icon>
  19. <el-icon class="icon">
  20. <Download @click="handleDownload(item)" />
  21. </el-icon>
  22. </div>
  23. </div>
  24. </template>
  25. <template v-else>
  26. <div class="empty">暂没数据</div>
  27. </template>
  28. </div>
  29. </div>
  30. </div>
  31. <SingleInput :visible="isShowPolyEditName" @update:visible="isShowPolyEditName = false" :value="currentPoly.name"
  32. :update-value="updatePolyName" title="修改边界名称" />
  33. </div>
  34. </template>
  35. <script setup lang="ts">
  36. import { ref, watchEffect } from "vue";
  37. import type { PolyDataType, DrawingDataType } from "@/request/drawing.ts";
  38. import { Delete, Download, Edit } from "@element-plus/icons-vue";
  39. import SingleInput from "@/components/single-input.vue";
  40. import { downloadPointsXLSL2 } from "@/util/pc4xlsl";
  41. import { scenePoints } from "@/store/scene";
  42. import { relics } from "@/store/relics";
  43. import { ElMessageBox } from "element-plus";
  44. import { getWholeLinePolygonPoints } from "drawing-board";
  45. const props = defineProps<{
  46. data: DrawingDataType | null;
  47. }>();
  48. const emit = defineEmits<{
  49. (e: "del", id: string): void;
  50. (e: "edit", data: PolyDataType): void;
  51. // (e: "edit", id: string): void;
  52. }>();
  53. const relicsName = ref("");
  54. const currentPoly = ref<PolyDataType>({
  55. id: "",
  56. name: "",
  57. lineIds: [],
  58. });
  59. const isShowPolyEditName = ref(false);
  60. watchEffect(() => {
  61. relicsName.value = relics.value?.name || "";
  62. console.log("props", props.data);
  63. });
  64. const updatePolyName = (name: string) => {
  65. currentPoly.value.name = name;
  66. emit("edit", currentPoly.value);
  67. };
  68. const handleShowEditModel = (item: PolyDataType) => {
  69. isShowPolyEditName.value = true;
  70. currentPoly.value = item;
  71. };
  72. const del = async (id: string) => {
  73. const ok = await ElMessageBox.confirm("确定要删除吗", {
  74. type: "warning",
  75. });
  76. if (ok) {
  77. emit("del", id);
  78. }
  79. };
  80. const handleDownload = async (item: any) => {
  81. const polygonPoints: any[] = getWholeLinePolygonPoints(props.data as any, item.id);
  82. const points = polygonPoints.map((p) => {
  83. const pos = [p.x, p.y, 0];
  84. if (p.rtk) {
  85. const sPoint = scenePoints.value.find(({ id }) => id.toString() === p.title);
  86. if (sPoint) {
  87. pos[2] = sPoint.pos[2];
  88. }
  89. }
  90. return pos;
  91. });
  92. const dists = polygonPoints.map((p) => ({
  93. title: p.id,
  94. desc: p.title || p.id,
  95. }));
  96. await downloadPointsXLSL2(
  97. points,
  98. dists,
  99. `${item.name ? item.name : "本体边界" + item.id}`
  100. );
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .tree-item {
  105. display: flex;
  106. width: calc(100% - 50px);
  107. align-items: center;
  108. justify-content: space-between;
  109. .title {
  110. flex: 1;
  111. overflow: hidden;
  112. text-overflow: ellipsis; //文本溢出显示省略号
  113. white-space: nowrap; //文本不会换行
  114. }
  115. .oper {
  116. flex: none;
  117. }
  118. }
  119. .disable {
  120. pointer-events: all;
  121. }
  122. .tree-layout {
  123. p {
  124. color: #303133;
  125. font-size: 14px;
  126. }
  127. .sub-title {
  128. font-size: 14px;
  129. font-weight: bolder;
  130. margin-bottom: 30px;
  131. }
  132. }
  133. .right-layout {
  134. display: flex;
  135. height: 100%;
  136. flex-direction: column;
  137. font-size: 16px;
  138. .right-content {
  139. flex: 1;
  140. overflow-y: auto;
  141. }
  142. }
  143. .tree-layout .tree-scene-name {
  144. font-size: 10px;
  145. margin: 0;
  146. color: #999;
  147. }
  148. .poly-list {
  149. width: 100%;
  150. display: flex;
  151. flex-direction: column;
  152. font-size: 14px;
  153. user-select: none;
  154. .poly-list-item {
  155. width: 100%;
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: space-between;
  159. align-items: center;
  160. margin-bottom: 10px;
  161. .icon {
  162. margin-left: 8px;
  163. font-size: 16px;
  164. color: #409eff;
  165. cursor: pointer;
  166. }
  167. }
  168. .empty {
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. font-size: 13px;
  173. color: gray;
  174. padding-top: 40px;
  175. }
  176. }
  177. </style>