Blame view

src/components/oa/viewImage.vue 1.79 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
9d019fa6   wuxw   测试OA相关流程
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    <div class="view-image-container">
      <el-dialog
        :visible.sync="dialogVisible"
        fullscreen
        :show-close="false"
        custom-class="image-viewer-dialog"
      >
        <div class="image-wrapper">
          <img 
            :src="imageUrl" 
            :style="imageStyle"
            @error="handleImageError"
          />
          <i 
            class="el-icon-close close-icon" 
            @click="close"
          />
        </div>
      </el-dialog>
d4a6b78f   wuxw   OA 中考勤功能开发完成
21
    </div>
a99eb7a5   wuxw   开发完成办公下功能
22
23
24
25
26
27
28
  </template>
  
  <script>
  export default {
    name: 'ViewImage',
    data() {
      return {
9d019fa6   wuxw   测试OA相关流程
29
        dialogVisible: false,
a99eb7a5   wuxw   开发完成办公下功能
30
        imageUrl: '',
9d019fa6   wuxw   测试OA相关流程
31
32
33
34
35
36
        imageStyle: {
          width: '800px',
          height: 'auto',
          display: 'block',
          margin: '0 auto'
        }
a99eb7a5   wuxw   开发完成办公下功能
37
38
39
40
41
      }
    },
    methods: {
      open(url) {
        this.imageUrl = url
9d019fa6   wuxw   测试OA相关流程
42
43
44
        this.dialogVisible = true
        
        // 预加载图片获取实际尺寸
a99eb7a5   wuxw   开发完成办公下功能
45
46
47
        const img = new Image()
        img.src = url
        img.onload = () => {
d4a6b78f   wuxw   OA 中考勤功能开发完成
48
          const imgScale = img.width / img.height
9d019fa6   wuxw   测试OA相关流程
49
50
          this.imageStyle.width = '800px'
          this.imageStyle.height = `${800 / imgScale}px`
d4a6b78f   wuxw   OA 中考勤功能开发完成
51
52
        }
      },
9d019fa6   wuxw   测试OA相关流程
53
54
55
      close() {
        this.dialogVisible = false
        this.imageUrl = ''
d4a6b78f   wuxw   OA 中考勤功能开发完成
56
      },
9d019fa6   wuxw   测试OA相关流程
57
58
      handleImageError(e) {
        e.target.src = '/img/noPhoto.jpg'
d4a6b78f   wuxw   OA 中考勤功能开发完成
59
      }
d4a6b78f   wuxw   OA 中考勤功能开发完成
60
61
62
63
64
    }
  }
  </script>
  
  <style lang="scss" scoped>
9d019fa6   wuxw   测试OA相关流程
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  .view-image-container {
    .image-viewer-dialog {
      background-color: rgba(0, 0, 0, 0.8);
      
      .image-wrapper {
        position: relative;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        
        .close-icon {
          position: absolute;
          top: 20px;
          right: 20px;
          font-size: 24px;
          color: #fff;
          cursor: pointer;
          z-index: 2001;
          
          &:hover {
            color: #f56c6c;
          }
a99eb7a5   wuxw   开发完成办公下功能
88
89
90
91
        }
      }
    }
  }
d4a6b78f   wuxw   OA 中考勤功能开发完成
92
  </style>