albumCarousel.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <album-carousel-item v-if="images" :farmId="farmId" :images="images" :lock="lock"></album-carousel-item>
  3. </template>
  4. <script setup>
  5. import { ref, computed, onMounted, onUnmounted, watch } from "vue";
  6. import "./cacheImg.js"
  7. import AlbumCarouselItem from "./albumCarouselItem";
  8. import {dateFormat} from "@/utils/date_util.js"
  9. import eventBus from "@/api/eventBus.js";
  10. const props =defineProps({
  11. sampleId:{
  12. type: [Number, String],
  13. required: false
  14. },
  15. farmId:{
  16. type: [Number, String],
  17. required: true
  18. },
  19. blueGeoHash:{
  20. type: String,
  21. required: false
  22. },
  23. farmWork:{
  24. type: Object,
  25. required: false
  26. },
  27. lock:{
  28. type: Boolean,
  29. default: true
  30. }
  31. })
  32. const images = ref(null);
  33. onMounted(() => {
  34. getList()
  35. });
  36. watch(()=>props.farmId,(newValue,oldValue) =>{
  37. if(newValue){
  38. getList()
  39. }
  40. })
  41. const getList = () =>{
  42. if(!props.farmId) return
  43. let params = {farmId: props.farmId}
  44. if(props.blueGeoHash){
  45. params.blueZone = props.blueGeoHash
  46. }
  47. if(props.sampleId){
  48. params.sampleId = props.sampleId
  49. }
  50. if(props.farmWork?.executeDate){
  51. let execcuteDate = new Date(props.farmWork.executeDate)
  52. let beforeExecuteDate = new Date(props.farmWork.beforeExecuteDate)
  53. const pastDate = new Date(beforeExecuteDate);
  54. const futureDate = new Date(execcuteDate);
  55. params.startDate = dateFormat(pastDate, "YY-mm-dd");
  56. params.endDate = dateFormat(futureDate, "YY-mm-dd");
  57. }
  58. VE_API.image.list(params).then(res => {
  59. if(res.code === 0){
  60. images.value = res.data
  61. eventBus.emit('image:resultNum',res.data.length)
  62. }
  63. })
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. @import "src/styles/index";
  68. </style>