From 166ff56efefe6682a9d840fe0f1fa6e456833556 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 04 九月 2026 18:34:23 +0800
Subject: [PATCH] fix: 时效模块原型
---
src/pages/production/twist/receive/steelCore/index.vue | 268 ++++++++++++++++++-----------------------------------
1 files changed, 90 insertions(+), 178 deletions(-)
diff --git a/src/pages/production/twist/receive/steelCore/index.vue b/src/pages/production/twist/receive/steelCore/index.vue
index 77e607a..d4f8c7e 100644
--- a/src/pages/production/twist/receive/steelCore/index.vue
+++ b/src/pages/production/twist/receive/steelCore/index.vue
@@ -2,6 +2,7 @@
<view class="list_box">
<z-paging
ref="pagingRef"
+ v-model="steelData"
:fixed="false"
:auto-show-back-to-top="true"
:loading-more-enabled="false"
@@ -11,38 +12,34 @@
<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="openAddForm"></wd-button>
+ <wd-button
+ type="icon"
+ icon="add-circle"
+ color="#0D867F"
+ @click="openAddForm"
+ ></wd-button>
</template>
</CardTitle>
</template>
- <!-- 灞傜骇 tabs -->
- <wd-tabs v-model="tab" slidable="always" class="tabs-container">
- <block v-for="item in nodeList" :key="item.twistedLayer">
- <wd-tab :title="item.twistedLayer" :name="item.twistedLayer">
- <scroll-view class="content" scroll-y>
- <SteelCoreCard
- v-for="(m, i) in item.strandedWireDish"
- :key="i"
- :data="m"
- @delete="handleDeleteCard(item, m)"
- />
- </scroll-view>
- </wd-tab>
- </block>
- </wd-tabs>
-
- <template #bottom>
- <view class="flex justify-center items-center">
- <wd-button block @click="save">
- <text class="text-[#fff]">淇濆瓨</text>
- </wd-button>
- </view>
- </template>
+ <view class="content">
+ <SteelCoreCard
+ v-for="item in steelData"
+ :key="item.id || item.monofilamentNumber"
+ :data="item"
+ @delete="handleDeleteCard(item)"
+ />
+ </view>
</z-paging>
+ <view class="save-footer">
+ <wd-button block @click="save">
+ <text class="text-[#fff]">淇濆瓨</text>
+ </wd-button>
+ </view>
+
<!-- 鏂板閽㈣姱寮圭獥 -->
- <wd-popup v-model="showAddForm" position="bottom" custom-class="yl-popup">
+ <wd-popup v-model="showAddForm" position="bottom" :z-index="30" custom-class="yl-popup">
<view class="action px-3">
<wd-button type="text" @click="cancelAdd">鍙栨秷</wd-button>
<wd-button type="text" @click="submitAdd">纭畾</wd-button>
@@ -70,59 +67,37 @@
const addFormRef = ref();
const scanRef = ref();
const toast = useToast();
-const tab = ref("");
-const nodeList = ref<any[]>([]);
+const steelData = ref<any[]>([]);
const showAddForm = ref(false);
const isPageVisible = ref(false);
-// 鐩戝惉鏍囩鍒囨崲
-watch(tab, () => {
- if (tab.value) {
- getList();
- }
-});
-
-// 鑾峰彇閽㈣姱灞傜骇鏁版嵁锛堝弬鐓C绔� getSteelCoreDishTypeByWire锛�
+// 閽㈣姱涓� PC 绔繚鎸佷竴鑷达紝鐩存帴浣跨敤鈥滃叾浠栤�濇暟鎹紝涓嶅啀鎸夌粸绾垮眰绾ч鐢ㄣ��
const fetchSteelCoreData = async (wireId: number) => {
const { code, data, msg } = await TwistApi.getSteelCoreDishTypeByWire(wireId);
if (code === 200 && data) {
- nodeList.value = data.nodeList || [];
-
- // 杩藉姞"鍏朵粬"灞�
- if (data.otherStrandedWireDish && data.otherStrandedWireDish.length > 0) {
- nodeList.value.push({
- strandedWireDish: data.otherStrandedWireDish,
- twistedLayer: "鍏朵粬",
- twistId: null,
- });
- }
-
- // 璁剧疆榛樿绗竴灞�
- if (nodeList.value.length > 0 && !tab.value) {
- tab.value = nodeList.value[0].twistedLayer;
- getList();
- }
+ const list = Array.isArray(data.otherStrandedWireDish)
+ ? data.otherStrandedWireDish.map((item: any) => ({
+ ...item,
+ batchNo: item.batchNo || item.batchCode || "",
+ batchCode: item.batchCode || item.batchNo || "",
+ type: item.type || "閽㈣姱",
+ saleTwistId: null,
+ }))
+ : [];
+ pagingRef.value?.complete(list);
} else {
- toast.error(msg || "鑾峰彇閽㈣姱灞傜骇鏁版嵁澶辫触");
+ pagingRef.value?.complete([]);
+ toast.error(msg || "鑾峰彇閽㈣姱棰嗙敤鏁版嵁澶辫触");
}
};
-// 浠庡綋鍓嶉�変腑灞傝幏鍙栧垪琛ㄦ暟鎹�
const getList = async () => {
- const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
- if (currentLayer && currentLayer.strandedWireDish) {
- pagingRef.value.complete(currentLayer.strandedWireDish);
- } else {
- pagingRef.value.complete([]);
- }
+ if (!paramsId.value) return;
+ await fetchSteelCoreData(Number(paramsId.value));
};
// 鎵撳紑鏂板琛ㄥ崟
const openAddForm = () => {
- if (!tab.value) {
- toast.error("璇峰厛閫夋嫨涓�涓眰");
- return;
- }
if (addFormRef.value) {
addFormRef.value.resetFormData();
}
@@ -134,16 +109,8 @@
const formData = await addFormRef.value.submit();
if (!formData) return;
- // 鏌ユ壘褰撳墠灞�
- const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
- if (!currentLayer) {
- toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
- return;
- }
-
- // 鍚屽眰閲嶅妫�鏌�
if (formData.monofilamentNumber) {
- const exists = currentLayer.strandedWireDish?.some(
+ const exists = steelData.value.some(
(item: any) => item.monofilamentNumber === formData.monofilamentNumber
);
if (exists) {
@@ -152,16 +119,12 @@
}
}
- // 娣诲姞鍒板綋鍓嶅眰
- if (!currentLayer.strandedWireDish) {
- currentLayer.strandedWireDish = [];
- }
- currentLayer.strandedWireDish.push({
+ steelData.value.push({
...formData,
wireId: paramsId.value,
+ saleTwistId: null,
});
- getList();
showAddForm.value = false;
toast.success("娣诲姞鎴愬姛");
};
@@ -177,18 +140,13 @@
}
try {
- if (!tab.value) {
- toast.error("璇峰厛閫夋嫨涓�涓眰");
- return;
- }
-
- const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
- if (!currentLayer) {
- toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
- return;
- }
-
const parseData = JSON.parse(code.code);
+
+ const batchNo = parseData.batchNo || parseData.batchCode || "";
+ if (!batchNo) {
+ toast.error("浜岀淮鐮侀敊璇紝缂哄皯鎵规鍙凤紒");
+ return;
+ }
// 妫�鏌ュ繀闇�瀛楁
const requiredFields = ["model", "supplier", "diskMaterial"];
@@ -198,9 +156,8 @@
return;
}
- // 鍚屽眰閲嶅妫�鏌�
if (parseData.monofilamentNumber) {
- const exists = currentLayer.strandedWireDish?.some(
+ const exists = steelData.value.some(
(item: any) => item.monofilamentNumber === parseData.monofilamentNumber
);
if (exists) {
@@ -213,19 +170,18 @@
const newItem = {
wireId: paramsId.value,
diskMaterial: parseData.diskMaterial || "",
+ batchNo,
+ batchCode: batchNo,
model: parseData.model || "",
monofilamentNumber: parseData.monofilamentNumber || "",
amount: parseData.oneLength || parseData.amount || "",
weight: parseData.weight || "",
supplier: parseData.supplier || "",
type: "閽㈣姱",
+ saleTwistId: null,
};
- if (!currentLayer.strandedWireDish) {
- currentLayer.strandedWireDish = [];
- }
- currentLayer.strandedWireDish.push(newItem);
- getList();
+ steelData.value.push(newItem);
toast.success("鎵爜鎴愬姛");
} catch (error) {
toast.error("浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
@@ -239,25 +195,11 @@
// 淇濆瓨锛堟壒閲忔彁浜わ級
const save = () => {
- // 妫�鏌ユ槸鍚︽湁鏂版暟鎹渶瑕佷繚瀛�
- let hasNewData = false;
- let newCount = 0;
+ const newCount = steelData.value.filter(
+ (item: { id?: number }) => item.id === undefined || item.id === null
+ ).length;
- 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;
- newCount += node.strandedWireDish.filter(
- (item: { id?: number }) => item.id === undefined || item.id === null
- ).length;
- }
- }
- });
-
- if (!hasNewData) {
+ if (!newCount) {
toast.error("娌℃湁鏂扮殑閽㈣姱鏁版嵁闇�瑕佷繚瀛�");
return;
}
@@ -276,23 +218,21 @@
// 鎵ц鎵归噺淇濆瓨
const handleConfirmSave = async () => {
- const newData: any[] = [];
-
- nodeList.value.forEach((node) => {
- // 闄勫姞涓婁笅绾� twistId
- if (node.strandedWireDish && Array.isArray(node.strandedWireDish)) {
- node.strandedWireDish.forEach((item: any) => {
- item.saleTwistId = node.twistId;
- });
- const layerNewData = node.strandedWireDish.filter(
- (item: { id?: number }) => item.id === undefined || item.id === null
- );
- newData.push(...layerNewData);
- }
- });
+ const newData = steelData.value
+ .filter((item: { id?: number }) => item.id === undefined || item.id === null)
+ .map((item) => ({
+ ...item,
+ saleTwistId: null,
+ }));
if (newData.length === 0) {
toast.error("娌℃湁鏂扮殑閽㈣姱鏁版嵁闇�瑕佷繚瀛�");
+ return;
+ }
+
+ const invalidBatchItem = newData.find((item) => !(item.batchNo || item.batchCode));
+ if (invalidBatchItem) {
+ toast.error(`${invalidBatchItem.monofilamentNumber || "閽㈣姱"}锛氳閫夋嫨鎵规鍙穈);
return;
}
@@ -307,7 +247,7 @@
};
// 鍒犻櫎鍗$墖
-const handleDeleteCard = async (layer: any, cardData: any) => {
+const handleDeleteCard = async (cardData: any) => {
uni.showModal({
title: "鎻愮ず",
content: "纭畾瑕佸垹闄よ閽㈣姱鍚楋紵",
@@ -323,16 +263,12 @@
}
}
- // 鍓嶇绉婚櫎
- 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();
- }
+ const index = steelData.value.findIndex(
+ (item: any) => item.monofilamentNumber === cardData.monofilamentNumber
+ );
+ if (index !== -1) {
+ steelData.value.splice(index, 1);
+ toast.success("鍒犻櫎鎴愬姛");
}
} catch (error: any) {
toast.error(error.msg || "鍒犻櫎澶辫触");
@@ -345,7 +281,7 @@
onLoad(async (options: any) => {
uni.$on("scanSteelCore", getScanCode);
paramsId.value = options.id;
- fetchSteelCoreData(options.id);
+ fetchSteelCoreData(Number(options.id));
});
onShow(() => {
@@ -379,15 +315,22 @@
color: #0d867f;
}
-.tabs-container {
- height: calc(100vh - 200px);
- display: flex;
- flex-direction: column;
+.content {
+ width: 100%;
+ padding-bottom: 76px;
+ box-sizing: border-box;
}
-.content {
- height: calc(100vh - 200px);
- width: 100%;
+.save-footer {
+ position: fixed;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 20;
+ padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
+ background: #ffffff;
+ border-top: 1px solid #eeeeee;
+ box-shadow: 0 -2px 10px rgb(0 0 0 / 6%);
}
:deep(.zp-paging-container) {
@@ -404,38 +347,7 @@
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;
- padding: 8px 12px;
}
</style>
--
Gitblit v1.9.3