From 5b62f70d5df5731a571d709f0f9ff312a7cec5dc Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 20 十一月 2025 16:25:59 +0800
Subject: [PATCH] fix: 巡检加上绞合外径可选
---
src/pages/production/twist/receive/monofil.vue | 368 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 317 insertions(+), 51 deletions(-)
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index d5cc002..b4998fc 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -11,16 +11,27 @@
<CardTitle title="鍗曚笣棰嗙敤" :hideAction="false">
<template #action>
<wd-button type="icon" icon="scan" color="#0D867F" @click="openScan"></wd-button>
+ <wd-button
+ type="icon"
+ icon="add-circle"
+ color="#0D867F"
+ @click="openManualInput"
+ ></wd-button>
</template>
</CardTitle>
</template>
<!-- <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" /> -->
- <wd-tabs v-model="tab" slidable="always">
+ <wd-tabs v-model="tab" slidable="always" class="tabs-container">
<block v-for="item in nodeList" :key="item">
<wd-tab :title="item.twistedLayer" :name="item.twistedLayer">
- <view class="content">
- <MonofilCard v-for="(m, i) in item.strandedWireDish" :key="i" :data="m" />
- </view>
+ <scroll-view class="content" scroll-y>
+ <MonofilCard
+ v-for="(m, i) in item.strandedWireDish"
+ :key="i"
+ :data="m"
+ @delete="handleDeleteCard(item, m)"
+ />
+ </scroll-view>
</wd-tab>
</block>
</wd-tabs>
@@ -38,6 +49,32 @@
:nodeList="nodeList"
@confirm="handleConfirmSave"
/>
+
+ <!-- 鎵嬪姩杈撳叆璐ㄩ噺杩芥函鍙峰脊妗� -->
+ <wd-popup v-model="showManualInput" position="center" :close-on-click-modal="false">
+ <view class="manual-input-modal">
+ <view class="modal-header">
+ <text class="title">鎵嬪姩棰嗙敤鍗曚笣</text>
+ <wd-icon name="close" @click="closeManualInput" />
+ </view>
+ <view class="modal-content">
+ <view class="input-label">鍗曚笣缂栧彿</view>
+ <wd-input
+ v-model="manualOutPutId"
+ placeholder="璇疯緭鍏ュ崟涓濈紪鍙�"
+ clearable
+ @clear="manualOutPutId = ''"
+ />
+ </view>
+ <view class="modal-footer">
+ <wd-button @click="closeManualInput" type="default">鍙栨秷</wd-button>
+ <wd-button type="primary" @click="handleManualConfirm" custom-class="confirm-btn">
+ 纭畾
+ </wd-button>
+ </view>
+ </view>
+ </wd-popup>
+
<wd-toast />
</view>
</template>
@@ -47,7 +84,7 @@
import MonofilCard from "../components/MonofilCard.vue";
import StatisticsModal from "../components/StatisticsModal.vue";
import { useToast } from "wot-design-uni";
-import { onLoad, onUnload } from "@dcloudio/uni-app";
+import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
import Scan from "@/components/scan/index.vue";
import ManageApi from "@/api/product/manage";
import TwistApi from "@/api/product/twist";
@@ -61,67 +98,155 @@
const toast = useToast();
const tab = ref("");
const showStatisticsModal = ref(false);
+const showManualInput = ref(false);
+const manualOutPutId = ref("");
+const isPageVisible = ref(false); // 鏍囪椤甸潰鏄惁鍙
// 鐩戝惉鏍囩鍒囨崲
watch(tab, () => {
if (tab.value) {
- console.log("tab.value:===========1", tab.value);
getList();
}
});
const getScanCode = async (code: any) => {
- console.log("鑷畾涔夋壂鎻忕殑缁撴灉鍥炶皟鍑芥暟:", code);
- // let parseData = code.trim();
- console.log("code:===========", JSON.parse(code.code));
- console.log("id:=============", JSON.parse(code.code).id);
- const { data } = await TwistApi.getScarn({
- outPutId: JSON.parse(code.code).id,
- });
-
- // 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
- if (!tab.value) {
- toast.error("璇峰厛閫夋嫨涓�涓眰");
+ // 妫�鏌ラ〉闈㈡槸鍚﹀彲瑙侊紝濡傛灉涓嶅彲瑙佸垯涓嶅鐞嗘壂鐮佹暟鎹�
+ if (!isPageVisible.value) {
return;
}
- // 鎵惧埌褰撳墠閫変腑鐨勫眰
- console.log("tab.value:===========2", tab.value);
- const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
- if (!currentLayer) {
- toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
- return;
- }
-
- // 妫�鏌ュ綋鍓嶅眰鏄惁宸插瓨鍦ㄨ鍗曚笣
- const exists = currentLayer.strandedWireDish?.some(
- (item: any) => item.monofilamentNumber === data.monofilamentNumber
- );
- if (!exists) {
- const { id, outPutId, wireId, oneLength, ...rest } = data;
- const newItem = {
- wireId: paramsId.value,
- outputId: id,
- amount: oneLength,
- ongLength: oneLength,
- ...rest,
- };
-
- // 娣诲姞鍒板綋鍓嶅眰鐨� strandedWireDish 涓�
- if (!currentLayer.strandedWireDish) {
- currentLayer.strandedWireDish = [];
+ try {
+ // 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
+ return;
}
- currentLayer.strandedWireDish.push(newItem);
- // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
- getList();
- } else {
- toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆壂鐮�");
+ // 鎵惧埌褰撳墠閫変腑鐨勫眰
+ const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
+ if (!currentLayer) {
+ toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
+ return;
+ }
+
+ // 瑙f瀽鎵爜鏁版嵁
+ const scanData = JSON.parse(code.code);
+
+ // 鍒ゆ柇灞傜骇鏄惁鍖归厤
+ if (scanData.layer && scanData.layer !== currentLayer.twistedLayer) {
+ toast.error(
+ `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${scanData.layer}`
+ );
+ // return;
+ }
+
+ const { data } = await TwistApi.getScarn({
+ outPutId: scanData.id,
+ twistId: currentLayer.twistId,
+ });
+
+ // 妫�鏌ュ綋鍓嶅眰鏄惁宸插瓨鍦ㄨ鍗曚笣
+ const exists = currentLayer.strandedWireDish?.some(
+ (item: any) => item.monofilamentNumber === data.monofilamentNumber
+ );
+ if (!exists) {
+ const { id, outPutId, wireId, oneLength, ...rest } = data;
+ const newItem = {
+ wireId: paramsId.value,
+ outputId: id,
+ amount: oneLength,
+ ongLength: oneLength,
+ ...rest,
+ };
+
+ // 娣诲姞鍒板綋鍓嶅眰鐨� strandedWireDish 涓�
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push(newItem);
+
+ // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+ getList();
+ } else {
+ toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆壂鐮�");
+ }
+ } catch (error) {
+ toast.error("浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
}
};
const openScan = () => {
scanRef.value.triggerScan();
+};
+
+// 鎵撳紑鎵嬪姩杈撳叆寮规
+const openManualInput = () => {
+ // 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
+ return;
+ }
+ showManualInput.value = true;
+};
+
+// 鍏抽棴鎵嬪姩杈撳叆寮规
+const closeManualInput = () => {
+ showManualInput.value = false;
+ manualOutPutId.value = "";
+};
+
+// 鎵嬪姩杈撳叆纭
+const handleManualConfirm = async () => {
+ if (!manualOutPutId.value.trim()) {
+ toast.error("璇疯緭鍏ヨ川閲忚拷婧彿");
+ return;
+ }
+
+ try {
+ const { data } = await TwistApi.selectByMonofilamentNumber({
+ monofilamentNumber: manualOutPutId.value.trim(),
+ });
+
+ // 鎵惧埌褰撳墠閫変腑鐨勫眰
+ const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
+ if (!currentLayer) {
+ toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
+ return;
+ }
+
+ // 妫�鏌ュ綋鍓嶅眰鏄惁宸插瓨鍦ㄨ鍗曚笣
+ const exists = currentLayer.strandedWireDish?.some(
+ (item: any) => item.monofilamentNumber === data.monofilamentNumber
+ );
+
+ if (!exists) {
+ const { id, outPutId, wireId, oneLength, ...rest } = data;
+ const newItem = {
+ wireId: paramsId.value,
+ outputId: id,
+ amount: oneLength,
+ ongLength: oneLength,
+ ...rest,
+ };
+
+ // 娣诲姞鍒板綋鍓嶅眰鐨� strandedWireDish 涓�
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push(newItem);
+
+ // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+ getList();
+
+ // 鍏抽棴寮规骞舵竻绌鸿緭鍏�
+ closeManualInput();
+ toast.success("娣诲姞鎴愬姛");
+ } else {
+ toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆坊鍔�");
+ }
+ } catch (error: any) {
+ toast.error(error.msg || "鏌ヨ澶辫触");
+ }
};
const getList = async () => {
@@ -150,7 +275,6 @@
// 璁剧疆榛樿绗竴灞�
if (nodeList.value && nodeList.value.length > 0 && !tab.value) {
tab.value = nodeList.value[0].twistedLayer;
- console.log("璁剧疆榛樿绗竴灞�:", tab.value);
// 璁剧疆榛樿鏍囩鍚庯紝鍔犺浇绗竴灞傜殑鏁版嵁
getList();
}
@@ -189,7 +313,7 @@
nodeList.value.forEach((node) => {
node.strandedWireDish.forEach((item: any) => {
- item.twistId = node.twistId;
+ item.saleTwistId = node.twistId;
});
if (node.strandedWireDish && Array.isArray(node.strandedWireDish)) {
const layerNewData = node.strandedWireDish.filter(
@@ -226,6 +350,44 @@
}
};
+// 鍒犻櫎鍗$墖
+const handleDeleteCard = async (layer: any, cardData: any) => {
+ // 鏄剧ず纭鎻愮ず
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "纭畾瑕佸垹闄よ鍗曚笣鍚楋紵",
+ success: async (res) => {
+ if (res.confirm) {
+ try {
+ // 濡傛灉鏈塱d锛岃皟鐢ㄦ帴鍙e垹闄�
+ if (cardData.id !== undefined && cardData.id !== null) {
+ const { code, msg } = await TwistApi.deleteStrandedWireDish(cardData.id);
+ if (code !== 200) {
+ toast.error(msg || "鍒犻櫎澶辫触");
+ return;
+ }
+ }
+
+ // 鍓嶇鐩存帴鍒犻櫎锛堟棤璁烘槸鍚︽湁id锛岄兘浠庡墠绔垹闄わ級
+ if (layer.strandedWireDish && Array.isArray(layer.strandedWireDish)) {
+ const index = layer.strandedWireDish.findIndex(
+ (item: any) => item.monofilamentNumber === cardData.monofilamentNumber
+ );
+ if (index !== -1) {
+ layer.strandedWireDish.splice(index, 1);
+ toast.success("鍒犻櫎鎴愬姛");
+ // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+ getList();
+ }
+ }
+ } catch (error: any) {
+ toast.error(error.msg || "鍒犻櫎澶辫触");
+ }
+ }
+ },
+ });
+};
+
onLoad(async (options: any) => {
// 寮�鍚箍鎾洃鍚簨浠�
uni.$on("scanMono", getScanCode);
@@ -235,30 +397,134 @@
getRootNumber(options.id);
// getRootNumber(118);
});
+
+onShow(() => {
+ // 椤甸潰鏄剧ず鏃舵爣璁颁负鍙
+ isPageVisible.value = true;
+});
+
+onHide(() => {
+ // 椤甸潰闅愯棌鏃舵爣璁颁负涓嶅彲瑙�
+ isPageVisible.value = false;
+});
+
onUnload(() => {
- // 寮�鍚箍鎾洃鍚簨浠�
+ // 鍙栨秷骞挎挱鐩戝惉浜嬩欢
uni.$off("scanMono", getScanCode);
+ isPageVisible.value = false;
});
</script>
<style lang="scss" scoped>
.list_box {
- height: calc(100vh - 100px);
+ height: calc(100vh - 50px);
background: #f3f9f8;
+ display: flex;
+ flex-direction: column;
}
+
+// 鎵嬪姩杈撳叆寮规鏍峰紡
+.manual-input-modal {
+ width: 320px;
+ background: #fff;
+ border-radius: 12px;
+ overflow: hidden;
+
+ .modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px 20px;
+ border-bottom: 1px solid #f0f0f0;
+
+ .title {
+ font-size: 18px;
+ font-weight: 600;
+ color: #333;
+ }
+ }
+
+ .modal-content {
+ padding: 20px;
+
+ .input-label {
+ font-size: 14px;
+ color: #333;
+ margin-bottom: 8px;
+ font-weight: 500;
+ }
+ }
+
+ .modal-footer {
+ display: flex;
+ gap: 12px;
+ padding: 16px 20px;
+ border-top: 1px solid #f0f0f0;
+ }
+}
+
+:deep(.manual-input-modal .confirm-btn) {
+ background-color: #0d867f !important;
+ border-color: #0d867f !important;
+
+ .wd-button__content {
+ color: #fff !important;
+ }
+}
+
+// tab瀹瑰櫒鏍峰紡
+.tabs-container {
+ height: calc(100vh - 200px);
+ display: flex;
+ flex-direction: column;
+}
+
+.content {
+ height: calc(100vh - 200px);
+ width: 100%;
+}
+
:deep(.wd-button__content) {
color: #0d867f;
}
:deep(.zp-paging-container) {
background: transparent !important;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
}
:deep(.zp-paging-container-content) {
background: transparent !important;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
}
:deep(.wd-tabs) {
background: transparent !important;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
}
:deep(.wd-tabs__nav) {
margin-bottom: 10px;
+ flex-shrink: 0;
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ background: #f3f9f8;
+}
+:deep(.wd-tabs__content) {
+ flex: 1;
+ overflow: visible;
+}
+:deep(.wd-tab__pane) {
+ height: 100%;
+}
+:deep(.zp-paging-container-top) {
+ flex-shrink: 0;
+}
+:deep(.zp-paging-container-bottom) {
+ flex-shrink: 0;
}
</style>
--
Gitblit v1.9.3