| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view v-if="show" class="swm-mask" @touchmove.stop.prevent @tap.stop> |
| | | <view class="swm-card" @tap.stop> |
| | | <view class="swm-figure"> |
| | | <view v-if="status === 'waiting'" class="swm-scan-box"> |
| | | <view class="swm-scan-line" /> |
| | | <view class="swm-scan-corner tl" /> |
| | | <view class="swm-scan-corner tr" /> |
| | | <view class="swm-scan-corner bl" /> |
| | | <view class="swm-scan-corner br" /> |
| | | </view> |
| | | <view v-else-if="status === 'done'" class="swm-check"> |
| | | <view class="swm-check-mark" /> |
| | | </view> |
| | | <view v-else class="swm-warn"> |
| | | <view class="swm-warn-bar" /> |
| | | <view class="swm-warn-dot" /> |
| | | </view> |
| | | </view> |
| | | <view class="swm-title">{{ titleText }}</view> |
| | | <view class="swm-sub">{{ subText }}</view> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed } from "vue"; |
| | | |
| | | const props = defineProps({ |
| | | show: { type: Boolean, default: false }, |
| | | status: { type: String, default: "waiting" }, |
| | | title: { type: String, default: "" }, |
| | | subTitle: { type: String, default: "" }, |
| | | }); |
| | | |
| | | const titleText = computed(() => { |
| | | if (props.title) return props.title; |
| | | if (props.status === "done") return "æ«ç 宿"; |
| | | if (props.status === "timeout") return "æ«ç è¶
æ¶"; |
| | | return "çå¾
æ«ç "; |
| | | }); |
| | | |
| | | const subText = computed(() => { |
| | | if (props.subTitle) return props.subTitle; |
| | | if (props.status === "done") return "æ£å¨å¤çæ«ç ç»æ"; |
| | | if (props.status === "timeout") return "æªæ¶å°æ«ç æ°æ®ï¼è¯·éè¯"; |
| | | return "请对åäºç»´ç /æ¡ç è¿è¡æ«æ"; |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .swm-mask { |
| | | position: fixed; |
| | | left: 0; |
| | | top: 0; |
| | | right: 0; |
| | | bottom: 0; |
| | | z-index: 9999; |
| | | background: rgba(0, 0, 0, 0.5); |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .swm-card { |
| | | width: 620rpx; |
| | | padding: 36rpx 32rpx 30rpx; |
| | | background: #ffffff; |
| | | border-radius: 24rpx; |
| | | box-shadow: 0 16rpx 44rpx rgba(0, 0, 0, 0.22); |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | } |
| | | |
| | | .swm-figure { |
| | | width: 260rpx; |
| | | height: 260rpx; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | margin-bottom: 18rpx; |
| | | } |
| | | |
| | | .swm-title { |
| | | font-size: 34rpx; |
| | | font-weight: 700; |
| | | color: rgba(0, 0, 0, 0.88); |
| | | margin-bottom: 10rpx; |
| | | } |
| | | |
| | | .swm-sub { |
| | | font-size: 26rpx; |
| | | color: rgba(0, 0, 0, 0.55); |
| | | text-align: center; |
| | | line-height: 38rpx; |
| | | } |
| | | |
| | | .swm-scan-box { |
| | | width: 220rpx; |
| | | height: 220rpx; |
| | | border-radius: 22rpx; |
| | | background: rgba(25, 137, 250, 0.06); |
| | | position: relative; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .swm-scan-line { |
| | | position: absolute; |
| | | left: 14rpx; |
| | | right: 14rpx; |
| | | height: 6rpx; |
| | | top: 18rpx; |
| | | border-radius: 6rpx; |
| | | background: linear-gradient(90deg, rgba(25, 137, 250, 0), #1989fa, rgba(25, 137, 250, 0)); |
| | | animation: swmScan 1.2s linear infinite; |
| | | } |
| | | |
| | | .swm-scan-corner { |
| | | position: absolute; |
| | | width: 34rpx; |
| | | height: 34rpx; |
| | | border-color: #1989fa; |
| | | border-style: solid; |
| | | } |
| | | |
| | | .swm-scan-corner.tl { |
| | | left: 0; |
| | | top: 0; |
| | | border-width: 6rpx 0 0 6rpx; |
| | | border-top-left-radius: 20rpx; |
| | | } |
| | | |
| | | .swm-scan-corner.tr { |
| | | right: 0; |
| | | top: 0; |
| | | border-width: 6rpx 6rpx 0 0; |
| | | border-top-right-radius: 20rpx; |
| | | } |
| | | |
| | | .swm-scan-corner.bl { |
| | | left: 0; |
| | | bottom: 0; |
| | | border-width: 0 0 6rpx 6rpx; |
| | | border-bottom-left-radius: 20rpx; |
| | | } |
| | | |
| | | .swm-scan-corner.br { |
| | | right: 0; |
| | | bottom: 0; |
| | | border-width: 0 6rpx 6rpx 0; |
| | | border-bottom-right-radius: 20rpx; |
| | | } |
| | | |
| | | @keyframes swmScan { |
| | | 0% { |
| | | transform: translateY(0); |
| | | opacity: 0.9; |
| | | } |
| | | 90% { |
| | | opacity: 0.95; |
| | | } |
| | | 100% { |
| | | transform: translateY(180rpx); |
| | | opacity: 0.55; |
| | | } |
| | | } |
| | | |
| | | .swm-check { |
| | | width: 180rpx; |
| | | height: 180rpx; |
| | | border-radius: 90rpx; |
| | | background: rgba(18, 185, 129, 0.12); |
| | | border: 6rpx solid rgba(18, 185, 129, 0.85); |
| | | position: relative; |
| | | } |
| | | |
| | | .swm-check-mark { |
| | | position: absolute; |
| | | left: 58rpx; |
| | | top: 72rpx; |
| | | width: 56rpx; |
| | | height: 30rpx; |
| | | border-left: 10rpx solid rgba(18, 185, 129, 0.95); |
| | | border-bottom: 10rpx solid rgba(18, 185, 129, 0.95); |
| | | transform: rotate(-45deg); |
| | | } |
| | | |
| | | .swm-warn { |
| | | width: 180rpx; |
| | | height: 180rpx; |
| | | border-radius: 90rpx; |
| | | background: rgba(245, 158, 11, 0.12); |
| | | border: 6rpx solid rgba(245, 158, 11, 0.9); |
| | | position: relative; |
| | | } |
| | | |
| | | .swm-warn-bar { |
| | | position: absolute; |
| | | left: 50%; |
| | | top: 44rpx; |
| | | width: 10rpx; |
| | | height: 72rpx; |
| | | border-radius: 10rpx; |
| | | transform: translateX(-50%); |
| | | background: rgba(245, 158, 11, 0.95); |
| | | } |
| | | |
| | | .swm-warn-dot { |
| | | position: absolute; |
| | | left: 50%; |
| | | bottom: 42rpx; |
| | | width: 14rpx; |
| | | height: 14rpx; |
| | | border-radius: 14rpx; |
| | | transform: translateX(-50%); |
| | | background: rgba(245, 158, 11, 0.95); |
| | | } |
| | | </style> |
| | | |
| | |
| | | const uploading = ref(false); |
| | | const uploadProgress = ref(0); |
| | | |
| | | // çå¬ä¸ä¼ ç¶æï¼ååºäºä»¶ |
| | | const watchUploading = val => { |
| | | emit("uploading", val); |
| | | }; |
| | | // çå¬è¿åº¦ï¼ååºäºä»¶ |
| | | const watchProgress = val => { |
| | | emit("progress", val); |
| | | }; |
| | |
| | | font-size: 13px; |
| | | } |
| | | </style> |
| | | |
| | |
| | | extraKey: { type: String, default: "" }, |
| | | debounceMs: { type: Number, default: 150 }, |
| | | }, |
| | | data() { |
| | | return { |
| | | _ensureTimer: null, |
| | | _ensureTries: 0, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.init(); |
| | | if (this.active) this.start(); |
| | | this.ensureStarted(); |
| | | }, |
| | | onHide() { |
| | | this.stop(); |
| | | }, |
| | | beforeUnmount() { |
| | | this.stop(); |
| | |
| | | watch: { |
| | | active(val) { |
| | | if (val) { |
| | | this.init(); |
| | | this.start(); |
| | | this.ensureStarted(); |
| | | } else { |
| | | this.stop(); |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | ensureStarted() { |
| | | if (!this.active) return; |
| | | this._ensureTries = 0; |
| | | if (this._ensureTimer) { |
| | | clearInterval(this._ensureTimer); |
| | | this._ensureTimer = null; |
| | | } |
| | | |
| | | const tick = () => { |
| | | if (!this.active) return; |
| | | if (isRegistered) return; |
| | | this.init(); |
| | | this.start(); |
| | | this._ensureTries += 1; |
| | | if (isRegistered) { |
| | | if (this._ensureTimer) { |
| | | clearInterval(this._ensureTimer); |
| | | this._ensureTimer = null; |
| | | } |
| | | } else if (this._ensureTries >= 50) { |
| | | if (this._ensureTimer) { |
| | | clearInterval(this._ensureTimer); |
| | | this._ensureTimer = null; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | tick(); |
| | | if (!isRegistered) { |
| | | this._ensureTimer = setInterval(tick, 200); |
| | | } |
| | | }, |
| | | canUseAndroidBroadcast() { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | |
| | | } |
| | | }, |
| | | resolveBroadcastConfig(sys) { |
| | | if (this.action && this.extraKey) { |
| | | return { action: this.action, extraKey: this.extraKey }; |
| | | } |
| | | |
| | | try { |
| | | const brand = String(sys?.brand || "").toUpperCase(); |
| | | const model = String(sys?.model || "").toUpperCase(); |
| | | |
| | | if ( |
| | | brand.includes("DROI") || |
| | | model.includes("MV-IDP5204") || |
| | |
| | | ) { |
| | | return { action: "com.service.scanner.data", extraKey: "ScanCode" }; |
| | | } |
| | | } catch (e) {} |
| | | if (this.action && this.extraKey) { |
| | | return { action: this.action, extraKey: this.extraKey }; |
| | | } |
| | | |
| | | return { action: "", extraKey: "" }; |
| | | return { action: "com.service.scanner.data", extraKey: "ScanCode" }; |
| | | }, |
| | | init() { |
| | | if (!this.canUseAndroidBroadcast()) return; |
| | |
| | | "android.content.IntentFilter" |
| | | ); |
| | | intentFilter = new IntentFilter(); |
| | | intentFilter.addAction(action); |
| | | const pickActions = v => { |
| | | const list = []; |
| | | if (v) { |
| | | String(v) |
| | | .split(/[,\s]+/) |
| | | .map(s => s.trim()) |
| | | .filter(Boolean) |
| | | .forEach(a => list.push(a)); |
| | | } |
| | | [ |
| | | "com.service.scanner.data", |
| | | "com.scanner.broadcast", |
| | | "com.android.scanner.broadcast", |
| | | "com.seuic.scanner.data", |
| | | "com.android.scanner.receiver", |
| | | "com.android.scanner.result", |
| | | "com.rfid.SCAN", |
| | | "com.honeywell.decode.intent.action", |
| | | "com.symbol.datawedge.data", |
| | | "com.symbol.datawedge.api.RESULT_ACTION", |
| | | "com.datalogic.decodewedge.decode_action", |
| | | "android.intent.ACTION_DECODE_DATA", |
| | | "android.intent.action.SCANRESULT", |
| | | "android.intent.action.DECODE_DATA", |
| | | "scan.rcv.message", |
| | | ].forEach(a => { |
| | | if (!list.includes(a)) list.push(a); |
| | | }); |
| | | return list; |
| | | }; |
| | | |
| | | const actions = pickActions(action); |
| | | actions.forEach(a => intentFilter.addAction(a)); |
| | | |
| | | const pickExtraKeys = key => { |
| | | const list = []; |
| | | if (key) { |
| | | String(key) |
| | | .split(/[,\s]+/) |
| | | .map(s => s.trim()) |
| | | .filter(Boolean) |
| | | .forEach(k => list.push(k)); |
| | | } |
| | | [ |
| | | "ScanCode", |
| | | "scanCode", |
| | | "barcode", |
| | | "barCode", |
| | | "data", |
| | | "DATA", |
| | | "code", |
| | | "CODE", |
| | | "result", |
| | | "RESULT", |
| | | "scannerdata", |
| | | "decode_data", |
| | | "SCAN_RESULT", |
| | | "data_string", |
| | | "com.symbol.datawedge.data_string", |
| | | "com.symbol.datawedge.label_type", |
| | | ].forEach(k => { |
| | | if (!list.includes(k)) list.push(k); |
| | | }); |
| | | return list; |
| | | }; |
| | | |
| | | const extraKeys = pickExtraKeys(extraKey); |
| | | |
| | | receiver = plus.android.implements( |
| | | "io.dcloud.feature.internal.reflect.BroadcastReceiver", |
| | | { |
| | | onReceive(context, intent) { |
| | | plus.android.importClass(intent); |
| | | const code = intent.getStringExtra(extraKey); |
| | | let code = ""; |
| | | for (let i = 0; i < extraKeys.length; i++) { |
| | | const k = extraKeys[i]; |
| | | try { |
| | | const v = intent.getStringExtra(k); |
| | | if (v) { |
| | | code = v; |
| | | break; |
| | | } |
| | | } catch (e) {} |
| | | try { |
| | | const bytes = intent.getByteArrayExtra(k); |
| | | if (bytes && bytes.length) { |
| | | const JString = plus.android.importClass("java.lang.String"); |
| | | code = new JString(bytes); |
| | | if (code) break; |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | if (!code) { |
| | | try { |
| | | const ds = intent.getDataString(); |
| | | if (ds) code = ds; |
| | | } catch (e) {} |
| | | } |
| | | if (!code) { |
| | | try { |
| | | const extras = intent.getExtras(); |
| | | if (extras) { |
| | | plus.android.importClass(extras); |
| | | const keySet = extras.keySet(); |
| | | if (keySet) { |
| | | plus.android.importClass(keySet); |
| | | const it = keySet.iterator(); |
| | | if (it) { |
| | | plus.android.importClass(it); |
| | | while (it.hasNext()) { |
| | | const k = it.next(); |
| | | const ks = String(k); |
| | | let v = ""; |
| | | try { |
| | | v = extras.getString(ks); |
| | | } catch (e) {} |
| | | if (!v) { |
| | | try { |
| | | const any = extras.get(ks); |
| | | if (any != null) v = String(any); |
| | | } catch (e) {} |
| | | } |
| | | const text = (v == null ? "" : String(v)) |
| | | .replace(/\n/g, "") |
| | | .trim(); |
| | | if ( |
| | | text && |
| | | text.length >= 3 && |
| | | text.length <= 300 && |
| | | /[0-9A-Za-z]/.test(text) && |
| | | !text.includes("android.") && |
| | | !text.includes("com.") |
| | | ) { |
| | | code = text; |
| | | break; |
| | | } |
| | | if ( |
| | | !code && |
| | | text && |
| | | text.length >= 3 && |
| | | text.length <= 300 && |
| | | /[0-9A-Za-z]/.test(text) |
| | | ) { |
| | | code = text; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (e) {} |
| | | } |
| | | _this.emitCode(code); |
| | | }, |
| | | } |
| | |
| | | try { |
| | | mainActivity.registerReceiver(receiver, intentFilter); |
| | | isRegistered = true; |
| | | } catch (e) {} |
| | | } catch (e) { |
| | | isRegistered = false; |
| | | } |
| | | }, |
| | | stop() { |
| | | if (this._ensureTimer) { |
| | | clearInterval(this._ensureTimer); |
| | | this._ensureTimer = null; |
| | | } |
| | | if (!this.canUseAndroidBroadcast()) return; |
| | | if (!mainActivity || !receiver) return; |
| | | if (!isRegistered) return; |
| | |
| | | @confirm="onDateConfirm" |
| | | @cancel="showDate = false" |
| | | mode="date" /> |
| | | <PdaScan :active="pdaScanActive" |
| | | eventName="scan_repair_device" /> |
| | | <ScanWaitMask :show="scanMaskShow" :status="scanMaskStatus" /> |
| | | <PdaScan /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import { onShow, onLoad } from "@dcloudio/uni-app"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import CommonUpload from "@/components/CommonUpload.vue"; |
| | | import ScanWaitMask from "@/components/ScanWaitMask.vue"; |
| | | import PdaScan from "@/components/pda-scan/pda-scan.vue"; |
| | | import { getDeviceLedger } from "@/api/equipmentManagement/ledger"; |
| | | import { |
| | |
| | | // æ«ç ç¸å
³ç¶æ |
| | | const isScanning = ref(false); |
| | | const scanTimer = ref(null); |
| | | const pdaScanActive = ref(false); |
| | | const pdaScanTimer = ref(null); |
| | | const pendingDeviceScan = ref(false); |
| | | let pendingDeviceScanTimer = null; |
| | | const scanMaskShow = ref(false); |
| | | const scanMaskStatus = ref("waiting"); |
| | | const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
| | | |
| | | const canUsePdaBroadcast = () => { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | | if (plus?.os?.name !== "Android") return false; |
| | | if (!plus?.android) return false; |
| | | |
| | | const sys = uni.getSystemInfoSync?.() || {}; |
| | | const brand = String(sys?.brand || "").toUpperCase(); |
| | | const model = String(sys?.model || "").toUpperCase(); |
| | | |
| | | return ( |
| | | brand.includes("DROI") || |
| | | model.includes("MV-IDP5204") || |
| | | model.includes("IDP") |
| | | ); |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | onShow(() => { |
| | | uni.$off("scan"); |
| | | uni.$on("scan", data => { |
| | | console.log("onscan"); |
| | | console.log("æ«ç ç»æï¼", data.code); |
| | | if (!pendingDeviceScan.value) return; |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | delay(350).then(() => { |
| | | scanMaskShow.value = false; |
| | | handleScanResult(data.code); |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | // 表åéªè¯è§å |
| | | const formRules = { |
| | |
| | | |
| | | // æ«æäºç»´ç åè½ |
| | | const startScan = () => { |
| | | if (isScanning.value) { |
| | | showToast("æ£å¨æ«æä¸ï¼è¯·ç¨å..."); |
| | | return; |
| | | pendingDeviceScan.value = true; |
| | | scanMaskStatus.value = "waiting"; |
| | | scanMaskShow.value = true; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | |
| | | const canUsePdaBroadcast = () => { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | | if (plus?.os?.name !== "Android") return false; |
| | | if (!plus?.android) return false; |
| | | |
| | | const sys = uni.getSystemInfoSync?.() || {}; |
| | | const brand = String(sys?.brand || "").toUpperCase(); |
| | | const model = String(sys?.model || "").toUpperCase(); |
| | | |
| | | return ( |
| | | brand.includes("DROI") || |
| | | model.includes("MV-IDP5204") || |
| | | model.includes("IDP") |
| | | ); |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | if (canUsePdaBroadcast()) { |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | pdaScanTimer.value = null; |
| | | } |
| | | uni.$off("scan_repair_device"); |
| | | uni.$on("scan_repair_device", data => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_repair_device"); |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | pdaScanTimer.value = null; |
| | | } |
| | | handleScanResult(data?.code); |
| | | pendingDeviceScanTimer = setTimeout(() => { |
| | | pendingDeviceScan.value = false; |
| | | pendingDeviceScanTimer = null; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | pdaScanActive.value = true; |
| | | uni.showToast({ title: "请使ç¨PDAæ«ç ", icon: "none" }); |
| | | pdaScanTimer.value = setTimeout(() => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_repair_device"); |
| | | pdaScanTimer.value = null; |
| | | }, 20000); |
| | | return; |
| | | } |
| | | |
| | | if (canUsePdaBroadcast()) return; |
| | | uni.scanCode({ |
| | | scanType: ["qrCode", "barCode"], |
| | | success: res => { |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | delay(350).then(() => { |
| | | scanMaskShow.value = false; |
| | | handleScanResult(res.result); |
| | | }); |
| | | }, |
| | | fail: err => { |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | console.error("æ«ç 失败:", err); |
| | | showToast("æ«ç 失败ï¼è¯·éè¯"); |
| | | }, |
| | |
| | | showDate.value = false; |
| | | }; |
| | | |
| | | onShow(() => { |
| | | // 页颿¾ç¤ºæ¶é»è¾ |
| | | }); |
| | | |
| | | onMounted(() => { |
| | | // 页é¢å è½½æ¶è·å设å¤å表 |
| | | loadDeviceName(); |
| | |
| | | if (scanTimer.value) { |
| | | clearTimeout(scanTimer.value); |
| | | } |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | uni.$off("scan_repair_device"); |
| | | scanMaskShow.value = false; |
| | | uni.$off("scan"); |
| | | }); |
| | | |
| | | // æäº¤è¡¨å |
| | |
| | | @confirm="onDateConfirm" |
| | | @cancel="showDate = false" |
| | | mode="date" /> |
| | | <PdaScan :active="pdaScanActive" |
| | | eventName="scan_upkeep_device" /> |
| | | <ScanWaitMask :show="scanMaskShow" |
| | | :status="scanMaskStatus" /> |
| | | <PdaScan /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import { onShow } from "@dcloudio/uni-app"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import CommonUpload from "@/components/CommonUpload.vue"; |
| | | import ScanWaitMask from "@/components/ScanWaitMask.vue"; |
| | | import PdaScan from "@/components/pda-scan/pda-scan.vue"; |
| | | import { getDeviceLedger } from "@/api/equipmentManagement/ledger"; |
| | | import { |
| | |
| | | // æ«ç ç¸å
³ç¶æ |
| | | const isScanning = ref(false); |
| | | const scanTimer = ref(null); |
| | | const pdaScanActive = ref(false); |
| | | const pdaScanTimer = ref(null); |
| | | const pendingDeviceScan = ref(false); |
| | | let pendingDeviceScanTimer = null; |
| | | const scanMaskShow = ref(false); |
| | | const scanMaskStatus = ref("waiting"); |
| | | const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
| | | |
| | | const canUsePdaBroadcast = () => { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | | if (plus?.os?.name !== "Android") return false; |
| | | if (!plus?.android) return false; |
| | | |
| | | const sys = uni.getSystemInfoSync?.() || {}; |
| | | const brand = String(sys?.brand || "").toUpperCase(); |
| | | const model = String(sys?.model || "").toUpperCase(); |
| | | |
| | | return ( |
| | | brand.includes("DROI") || |
| | | model.includes("MV-IDP5204") || |
| | | model.includes("IDP") |
| | | ); |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | onShow(() => { |
| | | uni.$off("scan"); |
| | | uni.$on("scan", data => { |
| | | console.log("onscan"); |
| | | console.log("æ«ç ç»æï¼", data.code); |
| | | if (!pendingDeviceScan.value) return; |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | delay(350).then(() => { |
| | | scanMaskShow.value = false; |
| | | processScanResult(data.code); |
| | | }); |
| | | }); |
| | | getPageParams(); |
| | | }); |
| | | |
| | | // 表åéªè¯è§å |
| | | const formRules = { |
| | |
| | | |
| | | // æ«æäºç»´ç åè½ |
| | | const startScan = () => { |
| | | if (isScanning.value) { |
| | | showToast("æ£å¨æ«æä¸ï¼è¯·ç¨å..."); |
| | | return; |
| | | pendingDeviceScan.value = true; |
| | | scanMaskStatus.value = "waiting"; |
| | | scanMaskShow.value = true; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | |
| | | const canUsePdaBroadcast = () => { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | | if (plus?.os?.name !== "Android") return false; |
| | | if (!plus?.android) return false; |
| | | |
| | | const sys = uni.getSystemInfoSync?.() || {}; |
| | | const brand = String(sys?.brand || "").toUpperCase(); |
| | | const model = String(sys?.model || "").toUpperCase(); |
| | | |
| | | return ( |
| | | brand.includes("DROI") || |
| | | model.includes("MV-IDP5204") || |
| | | model.includes("IDP") |
| | | ); |
| | | } catch (e) { |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | if (canUsePdaBroadcast()) { |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | pdaScanTimer.value = null; |
| | | } |
| | | uni.$off("scan_upkeep_device"); |
| | | uni.$on("scan_upkeep_device", data => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_upkeep_device"); |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | pdaScanTimer.value = null; |
| | | } |
| | | handleScanResult(data?.code); |
| | | pendingDeviceScanTimer = setTimeout(() => { |
| | | pendingDeviceScan.value = false; |
| | | pendingDeviceScanTimer = null; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | pdaScanActive.value = true; |
| | | uni.showToast({ title: "请使ç¨PDAæ«ç ", icon: "none" }); |
| | | pdaScanTimer.value = setTimeout(() => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_upkeep_device"); |
| | | pdaScanTimer.value = null; |
| | | }, 20000); |
| | | return; |
| | | } |
| | | |
| | | if (canUsePdaBroadcast()) return; |
| | | uni.scanCode({ |
| | | scanType: ["qrCode", "barCode"], |
| | | success: res => { |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | delay(350).then(() => { |
| | | scanMaskShow.value = false; |
| | | handleScanResult(res.result); |
| | | }); |
| | | }, |
| | | fail: err => { |
| | | pendingDeviceScan.value = false; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | console.error("æ«ç 失败:", err); |
| | | showToast("æ«ç 失败ï¼è¯·éè¯"); |
| | | }, |
| | |
| | | showDate.value = false; |
| | | }; |
| | | |
| | | onShow(() => { |
| | | // 页颿¾ç¤ºæ¶è·ååæ° |
| | | getPageParams(); |
| | | }); |
| | | |
| | | onMounted(() => { |
| | | // 页é¢å è½½æ¶è·å设å¤å表ååæ° |
| | | loadDeviceName(); |
| | |
| | | if (scanTimer.value) { |
| | | clearTimeout(scanTimer.value); |
| | | } |
| | | if (pdaScanTimer.value) { |
| | | clearTimeout(pdaScanTimer.value); |
| | | if (pendingDeviceScanTimer) { |
| | | clearTimeout(pendingDeviceScanTimer); |
| | | pendingDeviceScanTimer = null; |
| | | } |
| | | uni.$off("scan_upkeep_device"); |
| | | scanMaskShow.value = false; |
| | | uni.$off("scan"); |
| | | }); |
| | | |
| | | // æäº¤è¡¨å |
| | |
| | | <PdaMediaUpload v-model="beforeModelValue" |
| | | :action="uploadFileUrl" |
| | | :limit="uploadConfig.limit" |
| | | :fileSize="uploadConfig.fileSize" |
| | | :uploadType="10" |
| | | :formData="{ type: 10 }" |
| | | :allowCamera="true" |
| | | :allowVideo="true" |
| | | @update:modelValue="handleFilesUpdate" |
| | | @choose-media="handleChooseMedia" |
| | | @uploading="uploading = $event" |
| | | @progress="uploadProgress = $event" /> |
| | | <!-- ç»è®¡ä¿¡æ¯ --> |
| | |
| | | |
| | | <script setup> |
| | | import { ref, computed, onMounted } from "vue"; |
| | | import { onLoad, onShow, onHide } from "@dcloudio/uni-app"; |
| | | import { onLoad } from "@dcloudio/uni-app"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import PdaMediaUpload from "@/components/pda-media-upload/pda-media-upload.vue"; |
| | | import { uploadInspectionTask } from "@/api/inspectionManagement"; |
| | |
| | | }, |
| | | }); |
| | | |
| | | // çå¬ä¸ä¼ è¿åº¦ |
| | | uploadTask.onProgressUpdate(res => { |
| | | uploadProgress.value = res.progress; |
| | | }); |
| | | }; |
| | | |
| | | // ç嬿件å表ååï¼ç»ä»¶å
é¨å¤çå é¤ï¼ç¶ç»ä»¶åªåæ¥ï¼ |
| | | const handleFilesUpdate = files => { |
| | | beforeModelValue.value = files; |
| | | }; |
| | | |
| | | // çå¬ç»ä»¶ç choose-media äºä»¶ï¼ç¨äºå
¼å®¹æ§é»è¾ï¼æè
å¨è¿éæ·»å èªå®ä¹æä½ï¼ |
| | | const handleChooseMedia = type => { |
| | | // å¯ä»¥å¨è¿éæ·»å èªå®ä¹çåç½®æä½ |
| | | console.log("ç¨æ·éæ©ä¸ä¼ ç±»å:", type); |
| | | }; |
| | | |
| | | // PDA æ«ç çå¬ï¼å¯éï¼å¦æéè¦éè¿æ«ç æ·»å æä¸ªæ ç¾æä¿¡æ¯ï¼å¨è¿éå¤çï¼ |
| | | const handlePdaScan = data => { |
| | | console.log("PDA æ«ç ç»æ:", data); |
| | | uni.showToast({ |
| | | title: `æ«ç ç»æ: ${data.code}`, |
| | | icon: "none", |
| | | }); |
| | | }; |
| | | |
| | | onShow(() => { |
| | | // 页颿¾ç¤ºæ¶ï¼çå¬ PDA æ«ç ï¼å¦ææéè¦çè¯ï¼ |
| | | uni.$on("scan_inspection", handlePdaScan); |
| | | }); |
| | | |
| | | onHide(() => { |
| | | uni.$off("scan_inspection"); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </up-grid> |
| | | </view> |
| | | </view> |
| | | <PdaScan :active="pdaScanActive" |
| | | eventName="scan_work_report" /> |
| | | <ScanWaitMask :show="scanMaskShow" |
| | | :status="scanMaskStatus" /> |
| | | <PdaScan /> |
| | | <DownloadProgressMask /> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, nextTick, reactive, computed } from "vue"; |
| | | import { onShow } from "@dcloudio/uni-app"; |
| | | import { userLoginFacotryList } from "@/api/login"; |
| | | import { getProductWorkOrderById } from "@/api/productionManagement/productionReporting"; |
| | | import DownloadProgressMask from "@/components/DownloadProgressMask.vue"; |
| | | import ScanWaitMask from "@/components/ScanWaitMask.vue"; |
| | | import PdaScan from "@/components/pda-scan/pda-scan.vue"; |
| | | import modal from "@/plugins/modal"; |
| | | import useUserStore from "@/store/modules/user"; |
| | |
| | | const show = ref(false); |
| | | const factoryList = ref([]); |
| | | const factoryListTem = ref([]); |
| | | const pdaScanActive = ref(false); |
| | | const pendingWorkReportScan = ref(false); |
| | | let scanWorkReportTimer = null; |
| | | const scanMaskShow = ref(false); |
| | | const scanMaskStatus = ref("waiting"); |
| | | const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
| | | const iconStyle = { |
| | | fontSize: "1.125rem", |
| | | color: "#2979ff", |
| | |
| | | factoryList.value = []; |
| | | }); |
| | | } |
| | | const getcode = async () => { |
| | | |
| | | const canUsePdaBroadcast = () => { |
| | | try { |
| | | if (typeof plus === "undefined") return false; |
| | |
| | | }); |
| | | }; |
| | | |
| | | if (canUsePdaBroadcast()) { |
| | | onShow(() => { |
| | | uni.$off("scan"); |
| | | uni.$on("scan", async data => { |
| | | console.log("onscan"); |
| | | console.log("æ«ç ç»æï¼", data.code); |
| | | if (!pendingWorkReportScan.value) return; |
| | | |
| | | pendingWorkReportScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (scanWorkReportTimer) { |
| | | clearTimeout(scanWorkReportTimer); |
| | | scanWorkReportTimer = null; |
| | | } |
| | | uni.$off("scan_work_report"); |
| | | uni.$on("scan_work_report", async data => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_work_report"); |
| | | if (scanWorkReportTimer) { |
| | | clearTimeout(scanWorkReportTimer); |
| | | scanWorkReportTimer = null; |
| | | } |
| | | await delay(350); |
| | | scanMaskShow.value = false; |
| | | await handleWorkReportScan(data?.code); |
| | | }); |
| | | pdaScanActive.value = true; |
| | | uni.showToast({ |
| | | title: "请使ç¨PDAæ«ç ", |
| | | icon: "none", |
| | | }); |
| | | scanWorkReportTimer = setTimeout(() => { |
| | | pdaScanActive.value = false; |
| | | uni.$off("scan_work_report"); |
| | | |
| | | const getcode = async () => { |
| | | pendingWorkReportScan.value = true; |
| | | scanMaskStatus.value = "waiting"; |
| | | scanMaskShow.value = true; |
| | | |
| | | if (scanWorkReportTimer) { |
| | | clearTimeout(scanWorkReportTimer); |
| | | scanWorkReportTimer = null; |
| | | }, 20000); |
| | | return; |
| | | } |
| | | |
| | | scanWorkReportTimer = setTimeout(() => { |
| | | pendingWorkReportScan.value = false; |
| | | scanWorkReportTimer = null; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | }, 20000); |
| | | |
| | | if (canUsePdaBroadcast()) return; |
| | | |
| | | uni.scanCode({ |
| | | success: async res => { |
| | | pendingWorkReportScan.value = false; |
| | | scanMaskStatus.value = "done"; |
| | | if (scanWorkReportTimer) { |
| | | clearTimeout(scanWorkReportTimer); |
| | | scanWorkReportTimer = null; |
| | | } |
| | | await delay(350); |
| | | scanMaskShow.value = false; |
| | | await handleWorkReportScan(res.result); |
| | | }, |
| | | fail: err => { |
| | | pendingWorkReportScan.value = false; |
| | | scanMaskStatus.value = "timeout"; |
| | | delay(900).then(() => { |
| | | scanMaskShow.value = false; |
| | | }); |
| | | if (scanWorkReportTimer) { |
| | | clearTimeout(scanWorkReportTimer); |
| | | scanWorkReportTimer = null; |
| | | } |
| | | uni.showToast({ |
| | | title: "æ«ç 失败", |
| | | icon: "none", |