From aca7aa9ce32acc4c8795342f945b027d3bc9f62a Mon Sep 17 00:00:00 2001
From: 曹睿 <360930172@qq.com>
Date: 星期二, 10 六月 2025 17:37:34 +0800
Subject: [PATCH] feat: 添加时效报工,修复扫码内存泄漏
---
src/pages/production/index.vue | 111 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 79 insertions(+), 32 deletions(-)
diff --git a/src/pages/production/index.vue b/src/pages/production/index.vue
index d82c8d7..017062f 100644
--- a/src/pages/production/index.vue
+++ b/src/pages/production/index.vue
@@ -5,44 +5,94 @@
<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-row>
- <wd-tabs v-model="tab" :lineWidth="110">
- <block v-for="(item, index) in productList" :key="index" class="tab_bg">
- <wd-tab :title="item.label">
- <view class="card_box">
- <Statistics class="statistics_box" />
- <ProductCard v-for="item in 10" @click="toDetail" />
- <wd-loadmore custom-class="loadmore" state="loading" />
- </view>
- </wd-tab>
- </block>
+ <wd-tabs v-model="tab" auto-line-width>
+ <wd-tab :title="`寰呯敓浜�(${total.wait})`" class="tab_bg">
+ <ProductList
+ ref="waitRef"
+ :api="ManageApi.getProductList"
+ state="寰呭畬鎴�"
+ @ok="changeWait"
+ />
+ </wd-tab>
+ <wd-tab :title="`宸茬敓浜�(${total.already})`" class="tab_bg">
+ <ProductList
+ ref="alreadyRef"
+ :api="ManageApi.getProductList"
+ state="宸插畬鎴�"
+ @ok="changeAlready"
+ />
+ </wd-tab>
</wd-tabs>
+ <Scan ref="scanRef" emitName="scan" />
+ <wd-toast />
</view>
</template>
<script lang="ts" setup>
-import ProductCard from "@/components/product_card/index.vue";
-import Statistics from "./components/Statistics.vue";
+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 tab = ref<number>(0);
+const total = reactive({
+ wait: 0,
+ already: 0,
+});
-const productList = ref<any[]>([
- {
- label: "寰呯敓浜�(10)",
- },
- {
- label: "宸茬敓浜�(20)",
- },
-]);
-
-const toDetail = () => {
- uni.navigateTo({
- url: "/pages/production/detail/wireDetail",
- });
+const changeWait = (num: number) => {
+ total.wait = num;
};
+
+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>
@@ -50,12 +100,12 @@
border-radius: unset;
}
.scan_box {
- padding: 6px;
display: flex;
align-items: center;
justify-content: center;
width: 38px;
height: 38px;
+ padding: 6px;
background: #fff;
}
::v-deep .wd-tabs__line {
@@ -65,7 +115,7 @@
border-bottom: 1px #dddddd solid;
}
.tab_bg {
- background: linear-gradient(0, #ffffff 29%, #f3f9f8 100%);
+ background: #f3f9f8;
}
.icon_box {
@@ -77,10 +127,7 @@
background: #e7f4ec99;
border-radius: 50%;
}
-.card_box {
- height: calc(100vh - 160px);
- overflow: scroll;
-}
+
.statistics_box {
margin: 15px;
}
--
Gitblit v1.9.3