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.json | 6 src/pages/production/list/index.vue | 1 src/pages/production/twist/receive/monofil.vue | 6 src/components/scan/index3.vue | 104 +++++++++ src/pages/index/index.vue | 81 ++++--- src/pages/timely/index.vue | 108 +++++++++ src/components/scan/index.vue | 187 ++++++++-------- .env.development | 7 /dev/null | 48 ---- src/api/home/index.ts | 13 + src/api/product/twist.ts | 8 .env.production | 6 src/pages/production/wire/report/wireForm.vue | 28 +- src/pages/production/index.vue | 44 +++ src/components/product_card/index.vue | 6 15 files changed, 452 insertions(+), 201 deletions(-) diff --git a/.env.development b/.env.development index a01cc4d..5f42f2f 100644 --- a/.env.development +++ b/.env.development @@ -4,7 +4,10 @@ VITE_APP_PORT = 4096 # API 鍩虹璺緞锛屽紑鍙戠幆澧冧笅鐨勮姹傚墠缂� -VITE_APP_BASE_API = 'http://114.132.189.42:7002/mes' +# VITE_APP_BASE_API = 'http://114.132.189.42:7002/mes' +# VITE_APP_BASE_API = 'http://192.168.0.206:7002/mes' # 閭硅 +VITE_APP_BASE_API = 'http://192.168.0.244:8893/mes' # # API 鏈嶅姟鍣ㄧ殑 URL -VITE_APP_API_URL = 'http://114.132.189.42:7002/mes' +# VITE_APP_API_URL = 'http://114.132.189.42:7002/mes' +VITE_APP_API_URL = 'http://192.168.0.244:8893/mes' # diff --git a/.env.production b/.env.production index 1226d8b..a5aa117 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,8 @@ # API 鍩虹璺緞锛屽紑鍙戠幆澧冧笅鐨勮姹傚墠缂� -VITE_APP_BASE_API = '/prod-api' +# VITE_APP_BASE_API = 'http://114.132.189.42:7002/mes' +# API 鏈嶅姟鍣ㄧ殑 URL +# VITE_APP_API_URL = 'http://114.132.189.42:7002/mes' +# 灞变笢 +VITE_APP_API_URL = 'http://192.168.100.131:7002/mes' diff --git a/src/api/home/index.ts b/src/api/home/index.ts new file mode 100644 index 0000000..de1a66a --- /dev/null +++ b/src/api/home/index.ts @@ -0,0 +1,13 @@ +import request from "@/utils/request"; +import { BaseResult } from "@/models/base"; + +const HomeApi = { + getIndex() { + return request<BaseResult<any>>({ + url: "/app/getIndex", + method: "GET", + }); + }, +}; + +export default HomeApi; diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts index 57996cd..900e4a9 100644 --- a/src/api/product/twist.ts +++ b/src/api/product/twist.ts @@ -36,6 +36,14 @@ data: data, }); }, + + saveAge(data: any) { + return request<BaseResult<any>>({ + url: "/app/ageing", + method: "POST", + data: data, + }); + }, }; export default TwistApi; diff --git a/src/components/product_card/index.vue b/src/components/product_card/index.vue index 3cb28bb..9fb6b8c 100644 --- a/src/components/product_card/index.vue +++ b/src/components/product_card/index.vue @@ -16,7 +16,7 @@ </view> <text class="text-[#646874] mx-2"> 鎬婚渶姹傛暟閲�: - <text class="text-[#252525]">{{ data[map.totalAmount] }}m</text> + <text class="text-[#252525]">{{ data[map.totalAmount] }}{{ data[map.unit] }}</text> </text> </view> </wd-col> @@ -29,7 +29,7 @@ </view> <text class="text-[#646874] mx-2"> 宸茬敓浜ф暟閲�: - <text class="text-[#252525]">{{ data[map.amount] }}m</text> + <text class="text-[#252525]">{{ data[map.amount] }}{{ data[map.unit] }}</text> </text> </view> </wd-col> @@ -40,7 +40,7 @@ </view> <text class="text-[#646874] mx-2"> 寰呮帓浜ф暟閲�: - <text class="text-[#252525]">{{ data[map.unAmount] }}m</text> + <text class="text-[#252525]">{{ data[map.unAmount] }}{{ data[map.unit] }}</text> </text> </view> </wd-col> diff --git a/src/components/scan/index.vue b/src/components/scan/index.vue index 72b928f..018c202 100644 --- a/src/components/scan/index.vue +++ b/src/components/scan/index.vue @@ -3,100 +3,101 @@ <view class="content"></view> </view> </template> -<!-- 婵�鍏夋壂鐮侊紝骞挎挱妯″紡 --> -<script> -var main, receiver, filter; -var codeQueryTag = false; -export default { - data() { - return { - scanCode: "", - }; +<script lang="ts" setup> +const main = ref(); +const receiver = ref(); +const filter = ref(); +const codeQueryTag = ref(false); +const props = defineProps({ + emitName: { + type: String, + default: "scan", }, - created() { - // 鍒濆鍖� - this.initScan(); - // 鍚姩骞挎挱 - this.startScan(); - }, - onHide() { - // 缁撴潫骞挎挱 - this.stopScan(); - }, - destroyed() { - // 缁撴潫骞挎挱 - this.stopScan(); - }, - methods: { - // 鍒濆鍖� - initScan() { - // #ifdef APP - // console.log('initScan:鎵爜鍒濆鍖�'); - let that = this; - main = plus.android.runtimeMainActivity(); //鑾峰彇activity - //var context = plus.android.importClass('android.content.Context'); //涓婁笅鏂� - var IntentFilter = plus.android.importClass("android.content.IntentFilter"); - filter = new IntentFilter(); - //涓嬮潰鐨刟ddAction 鏀逛负鑷繁 pad 璁惧鐨勫箍鎾姩浣滐紙鍦ㄦ壂鎻忚缃垨鑰呭巶鍟嗛檮甯︾殑app 閲岄潰璁剧疆涓哄箍鎾ā寮忥紝鐒跺悗鏌ョ湅鐩稿簲鍙傛暟锛� - filter.addAction("com.dwexample.ACTION"); - receiver = plus.android.implements("io.dcloud.feature.internal.reflect.BroadcastReceiver", { - onReceive: (context, intent) => { - console.log("---onReceive锛�", context, intent); - plus.android.importClass(intent); - //涓嬮潰鐨刧etStringExtra鍐呮敼涓鸿嚜宸辩殑骞挎挱鏍囩锛堥敭鍊�/key锛夛細 data - //鏂戦┈ TC20 - var banMaSacanInfo = intent.getStringExtra( - "com.motorolasolutions.emdk.datawedge.data_string" - ); - // callback(intent.getStringExtra('com.motorolasolutions.emdk.datawedge.data_string')); - console.log("鏂戦┈鎵弿缁撴灉", banMaSacanInfo); - // 浼犲叆鎺ユ敹鍒扮殑鍙傛暟 - that.queryCode(banMaSacanInfo); - }, - }); - // #endif +}); + +const initScan = () => { + main.value = plus.android.runtimeMainActivity(); //鑾峰彇activity + let IntentFilter: any = plus.android.importClass("android.content.IntentFilter"); + filter.value = new IntentFilter(); + //涓嬮潰鐨刟ddAction 鏀逛负鑷繁 pad 璁惧鐨勫箍鎾姩浣滐紙鍦ㄦ壂鎻忚缃垨鑰呭巶鍟嗛檮甯︾殑app 閲岄潰璁剧疆涓哄箍鎾ā寮忥紝鐒跺悗鏌ョ湅鐩稿簲鍙傛暟锛� + filter.value.addAction("com.dwexample.ACTION"); + receiver.value = plus.android.implements("io.dcloud.feature.internal.reflect.BroadcastReceiver", { + onReceive: (context: any, intent: any) => { + console.log("---onReceive锛�", context, intent); + plus.android.importClass(intent); + //涓嬮潰鐨刧etStringExtra鍐呮敼涓鸿嚜宸辩殑骞挎挱鏍囩锛堥敭鍊�/key锛夛細 data + //鏂戦┈ TC20 + var banMaSacanInfo = intent.getStringExtra( + "com.motorolasolutions.emdk.datawedge.data_string" + ); + // callback(intent.getStringExtra('com.motorolasolutions.emdk.datawedge.data_string')); + console.log("鏂戦┈鎵弿缁撴灉", banMaSacanInfo); + // 浼犲叆鎺ユ敹鍒扮殑鍙傛暟 + queryCode(banMaSacanInfo); }, - // 寮�鍚箍鎾� - startScan() { - // #ifdef APP - console.log("startScan,寮�鍚箍鎾帴鏀�"); - main.registerReceiver(receiver, filter); - // #endif - }, - // 鍏抽棴骞挎挱 - stopScan() { - // #ifdef APP - console.log("stopScan缁撴潫"); - main.unregisterReceiver(receiver); - // #endif - }, - // 閬垮厤閲嶅鎵爜 - queryCode: function (code) { - // #ifdef APP - if (codeQueryTag) return false; - codeQueryTag = true; - setTimeout(function () { - codeQueryTag = false; - }, 150); - // console.log('-****--鎵爜code锛� ', code); - let data = code; - uni.$emit("scan", { - code: data, - }); - // #endif - }, - triggerScan() { - console.log("瑙﹀彂鎵弿"); - // 鑾峰彇Android鎰忓浘绫� - let Intent = plus.android.importClass("android.content.Intent"); - // 瀹炰緥鍖栨剰鍥� - let intent = new Intent(); - // 瀹氫箟鎰忓浘锛岀敱鍘傚晢鎻愪緵(姝ゅ璁剧疆涓轰笢澶х殑锛� 寮�濮嬫壂鎻忓箍鎾璫om.scan.onStartScan锛屽搴旂殑鍋滄鎵弿骞挎挱涓篶om.scan.onEndScan) - intent.setAction("com.symbol.datawedge.api.ACTION"); - intent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); - // 骞挎挱杩欎釜鎰忓浘 - main.sendBroadcast(intent); - }, - }, + }); }; + +// 寮�鍚箍鎾� +const startScan = () => { + // #ifdef APP + console.log("startScan,寮�鍚箍鎾帴鏀�"); + main.value.registerReceiver(receiver.value, filter.value); + // #endif +}; +// 鍏抽棴骞挎挱 +const stopScan = () => { + // #ifdef APP + console.log("stopScan缁撴潫"); + main.value.unregisterReceiver(receiver.value); + // #endif +}; + +const queryCode = (code: any) => { + // #ifdef APP + if (codeQueryTag.value) return false; + codeQueryTag.value = true; + setTimeout(function () { + codeQueryTag.value = false; + }, 150); + // console.log('-****--鎵爜code锛� ', code); + let data = code; + uni.$emit(props.emitName, { + code: data, + }); + // #endif +}; + +const triggerScan = () => { + console.log("瑙﹀彂鎵弿"); + // 鑾峰彇Android鎰忓浘绫� + let Intent = plus.android.importClass("android.content.Intent"); + // 瀹炰緥鍖栨剰鍥� + let intent = new Intent(); + // 瀹氫箟鎰忓浘锛岀敱鍘傚晢鎻愪緵(姝ゅ璁剧疆涓轰笢澶х殑锛� 寮�濮嬫壂鎻忓箍鎾璫om.scan.onStartScan锛屽搴旂殑鍋滄鎵弿骞挎挱涓篶om.scan.onEndScan) + intent.setAction("com.symbol.datawedge.api.ACTION"); + intent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); + // 骞挎挱杩欎釜鎰忓浘 + main.value.sendBroadcast(intent); +}; + +onLoad(() => { + console.log("鍒濆鍖�"); + // 鍒濆鍖� + initScan(); + // 鍚姩骞挎挱 + startScan(); +}); + +onHide(() => { + stopScan(); +}); + +onUnmounted(() => { + stopScan(); +}); + +defineExpose({ + triggerScan, +}); </script> diff --git a/src/components/scan/index3.vue b/src/components/scan/index3.vue new file mode 100644 index 0000000..b3984d6 --- /dev/null +++ b/src/components/scan/index3.vue @@ -0,0 +1,104 @@ +<template> + <view> + <view class="content"></view> + </view> +</template> +<!-- 婵�鍏夋壂鐮侊紝骞挎挱妯″紡 --> +<script> +var main, receiver, filter; +var codeQueryTag = false; +export default { + data() { + return { + scanCode: "", + }; + }, + + onLoad() { + console.log("鍒濆鍖�"); + // 鍒濆鍖� + this.initScan(); + // 鍚姩骞挎挱 + this.startScan(); + }, + onHide() { + // 缁撴潫骞挎挱 + this.stopScan(); + }, + destroyed() { + // 缁撴潫骞挎挱 + this.stopScan(); + }, + methods: { + // 鍒濆鍖� + initScan() { + // #ifdef APP + // console.log('initScan:鎵爜鍒濆鍖�'); + let that = this; + main = plus.android.runtimeMainActivity(); //鑾峰彇activity + //var context = plus.android.importClass('android.content.Context'); //涓婁笅鏂� + var IntentFilter = plus.android.importClass("android.content.IntentFilter"); + filter = new IntentFilter(); + //涓嬮潰鐨刟ddAction 鏀逛负鑷繁 pad 璁惧鐨勫箍鎾姩浣滐紙鍦ㄦ壂鎻忚缃垨鑰呭巶鍟嗛檮甯︾殑app 閲岄潰璁剧疆涓哄箍鎾ā寮忥紝鐒跺悗鏌ョ湅鐩稿簲鍙傛暟锛� + filter.addAction("com.dwexample.ACTION"); + receiver = plus.android.implements("io.dcloud.feature.internal.reflect.BroadcastReceiver", { + onReceive: (context, intent) => { + console.log("---onReceive锛�", context, intent); + plus.android.importClass(intent); + //涓嬮潰鐨刧etStringExtra鍐呮敼涓鸿嚜宸辩殑骞挎挱鏍囩锛堥敭鍊�/key锛夛細 data + //鏂戦┈ TC20 + var banMaSacanInfo = intent.getStringExtra( + "com.motorolasolutions.emdk.datawedge.data_string" + ); + // callback(intent.getStringExtra('com.motorolasolutions.emdk.datawedge.data_string')); + console.log("鏂戦┈鎵弿缁撴灉", banMaSacanInfo); + // 浼犲叆鎺ユ敹鍒扮殑鍙傛暟 + that.queryCode(banMaSacanInfo); + }, + }); + // #endif + }, + // 寮�鍚箍鎾� + startScan() { + // #ifdef APP + console.log("startScan,寮�鍚箍鎾帴鏀�"); + main.registerReceiver(receiver, filter); + // #endif + }, + // 鍏抽棴骞挎挱 + stopScan() { + // #ifdef APP + console.log("stopScan缁撴潫"); + main.unregisterReceiver(receiver); + // #endif + }, + // 閬垮厤閲嶅鎵爜 + queryCode: function (code) { + // #ifdef APP + if (codeQueryTag) return false; + codeQueryTag = true; + setTimeout(function () { + codeQueryTag = false; + }, 150); + // console.log('-****--鎵爜code锛� ', code); + let data = code; + uni.$emit(this.emitName, { + code: data, + }); + // #endif + }, + triggerScan() { + console.log("瑙﹀彂鎵弿"); + // 鑾峰彇Android鎰忓浘绫� + let Intent = plus.android.importClass("android.content.Intent"); + // 瀹炰緥鍖栨剰鍥� + let intent = new Intent(); + // 瀹氫箟鎰忓浘锛岀敱鍘傚晢鎻愪緵(姝ゅ璁剧疆涓轰笢澶х殑锛� 寮�濮嬫壂鎻忓箍鎾璫om.scan.onStartScan锛屽搴旂殑鍋滄鎵弿骞挎挱涓篶om.scan.onEndScan) + intent.setAction("com.symbol.datawedge.api.ACTION"); + intent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); + // 骞挎挱杩欎釜鎰忓浘 + main.sendBroadcast(intent); + }, + }, +}; +</script> diff --git a/src/pages.json b/src/pages.json index e5b5e6b..279327f 100644 --- a/src/pages.json +++ b/src/pages.json @@ -260,6 +260,12 @@ "style": { "navigationBarTitleText": "缁炵嚎鏉傚伐缂栬緫" } + }, + { + "path": "pages/timely/index", + "style": { + "navigationBarTitleText": "鏃舵晥鎶ュ伐" + } } ], "globalStyle": { diff --git a/src/pages/index/components/ReportWorkTime.vue b/src/pages/index/components/ReportWorkTime.vue deleted file mode 100644 index 4f67ec1..0000000 --- a/src/pages/index/components/ReportWorkTime.vue +++ /dev/null @@ -1,48 +0,0 @@ -<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 a1fa7f1..844ab8b 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -6,9 +6,6 @@ <view class="text-[#0D867F] font-medium py-2 text-lg"> <text>浜ㄦ椇鐗瑰绾跨紗涓婃姤绯荤粺</text> </view> - <view> - <ReportWorkTime /> - </view> </view> <WorkerCallingCard /> @@ -20,19 +17,15 @@ </template> </wd-notice-bar> <!-- 蹇嵎瀵艰埅 --> - <wd-grid clickable :column="4" class="mt-2"> - <wd-grid-item - v-for="(item, index) in navList" - :key="index" - use-slot - link-type="navigateTo" - :url="item.url" - > - <view class="p-2"> - <image class="w-72rpx h-72rpx rounded-8rpx" :src="item.icon" /> - </view> - <view class="text">{{ item.title }}</view> - </wd-grid-item> + <wd-grid clickable :column="1" class="mt-2"> + <view v-for="(item, index) in navList"> + <wd-grid-item v-if="item.show" :key="index" use-slot link-type="navigateTo" :url="item.url"> + <view class="p-2"> + <image class="w-72rpx h-72rpx rounded-8rpx" :src="item.icon" /> + </view> + <view class="text">{{ item.title }}</view> + </wd-grid-item> + </view> </wd-grid> <!-- 鏁版嵁缁熻 --> @@ -87,10 +80,11 @@ </template> <script setup lang="ts"> +import { reactive } from "vue"; 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"; +import HomeApi from "@/api/home"; const visitStatsData = ref<VisitStatsVO>({ todayUvCount: 0, @@ -141,24 +135,31 @@ icon: "/static/icons/user.png", title: "鐢熶骇绠$悊", url: "/pages/production/index", + show: false, }, + // { + // icon: "/static/icons/role.png", + // title: "瑙掕壊绠$悊", + // url: "/pages/work/role/index", + // prem: "sys:role:query", + // }, + // { + // icon: "/static/icons/notice.png", + // title: "閫氱煡鍏憡", + // url: "/pages/work/notice/index", + // prem: "sys:notice:query", + // }, + // { + // icon: "/static/icons/setting.png", + // title: "绯荤粺閰嶇疆", + // url: "/pages/work/config/index", + // prem: "sys:config:query", + // }, { - icon: "/static/icons/role.png", - title: "瑙掕壊绠$悊", - url: "/pages/work/role/index", - prem: "sys:role:query", - }, - { - icon: "/static/icons/notice.png", - title: "閫氱煡鍏憡", - url: "/pages/work/notice/index", - prem: "sys:notice:query", - }, - { - icon: "/static/icons/setting.png", - title: "绯荤粺閰嶇疆", - url: "/pages/work/config/index", - prem: "sys:config:query", + icon: "/static/icons/log.png", + title: "鏃舵晥鎶ュ伐", + url: "/pages/timely/index", + show: false, }, ]); @@ -205,9 +206,17 @@ loadVisitTrendData(); }; -onReady(() => { - // loadVisitStatsData(); - // loadVisitTrendData(); +const init = async () => { + const { data } = await HomeApi.getIndex(); + if (data.deviceGroupName == "鏃舵晥缁�") { + navList[1].show = true; + } else { + navList[0].show = true; + } +}; + +onMounted(() => { + init(); }); </script> diff --git a/src/pages/production/index.vue b/src/pages/production/index.vue index a55a50a..017062f 100644 --- a/src/pages/production/index.vue +++ b/src/pages/production/index.vue @@ -5,7 +5,7 @@ <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> @@ -28,6 +28,8 @@ /> </wd-tab> </wd-tabs> + <Scan ref="scanRef" emitName="scan" /> + <wd-toast /> </view> </template> @@ -35,6 +37,15 @@ 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(); @@ -51,6 +62,37 @@ 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> diff --git a/src/pages/production/list/index.vue b/src/pages/production/list/index.vue index 93d3a2e..92862f8 100644 --- a/src/pages/production/list/index.vue +++ b/src/pages/production/list/index.vue @@ -39,6 +39,7 @@ totalAmount: "totalAmount", amount: "amount", unAmount: "unAmount", + unit: "unit", }); const props = defineProps({ api: { diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue index ab8eb9f..9f3fb11 100644 --- a/src/pages/production/twist/receive/monofil.vue +++ b/src/pages/production/twist/receive/monofil.vue @@ -23,7 +23,7 @@ </view> </template> </z-paging> - <Scan ref="scanRef" /> + <Scan ref="scanRef" emitName="scanMono" /> <wd-toast /> </view> </template> @@ -103,12 +103,12 @@ onLoad((options: any) => { // 寮�鍚箍鎾洃鍚簨浠� - uni.$on("scan", getScanCode); + uni.$on("scanMono", getScanCode); paramsId.value = options.id; }); onUnload(() => { // 寮�鍚箍鎾洃鍚簨浠� - uni.$off("scan", getScanCode); + uni.$off("scanMono", getScanCode); }); </script> diff --git a/src/pages/production/wire/report/wireForm.vue b/src/pages/production/wire/report/wireForm.vue index b2c4b74..f4e71f6 100644 --- a/src/pages/production/wire/report/wireForm.vue +++ b/src/pages/production/wire/report/wireForm.vue @@ -51,9 +51,9 @@ clearable placeholder="璇疯緭鍏ユ潌鍖呭彿" > - <template #label> - <span style="color: #F56C6C">鏉嗗寘鍙�</span> - </template> + <template #label> + <span style="color: #f56c6c">鏉嗗寘鍙�</span> + </template> </wd-input> <wd-input v-model="model.dishModel" @@ -62,9 +62,9 @@ clearable placeholder="璇疯緭鍏ョ洏鍨嬪彿" > - <template #label> - <span style="color: #F56C6C">鐩樺瀷鍙�</span> - </template> + <template #label> + <span style="color: #f56c6c">鐩樺瀷鍙�</span> + </template> </wd-input> <wd-input v-model="model.actuallyLength" @@ -73,9 +73,9 @@ clearable placeholder="璇疯緭鍏ュ疄闄呴暱搴�" > - <template #label> - <span style="color: #F56C6C">瀹為檯闀垮害(m)</span> - </template> + <template #label> + <span style="color: #f56c6c">瀹為檯闀垮害(m)</span> + </template> </wd-input> <wd-input v-model="model.actuallyWeight" @@ -84,9 +84,9 @@ clearable placeholder="璇疯緭鍏ュ疄闄呴噸閲�" > - <template #label> - <span style="color: #F56C6C">瀹為檯閲嶉噺(kg)</span> - </template> + <template #label> + <span style="color: #f56c6c">瀹為檯閲嶉噺(kg)</span> + </template> </wd-input> </wd-cell-group> <wd-toast /> @@ -123,7 +123,7 @@ }); if (code == 200) { toast.success("鎻愪氦鎴愬姛"); - resetForm() + resetForm(); return true; } else { toast.error("鎻愪氦澶辫触"); @@ -142,7 +142,7 @@ const arr = code.code.split(","); model.poleNumber = arr[3]; // 棰嗙敤鏉嗗彿 model.poleWeight = arr[4]; // 鏉嗛噸 - model.poleModel = '桅' + arr[1].slice(2); // 鏉嗗瀷鍙� + model.poleModel = arr[2]; // 鏉嗗瀷鍙� }; onLoad((options: any) => { diff --git a/src/pages/timely/index.vue b/src/pages/timely/index.vue new file mode 100644 index 0000000..ab55d7b --- /dev/null +++ b/src/pages/timely/index.vue @@ -0,0 +1,108 @@ +<template> + <view class="list_box"> + <z-paging ref="pagingRef" v-model="cardList" :fixed="false" :auto-show-back-to-top="true"> + <template #top> + <CardTitle title="鏃舵晥鎶ュ伐" :hideAction="false"> + <template #action> + <wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button> + </template> + </CardTitle> + </template> + <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" /> + <template #bottom> + <view class="flex justify-center items-center"> + <wd-button block @click="save"> + <text class="text-[#fff]">淇濆瓨</text> + </wd-button> + </view> + </template> + </z-paging> + <Scan ref="scanRef" emitName="scanTime" /> + <wd-toast /> + </view> +</template> + +<script setup lang="ts"> +import CardTitle from "@/components/card-title/index.vue"; +import zPaging from "@/components/z-paging/z-paging.vue"; +import Scan from "@/components/scan/index.vue"; +import MonofilCard from "../production/twist/components/MonofilCard.vue"; +import TwistApi from "@/api/product/twist"; +import { useToast } from "wot-design-uni"; + +const pagingRef = ref(); +const scanRef = ref(); +const toast = useToast(); +const cardList = ref<any>([]); + +const getScanCode = async (code: any) => { + console.log("鏃舵晥鎵爜鍥炶皟:", code); + console.log("json:", JSON.parse(code.code)); + console.log("id:=============", JSON.parse(code.code).id); + const { data } = await TwistApi.getScarn({ + outPutId: JSON.parse(code.code).id, + }); + console.log("=======璇锋眰========", data); + const exists = cardList.value.some( + (item: any) => item.monofilamentNumber === data.monofilamentNumber + ); + if (!exists) { + const { id, outPutId, wireId, oneLength, ...rest } = data; + console.log("sb", { + outputId: id, + amount: oneLength, + ongLength: oneLength, + ...rest, + }); + cardList.value.push({ + outputId: id, + amount: oneLength, + ongLength: oneLength, + ...rest, + }); + pagingRef.value.complete(cardList.value); + } else { + toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆壂鐮�"); + } +}; +const save = async () => { + const { code } = await TwistApi.saveAge(cardList.value); + if (code == 200) { + toast.success("淇濆瓨鎴愬姛"); + pagingRef.value.refresh(); + } else { + toast.error("淇濆瓨澶辫触"); + } +}; + +const openScan = () => { + scanRef.value.triggerScan(); +}; + +// 纭繚鍏堢Щ闄ゅ啀娣诲姞鐩戝惉 +const setupScanListener = () => { + uni.$off("scanTime", getScanCode); // 鍏堢Щ闄ゆ棫鐨� + uni.$on("scanTime", getScanCode); // 鍐嶆坊鍔犳柊鐨� +}; + +onMounted(() => { + setupScanListener(); + console.log("椤甸潰鏄剧ず - 鎵爜鐩戝惉宸茶缃�"); +}); + +onUnmounted(() => { + // 寮�鍚箍鎾洃鍚簨浠� + uni.$off("scanTime", getScanCode); + console.log("椤甸潰鍗歌浇 - 鎵爜鐩戝惉宸茬Щ闄�"); +}); +</script> + +<style lang="scss" scoped> +.list_box { + height: calc(100vh - 100px); + background: #f3f9f8; +} +:deep(.wd-button__content) { + color: #0d867f; +} +</style> -- Gitblit v1.9.3