Blame view

src/components/inspection/inspectionPointQrCode.vue 2.05 KB
1d73dc48   wuxw   继续晚上巡检功能
1
  <template>
48ea9c43   wuxw   巡检开发完成
2
3
4
5
6
    <el-dialog :title="$t('inspectionPointQrCode.title')" :visible.sync="dialogVisible" width="400px" center>
      <div class="qr-code-container text-center">
        <div id="qrcode" ref="qrcode" style="width: 200px; height: 200px; margin: 0 auto;"></div>
        <p class="inspection-name">{{ inspectionPointQrCodeInfo.inspectionName }}</p>
        <p class="tip-text">{{ $t('inspectionPointQrCode.tip') }}</p>
1d73dc48   wuxw   继续晚上巡检功能
7
      </div>
48ea9c43   wuxw   巡检开发完成
8
9
10
11
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">{{ $t('common.close') }}</el-button>
      </span>
1d73dc48   wuxw   继续晚上巡检功能
12
13
14
15
16
    </el-dialog>
  </template>
  
  <script>
  import QRCode from 'qrcodejs2'
48ea9c43   wuxw   巡检开发完成
17
  import { getCommunityId } from '@/api/community/communityApi'
1d73dc48   wuxw   继续晚上巡检功能
18
19
20
21
22
  
  export default {
    name: 'InspectionPointQrCode',
    data() {
      return {
48ea9c43   wuxw   巡检开发完成
23
        dialogVisible: false,
1d73dc48   wuxw   继续晚上巡检功能
24
25
26
27
        inspectionPointQrCodeInfo: {
          url: '',
          inspectionName: ''
        },
48ea9c43   wuxw   巡检开发完成
28
29
        qrcode: null,
        communityId: ''
1d73dc48   wuxw   继续晚上巡检功能
30
31
      }
    },
48ea9c43   wuxw   巡检开发完成
32
33
34
    created() {
      this.communityId = getCommunityId()
    },
1d73dc48   wuxw   继续晚上巡检功能
35
    methods: {
48ea9c43   wuxw   巡检开发完成
36
37
38
      open(inspectionPoint) {
        this.dialogVisible = true
        this.inspectionPointQrCodeInfo = {
1597d420   wuxw   v1.9 解决巡检点二维码打开bug
39
          url:  inspectionPoint.url,
48ea9c43   wuxw   巡检开发完成
40
41
42
          inspectionName: inspectionPoint.inspectionName
        }
  
1d73dc48   wuxw   继续晚上巡检功能
43
44
45
46
        this.$nextTick(() => {
          this.generateQrCode()
        })
      },
48ea9c43   wuxw   巡检开发完成
47
  
48ea9c43   wuxw   巡检开发完成
48
  
1d73dc48   wuxw   继续晚上巡检功能
49
      generateQrCode() {
48ea9c43   wuxw   巡检开发完成
50
51
52
53
        // 清除现有的二维码
        if (this.qrcode) {
          this.qrcode.clear()
          this.$refs.qrcode.innerHTML = ''
1d73dc48   wuxw   继续晚上巡检功能
54
        }
48ea9c43   wuxw   巡检开发完成
55
56
57
  
        // 生成新的二维码
        this.qrcode = new QRCode(this.$refs.qrcode, {
1d73dc48   wuxw   继续晚上巡检功能
58
59
60
          text: this.inspectionPointQrCodeInfo.url,
          width: 200,
          height: 200,
48ea9c43   wuxw   巡检开发完成
61
62
          colorDark: "#000000",
          colorLight: "#ffffff",
1d73dc48   wuxw   继续晚上巡检功能
63
64
65
66
67
          correctLevel: QRCode.CorrectLevel.L
        })
      }
    },
    beforeDestroy() {
48ea9c43   wuxw   巡检开发完成
68
69
      if (this.qrcode) {
        this.qrcode.clear()
1d73dc48   wuxw   继续晚上巡检功能
70
71
72
73
74
75
      }
    }
  }
  </script>
  
  <style scoped>
48ea9c43   wuxw   巡检开发完成
76
77
  .qr-code-container {
    padding: 20px;
1d73dc48   wuxw   继续晚上巡检功能
78
79
  }
  
48ea9c43   wuxw   巡检开发完成
80
81
  .text-center {
    text-align: center;
1d73dc48   wuxw   继续晚上巡检功能
82
83
  }
  
48ea9c43   wuxw   巡检开发完成
84
85
  .inspection-name {
    font-size: 18px;
1d73dc48   wuxw   继续晚上巡检功能
86
    font-weight: bold;
48ea9c43   wuxw   巡检开发完成
87
    margin: 15px 0;
1d73dc48   wuxw   继续晚上巡检功能
88
89
  }
  
48ea9c43   wuxw   巡检开发完成
90
  .tip-text {
1d73dc48   wuxw   继续晚上巡检功能
91
    font-size: 14px;
48ea9c43   wuxw   巡检开发完成
92
93
    color: #606266;
    margin-top: 10px;
1d73dc48   wuxw   继续晚上巡检功能
94
95
  }
  </style>