| | |
| | | <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" /> |
| | | </div> |
| | | </span> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { BrowserMultiFormatReader, NotFoundException, ChecksumException, FormatException } from '@zxing/library'; |
| | | import TQS88 from "../img/TQS88.png"; |
| | | import shezhi from '../img/shezhi.png' |
| | | import xinlv from '../img/xinlv.png' |
| | |
| | | ], |
| | | }); |
| | | // 告警提示 |
| | | const textbaojing = ref(""); |
| | | const iscomfig = ref(false); |
| | | // 识别窗口 |
| | | const video = ref<HTMLVideoElement | null>(null); |
| | | // 识别数据流 |
| | | let stream: MediaStream | null = null; |
| | | const centerDialogVisible = ref(false); |
| | | const background = ref(""); |
| | | const txztText = ref(""); |
| | |
| | | }else{ |
| | | ElMessage.warning('请先输入设备编号') |
| | | } |
| | | } |
| | | const onFileChange=async(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 = async (e) => { |
| | | if (e.target && typeof e.target.result === 'string') { |
| | | try { |
| | | const codeReader = new BrowserMultiFormatReader(); |
| | | const result = await codeReader.decodeFromImage(undefined, e.target.result); |
| | | deviceCode.value = result.text; |
| | | ElMessage.success('识别成功') |
| | | } catch (err) { |
| | | if (err instanceof NotFoundException) { |
| | | ElMessage.error("未找到二维码"); |
| | | } else if (err instanceof ChecksumException) { |
| | | ElMessage.error("校验错误"); |
| | | } else if (err instanceof FormatException) { |
| | | ElMessage.error("格式错误"); |
| | | } else { |
| | | ElMessage.error("识别错误请重新识别"); |
| | | console.error(err); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | reader.readAsDataURL(file); |
| | | } |
| | | const shaoma=()=>{ |
| | | } |
| | | watch( |
| | | () => deviceData.value.设备变化, |
| | |
| | | } |
| | | |
| | | .right-div { |
| | | width: 100px; /* 固定宽度 */ |
| | | width: 50px; /* 固定宽度 */ |
| | | font-size: 16px; |
| | | display: flex; |
| | | justify-content: center; /* 水平居中 */ |