map-right.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="right-layout">
  3. <div class="right-content">
  4. <el-form :inline="false" v-if="router.currentRoute.value.name === 'map'">
  5. <el-form-item v-if="relics">
  6. <el-input v-model="relicsName" :maxlength="50" placeholder="不可移动文物名称">
  7. <template #append>
  8. <el-button type="primary" @click="updateRelics">修改</el-button>
  9. </template>
  10. </el-input>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" :icon="Plus" style="width: 100%" @click="addHandler">
  14. 添加场景
  15. </el-button>
  16. </el-form-item>
  17. </el-form>
  18. <div class="tree-layout">
  19. <p>全部数据</p>
  20. <el-tree
  21. style="max-width: 600px"
  22. :data="treeNode"
  23. node-key="id"
  24. ref="treeRef"
  25. show-checkbox
  26. default-expand-all
  27. :expand-on-click-node="false"
  28. >
  29. <template #default="{ node, data }">
  30. <div
  31. class="tree-item"
  32. @click="!data.disable && emit((data.type === 'scene' ? 'flyScene' : 'flyPoint') as any, data.raw)"
  33. >
  34. <el-tooltip
  35. v-if="data.type === 'scene'"
  36. class="box-item"
  37. effect="dark"
  38. :content="data.raw.sceneName + ' ' + node.label"
  39. placement="top"
  40. >
  41. <span :class="{ disable: data.disable }" class="title">
  42. <el-icon> <Grid /> </el-icon>
  43. {{ data.raw.sceneName }}
  44. <span class="tree-scene-name">{{ node.label }}</span>
  45. </span>
  46. </el-tooltip>
  47. <span :class="{ disable: data.disable }" class="title" v-else>
  48. <el-icon>
  49. <LocationInformation />
  50. </el-icon>
  51. {{ node.label }}
  52. </span>
  53. <span class="oper">
  54. <template v-if="router.currentRoute.value.name === 'map'">
  55. <template v-if="data.type === 'scene'">
  56. <el-icon color="#409efc" v-if="data.raw.creationMethod !== 2">
  57. <Delete @click.stop="delRelicsScene(data.raw)" />
  58. </el-icon>
  59. </template>
  60. <el-icon v-else color="#409efc">
  61. <Edit @click.stop="inputPoint = data.raw" />
  62. </el-icon>
  63. </template>
  64. <el-icon color="#409efc" style="margin-left: 8px">
  65. <Link
  66. @click.stop="
  67. data.type === 'scene'
  68. ? gotoScene(data.raw)
  69. : emit('gotoPoint', data.raw)
  70. "
  71. />
  72. </el-icon>
  73. </span>
  74. </div>
  75. </template>
  76. </el-tree>
  77. </div>
  78. </div>
  79. <el-button
  80. type="primary"
  81. :icon="Document"
  82. style="width: 100%"
  83. @click="exportFile(getSelectPoints())"
  84. >
  85. 导出四普数据
  86. </el-button>
  87. <el-button
  88. type="primary"
  89. :icon="Document"
  90. style="width: 100%; margin-top: 20px; margin-left: 0"
  91. @click="
  92. exportImage(
  93. getSelectPoints().filter(
  94. (point) => getPointSelect(point)?.cameraType === DeviceType.VR
  95. )
  96. )
  97. "
  98. >
  99. 下载全景图
  100. </el-button>
  101. </div>
  102. <SingleInput
  103. :visible="!!inputPoint"
  104. @update:visible="inputPoint = null"
  105. :value="inputPoint?.name || ''"
  106. :update-value="updatePointName"
  107. title="修改点位名称"
  108. />
  109. </template>
  110. <script setup lang="ts">
  111. import {
  112. Plus,
  113. Delete,
  114. Document,
  115. Grid,
  116. LocationInformation,
  117. Edit,
  118. Link,
  119. } from "@element-plus/icons-vue";
  120. import { computed, ref, watchEffect } from "vue";
  121. import {
  122. Scene,
  123. scenes,
  124. ScenePoint,
  125. delRelicsScene,
  126. updateScenePointName,
  127. gotoScene,
  128. relicsId,
  129. refreshScenes,
  130. } from "@/store/scene";
  131. import { relics, updateRelicsName } from "@/store/relics";
  132. import SingleInput from "@/components/single-input.vue";
  133. import { ElMessage } from "element-plus";
  134. import { router } from "@/router";
  135. import { selectScenes } from "../quisk";
  136. import { addRelicsSceneFetch, delRelicsSceneFetch } from "@/request";
  137. import { exportFile, exportImage } from "./pc4Helper";
  138. import { DeviceType } from "@/store/device";
  139. const emit = defineEmits<{
  140. (e: "flyScene", data: Scene): void;
  141. (e: "flyPoint", data: ScenePoint): void;
  142. (e: "gotoPoint", data: ScenePoint): void;
  143. }>();
  144. const inputPoint = ref<ScenePoint | null>(null);
  145. const updatePointName = async (title: string) => {
  146. await updateScenePointName(inputPoint.value!, title);
  147. };
  148. const relicsName = ref("");
  149. watchEffect(() => (relicsName.value = relics.value?.name || ""));
  150. const updateRelics = async () => {
  151. await updateRelicsName(relicsName.value);
  152. ElMessage.success("修改成功");
  153. };
  154. const treeRef = ref<any>();
  155. const treeNode = computed(() =>
  156. scenes.value.map((scene) => ({
  157. label: scene.sceneCode,
  158. id: scene.id,
  159. type: "scene",
  160. disable: scene.scenePos.every((pos) => !pos.pos || pos.pos.length === 0),
  161. raw: scene,
  162. children: scene.scenePos.map((pos) => ({
  163. label: pos.name,
  164. disable: !pos.pos || pos.pos.length === 0,
  165. id: pos.id,
  166. type: "point",
  167. raw: pos,
  168. })),
  169. }))
  170. );
  171. const getSelectPoints = () =>
  172. treeRef
  173. .value!.getCheckedNodes(false, false)
  174. .filter((option: any) => option.type === "point")
  175. .map((option: any) => option.raw) as ScenePoint[];
  176. const getPointSelect = (point: ScenePoint) =>
  177. scenes.value.find((scene) => scene.sceneCode === point.sceneCode);
  178. const addHandler = async () => {
  179. const sceneCodes = scenes.value.map((scene) => scene.sceneCode);
  180. await selectScenes({
  181. sceneCodes: sceneCodes,
  182. selfSceneCodes: scenes.value
  183. .filter((scene) => scene.creationMethod === 2)
  184. .map((scene) => scene.sceneCode),
  185. submit: async (nSceneCodes) => {
  186. const requests: Promise<any>[] = [];
  187. for (let i = 0; i < sceneCodes.length; i++) {
  188. if (!nSceneCodes.includes(sceneCodes[i])) {
  189. requests.push(delRelicsSceneFetch(relicsId.value, scenes.value[i].id));
  190. }
  191. }
  192. for (let i = 0; i < nSceneCodes.length; i++) {
  193. if (!sceneCodes.includes(nSceneCodes[i])) {
  194. requests.push(addSceneHandler(nSceneCodes[i]));
  195. }
  196. }
  197. await Promise.all(requests);
  198. },
  199. });
  200. await refreshScenes();
  201. };
  202. const addSceneHandler = async (sceneCode: string) => {
  203. const sceneTypes = ["SS", "KJ", "SG"];
  204. if (sceneTypes.every((type) => !sceneCode.startsWith(type))) {
  205. ElMessage.error("场景码不正确");
  206. throw "场景码不正确";
  207. } else {
  208. await addRelicsSceneFetch(relicsId.value!, sceneCode);
  209. }
  210. };
  211. </script>
  212. <style lang="scss" scoped>
  213. .tree-item {
  214. display: flex;
  215. width: calc(100% - 50px);
  216. align-items: center;
  217. justify-content: space-between;
  218. .title {
  219. flex: 1;
  220. overflow: hidden;
  221. text-overflow: ellipsis; //文本溢出显示省略号
  222. white-space: nowrap; //文本不会换行
  223. }
  224. .oper {
  225. flex: none;
  226. }
  227. }
  228. .tree-layout {
  229. p {
  230. color: #303133;
  231. font-size: 14px;
  232. }
  233. }
  234. .right-layout {
  235. display: flex;
  236. height: 100%;
  237. flex-direction: column;
  238. .right-content {
  239. flex: 1;
  240. overflow-y: auto;
  241. }
  242. }
  243. .tree-layout .tree-scene-name {
  244. font-size: 10px;
  245. margin: 0;
  246. color: #999;
  247. }
  248. </style>