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/form.vue | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 236 insertions(+), 4 deletions(-)
diff --git a/src/pages/production/twist/receive/steelCore/form.vue b/src/pages/production/twist/receive/steelCore/form.vue
index 7d31a3c..b853066 100644
--- a/src/pages/production/twist/receive/steelCore/form.vue
+++ b/src/pages/production/twist/receive/steelCore/form.vue
@@ -11,13 +11,23 @@
clearable
@confirm="handleDiskMaterialChange"
/>
+ <wd-cell
+ title="鎵规鍙�"
+ title-width="100px"
+ :value="model.batchNo || '璇烽�夋嫨鎵规鍙�'"
+ :value-class="model.batchNo ? '' : 'batch-placeholder'"
+ is-link
+ required
+ clickable
+ @click="openBatchSelector"
+ />
<wd-input
v-model="model.model"
label="瑙勬牸鍨嬪彿"
label-width="100px"
prop="model"
- clearable
- placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+ readonly
+ placeholder="閫夋嫨鎵规鍚庤嚜鍔ㄥ甫鍑�"
/>
<wd-input
v-model="model.monofilamentNumber"
@@ -37,11 +47,11 @@
/>
<wd-input
v-model="model.weight"
- label="閲嶉噺"
+ label="棰嗙敤閲嶉噺"
label-width="100px"
prop="weight"
clearable
- placeholder="璇疯緭鍏ラ噸閲�"
+ placeholder="璇疯緭鍏ラ鐢ㄩ噸閲�(kg)"
/>
<wd-picker
v-model="model.supplier"
@@ -55,12 +65,57 @@
/>
</wd-cell-group>
</wd-form>
+
+ <wd-popup
+ v-model="showBatchSelector"
+ position="bottom"
+ :z-index="30"
+ :close-on-click-modal="false"
+ custom-style="height: 72vh; border-radius: 24rpx 24rpx 0 0;"
+ >
+ <view class="batch-selector">
+ <view class="batch-header">
+ <text class="batch-title">閫夋嫨鎵规鍙�</text>
+ <wd-icon name="close" size="20px" @click="showBatchSelector = false" />
+ </view>
+ <wd-search
+ v-model="batchKeyword"
+ placeholder="璇疯緭鍏ユ壒娆″彿鎼滅储"
+ hide-cancel
+ @search="searchBatchRemote"
+ @clear="searchBatchRemote('')"
+ />
+ <scroll-view class="batch-list" scroll-y>
+ <view v-if="batchSearching" class="batch-state">姝e湪鍔犺浇鎵规...</view>
+ <template v-else-if="filteredBatchOptions.length">
+ <view
+ v-for="batch in filteredBatchOptions"
+ :key="batch.batchCode"
+ class="batch-item"
+ :class="{ active: batch.batchCode === model.batchNo }"
+ @click="selectBatch(batch)"
+ >
+ <view class="batch-item-header">
+ <text class="batch-code">{{ batch.batchCode }}</text>
+ <text class="batch-weight">褰撳墠 {{ stockWeightKg(batch) ?? "-" }} kg</text>
+ </view>
+ <view class="batch-meta">
+ <text>{{ batch.materialName || "-" }}</text>
+ <text>{{ getBatchModel(batch) }}</text>
+ </view>
+ </view>
+ </template>
+ <view v-else class="batch-state">鏆傛棤鍙鐢ㄧ殑鍚堟牸鎵规</view>
+ </scroll-view>
+ </view>
+ </wd-popup>
</template>
<script lang="ts" setup>
import { onMounted, watch } from "vue";
import useFormData from "@/hooks/useFormData";
import ManageApi from "@/api/product/manage";
+import TwistApi from "@/api/product/twist";
import { useToast } from "wot-design-uni";
const props = defineProps({
@@ -82,6 +137,8 @@
const toast = useToast();
const { form: model } = useFormData({
diskMaterial: undefined, // 鑺嚎绫诲瀷
+ batchNo: undefined, // 鎵规鍙凤紙灞曠ず鍙婇挗鑺鐢ㄥ瓧娈碉級
+ batchCode: undefined, // 鍏煎搴撳瓨棰嗙敤瀛楁
model: undefined, // 瑙勬牸鍨嬪彿
monofilamentNumber: undefined, // 鐩樺彿
amount: undefined, // 鏁伴噺
@@ -89,6 +146,75 @@
supplier: undefined, // 鍘傚
type: "閽㈣姱",
});
+
+interface MaterialBatch {
+ batchCode: string;
+ materialName?: string;
+ resolvedSpecModel?: string;
+ mesSpec?: string;
+ ncSpec?: string;
+ currentWeight?: number;
+ mainUnit?: string;
+ qualityStatus?: string;
+ ncReturnFlag?: string;
+}
+
+const showBatchSelector = ref(false);
+const batchKeyword = ref("");
+const batchOptions = ref<MaterialBatch[]>([]);
+const batchSearching = ref(false);
+
+const filteredBatchOptions = computed(() =>
+ batchOptions.value.filter((batch) => {
+ const qualified = batch.qualityStatus === "鍚堟牸" || batch.qualityStatus === "OK";
+ return qualified && batch.ncReturnFlag !== "Y";
+ })
+);
+
+const getBatchModel = (batch: MaterialBatch) =>
+ batch.resolvedSpecModel || batch.mesSpec || batch.ncSpec || "-";
+
+const stockWeightKg = (batch: MaterialBatch) => {
+ if (batch.currentWeight === undefined || batch.currentWeight === null) return undefined;
+ const weight = Number(batch.currentWeight);
+ if (!Number.isFinite(weight)) return undefined;
+ return batch.mainUnit === "鍚�" ? weight * 1000 : weight;
+};
+
+const searchBatchRemote = async (keyword: string | { value?: string } = batchKeyword.value) => {
+ const searchValue =
+ typeof keyword === "string" ? keyword : String(keyword?.value || batchKeyword.value || "");
+ batchKeyword.value = searchValue;
+ batchSearching.value = true;
+ try {
+ const { code, data } = await TwistApi.getMaterialBatchStockPage({
+ batchCode: searchValue.trim() || undefined,
+ materialType: "鍘熸潗鏂�",
+ current: 1,
+ size: 20,
+ });
+ batchOptions.value = code === 200 && Array.isArray(data?.records) ? data.records : [];
+ } catch (error: any) {
+ batchOptions.value = [];
+ toast.error(error?.message || "鎵规鏌ヨ澶辫触");
+ } finally {
+ batchSearching.value = false;
+ }
+};
+
+const openBatchSelector = () => {
+ showBatchSelector.value = true;
+ batchKeyword.value = model.batchNo || "";
+ searchBatchRemote(batchKeyword.value);
+};
+
+const selectBatch = (batch: MaterialBatch) => {
+ const batchModel = getBatchModel(batch);
+ model.batchNo = batch.batchCode;
+ model.batchCode = batch.batchCode;
+ model.model = batchModel === "-" ? "" : batchModel;
+ showBatchSelector.value = false;
+};
// 鑺嚎绫诲瀷瀛楀吀鏁版嵁
const diskMaterialOptions = ref<Array<{ label: string; value: string }>>([]);
@@ -148,13 +274,37 @@
// 鏀堕泦琛ㄥ崟鏁版嵁锛堜笉璋� API锛岃繑鍥炵粰鐖剁粍浠跺鐞嗭級
const collectData = () => {
+ if (!model.batchNo) {
+ toast.error("璇烽�夋嫨鎵规鍙�");
+ return null;
+ }
+ if (!model.diskMaterial) {
+ toast.error("璇烽�夋嫨鑺嚎绫诲瀷");
+ return null;
+ }
+ if (!model.monofilamentNumber) {
+ toast.error("璇疯緭鍏ョ洏鍙�");
+ return null;
+ }
+ if (!Number.isFinite(Number(model.weight)) || Number(model.weight) <= 0) {
+ toast.error("璇疯緭鍏ュぇ浜�0鐨勯鐢ㄩ噸閲�");
+ return null;
+ }
+ if (!model.supplier) {
+ toast.error("璇烽�夋嫨鍘傚");
+ return null;
+ }
+
return {
diskMaterial: model.diskMaterial,
+ batchNo: model.batchNo,
+ batchCode: model.batchNo,
model: model.model,
monofilamentNumber: model.monofilamentNumber,
amount: model.amount,
weight: model.weight,
supplier: model.supplier,
+ unit: "kg",
type: model.type,
};
};
@@ -172,6 +322,8 @@
// 閲嶇疆琛ㄥ崟鏁版嵁
const resetFormData = () => {
model.diskMaterial = undefined;
+ model.batchNo = undefined;
+ model.batchCode = undefined;
model.model = undefined;
model.monofilamentNumber = undefined;
model.amount = undefined;
@@ -179,12 +331,16 @@
model.supplier = undefined;
model.type = "閽㈣姱";
diskMaterialValue.value = "";
+ batchKeyword.value = "";
+ batchOptions.value = [];
};
// 濉厖琛ㄥ崟鏁版嵁锛堢敤浜庢壂鐮佸悗鍥炴樉锛�
const fillFormData = (data: any) => {
if (data) {
model.diskMaterial = data.diskMaterial || "";
+ model.batchNo = data.batchNo || data.batchCode || "";
+ model.batchCode = data.batchCode || data.batchNo || "";
model.model = data.model || "";
model.monofilamentNumber = data.monofilamentNumber || "";
model.amount = data.amount || data.oneLength || "";
@@ -199,6 +355,8 @@
const setFormData = (item: any) => {
if (item) {
model.diskMaterial = item.diskMaterial || "";
+ model.batchNo = item.batchNo || item.batchCode || "";
+ model.batchCode = item.batchCode || item.batchNo || "";
model.model = item.model || "";
model.monofilamentNumber = item.monofilamentNumber || "";
model.amount = item.amount || "";
@@ -241,4 +399,78 @@
bottom: 0;
width: 100%;
}
+
+:deep(.batch-placeholder) {
+ color: #bfbfbf;
+}
+
+.batch-selector {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
+
+.batch-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16px;
+ border-bottom: 1px solid #eeeeee;
+}
+
+.batch-title {
+ font-size: 17px;
+ font-weight: 600;
+ color: #333333;
+}
+
+.batch-list {
+ flex: 1;
+ height: 0;
+ padding: 0 12px 16px;
+ box-sizing: border-box;
+}
+
+.batch-item {
+ padding: 14px 12px;
+ margin-bottom: 8px;
+ background: #ffffff;
+ border: 1px solid #e5e5e5;
+ border-radius: 8px;
+}
+
+.batch-item.active {
+ background: #f0fbfa;
+ border-color: #0d867f;
+}
+
+.batch-item-header,
+.batch-meta {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.batch-code {
+ font-weight: 600;
+ color: #222222;
+}
+
+.batch-weight {
+ font-size: 12px;
+ color: #0d867f;
+}
+
+.batch-meta {
+ margin-top: 8px;
+ font-size: 12px;
+ color: #888888;
+}
+
+.batch-state {
+ padding: 48px 16px;
+ color: #999999;
+ text-align: center;
+}
</style>
--
Gitblit v1.9.3