index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="layer">
  3. <login />
  4. <ly-top class="top" />
  5. <ly-slide class="slide" :names="menuRouteNames" v-if="!hiddenSlide" />
  6. <div class="content">
  7. <router-view v-slot="{ Component }" v-if="isSystem">
  8. <component :is="Component" />
  9. </router-view>
  10. <template v-else>
  11. <div class="view" :class="{ full: hiddenSlide }">
  12. <div class="main p-4" :class="{ fullmain: hiddenSlide }">
  13. <router-view v-slot="{ Component }">
  14. <component :is="Component" />
  15. </router-view>
  16. </div>
  17. <!-- <div class="app-wrap m-4" v-if="!hiddenSlide">
  18. <div
  19. class="app-scene"
  20. ref="sceneRef"
  21. :style="{
  22. width: '100%',
  23. height: 'calc(100% - 24px)',
  24. }"
  25. >
  26. <iframe
  27. v-if="caseId"
  28. :key="qpisceneList.length"
  29. :src="'https://survey.4dkankan.com' + sceneURL"
  30. frameborder="0"
  31. :style="{ width: '100%', height: '100%' }"
  32. ></iframe>
  33. </div>
  34. </div> -->
  35. </div>
  36. </template>
  37. </div>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import lyTop from "./top/index.vue";
  42. import login from "./loginDialog.vue";
  43. import lySlide from "./slide/index.vue";
  44. import { routeIsSystem, router } from "@/router";
  45. import { computed, ref, onMounted, watch } from "vue";
  46. import { menuRouteNames } from "@/app";
  47. import {
  48. updateByTreeFileLists,
  49. getCaseSceneListData,
  50. getUrlSrc,
  51. getcaseLists,
  52. getCaseSceneList,
  53. Extract,
  54. } from "@/store/case";
  55. import { json } from "stream/consumers";
  56. console.log(menuRouteNames, "menuRouteNames", router.currentRoute.value.name);
  57. const isSystem = computed(() => routeIsSystem());
  58. const caseId = computed(() => {
  59. const caseId = router.currentRoute.value.params.caseId;
  60. if (caseId) {
  61. return Number(caseId);
  62. }
  63. });
  64. // const qpisceneList = ref(getCaseSceneListData() as any[]);
  65. const sceneList = ref([]);
  66. const sceneURL = ref(`/code/index.html?caseId=${caseId.value}#/show`);
  67. const sceneListName = ref("");
  68. const modeList = ref([]);
  69. const init = async () => {
  70. modeList.value =
  71. modeList.value.length == 0
  72. ? await getcaseLists(caseId.value as number)
  73. : modeList.value;
  74. let listss = await getCaseSceneList(caseId.value as number);
  75. sceneList.value = listss;
  76. if (listss.length) {
  77. // sceneList.value.unshift({ id: -1, type: 99, name: "多元融合" });
  78. let url = getUrlSrc({ id: 0, ...listss[0] }, caseId.value);
  79. sceneURL.value = url;
  80. }
  81. console.log("init", modeList.value, sceneList.value, modeList.value.length);
  82. // handleCommand();
  83. // let url = getUrlSrc({ id: 0 }, caseId.value)
  84. // sceneURL.value = url;
  85. };
  86. init();
  87. const qpisceneList = computed(() =>
  88. getCaseSceneListData(caseId.value as number)
  89. );
  90. watch(
  91. () => Extract.value,
  92. () => {
  93. if (Extract.value) {
  94. sceneURL.value = sceneURL.value + "#/repair";
  95. } else {
  96. sceneURL.value = sceneURL.value.replace("#/repair", "");
  97. }
  98. console.log(Extract.value, "Extract");
  99. }
  100. );
  101. onMounted(() => {
  102. // setupSDK(document.querySelector('iframe') as HTMLIFrameElement)
  103. });
  104. updateByTreeFileLists();
  105. const hiddenSlide = computed(
  106. () => !menuRouteNames.includes(router.currentRoute.value.name as string)
  107. );
  108. const handleCommand = (command) => {
  109. let newid = command || sceneList.value[0].id;
  110. console.log("handleCommand", command, newid, sceneList.value);
  111. let item = sceneList.value.find((item) => item.id == newid);
  112. sceneListName.value = item.name;
  113. let url = getUrlSrc(item, caseId.value);
  114. sceneURL.value = url;
  115. console.log("handleCommand", command, item, url);
  116. };
  117. const handleClick = (command: string) => {
  118. console.log("handleClick", command);
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .layer {
  123. position: absolute;
  124. z-index: 1;
  125. width: 100%;
  126. height: 100%;
  127. display: flex;
  128. flex-direction: column;
  129. .top {
  130. flex: 0 0 auto;
  131. }
  132. .content {
  133. flex: 1 0;
  134. display: flex;
  135. overflow: hidden;
  136. .slide {
  137. width: 100%;
  138. flex: 0 0 auto;
  139. }
  140. .view {
  141. flex: 0 0 auto;
  142. width: 100%;
  143. background-color: var(--bgColor);
  144. // flex-direction: column;
  145. display: flex;
  146. &.full {
  147. width: 100%;
  148. }
  149. .app-wrap,
  150. .app-view {
  151. width: calc(100% - 640px);
  152. height: 100%;
  153. }
  154. .player {
  155. flex: 0 0 auto;
  156. height: 32px;
  157. }
  158. .main {
  159. margin: 0 0px 10px 0;
  160. display: flex;
  161. flex-direction: column;
  162. overflow: hidden;
  163. flex: 1;
  164. background: #fff;
  165. padding: 1rem 20px 1rem 32px;
  166. border-top: 1px solid #e6e6e6;
  167. }
  168. .fullmain {
  169. background-color: var(--bgColor);
  170. overflow-y: scroll;
  171. }
  172. .app-scene {
  173. position: relative;
  174. }
  175. .sceneList {
  176. position: absolute;
  177. width: 200px;
  178. text-align: center;
  179. left: calc(50% - 100px);
  180. top: 42px;
  181. color: #fff;
  182. font-weight: bold;
  183. }
  184. // .sceneList{
  185. // width: 48px;
  186. // height: 38px;
  187. // position: absolute;
  188. // left: 10px;
  189. // top: 10px;
  190. // padding: 6px 0;
  191. // line-height: 42px;
  192. // background: rgba(27, 27, 28, 0.80);
  193. // text-align: center;
  194. // cursor: pointer;
  195. // }
  196. }
  197. }
  198. }
  199. </style>
  200. <style lang="scss">
  201. .el-dropdown {
  202. width: 200px;
  203. }
  204. </style>