|
@@ -66,7 +66,7 @@
|
|
|
</zz-table>
|
|
|
</div>
|
|
|
<el-dialog title="下载二维码" :visible.sync="centerDialogVisible" width="400px">
|
|
|
- <div class="QRImg">
|
|
|
+ <div class="QRImg" ref="QRImg">
|
|
|
<img :src="QRImg" alt="设施二维码" />
|
|
|
<div>{{ facilityName }} - {{ facilityNo }}</div>
|
|
|
</div>
|
|
@@ -79,9 +79,10 @@
|
|
|
|
|
|
<script>
|
|
|
import list from '@utils/list.js';
|
|
|
+import html2canvas from 'html2canvas';
|
|
|
export default {
|
|
|
mixins: [list],
|
|
|
- name:'deviceManagementIndexFacilities',
|
|
|
+ name: 'deviceManagementIndexFacilities',
|
|
|
data() {
|
|
|
const _this = this;
|
|
|
return {
|
|
@@ -167,7 +168,7 @@ export default {
|
|
|
centerDialogVisible: false,
|
|
|
QRImg: '',
|
|
|
facilityNo: '',
|
|
|
- facilityName:"",
|
|
|
+ facilityName: ''
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -242,13 +243,24 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
downImg() {
|
|
|
- let a = document.createElement('a');
|
|
|
- a.download = `${this.facilityName}${this.facilityNo}.png`;
|
|
|
- a.href = this.QRImg;
|
|
|
- document.body.appendChild(a);
|
|
|
- a.click();
|
|
|
- document.body.removeChild(a);
|
|
|
- this.centerDialogVisible = !this.centerDialogVisible;
|
|
|
+ html2canvas(this.$refs.QRImg).then((canvas) => {
|
|
|
+ let dataURL = canvas.toDataURL('image/png');
|
|
|
+ let a = document.createElement('a');
|
|
|
+ a.download = `${this.facilityName} - ${this.facilityNo}`;
|
|
|
+ a.href = dataURL;
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ document.body.removeChild(a);
|
|
|
+ this.centerDialogVisible = !this.centerDialogVisible;
|
|
|
+ });
|
|
|
+
|
|
|
+ // let a = document.createElement('a');
|
|
|
+ // a.download = `${this.facilityName}${this.facilityNo}.png`;
|
|
|
+ // a.href = this.QRImg;
|
|
|
+ // document.body.appendChild(a);
|
|
|
+ // a.click();
|
|
|
+ // document.body.removeChild(a);
|
|
|
+ // this.centerDialogVisible = !this.centerDialogVisible;
|
|
|
},
|
|
|
addOrEdit(todo, data = {}) {
|
|
|
new Promise((resolve) => {
|
|
@@ -311,4 +323,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-</script>
|
|
|
+</script>
|
|
|
+<style scoped lang='scss'>
|
|
|
+.QRImg > div {
|
|
|
+ position: absolute;
|
|
|
+ width: 100%;
|
|
|
+ bottom: 0;
|
|
|
+ text-align: center;
|
|
|
+ left: 50%;
|
|
|
+ transform: translateX(-50%);
|
|
|
+}
|
|
|
+</style>
|