| | |
| | | <wd-search placeholder-left hide-cancel></wd-search> |
| | | </wd-col> |
| | | <wd-col :span="3"> |
| | | <view class="scan_box"> |
| | | <view class="scan_box" @click="openScan"> |
| | | <wd-icon name="scan" size="24px" color="#0D867F"></wd-icon> |
| | | </view> |
| | | </wd-col> |
| | |
| | | /> |
| | | </wd-tab> |
| | | </wd-tabs> |
| | | <Scan ref="scanRef" emitName="scan" /> |
| | | <wd-toast /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import ManageApi from "@/api/product/manage"; |
| | | import { ref } from "vue"; |
| | | import ProductList from "./list/index.vue"; |
| | | import Scan from "@/components/scan/index.vue"; |
| | | import { useUserStore } from "@/store/modules/user"; |
| | | import reportApi from "@/api/work/report"; |
| | | import { useToast } from "wot-design-uni"; |
| | | |
| | | const scanRef = ref(); |
| | | const userStore = useUserStore(); |
| | | const userInfo: any = computed(() => userStore.userInfo); |
| | | const toast = useToast(); |
| | | |
| | | const waitRef = ref(); |
| | | const alreadyRef = ref(); |
| | |
| | | const changeAlready = (num: number) => { |
| | | total.already = num; |
| | | }; |
| | | |
| | | const openScan = () => { |
| | | scanRef.value.triggerScan(); |
| | | }; |
| | | |
| | | const getScanCode = async () => { |
| | | console.log("生产管理扫码回调"); |
| | | const { code } = await reportApi.sendWorkTime({ |
| | | userName: userInfo.value.userName, |
| | | }); |
| | | if (code == 200) { |
| | | toast.success("扫码成功"); |
| | | } |
| | | }; |
| | | |
| | | // 确保先移除再添加监听 |
| | | const setupScanListener = () => { |
| | | uni.$off("scan", getScanCode); // 先移除旧的 |
| | | uni.$on("scan", getScanCode); // 再添加新的 |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | // 开启广播监听事件 |
| | | setupScanListener(); |
| | | console.log("显示1"); |
| | | }); |
| | | onUnmounted(() => { |
| | | // 开启广播监听事件 |
| | | uni.$off("scan", getScanCode); |
| | | console.log("离开1"); |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |