From da583971227d237848ea28d54641dd20428f3da6 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 29 九月 2025 11:04:35 +0800
Subject: [PATCH] 绞线报工:二维码领用单丝,一层领完之后就自动切换层(从里到外),PDA:领用时需要选中层数,然后进行领用。PC端需要分层展示各层单丝领用情况。
---
src/pages/production/twist/receive/monofil.vue | 189 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 163 insertions(+), 26 deletions(-)
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 1f5b19d..d5cc002 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -2,9 +2,9 @@
<view class="list_box">
<z-paging
ref="pagingRef"
- v-model="cardList"
:fixed="false"
:auto-show-back-to-top="true"
+ :loading-more-enabled="false"
@query="getList"
>
<template #top>
@@ -14,7 +14,16 @@
</template>
</CardTitle>
</template>
- <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" />
+ <!-- <MonofilCard v-for="(item, index) in cardList" :key="index" :data="item" /> -->
+ <wd-tabs v-model="tab" slidable="always">
+ <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>
+ </wd-tab>
+ </block>
+ </wd-tabs>
<template #bottom>
<view class="flex justify-center items-center">
<wd-button block @click="save">
@@ -24,6 +33,11 @@
</template>
</z-paging>
<Scan ref="scanRef" emitName="scanMono" />
+ <StatisticsModal
+ v-model:visible="showStatisticsModal"
+ :nodeList="nodeList"
+ @confirm="handleConfirmSave"
+ />
<wd-toast />
</view>
</template>
@@ -31,6 +45,7 @@
<script setup lang="ts">
import CardTitle from "@/components/card-title/index.vue";
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 Scan from "@/components/scan/index.vue";
@@ -43,8 +58,17 @@
const paramsId = ref();
const pagingRef = ref();
const scanRef = ref();
-const cardList = ref<any[]>([]);
const toast = useToast();
+const tab = ref("");
+const showStatisticsModal = ref(false);
+
+// 鐩戝惉鏍囩鍒囨崲
+watch(tab, () => {
+ if (tab.value) {
+ console.log("tab.value:===========1", tab.value);
+ getList();
+ }
+});
const getScanCode = async (code: any) => {
console.log("鑷畾涔夋壂鎻忕殑缁撴灉鍥炶皟鍑芥暟:", code);
@@ -54,24 +78,43 @@
const { data } = await TwistApi.getScarn({
outPutId: JSON.parse(code.code).id,
});
- const exists = cardList.value.some((item) => item.monofilamentNumber === data.monofilamentNumber);
+
+ // 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
+ 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;
- console.log("sb", {
+ const newItem = {
wireId: paramsId.value,
outputId: id,
amount: oneLength,
ongLength: oneLength,
...rest,
- });
- cardList.value.push({
- wireId: paramsId.value,
- outputId: id,
- amount: oneLength,
- ongLength: oneLength,
- ...rest,
- });
- pagingRef.value.complete(cardList.value);
+ };
+
+ // 娣诲姞鍒板綋鍓嶅眰鐨� strandedWireDish 涓�
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push(newItem);
+
+ // 鍒锋柊褰撳墠灞傜殑鏁版嵁鏄剧ず
+ getList();
} else {
toast.error("璇ュ崟涓濆凡棰嗙敤锛岃鍕块噸澶嶆壂鐮�");
}
@@ -82,22 +125,100 @@
};
const getList = async () => {
- const { code, data } = await ManageApi.getStrandedWireDish({
- wireId: paramsId.value,
- type: "鍗曚笣",
- });
- if (code == 200) {
- pagingRef.value.complete(data);
+ // 浠庡綋鍓嶉�変腑灞傜殑 strandedWireDish 涓幏鍙栨暟鎹�
+ const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
+ if (currentLayer && currentLayer.strandedWireDish) {
+ pagingRef.value.complete(currentLayer.strandedWireDish);
+ } else {
+ pagingRef.value.complete([]);
}
};
-const save = async () => {
- const value = cardList.value.filter((item: { id?: number }) => item.id === undefined);
+let nodeList = ref<any[]>([]);
+// 鑾峰彇鏍瑰彿
+const getRootNumber = async (wireId: number) => {
+ const { code, data, msg } = await TwistApi.getRootNumber({ wireId });
+ if (code === 200) {
+ nodeList.value = data.nodeList;
+ if (data.otherStrandedWireDish && data.otherStrandedWireDish.length > 0) {
+ nodeList.value.push({
+ strandedWireDish: data.otherStrandedWireDish,
+ twistedLayer: "鍏朵粬",
+ twistId: null,
+ });
+ }
+ // 璁剧疆榛樿绗竴灞�
+ if (nodeList.value && nodeList.value.length > 0 && !tab.value) {
+ tab.value = nodeList.value[0].twistedLayer;
+ console.log("璁剧疆榛樿绗竴灞�:", tab.value);
+ // 璁剧疆榛樿鏍囩鍚庯紝鍔犺浇绗竴灞傜殑鏁版嵁
+ getList();
+ }
+ } else {
+ toast.error(msg || "鑾峰彇鏍瑰彿澶辫触");
+ }
+};
- const { code } = await TwistApi.addStrandedWireDish(cardList.value);
+const save = () => {
+ // 妫�鏌� nodeList 涓槸鍚︽湁鏂扮殑鍗曚笣鏁版嵁闇�瑕佷繚瀛�
+ let hasNewData = false;
+
+ nodeList.value.forEach((node) => {
+ if (node.strandedWireDish && Array.isArray(node.strandedWireDish)) {
+ const hasNewInLayer = node.strandedWireDish.some(
+ (item: { id?: number }) => item.id === undefined || item.id === null
+ );
+ if (hasNewInLayer) {
+ hasNewData = true;
+ }
+ }
+ });
+
+ if (!hasNewData) {
+ toast.error("娌℃湁鏂扮殑鍗曚笣鏁版嵁闇�瑕佷繚瀛�");
+ return;
+ }
+
+ // 鏄剧ず缁熻寮规
+ showStatisticsModal.value = true;
+};
+
+const handleConfirmSave = async () => {
+ // 浠� nodeList 涓敹闆嗘墍鏈夐渶瑕佷繚瀛樼殑鏂板崟涓濇暟鎹�
+ const newData: any[] = [];
+
+ nodeList.value.forEach((node) => {
+ node.strandedWireDish.forEach((item: any) => {
+ item.twistId = node.twistId;
+ });
+ if (node.strandedWireDish && Array.isArray(node.strandedWireDish)) {
+ const layerNewData = node.strandedWireDish.filter(
+ (item: { id?: number }) => item.id === undefined || item.id === null
+ );
+ newData.push(...layerNewData);
+ }
+ });
+
+ if (newData.length === 0) {
+ toast.error("娌℃湁鏂扮殑鍗曚笣鏁版嵁闇�瑕佷繚瀛�");
+ return;
+ }
+
+ const { code, msg } = await TwistApi.addStrandedWireDish(newData);
if (code == 200) {
- toast.success("淇濆瓨鎴愬姛");
- cardList.value = [];
+ toast.success(msg);
+
+ // 娓呯┖鎵�鏈夊眰涓凡淇濆瓨鐨勬暟鎹紙缁欏凡淇濆瓨鐨勬暟鎹坊鍔� id锛�
+ nodeList.value.forEach((node) => {
+ if (node.strandedWireDish && Array.isArray(node.strandedWireDish)) {
+ node.strandedWireDish.forEach((item: any) => {
+ if (item.id === undefined || item.id === null) {
+ item.id = Date.now(); // 涓存椂鏍囪涓哄凡淇濆瓨
+ }
+ });
+ }
+ });
+
pagingRef.value.refresh();
getList();
} else {
@@ -105,10 +226,14 @@
}
};
-onLoad((options: any) => {
+onLoad(async (options: any) => {
// 寮�鍚箍鎾洃鍚簨浠�
uni.$on("scanMono", getScanCode);
paramsId.value = options.id;
+
+ // 璋冪敤鑾峰彇鏍瑰彿鎺ュ彛
+ getRootNumber(options.id);
+ // getRootNumber(118);
});
onUnload(() => {
// 寮�鍚箍鎾洃鍚簨浠�
@@ -124,4 +249,16 @@
:deep(.wd-button__content) {
color: #0d867f;
}
+:deep(.zp-paging-container) {
+ background: transparent !important;
+}
+:deep(.zp-paging-container-content) {
+ background: transparent !important;
+}
+:deep(.wd-tabs) {
+ background: transparent !important;
+}
+:deep(.wd-tabs__nav) {
+ margin-bottom: 10px;
+}
</style>
--
Gitblit v1.9.3