index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="photo">
  3. <div class="left">
  4. <div class="upload">
  5. <el-button type="primary" @click="addCaseFileHandler"> 上传照片 </el-button>
  6. <el-button
  7. type="primary"
  8. @click="sortType = !sortType"
  9. :icon="sortType ? FullScreen : Menu"
  10. >{{ sortType ? "横排" : "竖排" }}</el-button
  11. >
  12. </div>
  13. <draggable ref="draggableRef" :caseId="caseId" :sortType="sortType" @changeList="changeList" @handleItem="handleItem" />
  14. </div>
  15. <div class="right">
  16. <swiper
  17. class="swiper"
  18. slides-per-view="auto"
  19. :space-between="24"
  20. :centeredSlides="true"
  21. @swiper="onSwiper"
  22. style="height: 100%"
  23. @slideChange="onSlideChange"
  24. >
  25. <swiper-slide class="swiperItem" v-for="(item, index) in newlist" :key="index">
  26. <div class="swiperList">
  27. <div
  28. class="itemper"
  29. :class="{ oneItemper: sortType }"
  30. v-for="eleItem in item"
  31. :key="eleItem"
  32. >
  33. <img
  34. class="itemImg"
  35. :src="eleItem.imgUrl"
  36. alt=""
  37. />
  38. <div class="text">{{ eleItem.imgInfo }}</div>
  39. </div>
  40. <div class="page">
  41. <span style="margin-right: 16px">第 {{ index + 1 }} 页</span>
  42. <span>共 {{ newlist.length }} 页</span>
  43. </div>
  44. </div>
  45. </swiper-slide>
  46. </swiper>
  47. </div>
  48. </div>
  49. </template>
  50. <script setup>
  51. import { ref } from "vue";
  52. import { Menu, FullScreen } from "@element-plus/icons-vue";
  53. import { Swiper, SwiperSlide } from "swiper/vue";
  54. import "swiper/css";
  55. // import { addCaseFile } from "@/store/caseFile";
  56. import { addCaseImgFile } from "../quisk";
  57. import draggable from './draggable.vue';
  58. const props = defineProps({ caseId: Number });
  59. const newlist = ref([]);
  60. const swiperRef = ref(null);
  61. const draggableRef = ref(null);
  62. const caseId = ref(props.caseId);
  63. const sortType = ref(false);
  64. const addCaseFileHandler = async () => {
  65. await addCaseImgFile({ caseId: caseId.value, data: {
  66. imgUrl: '',
  67. imgInfo: '',
  68. id: '',
  69. sort: '',
  70. } });
  71. refresh();
  72. };
  73. function refresh() {
  74. console.log("changeList", draggableRef.value);
  75. }
  76. const changeList = (list) => {
  77. let newList = [];
  78. list.map((item, index) => {
  79. if (sortType.value) {
  80. newList.push([item]);
  81. } else {
  82. if (index % 2 == 0) {
  83. let newItem = list[index + 1] ? [item, list[index + 1]] : [item];
  84. newList.push(newItem);
  85. }
  86. }
  87. });
  88. newlist.value = newList;
  89. console.log("changeList", newList);
  90. };
  91. const onSwiper = (swiper) => {
  92. swiperRef.value = swiper;
  93. };
  94. const onSlideChange = (swiper) => {
  95. console.log(swiper);
  96. };
  97. const handleItem = (item) => {
  98. let active = sortType.value ? item : Math.floor(item / 2);
  99. swiperRef.value.slideTo(active);
  100. console.log("handleItem", item, active);
  101. };
  102. const handleDetele = async (item) => {
  103. if (await confirm("删除该场景,将同时从案件和融合模型中移除,确定要删除吗?")) {
  104. const scenes = getCaseScenes(list.value.filter((item) => item !== scene));
  105. await replaceCaseScenes(props.caseId, scenes);
  106. refresh();
  107. }
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .photo {
  112. display: flex;
  113. height: 100%;
  114. .left {
  115. width: 260px;
  116. padding: 16px 24px 30px 0;
  117. height: calc(100% - 46.16px);
  118. overflow-y: auto;
  119. background: #ffffff;
  120. box-shadow: 10px 0 10px -10px rgba(0, 0, 0, 0.15);
  121. // box-shadow: 0px 2px 8px 0px rgba(0,0,0,0.15);
  122. }
  123. .right {
  124. width: calc(100% - 260px);
  125. background-color: var(--bgColor);
  126. padding-left: 24px;
  127. height: calc(100% - 0px);
  128. .swiperItem {
  129. height: calc(100vh - 155.16px);
  130. width: calc((100vh - 156.16px) * 0.707);
  131. background: #ffffff;
  132. .swiperList {
  133. padding: 0 60px;
  134. height: 100%;
  135. .page {
  136. font-weight: 400;
  137. font-size: 12px;
  138. color: rgba(0, 0, 0, 0.85);
  139. line-height: 22px;
  140. text-align: right;
  141. margin-top: 30px;
  142. }
  143. .itemper {
  144. height: calc(50% - 100px);
  145. padding: 60px 0 0 0;
  146. .text {
  147. margin-top: 16px;
  148. border-radius: 0px 0px 0px 0px;
  149. border: 1px dotted #cccccc;
  150. text-align: center;
  151. font-family: Microsoft YaHei, Microsoft YaHei;
  152. font-weight: 400;
  153. font-size: 14px;
  154. line-height: 30px;
  155. color: rgba(0, 0, 0, 0.85);
  156. }
  157. .itemImg {
  158. width: 100%;
  159. height: calc(100% - 48px);
  160. display: block;
  161. object-fit: cover;
  162. }
  163. }
  164. .oneItemper {
  165. height: calc(100% - 120px);
  166. .itemImg {
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. </style>