Blame view

src/components/system/viewImage.vue 1.92 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
03f63ab4   wuxw   优化到商户信息
2
3
4
    <div class="view-image-container">
      <el-dialog
        :visible.sync="visible"
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
5
        :width="dialogWidth"
b6a90698   wuxw   优化图片方大问题
6
        :show-close="true"
03f63ab4   wuxw   优化到商户信息
7
        custom-class="image-viewer-dialog"
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
8
9
        @close="close"
        center
03f63ab4   wuxw   优化到商户信息
10
11
12
13
14
      >
        <div class="image-wrapper">
          <img
            :src="imageInfo.url"
            :style="{
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
15
16
              maxWidth: '100%',
              maxHeight: imageInfo.maxHeight + 'px'
03f63ab4   wuxw   优化到商户信息
17
18
19
            }"
            @error="handleImageError"
          />
1d73dc48   wuxw   继续晚上巡检功能
20
21
22
23
24
25
26
27
28
29
        </div>
      </el-dialog>
    </div>
  </template>
  
  <script>
  export default {
    name: 'ViewImage',
    data() {
      return {
03f63ab4   wuxw   优化到商户信息
30
        visible: false,
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
31
        dialogWidth: '50%',
03f63ab4   wuxw   优化到商户信息
32
33
        imageInfo: {
          url: '',
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
34
          maxHeight: 600
03f63ab4   wuxw   优化到商户信息
35
        }
1d73dc48   wuxw   继续晚上巡检功能
36
37
38
      }
    },
    methods: {
03f63ab4   wuxw   优化到商户信息
39
40
41
      open(params) {
        this.imageInfo.url = params.url
        this.visible = true
1d73dc48   wuxw   继续晚上巡检功能
42
        
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
43
44
45
46
47
48
49
50
51
52
53
        // 根据屏幕尺寸动态调整对话框大小
        const screenWidth = window.innerWidth
        if (screenWidth < 768) {
          this.dialogWidth = '90%'
          this.imageInfo.maxHeight = 400
        } else if (screenWidth < 1200) {
          this.dialogWidth = '70%'
          this.imageInfo.maxHeight = 500
        } else {
          this.dialogWidth = '50%'
          this.imageInfo.maxHeight = 600
03f63ab4   wuxw   优化到商户信息
54
55
56
57
58
59
        }
      },
      close() {
        this.visible = false
        this.imageInfo = {
          url: '',
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
60
          maxHeight: 600
1d73dc48   wuxw   继续晚上巡检功能
61
62
        }
      },
03f63ab4   wuxw   优化到商户信息
63
64
      handleImageError(e) {
        e.target.src = '/img/noPhoto.jpg'
1d73dc48   wuxw   继续晚上巡检功能
65
66
67
68
69
70
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
03f63ab4   wuxw   优化到商户信息
71
  .view-image-container {
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
72
73
74
75
76
77
78
79
80
    ::v-deep .image-viewer-dialog {
      .el-dialog__header {
        padding: 10px;
      }
      
      .el-dialog__body {
        padding: 20px;
        text-align: center;
      }
1d73dc48   wuxw   继续晚上巡检功能
81
      
03f63ab4   wuxw   优化到商户信息
82
      .image-wrapper {
03f63ab4   wuxw   优化到商户信息
83
84
85
        display: flex;
        justify-content: center;
        align-items: center;
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
86
        min-height: 200px;
03f63ab4   wuxw   优化到商户信息
87
88
        
        img {
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
89
90
91
          display: block;
          width: auto;
          height: auto;
03f63ab4   wuxw   优化到商户信息
92
          object-fit: contain;
10d41618   wuxw   v1.9 测试采购功能,部分页面功能优化
93
          border-radius: 4px;
03f63ab4   wuxw   优化到商户信息
94
        }
1d73dc48   wuxw   继续晚上巡检功能
95
96
97
98
      }
    }
  }
  </style>