From a8cc9d60a80afd7362e1d0fd31fb4307a6e04e2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 31 七月 2026 10:22:14 +0800
Subject: [PATCH] fix: 芯线分层领用
---
src/pages.json | 6
src/api/product/twist.ts | 9
src/pages/production/twist/components/SteelCoreCard.vue | 157 +++++++++++
src/pages/production/twist/receive/steelCore/index.vue | 489 ++++++++++++++++++++++++----------
src/pages/production/twist/receive/steelCore/form.vue | 151 +++-------
5 files changed, 553 insertions(+), 259 deletions(-)
diff --git a/src/api/product/twist.ts b/src/api/product/twist.ts
index 6541aab..c64fbc4 100644
--- a/src/api/product/twist.ts
+++ b/src/api/product/twist.ts
@@ -72,6 +72,15 @@
});
},
+ // 鑾峰彇閽㈣姱棰嗙敤灞傜骇鏁版嵁锛堝弬鐓C绔� getSteelCoreDishTypeByWire锛�
+ getSteelCoreDishTypeByWire(wireId: number) {
+ return request<BaseResult<any>>({
+ url: "/strandedWire/getSteelCoreDishTypeByWire",
+ method: "POST",
+ data: wireId,
+ });
+ },
+
// 鏍规嵁鍗曚笣缂栧彿鏌ヨ
selectByMonofilamentNumber(params: { monofilamentNumber: string }) {
return request<BaseResult<any>>({
diff --git a/src/pages.json b/src/pages.json
index 3fc3701..3f648e0 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -248,12 +248,6 @@
}
},
{
- "path": "pages/production/twist/receive/steelCore/edit",
- "style": {
- "navigationBarTitleText": "缁炵嚎閽㈣姱缂栬緫"
- }
- },
- {
"path": "pages/production/twist/selfInspect/index",
"style": {
"navigationBarTitleText": "缁炵嚎鑷"
diff --git a/src/pages/production/twist/components/SteelCoreCard.vue b/src/pages/production/twist/components/SteelCoreCard.vue
new file mode 100644
index 0000000..9e03def
--- /dev/null
+++ b/src/pages/production/twist/components/SteelCoreCard.vue
@@ -0,0 +1,157 @@
+<template>
+ <view class="swipe-container">
+ <view
+ class="swipe-content"
+ :style="{ transform: `translateX(${translateX}px)` }"
+ @touchstart="handleTouchStart"
+ @touchmove="handleTouchMove"
+ @touchend="handleTouchEnd"
+ >
+ <wd-card>
+ <wd-cell-group :border="true">
+ <wd-cell title="鑺嚎绫诲瀷" :value="data.diskMaterial || '-'" />
+ <wd-cell title="瑙勬牸鍨嬪彿" :value="data.model || '-'" />
+ <wd-cell title="鐩樺彿" :value="data.monofilamentNumber || '-'" />
+ <wd-cell title="鏁伴噺" :value="formatAmount" />
+ <wd-cell title="閲嶉噺" :value="formatWeight" />
+ <wd-cell title="鍘傚" :value="data.supplier || '-'" />
+ </wd-cell-group>
+ </wd-card>
+ </view>
+ <view class="swipe-delete" @click="handleDelete">
+ <text class="delete-text">鍒犻櫎</text>
+ </view>
+ </view>
+</template>
+
+<script setup lang="ts">
+import { ref, computed } from "vue";
+
+const props = defineProps({
+ data: {
+ type: Object,
+ default: () => ({}),
+ },
+});
+
+const emit = defineEmits(["delete", "swipe-open"]);
+
+const translateX = ref(0);
+const startX = ref(0);
+const startY = ref(0);
+const currentX = ref(0);
+const isSwipeOpen = ref(false);
+const deleteWidth = 80;
+const isHorizontalSwipe = ref(false);
+
+const formatAmount = computed(() => {
+ const val = props.data.amount;
+ if (val === undefined || val === null || val === "") return "-";
+ return `${val} ${props.data.unit || ""}`;
+});
+
+const formatWeight = computed(() => {
+ const val = props.data.weight;
+ if (val === undefined || val === null || val === "") return "-";
+ const unit = props.data.weightUnit || "kg";
+ return `${val} ${unit}`;
+});
+
+const handleTouchStart = (e: any) => {
+ startX.value = e.touches[0].clientX;
+ startY.value = e.touches[0].clientY;
+ currentX.value = translateX.value;
+ isHorizontalSwipe.value = false;
+};
+
+const handleTouchMove = (e: any) => {
+ const moveX = e.touches[0].clientX - startX.value;
+ const moveY = e.touches[0].clientY - startY.value;
+
+ if (!isHorizontalSwipe.value && Math.abs(moveX) > Math.abs(moveY) && Math.abs(moveX) > 10) {
+ isHorizontalSwipe.value = true;
+ }
+
+ if (isHorizontalSwipe.value) {
+ e.stopPropagation();
+ const newTranslateX = currentX.value + moveX;
+ if (newTranslateX <= 0 && newTranslateX >= -deleteWidth) {
+ translateX.value = newTranslateX;
+ } else if (newTranslateX < -deleteWidth) {
+ translateX.value = -deleteWidth;
+ } else if (newTranslateX > 0) {
+ translateX.value = 0;
+ }
+ }
+};
+
+const handleTouchEnd = (e: any) => {
+ if (isHorizontalSwipe.value) {
+ e.stopPropagation();
+ if (translateX.value < -deleteWidth / 2) {
+ translateX.value = -deleteWidth;
+ isSwipeOpen.value = true;
+ emit("swipe-open", props.data);
+ } else {
+ translateX.value = 0;
+ isSwipeOpen.value = false;
+ }
+ }
+ isHorizontalSwipe.value = false;
+};
+
+const handleDelete = () => {
+ translateX.value = 0;
+ isSwipeOpen.value = false;
+ emit("delete", props.data);
+};
+
+const closeSwipe = () => {
+ if (isSwipeOpen.value) {
+ translateX.value = 0;
+ isSwipeOpen.value = false;
+ }
+};
+
+defineExpose({
+ closeSwipe,
+ isSwipeOpen,
+});
+</script>
+
+<style lang="scss" scoped>
+.swipe-container {
+ position: relative;
+ overflow: hidden;
+ margin-bottom: 8px;
+}
+
+.swipe-content {
+ position: relative;
+ transition: transform 0.3s ease;
+ z-index: 2;
+ background: #fff;
+ touch-action: pan-y;
+}
+
+.swipe-delete {
+ position: absolute;
+ right: 0;
+ top: 12px;
+ bottom: 12px;
+ width: 80px;
+ background: #ff4444;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 1;
+ border-radius: 4px;
+ box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.05);
+
+ .delete-text {
+ color: #fff;
+ font-size: 14px;
+ font-weight: 500;
+ }
+}
+</style>
diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index d3fb9a4..7d31a3c 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -21,7 +21,7 @@
/>
<wd-input
v-model="model.monofilamentNumber"
- label="鏍峰搧缂栧彿"
+ label="鐩樺彿"
label-width="100px"
prop="monofilamentNumber"
clearable
@@ -33,7 +33,7 @@
label-width="100px"
prop="amount"
clearable
- placeholder="璇疯緭鍏ラ暱搴�"
+ placeholder="璇疯緭鍏ユ暟閲�"
/>
<wd-input
v-model="model.weight"
@@ -60,7 +60,6 @@
<script lang="ts" setup>
import { onMounted, watch } from "vue";
import useFormData from "@/hooks/useFormData";
-import TwistApi from "@/api/product/twist";
import ManageApi from "@/api/product/manage";
import { useToast } from "wot-design-uni";
@@ -80,14 +79,11 @@
});
const emits = defineEmits(["refresh"]);
-const paramsId = ref();
-const editId = ref(); // 缂栬緫鏃剁殑ID
-const allListData = ref<any[]>([]); // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
const toast = useToast();
const { form: model } = useFormData({
diskMaterial: undefined, // 鑺嚎绫诲瀷
model: undefined, // 瑙勬牸鍨嬪彿
- monofilamentNumber: undefined, // 鏍峰搧缂栧彿
+ monofilamentNumber: undefined, // 鐩樺彿
amount: undefined, // 鏁伴噺
weight: undefined, // 閲嶉噺
supplier: undefined, // 鍘傚
@@ -150,105 +146,28 @@
{ immediate: true }
);
-// 鏂板鎻愪氦
+// 鏀堕泦琛ㄥ崟鏁版嵁锛堜笉璋� API锛岃繑鍥炵粰鐖剁粍浠跺鐞嗭級
+const collectData = () => {
+ return {
+ diskMaterial: model.diskMaterial,
+ model: model.model,
+ monofilamentNumber: model.monofilamentNumber,
+ amount: model.amount,
+ weight: model.weight,
+ supplier: model.supplier,
+ type: model.type,
+ };
+};
+
+// 鏂板鎻愪氦锛堝吋瀹规棫妯″紡锛岀埗缁勪欢鍙皟鐢級
const submit = async () => {
- const currentWireId = props.wireId || paramsId.value;
- const { code } = await TwistApi.addStrandedWireDish([
- {
- wireId: currentWireId,
- ...model,
- },
- ]);
- if (code == 200) {
- toast.success("鏂板鎴愬姛");
- emits("refresh");
- return true;
- }
- return false;
+ return collectData();
};
-// 缂栬緫鎻愪氦锛堜篃璧版柊澧炴帴鍙o紝鎻愪氦鏁翠釜鍒楄〃锛�
+// 缂栬緫鎻愪氦锛堝吋瀹规棫妯″紡锛屼笉璋傾PI锛岃繑鍥炶〃鍗曟暟鎹級
const submitEdit = async (list?: any[], id?: number) => {
- const currentList = list || allListData.value;
- const currentId = id || editId.value;
-
- if (!currentId) {
- toast.error("缂哄皯璁板綍ID");
- return false;
- }
-
- // 鏇存柊鍒楄〃涓搴旂殑鏁版嵁椤�
- const updatedList = currentList.map((item) => {
- if (item.id === currentId) {
- // 淇濈暀鍘熸湁鏁版嵁锛岀劧鍚庢洿鏂颁慨鏀圭殑瀛楁
- const updatedItem = {
- ...item, // 鍏堜繚鐣欏師鏈夌殑鎵�鏈夋暟鎹�
- diskMaterial: model.diskMaterial,
- model: model.model,
- monofilamentNumber: model.monofilamentNumber,
- amount: model.amount,
- weight: model.weight,
- supplier: model.supplier,
- type: model.type,
- };
- return updatedItem;
- }
- return item;
- });
-
- // 鎻愪氦鏁翠釜鍒楄〃
- const { code } = await TwistApi.addStrandedWireDish(updatedList);
-
- if (code == 200) {
- toast.success("鏇存柊鎴愬姛");
- return true;
- }
- return false;
+ return collectData();
};
-
-// 璁剧疆琛ㄥ崟鏁版嵁锛堢敤浜庣紪杈戞椂鍥炴樉锛�
-const setFormData = (list: any[], currentEditId: number) => {
- // 瀹夊叏妫�鏌ワ細纭繚list鏄暟缁�
- if (!Array.isArray(list)) {
- return;
- }
-
- // 瀛樺偍瀹屾暣鍒楄〃鏁版嵁
- allListData.value = list;
- editId.value = currentEditId;
-
- // 鎵惧埌褰撳墠缂栬緫椤瑰苟鍥炴樉鍒拌〃鍗�
- const currentItem = list.find((item) => item.id === currentEditId);
- if (currentItem) {
- model.diskMaterial = currentItem.diskMaterial;
- model.model = currentItem.model;
- model.monofilamentNumber = currentItem.monofilamentNumber;
- model.amount = currentItem.amount;
- model.weight = currentItem.weight;
- model.supplier = currentItem.supplier;
- model.type = currentItem.type || "閽㈣姱";
- // 璁剧疆鑺嚎绫诲瀷鐨勫洖鏄惧��
- diskMaterialValue.value = currentItem.diskMaterial || "";
- }
-};
-
-// 鐩戝惉缂栬緫鏁版嵁鍙樺寲锛岃嚜鍔ㄥ洖鏄�
-watch(
- () => props.editData,
- (newData) => {
- if (newData && props.mode === "edit") {
- model.diskMaterial = newData.diskMaterial || "";
- model.model = newData.model || "";
- model.monofilamentNumber = newData.monofilamentNumber || "";
- model.amount = newData.amount || "";
- model.weight = newData.weight || "";
- model.supplier = newData.supplier || "";
- model.type = newData.type || "閽㈣姱";
- diskMaterialValue.value = newData.diskMaterial || "";
- }
- },
- { immediate: true, deep: true }
-);
// 閲嶇疆琛ㄥ崟鏁版嵁
const resetFormData = () => {
@@ -268,7 +187,7 @@
model.diskMaterial = data.diskMaterial || "";
model.model = data.model || "";
model.monofilamentNumber = data.monofilamentNumber || "";
- model.amount = data.oneLength || data.amount || "";
+ model.amount = data.amount || data.oneLength || "";
model.weight = data.weight || "";
model.supplier = data.supplier || "";
model.type = data.type || "閽㈣姱";
@@ -276,9 +195,30 @@
}
};
-onLoad((options: any) => {
- paramsId.value = options.id;
-});
+// 璁剧疆琛ㄥ崟鏁版嵁锛堢敤浜庣紪杈戞椂鍥炴樉锛屽吋瀹� edit.vue锛�
+const setFormData = (item: any) => {
+ if (item) {
+ model.diskMaterial = item.diskMaterial || "";
+ model.model = item.model || "";
+ model.monofilamentNumber = item.monofilamentNumber || "";
+ model.amount = item.amount || "";
+ model.weight = item.weight || "";
+ model.supplier = item.supplier || "";
+ model.type = item.type || "閽㈣姱";
+ diskMaterialValue.value = item.diskMaterial || "";
+ }
+};
+
+// 鐩戝惉缂栬緫鏁版嵁鍙樺寲锛岃嚜鍔ㄥ洖鏄�
+watch(
+ () => props.editData,
+ (newData) => {
+ if (newData && props.mode === "edit") {
+ setFormData(newData);
+ }
+ },
+ { immediate: true, deep: true }
+);
onMounted(async () => {
await loadDiskMaterialDict();
@@ -288,6 +228,7 @@
defineExpose({
submit,
submitEdit,
+ collectData,
setFormData,
resetFormData,
fillFormData,
diff --git a/src/pages/production/twist/receive/steelCore/index.vue b/src/pages/production/twist/receive/steelCore/index.vue
index 1e6b91c..77e607a 100644
--- a/src/pages/production/twist/receive/steelCore/index.vue
+++ b/src/pages/production/twist/receive/steelCore/index.vue
@@ -1,53 +1,55 @@
<template>
- <view class="list">
+ <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>
- <CardTitle title="鑺嚎棰嗙敤" :hideAction="false" :full="false">
+ <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="addReport"></wd-button>
+ <wd-button type="icon" icon="add-circle" color="#0D867F" @click="openAddForm"></wd-button>
</template>
</CardTitle>
</template>
- <wd-card v-for="(item, index) in cardList" :key="index" type="rectangle" custom-class="round">
- <template #title>
- <view class="flex justify-between">
- <view>
- <wd-icon name="a-rootlist" color="#0D867F"></wd-icon>
- <text class="text-[#252525] ml-2 font-medium">{{ item.model }}</text>
- </view>
- <view class="text-[#A8A8A8]" @click="toEdit(item.id)">缂栬緫</view>
- </view>
- </template>
- <ProductionCard :data="cardAttr" :value="item" color="#0D867F" />
- </wd-card>
+
+ <!-- 灞傜骇 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>
</z-paging>
- <wd-popup v-model="addDialog.visible" position="bottom" custom-class="yl-popup">
+
+ <!-- 鏂板閽㈣姱寮圭獥 -->
+ <wd-popup v-model="showAddForm" position="bottom" 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>
</view>
- <SteelCore ref="addFormRef" mode="add" :wireId="paramsId" @refresh="reloadList" />
+ <SteelCoreForm ref="addFormRef" mode="add" :wireId="paramsId" />
</wd-popup>
- <wd-popup v-model="editDialog.visible" position="bottom" custom-class="yl-popup">
- <view class="action px-3">
- <wd-button type="text" @click="cancelEdit">鍙栨秷</wd-button>
- <wd-button type="text" @click="submitEdit">纭畾</wd-button>
- </view>
- <SteelCore
- ref="editFormRef"
- mode="edit"
- :wireId="paramsId"
- :editData="editDialog.currentItem"
- @refresh="reloadList"
- />
- </wd-popup>
+
<Scan ref="scanRef" emitName="scanSteelCore" />
<wd-toast />
</view>
@@ -55,11 +57,10 @@
<script setup lang="ts">
import CardTitle from "@/components/card-title/index.vue";
-import ProductionCard from "../../../components/ProductionCard.vue";
+import SteelCoreCard from "../../components/SteelCoreCard.vue";
+import SteelCoreForm from "./form.vue";
import { useToast } from "wot-design-uni";
-import SteelCore from "./form.vue";
import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
-import ManageApi from "@/api/product/manage";
import TwistApi from "@/api/product/twist";
import zPaging from "@/components/z-paging/z-paging.vue";
import Scan from "@/components/scan/index.vue";
@@ -67,174 +68,306 @@
const paramsId = ref();
const pagingRef = ref();
const addFormRef = ref();
-const editFormRef = ref();
const scanRef = ref();
const toast = useToast();
-const isPageVisible = ref(false); // 鏍囪椤甸潰鏄惁鍙
-const addDialog = reactive({
- visible: false,
-});
-const editDialog = reactive({
- visible: false,
- currentItem: null as any,
- editId: undefined as number | undefined,
-});
-const cardList = ref<any[]>([]);
+const tab = ref("");
+const nodeList = ref<any[]>([]);
+const showAddForm = ref(false);
+const isPageVisible = ref(false);
-const cardAttr = ref<any[]>([
- {
- label: "鏍峰搧缂栧彿",
- prop: "monofilamentNumber",
- },
- {
- label: "鏁伴噺",
- prop: "amount",
- unitProp: "unit",
- },
- {
- label: "閲嶉噺",
- prop: "weight",
- unitProp: "weightUnit",
- },
- {
- label: "鍘傚",
- prop: "supplier",
- span: 16,
- },
-]);
+// 鐩戝惉鏍囩鍒囨崲
+watch(tab, () => {
+ if (tab.value) {
+ getList();
+ }
+});
-const toEdit = (id: number) => {
- const itemToEdit = cardList.value.find((item) => item.id === id);
- if (itemToEdit) {
- editDialog.currentItem = itemToEdit;
- editDialog.editId = id;
- editDialog.visible = true;
+// 鑾峰彇閽㈣姱灞傜骇鏁版嵁锛堝弬鐓C绔� getSteelCoreDishTypeByWire锛�
+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();
+ }
+ } else {
+ toast.error(msg || "鑾峰彇閽㈣姱灞傜骇鏁版嵁澶辫触");
}
};
-const addReport = () => {
+// 浠庡綋鍓嶉�変腑灞傝幏鍙栧垪琛ㄦ暟鎹�
+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([]);
+ }
+};
+
+// 鎵撳紑鏂板琛ㄥ崟
+const openAddForm = () => {
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
+ return;
+ }
if (addFormRef.value) {
addFormRef.value.resetFormData();
}
- addDialog.visible = true;
+ showAddForm.value = true;
};
+// 鎻愪氦鏂板
const submitAdd = async () => {
- const success = await addFormRef.value.submit();
- if (success) {
- addDialog.visible = false;
+ 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(
+ (item: any) => item.monofilamentNumber === formData.monofilamentNumber
+ );
+ if (exists) {
+ toast.error("璇ラ挗鑺凡棰嗙敤锛岃鍕块噸澶嶆坊鍔�");
+ return;
+ }
+ }
+
+ // 娣诲姞鍒板綋鍓嶅眰
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push({
+ ...formData,
+ wireId: paramsId.value,
+ });
+
+ getList();
+ showAddForm.value = false;
+ toast.success("娣诲姞鎴愬姛");
};
const cancelAdd = () => {
- toast.show("鍙栨秷");
- addDialog.visible = false;
+ showAddForm.value = false;
};
-const submitEdit = async () => {
- const success = await editFormRef.value.submitEdit(cardList.value, editDialog.editId);
- if (success) {
- editDialog.visible = false;
- reloadList();
- }
-};
-
-const cancelEdit = () => {
- toast.show("鍙栨秷");
- editDialog.visible = false;
-};
-
-const getList = async () => {
- const { code, data } = await ManageApi.getStrandedWireDish({
- wireId: paramsId.value,
- type: "閽㈣姱",
- });
- if (code == 200) {
- pagingRef.value.complete(data);
- }
-};
-
-const reloadList = () => {
- pagingRef.value.refresh();
-};
-
-// 鎵爜鐩稿叧鏂规硶
-const openScan = () => {
- scanRef.value.triggerScan();
-};
-
+// 鑾峰彇鎵爜鏁版嵁
const getScanCode = async (code: any) => {
- // 妫�鏌ラ〉闈㈡槸鍚﹀彲瑙侊紝濡傛灉涓嶅彲瑙佸垯涓嶅鐞嗘壂鐮佹暟鎹�
if (!isPageVisible.value) {
return;
}
try {
- const parseData = JSON.parse(code.code);
-
- // 妫�鏌ュ繀闇�瀛楁锛歮odel銆乻upplier銆乨iskMaterial
- const requiredFields = ["model", "supplier", "diskMaterial"];
- const missingFields = requiredFields.filter((field) => !parseData[field]);
-
- if (missingFields.length > 0) {
- toast.error(`浜岀淮鐮侀敊璇紝璇锋洿鎹簩缁寸爜锛乣);
+ if (!tab.value) {
+ toast.error("璇峰厛閫夋嫨涓�涓眰");
return;
}
- // 鎵撳紑鏂板寮规骞跺~鍏呮壂鐮佽幏鍙栫殑淇℃伅
- addDialog.visible = true;
+ const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
+ if (!currentLayer) {
+ toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
+ return;
+ }
- // 绛夊緟寮规鎵撳紑鍚庡~鍏呰〃鍗曟暟鎹�
- // 浣跨敤鍙岄噸绛夊緟锛歯extTick + setTimeout 纭繚缁勪欢宸插畬鍏ㄦ寕杞�
- nextTick(() => {
- setTimeout(() => {
- if (addFormRef.value) {
- addFormRef.value.fillFormData(parseData);
- toast.success("鎵爜鎴愬姛锛岃纭淇℃伅");
- } else {
- toast.error("琛ㄥ崟鍔犺浇澶辫触锛岃閲嶈瘯");
- }
- }, 200); // 寤惰繜200ms纭繚寮规鍜岀粍浠跺凡瀹屽叏娓叉煋
- });
+ const parseData = JSON.parse(code.code);
+
+ // 妫�鏌ュ繀闇�瀛楁
+ const requiredFields = ["model", "supplier", "diskMaterial"];
+ const missingFields = requiredFields.filter((field) => !parseData[field]);
+ if (missingFields.length > 0) {
+ toast.error("浜岀淮鐮侀敊璇紝璇锋洿鎹簩缁寸爜锛�");
+ return;
+ }
+
+ // 鍚屽眰閲嶅妫�鏌�
+ if (parseData.monofilamentNumber) {
+ const exists = currentLayer.strandedWireDish?.some(
+ (item: any) => item.monofilamentNumber === parseData.monofilamentNumber
+ );
+ if (exists) {
+ toast.error("璇ラ挗鑺凡棰嗙敤锛岃鍕块噸澶嶆壂鐮�");
+ return;
+ }
+ }
+
+ // 鏋勫缓鏂伴挗鑺暟鎹�
+ const newItem = {
+ wireId: paramsId.value,
+ diskMaterial: parseData.diskMaterial || "",
+ model: parseData.model || "",
+ monofilamentNumber: parseData.monofilamentNumber || "",
+ amount: parseData.oneLength || parseData.amount || "",
+ weight: parseData.weight || "",
+ supplier: parseData.supplier || "",
+ type: "閽㈣姱",
+ };
+
+ if (!currentLayer.strandedWireDish) {
+ currentLayer.strandedWireDish = [];
+ }
+ currentLayer.strandedWireDish.push(newItem);
+ getList();
+ toast.success("鎵爜鎴愬姛");
} catch (error) {
toast.error("浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
}
};
-onLoad((options: any) => {
- // 寮�鍚箍鎾洃鍚簨浠�
+// 鎵撳紑鎵弿
+const openScan = () => {
+ scanRef.value.triggerScan();
+};
+
+// 淇濆瓨锛堟壒閲忔彁浜わ級
+const save = () => {
+ // 妫�鏌ユ槸鍚︽湁鏂版暟鎹渶瑕佷繚瀛�
+ let hasNewData = false;
+ let newCount = 0;
+
+ 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) {
+ toast.error("娌℃湁鏂扮殑閽㈣姱鏁版嵁闇�瑕佷繚瀛�");
+ return;
+ }
+
+ // 纭淇濆瓨
+ uni.showModal({
+ title: "鎻愮ず",
+ content: `纭淇濆瓨 ${newCount} 鏉¢挗鑺鐢ㄦ暟鎹悧锛焋,
+ success: async (res) => {
+ if (res.confirm) {
+ await handleConfirmSave();
+ }
+ },
+ });
+};
+
+// 鎵ц鎵归噺淇濆瓨
+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);
+ }
+ });
+
+ if (newData.length === 0) {
+ toast.error("娌℃湁鏂扮殑閽㈣姱鏁版嵁闇�瑕佷繚瀛�");
+ return;
+ }
+
+ const { code, msg } = await TwistApi.addStrandedWireDish(newData);
+ if (code == 200) {
+ toast.success(msg || "淇濆瓨鎴愬姛");
+ // 鍒锋柊鏁版嵁鑾峰彇鏈�鏂扮殑 id
+ fetchSteelCoreData(paramsId.value);
+ } else {
+ toast.error(msg || "淇濆瓨澶辫触");
+ }
+};
+
+// 鍒犻櫎鍗$墖
+const handleDeleteCard = async (layer: any, cardData: any) => {
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "纭畾瑕佸垹闄よ閽㈣姱鍚楋紵",
+ success: async (res) => {
+ if (res.confirm) {
+ try {
+ // 宸蹭繚瀛樼殑鏁版嵁璋冪敤鎺ュ彛鍒犻櫎
+ if (cardData.id !== undefined && cardData.id !== null) {
+ const { code, msg } = await TwistApi.deleteStrandedWireDish(cardData.id);
+ if (code !== 200) {
+ toast.error(msg || "鍒犻櫎澶辫触");
+ return;
+ }
+ }
+
+ // 鍓嶇绉婚櫎
+ 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("scanSteelCore", getScanCode);
paramsId.value = options.id;
+ fetchSteelCoreData(options.id);
});
onShow(() => {
- // 椤甸潰鏄剧ず鏃舵爣璁颁负鍙
isPageVisible.value = true;
});
onHide(() => {
- // 椤甸潰闅愯棌鏃舵爣璁颁负涓嶅彲瑙�
isPageVisible.value = false;
});
onUnload(() => {
- // 鍙栨秷骞挎挱鐩戝惉浜嬩欢
uni.$off("scanSteelCore", getScanCode);
isPageVisible.value = false;
});
</script>
<style lang="scss" scoped>
-.list {
- height: calc(100vh - 120px);
- padding: 12px;
+.list_box {
+ height: calc(100vh - 50px);
background: #f3f9f8;
-
- :deep() {
- .round {
- border-radius: 4px;
- }
- }
+ display: flex;
+ flex-direction: column;
}
.action {
@@ -245,4 +378,64 @@
:deep(.wd-button__content) {
color: #0d867f;
}
+
+.tabs-container {
+ height: calc(100vh - 200px);
+ display: flex;
+ flex-direction: column;
+}
+
+.content {
+ height: calc(100vh - 200px);
+ width: 100%;
+}
+
+: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;
+ padding: 8px 12px;
+}
</style>
--
Gitblit v1.9.3