12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {inject, reactive} from "vue";
- import {useMachineStore} from "@/store/useMachineStore";
- export const machineFun = {
- machine: reactive({
- scan: false,
- bmi: false,
- }),
- notifyMachineUsb({id, up}) {
- console.log('notifyMachineUsb', id, up)
- const machineStore = useMachineStore()
- this.machine[id] = up
- machineStore.setStatus(id, up)
- },
- getOnlineUsb(machine, callback) {
- let list = machine.getOnlineUsb()
- if (list) {
- list.forEach(it => {
- this.notifyMachineUsb({
- id: it,
- up: true,
- })
- })
- }
- if (callback) callback()
- },
- setUsbNotify(open = true) {
- if (open) {
- uni.$on('machineUsb', this.notifyMachineUsb)
- } else {
- uni.$off('machineUsb', this.notifyMachineUsb)
- }
- },
- }
|