index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <MainPanel>
  3. <template v-slot:header>
  4. 现场图管理({{sortPhotos.length}})
  5. </template>
  6. <div class="photos-layout">
  7. <div class="photos">
  8. <div v-for="photo in sortPhotos" :key="photo.id" class="photo" @click="active = photo">
  9. <img :src="getStaticFile(photo.photoUrl)" />
  10. <p>{{ photo.title || '默认标题' }}</p>
  11. </div>
  12. </div>
  13. </div>
  14. </MainPanel>
  15. <FillSlide :data="sortPhotos" v-model:active="active" @quit="active = null" v-if="active">
  16. <template v-slot:header>
  17. <div class="btns">
  18. <ui-button width="100px" @click="gotoDraw()">修改</ui-button>
  19. </div>
  20. </template>
  21. <template v-slot:foot>
  22. <div class="foot">
  23. <ui-icon type="close" @click="delPhoto" ctrl />
  24. </div>
  25. </template>
  26. </FillSlide>
  27. </template>
  28. <script setup lang="ts">
  29. import MainPanel from '@/components/main-panel/index.vue'
  30. import FillSlide from '@/components/fill-slide/index.vue'
  31. import {roadPhotos, RoadPhoto} from '@/store/roadPhotos'
  32. import {getStaticFile} from "@/dbo/main";
  33. import UiIcon from "@/components/base/components/icon/index.vue";
  34. import {router, writeRouteName} from '@/router'
  35. import {computed, ref} from "vue";
  36. import {Mode} from '@/views/graphic/menus'
  37. import UiButton from "@/components/base/components/button/index.vue";
  38. const sortPhotos = computed(() => roadPhotos.value.reverse())
  39. const active = ref<RoadPhoto>()
  40. const delPhoto = () => {
  41. const index = roadPhotos.value.indexOf(active.value)
  42. if (~index) {
  43. roadPhotos.value.splice(index, 1)
  44. }
  45. }
  46. const gotoDraw = () => {
  47. router.push({
  48. name: writeRouteName.graphic,
  49. params: {mode: Mode.Road, id: active.value.id, action: 'update'}
  50. })
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .photos-layout {
  55. position: absolute;
  56. top: calc(var(--header-top) + var(--editor-head-height));
  57. left: 0;
  58. right: 0;
  59. bottom: 0;
  60. }
  61. .photos {
  62. display: grid;
  63. grid-gap: 10px;
  64. padding: 10px;
  65. //grid-template-rows: auto;
  66. grid-template-columns: repeat(5, 1fr);
  67. }
  68. .photo img {
  69. width: 100%;
  70. }
  71. .photo p {
  72. color: #000;
  73. }
  74. .btns {
  75. display: flex;
  76. align-items: center;
  77. height: 100%;
  78. justify-content: center;
  79. }
  80. .foot {
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. color: #fff;
  85. height: 100%;
  86. }
  87. </style>