From c056874186f0e2520f575d3363c5497df089e984 Mon Sep 17 00:00:00 2001 From: 曹睿 <360930172@qq.com> Date: 星期三, 04 六月 2025 13:59:28 +0800 Subject: [PATCH] feat: 首页支持扫码工时 --- src/api/work/report.ts | 14 +++++++ src/pages/production/twist/receive/monofil.vue | 6 -- src/pages/index/components/ReportWorkTime.vue | 48 ++++++++++++++++++++++++ src/pages/mine/index.vue | 18 ++++---- src/pages/index/index.vue | 19 ++++++--- 5 files changed, 84 insertions(+), 21 deletions(-) diff --git a/src/api/work/report.ts b/src/api/work/report.ts new file mode 100644 index 0000000..979913a --- /dev/null +++ b/src/api/work/report.ts @@ -0,0 +1,14 @@ +import request from "@/utils/request"; +import { BaseResult } from "@/models/base"; + +const reportApi = { + sendWorkTime(params: any) { + return request<BaseResult<any>>({ + url: "/app/updateTeamStartTime", + method: "GET", + data: params, + }); + }, +}; + +export default reportApi; diff --git a/src/pages/index/components/ReportWorkTime.vue b/src/pages/index/components/ReportWorkTime.vue new file mode 100644 index 0000000..4f67ec1 --- /dev/null +++ b/src/pages/index/components/ReportWorkTime.vue @@ -0,0 +1,48 @@ +<template> + <view> + <wd-icon name="scan" color="#999" size="18px" @click="openScan" /> + <Scan ref="scanRef" /> + <!-- 寮圭獥 --> + <wd-toast /> + </view> +</template> + +<script setup lang="ts"> +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"; + +defineOptions({ + name: "宸ユ椂鍙戦��", +}); + +const scanRef = ref(); +const userStore = useUserStore(); +const userInfo: any = computed(() => userStore.userInfo); +const toast = useToast(); + +const openScan = () => { + scanRef.value.triggerScan(); +}; + +const getScanCode = async () => { + const { code } = await reportApi.sendWorkTime({ + userName: userInfo.value.userName, + }); + if (code == 200) { + toast.success("鎵爜鎴愬姛"); + } +}; + +onLoad(() => { + // 寮�鍚箍鎾洃鍚簨浠� + uni.$on("scan", getScanCode); +}); +onUnload(() => { + // 寮�鍚箍鎾洃鍚簨浠� + uni.$off("scan", getScanCode); +}); +</script> + +<style lang="scss" scoped></style> diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 6024963..a1fa7f1 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -2,14 +2,18 @@ <view style="width: 100%; height: var(--status-bar-height)" /> <view class="home"> <!-- 褰撳墠鐢ㄦ埛 --> - <view class="text-[#0D867F] font-medium py-2 text-lg">浜ㄦ椇鐗瑰绾跨紗涓婃姤绯荤粺</view> + <view class="flex items-center justify-between"> + <view class="text-[#0D867F] font-medium py-2 text-lg"> + <text>浜ㄦ椇鐗瑰绾跨紗涓婃姤绯荤粺</text> + </view> + <view> + <ReportWorkTime /> + </view> + </view> <WorkerCallingCard /> <!-- 閫氱煡鍏憡 --> - <wd-notice-bar - text="vue-uniapp-template 鏄竴涓熀浜� Vue3 + UniApp 鐨勫墠绔ā鏉块」鐩紝鎻愪緵浜嗕竴濂楀畬鏁寸殑鍓嶇瑙e喅鏂规锛屽寘鎷櫥褰曘�佹潈闄愩�佸瓧鍏搞�佹帴鍙h姹傘�佺姸鎬佺鐞嗐�侀〉闈㈠竷灞�銆佺粍浠跺皝瑁呯瓑鍔熻兘銆�" - custom-class="space" - > + <wd-notice-bar text="杩欐槸涓�鏉℃祴璇曢�氱煡鐨勬暟鎹�" custom-class="space"> <template #prefix> <wd-icon class="prefix" name="warn-bold" size="14px"></wd-icon> <text class="text-xs">閫氱煡</text> @@ -57,7 +61,7 @@ </wd-grid-item> </wd-grid> --> - <wd-card> + <!-- <wd-card> <template #title> <view class="flex-between"> <view>璁块棶瓒嬪娍</view> @@ -78,7 +82,7 @@ <view class="charts-box"> <qiun-data-charts type="area" :chartData="chartData" :opts="chartOpts" /> </view> - </wd-card> + </wd-card> --> </view> </template> @@ -86,6 +90,7 @@ import { dayjs } from "wot-design-uni"; import LogAPI, { VisitStatsVO } from "@/api/system/log"; import WorkerCallingCard from "@/components/worker-calling-card/index.vue"; +import ReportWorkTime from "./components/ReportWorkTime.vue"; const visitStatsData = ref<VisitStatsVO>({ todayUvCount: 0, diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue index d6e1504..b164c37 100644 --- a/src/pages/mine/index.vue +++ b/src/pages/mine/index.vue @@ -268,14 +268,14 @@ }; // 甯歌闂 -const navigateToFAQ = () => { - uni.navigateTo({ url: "/pages/mine/faq/index" }); -}; +// const navigateToFAQ = () => { +// uni.navigateTo({ url: "/pages/mine/faq/index" }); +// }; // 鍏充簬鎴戜滑 -const navigateToAbout = () => { - uni.navigateTo({ url: "/pages/mine/about/index" }); -}; +// const navigateToAbout = () => { +// uni.navigateTo({ url: "/pages/mine/about/index" }); +// }; // 璁剧疆 const navigateToSettings = () => { @@ -283,9 +283,9 @@ }; // 闂鍙嶉 -const handleQuestionFeedback = () => { - uni.navigateTo({ url: "/pages/mine/feedback/index" }); -}; +// const handleQuestionFeedback = () => { +// uni.navigateTo({ url: "/pages/mine/feedback/index" }); +// }; // 瀵艰埅鍒板悇涓澘鍧� const navigateToSection = (section: string, subSection?: string) => { diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue index d6bd8ce..ab8eb9f 100644 --- a/src/pages/production/twist/receive/monofil.vue +++ b/src/pages/production/twist/receive/monofil.vue @@ -32,7 +32,7 @@ import CardTitle from "@/components/card-title/index.vue"; import MonofilCard from "../components/MonofilCard.vue"; import { useToast } from "wot-design-uni"; -import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app"; +import { onLoad, onUnload } from "@dcloudio/uni-app"; import Scan from "@/components/scan/index.vue"; import ManageApi from "@/api/product/manage"; import TwistApi from "@/api/product/twist"; @@ -110,10 +110,6 @@ // 寮�鍚箍鎾洃鍚簨浠� uni.$off("scan", getScanCode); }); - -onShow(() => {}); - -onHide(() => {}); </script> <style lang="scss" scoped> -- Gitblit v1.9.3