picModal.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class='picDia'>
  3. <el-dialog :visible.sync='dialogVisible' width='75%' :close-on-click-modal='false' :show-close='false'>
  4. <pic-view-rotation
  5. :picType='picType'
  6. :size='sizePic'
  7. :key='key'
  8. v-if='rotationImg.length>0'
  9. :rotationImg='rotationImg'
  10. style='height:100%;width:100%'
  11. ></pic-view-rotation>
  12. <span class='close' @click='close'>X</span>
  13. </el-dialog>
  14. </div>
  15. </template>
  16. <script>
  17. /**
  18. * @author yunxing
  19. * @date 2020-09-07
  20. * @description fix: 修复放大预览图片时,会出现蓝色头部的问题
  21. */
  22. import PicViewRotation from './picViewRotation'
  23. export default {
  24. data() {
  25. return {
  26. dialogVisible: false,
  27. mode: 'top',
  28. rotationImg: [], //要展示的大图
  29. picType: null, //图片类型 1 区位图 2 鸟瞰图
  30. key: 1,
  31. sizePic: '', //横向||纵向展示 width 横向展示 height 纵向展示
  32. imgInfo: {}, //返回图片信息
  33. }
  34. },
  35. methods: {
  36. showModal(params, type) {
  37. // debugger
  38. this.key++
  39. this.dialogVisible = true
  40. this.rotationImg = params
  41. this.picType = type
  42. if (this.rotationImg.length > 0) {
  43. let img = new Image()
  44. img.src = this.rotationImg[0].url
  45. const vm = this
  46. img.onload = function () {
  47. vm.$set(vm.imgInfo, 'width', img.width)
  48. vm.$set(vm.imgInfo, 'height', img.height)
  49. if (vm.imgInfo.width > vm.imgInfo.height) {
  50. vm.sizePic = 'width'
  51. } else {
  52. vm.sizePic = 'height'
  53. }
  54. }
  55. }
  56. },
  57. close() {
  58. this.dialogVisible = false
  59. },
  60. },
  61. components: {
  62. PicViewRotation,
  63. },
  64. }
  65. </script>
  66. <style lang="less" scoped>
  67. .picDia {
  68. img {
  69. width: 100%;
  70. height: 100%;
  71. }
  72. }
  73. .close {
  74. display: block;
  75. position: absolute;
  76. right: -40px;
  77. font-size: 20px;
  78. color: #fff;
  79. top: -30px;
  80. z-index: 10;
  81. cursor: pointer;
  82. }
  83. </style>
  84. <style lang='less'>
  85. .picDia {
  86. .el-dialog {
  87. height: 88%;
  88. margin-top: 5vh !important;
  89. position: relative;
  90. .el-dialog__header {
  91. padding: 0;// !important;
  92. height: 0;
  93. background: none; //!important;
  94. border-bottom: none;
  95. }
  96. .el-dialog__body {
  97. padding: 0;
  98. height: 100%;
  99. }
  100. }
  101. }
  102. </style>