1
0

index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="photo">
  3. <div class="left">
  4. <div class="upload">
  5. <el-button type="primary" @click="addCaseFileHandler">
  6. 上传照片
  7. </el-button>
  8. <el-button
  9. type="primary"
  10. @click="sortType = !sortType"
  11. :icon="sortType ? FullScreen : Menu"
  12. >{{ sortType ? "横排" : "竖排" }}</el-button
  13. >
  14. </div>
  15. <draggable
  16. ref="childRef"
  17. :caseId="caseId"
  18. :sortType="sortType"
  19. @changeList="changeList"
  20. @handleItem="handleItem"
  21. />
  22. </div>
  23. <div class="right">
  24. <div class="tools">
  25. <el-button @click="handleMark">标注方向</el-button>
  26. <el-button @click="handleLine">标注连线</el-button>
  27. <el-button @click="handleSave">保存</el-button>
  28. </div>
  29. <swiper
  30. class="swiper"
  31. v-if="false"
  32. slides-per-view="auto"
  33. :space-between="24"
  34. :centeredSlides="true"
  35. @swiper="onSwiper"
  36. style="height: 100%"
  37. @slideChange="onSlideChange"
  38. >
  39. <swiper-slide
  40. class="swiperItem"
  41. v-for="(item, index) in newlist"
  42. :key="index"
  43. >
  44. <div class="swiperList">
  45. <div
  46. class="itemper"
  47. :class="{ oneItemper: sortType }"
  48. v-for="eleItem in item"
  49. :key="eleItem"
  50. >
  51. <img class="itemImg" :src="eleItem.imgUrl" alt="" />
  52. <div class="text">{{ eleItem.imgInfo }}</div>
  53. </div>
  54. <div class="page">
  55. <span style="margin-right: 16px">第 {{ index + 1 }} 页</span>
  56. <span>共 {{ newlist.length }} 页</span>
  57. </div>
  58. </div>
  59. </swiper-slide>
  60. </swiper>
  61. <canvas id="canvas" v-show="true"></canvas>
  62. </div>
  63. </div>
  64. </template>
  65. <script setup>
  66. import { onMounted, ref } from "vue";
  67. import { Menu, FullScreen } from "@element-plus/icons-vue";
  68. import { Swiper, SwiperSlide } from "swiper/vue";
  69. import "swiper/css";
  70. // import { addCaseFile } from "@/store/caseFile";
  71. import { addCaseImgFile } from "../quisk";
  72. import { saveCaseImgTagData } from "@/store/case";
  73. import Scene from "@/core/Scene.js";
  74. import draggable from "./draggable.vue";
  75. const props = defineProps({ caseId: Number });
  76. const newlist = ref([]);
  77. const swiperRef = ref(null);
  78. const childRef = ref(null);
  79. const caseId = ref(props.caseId);
  80. const sortType = ref(false);
  81. let scene = null;
  82. const addCaseFileHandler = async () => {
  83. await addCaseImgFile({
  84. caseId: caseId.value,
  85. data: {
  86. imgUrl: "",
  87. imgInfo: "",
  88. id: "",
  89. sort: "",
  90. },
  91. });
  92. refresh();
  93. };
  94. function refresh() {
  95. console.log("changeList", childRef.value);
  96. if (childRef.value) {
  97. childRef.value.getList();
  98. }
  99. }
  100. const changeList = (list) => {
  101. let newList = [];
  102. list.map((item, index) => {
  103. if (sortType.value) {
  104. newList.push([item]);
  105. } else {
  106. if (index % 2 == 0) {
  107. let newItem = list[index + 1] ? [item, list[index + 1]] : [item];
  108. newList.push(newItem);
  109. }
  110. }
  111. });
  112. newlist.value = newList;
  113. const arr = [];
  114. newList.map((i) => arr.push(JSON.parse(JSON.stringify(i))));
  115. const type = sortType.value ? 2 : 1;
  116. if (scene) {
  117. scene.load(arr, type);
  118. console.log("changeList", arr, type);
  119. }
  120. };
  121. const renderCanvas = () => {
  122. const canvas = document.getElementById("canvas");
  123. // console.log(canvas)
  124. scene = new Scene(canvas);
  125. scene.init();
  126. window.scene = scene;
  127. };
  128. const onSwiper = (swiper) => {
  129. console.log("onSwiper");
  130. swiperRef.value = swiper;
  131. };
  132. const onSlideChange = (swiper) => {
  133. console.log(swiper);
  134. };
  135. const handleItem = (item) => {
  136. let active = sortType.value ? item : Math.floor(item / 2);
  137. swiperRef.value.slideTo(active);
  138. console.log("handleItem", item, active);
  139. };
  140. const handleDetele = async (item) => {
  141. if (
  142. await confirm("删除该场景,将同时从案件和融合模型中移除,确定要删除吗?")
  143. ) {
  144. const scenes = getCaseScenes(list.value.filter((item) => item !== scene));
  145. await replaceCaseScenes(props.caseId, scenes);
  146. refresh();
  147. }
  148. };
  149. const handleMark = () => {
  150. if (window.scene) {
  151. window.scene.player.setMode(2);
  152. }
  153. };
  154. const handleLine = () => {
  155. if (window.scene) {
  156. window.scene.player.setMode(1);
  157. }
  158. };
  159. const handleSave = () => {
  160. if (window.scene) {
  161. }
  162. };
  163. onMounted(() => {
  164. renderCanvas();
  165. });
  166. </script>
  167. <style lang="scss" scoped>
  168. #canvas {
  169. width: 100%;
  170. height: 100%;
  171. }
  172. .photo {
  173. display: flex;
  174. height: 100%;
  175. .left {
  176. width: 260px;
  177. padding: 16px 24px 30px 0;
  178. height: calc(100% - 46.16px);
  179. overflow-y: auto;
  180. background: #ffffff;
  181. box-shadow: 10px 0 10px -10px rgba(0, 0, 0, 0.15);
  182. // box-shadow: 0px 2px 8px 0px rgba(0,0,0,0.15);
  183. }
  184. .right {
  185. width: calc(100% - 260px);
  186. background-color: var(--bgColor);
  187. padding-left: 24px;
  188. height: calc(100% - 0px);
  189. position: relative;
  190. .tools {
  191. position: absolute;
  192. top: 15px;
  193. left: 30px;
  194. }
  195. .swiperItem {
  196. height: calc(100vh - 155.16px);
  197. width: calc((100vh - 156.16px) * 0.707);
  198. background: #ffffff;
  199. .swiperList {
  200. padding: 0 60px;
  201. height: 100%;
  202. .page {
  203. font-weight: 400;
  204. font-size: 12px;
  205. color: rgba(0, 0, 0, 0.85);
  206. line-height: 22px;
  207. text-align: right;
  208. margin-top: 30px;
  209. }
  210. .itemper {
  211. height: calc(50% - 100px);
  212. padding: 60px 0 0 0;
  213. .text {
  214. margin-top: 16px;
  215. border-radius: 0px 0px 0px 0px;
  216. border: 1px dotted #cccccc;
  217. text-align: center;
  218. font-family: Microsoft YaHei, Microsoft YaHei;
  219. font-weight: 400;
  220. font-size: 14px;
  221. line-height: 30px;
  222. color: rgba(0, 0, 0, 0.85);
  223. }
  224. .itemImg {
  225. width: 100%;
  226. height: calc(100% - 48px);
  227. display: block;
  228. object-fit: cover;
  229. }
  230. }
  231. .oneItemper {
  232. height: calc(100% - 120px);
  233. .itemImg {
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </style>