| | |
| | | <el-space fill> |
| | | <el-alert type="warning" show-icon :closable="false"> |
| | | <p>"请输入设备编号后才能使用不然无法定位到数据来源:</p> |
| | | <p>也可以选择二维码图片识别</p> |
| | | </el-alert> |
| | | <el-form-item label="设备编号"> |
| | | <el-input v-model="deviceCode" /> |
| | | </el-form-item> |
| | | </el-space> |
| | | </el-form> |
| | | <div> |
| | | <input type="file" pattern="选取二维码" accept="image/*" @change="onFileChange" /> |
| | | <input type="text" v-model="codeResult" placeholder="扫描结果将会显示在这里"> |
| | | </div> |
| | | </span> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | |
| | | import cljd from '../img/cljd.png' |
| | | import tizhong from '../img/tizhong.png' |
| | | import {EventSourcePolyfill} from 'event-source-polyfill'; |
| | | import jsQR from 'jsqr'; |
| | | import { computed, getCurrentInstance, onBeforeMount, onMounted, ref, watch, watchEffect } from "vue"; |
| | | import { Local } from '../utils/storage'; |
| | | import * as echarts from "echarts"; |
| | |
| | | ], |
| | | }); |
| | | // 告警提示 |
| | | const textbaojing = ref(""); |
| | | const iscomfig = ref(false); |
| | | // 识别窗口 |
| | | const video = ref<HTMLVideoElement | null>(null); |
| | | // 识别文本 |
| | | const codeResult = ref<string>(''); |
| | | // 识别数据流 |
| | | let stream: MediaStream | null = null; |
| | | const centerDialogVisible = ref(false); |
| | | const background = ref(""); |
| | | const txztText = ref(""); |
| | |
| | | ElMessage.warning('请先输入设备编号') |
| | | } |
| | | } |
| | | const onFileChange=(event: Event) =>{ |
| | | const inputElement = event.target as HTMLInputElement; |
| | | if (!inputElement.files || inputElement.files.length === 0) return; |
| | | |
| | | const file = inputElement.files[0]; |
| | | const reader = new FileReader(); |
| | | |
| | | reader.onload = function(e) { |
| | | if (e.target && typeof e.target.result === 'string') { |
| | | const img = document.createElement('img'); |
| | | img.src = e.target.result; |
| | | img.onload = function() { |
| | | const canvas = document.createElement('canvas'); |
| | | canvas.width = img.width; |
| | | canvas.height = img.height; |
| | | const ctx = canvas.getContext('2d'); |
| | | if (ctx) { |
| | | ctx.drawImage(img, 0, 0); |
| | | const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); |
| | | const code = jsQR(imageData.data, imageData.width, imageData.height); |
| | | if (code) { |
| | | codeResult.value = code.data; |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | }; |
| | | |
| | | reader.readAsDataURL(file); |
| | | } |
| | | const shaoma=()=>{ |
| | | } |
| | | watch( |
| | | () => deviceData.value.设备变化, |
| | | () => { |