From c4f8ae20c8a38ec986066bad7600b387ff2d8109 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 09 一月 2026 16:48:26 +0800
Subject: [PATCH] fix: 调整文字
---
src/pages/outbound/materialOutbound.vue | 541 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 541 insertions(+), 0 deletions(-)
diff --git a/src/pages/outbound/materialOutbound.vue b/src/pages/outbound/materialOutbound.vue
new file mode 100644
index 0000000..0c7bbcf
--- /dev/null
+++ b/src/pages/outbound/materialOutbound.vue
@@ -0,0 +1,541 @@
+<template>
+ <view class="material-page">
+ <view class="material-header">
+ <CardTitle title="鐗╂枡鍑哄簱" :hideAction="false">
+ <template #action>
+ <wd-button
+ type="icon"
+ icon="scan"
+ color="#0d867f"
+ @click="openScan"
+ style="color: #0d867f"
+ ></wd-button>
+ </template>
+ </CardTitle>
+
+ <!-- 褰撳墠鐗╂枡淇℃伅 -->
+ <view class="material-info" v-if="currentMaterial">
+ <wd-card custom-class="info-card">
+ <view class="info-compact">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <view class="info-text">
+ <view class="info-line">
+ <text class="label">鐗╂枡鍚嶇О锛�</text>
+ <text class="value">{{ currentMaterial.materialname || "-" }}</text>
+ </view>
+ <view class="info-line">
+ <text class="label">鐗╂枡瑙勬牸锛�</text>
+ <text class="value">{{ currentMaterial.materialspec || "-" }}</text>
+ </view>
+ <view class="info-line">
+ <text class="label">寰呭彂璐ф暟閲忥細</text>
+ <text class="value">{{ currentMaterial.shippedQuantity || 0 }} 鍚�</text>
+ </view>
+ </view>
+ </view>
+ </wd-card>
+ </view>
+ </view>
+
+ <!-- 璐х墿鍒楄〃 -->
+ <view class="list_content">
+ <view v-if="goodsList.length === 0" class="empty_tip">
+ <view class="empty_text">鏆傛棤璐х墿鏁版嵁</view>
+ </view>
+ <view v-for="(item, index) in goodsList" :key="index" class="outbound_item">
+ <view class="outbound_item_left">
+ <view class="outbound_item_content">
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">鍚堝悓鍙凤細</text>
+ <text class="outbound_item_value">{{ item.contractNo || "-" }}</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">鐢熶骇鎵规鍙凤細</text>
+ <text class="outbound_item_value">{{ item.monofilamentNumber || "-" }}</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">瑙勬牸鍨嬪彿锛�</text>
+ <text class="outbound_item_value">{{ item.model || "-" }}</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">閲嶉噺锛�</text>
+ <text class="outbound_item_value">{{ item.weight || "-" }} kg</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">鍘傚锛�</text>
+ <text class="outbound_item_value">{{ item.clienteleName || "-" }}</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">娈甸暱锛�</text>
+ <text class="outbound_item_value">{{ item.actuallyLength || "-" }} M</text>
+ </view>
+ <view class="outbound_item_row">
+ <text class="outbound_item_label">鐢熶骇鏃ユ湡锛�</text>
+ <text class="outbound_item_value">{{ item.productionDate || "-" }}</text>
+ </view>
+ </view>
+ </view>
+ <view class="outbound_item_action">
+ <wd-button
+ type="icon"
+ icon="delete"
+ size="small"
+ custom-class="delete-btn"
+ @click.stop="removeGoodsItem(index)"
+ ></wd-button>
+ </view>
+ </view>
+ </view>
+
+ <!-- 搴曢儴鎸夐挳 -->
+ <view v-if="goodsList.length > 0" class="outbound_footer">
+ <wd-button block @click="handleOutbound" style="background: #0d867f">
+ <text class="text-[#fff]">鍑哄簱</text>
+ </wd-button>
+ </view>
+
+ <Scan ref="scanRef" emitName="scanMaterial" />
+ <wd-toast />
+ </view>
+</template>
+
+<script setup lang="ts">
+import { ref, onMounted, onUnmounted } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+// @ts-ignore
+import CardTitle from "@/components/card-title/index.vue";
+// @ts-ignore
+import Scan from "@/components/scan/index.vue";
+import { useToast, dayjs } from "wot-design-uni";
+import OutboundApi from "@/api/product/outbound";
+
+const toast = useToast();
+const scanRef = ref();
+const vsrccode = ref<string>("");
+
+// 褰撳墠鐗╂枡淇℃伅
+const currentMaterial = ref<any | null>(null);
+
+// 璐х墿鍒楄〃
+const goodsList = ref<any[]>([]);
+
+// 鏍煎紡鍖栨椂闂�
+const formatTime = (date: Date) => {
+ return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
+};
+
+// 鐩存帴鎵爜
+const openScan = () => {
+ scanRef.value?.triggerScan();
+};
+
+// 鎵爜鍥炶皟
+const getScanCode = async (code: any) => {
+ try {
+ // 濡傛灉 code 鏄璞′笖鏈� code 瀛楁锛屼娇鐢� code.code锛涘惁鍒欑洿鎺ヤ娇鐢� code
+ let scanCode = code.code || code;
+
+ // 濡傛灉 scanCode 鏄璞★紝灏濊瘯鑾峰彇鍏� code 瀛楁
+ if (typeof scanCode === "object" && scanCode.code) {
+ scanCode = scanCode.code;
+ }
+
+ // 濡傛灉 scanCode 鏄瓧绗︿覆锛岀洿鎺ヤ娇鐢紱濡傛灉鏄璞★紝杞负瀛楃涓�
+ if (typeof scanCode !== "string") {
+ scanCode = JSON.stringify(scanCode);
+ }
+
+ if (!scanCode) {
+ toast.error("鎵爜鍐呭涓虹┖");
+ return;
+ }
+
+ // 瑙f瀽鎵爜鏁版嵁锛岀幇鍦ㄤ簩缁寸爜鍙寘鍚玦d
+ let scanData;
+ try {
+ scanData = JSON.parse(scanCode);
+ } catch (e) {
+ toast.error("浜岀淮鐮佹牸寮忛敊璇�");
+ return;
+ }
+
+ const outPutId = scanData.id;
+
+ if (!outPutId) {
+ toast.error("浜岀淮鐮佹牸寮忛敊璇紝缂哄皯id淇℃伅");
+ return;
+ }
+
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹甶d鍒ゆ柇锛�
+ const exists = goodsList.value.some((item) => {
+ const itemId = item.id;
+ return itemId && itemId === outPutId && itemId !== "-";
+ });
+
+ if (exists) {
+ toast.error("璇ユ潯鐮佸凡瀛樺湪锛岃鍕块噸澶嶆壂鐮�");
+ return;
+ }
+
+ // 璋冪敤鎺ュ彛鑾峰彇缁炵嚎/鎷変笣璇︾粏淇℃伅锛堝惈鍑哄簱鐘舵�侊級
+ const { data } = await OutboundApi.getTagByIdAll({
+ outPutId: outPutId,
+ });
+
+ const list = data || [];
+ if (!list.length) {
+ toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+ return;
+ }
+
+ const tagData = list[0];
+
+ // 宸插嚭搴撴牎楠�
+ if (tagData?.state === "宸插嚭搴�") {
+ toast.error("璇ユ潯鐮佸凡鍑哄簱锛屾棤娉曢噸澶嶅嚭搴�");
+ return;
+ }
+
+ // 鍚堝悓鍙锋牎楠岋細妫�鏌ユ壂鐮佺殑鍚堝悓鍙锋槸鍚︾瓑浜庡彂璐у崟鐨剉srccode
+ const scannedContractNo = tagData?.contractno || "";
+ if (scannedContractNo && vsrccode.value && scannedContractNo !== vsrccode.value) {
+ toast.error(`鍚堝悓鍙�"${scannedContractNo}"涓庡綋鍓嶅彂璐у崟涓�"${vsrccode.value}"涓嶅尮閰峘);
+ return;
+ }
+
+ // 鎻愬彇鏁版嵁瀛楁锛堟牴鎹帴鍙h繑鍥炵殑鏁版嵁缁撴瀯锛�
+ const parsedData = {
+ id: tagData?.id || outPutId,
+ contractNo: tagData?.contractno || tagData?.contractNo || "-",
+ monofilamentNumber:
+ tagData?.monofilamentnumber ||
+ tagData?.monofilamentNumber ||
+ tagData?.systemno ||
+ tagData?.systemNo ||
+ "-",
+ model: tagData?.model || "-",
+ weight: tagData?.actuallylength || tagData?.actuallyLength || tagData?.weight || "-",
+ clienteleName: tagData?.clientelename || tagData?.clienteleName || "-",
+ actuallyLength: tagData?.actuallylength || tagData?.actuallyLength || "-",
+ productionDate: tagData?.producttime || tagData?.productionDate || "-",
+ type: tagData?.type || "",
+ devicemodel: tagData?.devicemodel || "",
+ state: tagData?.state || "",
+ projectId: tagData?.projectid || tagData?.projectId || "",
+ productuser: tagData?.productuser || "",
+ // 淇濈暀鍘熷鏁版嵁
+ rawData: tagData,
+ scanCode: scanCode,
+ };
+
+ // 娣诲姞鍒板垪琛�
+ const newItem = {
+ ...parsedData,
+ scanTime: formatTime(new Date()),
+ };
+
+ goodsList.value.push(newItem);
+ toast.success("鎵爜鎴愬姛");
+ } catch (error: any) {
+ console.error("鎵爜澶勭悊澶辫触:", error);
+ toast.error(error.msg || "浜岀淮鐮佸紓甯革紝璇锋洿鎹簩缁寸爜锛�");
+ }
+};
+
+// 鍒犻櫎璐х墿椤�
+const removeGoodsItem = (index: number) => {
+ const item = goodsList.value[index];
+ const itemName = item.contractNo || item.monofilamentNumber || `绗�${index + 1}椤筦;
+
+ uni.showModal({
+ title: "纭鍒犻櫎",
+ content: `纭畾瑕佸垹闄�"${itemName}"鍚楋紵`,
+ confirmText: "鍒犻櫎",
+ cancelText: "鍙栨秷",
+ confirmColor: "#ff4444",
+ success: (res) => {
+ if (res.confirm) {
+ goodsList.value.splice(index, 1);
+ toast.success("鍒犻櫎鎴愬姛");
+ }
+ },
+ });
+};
+
+// 缁熻鐗╂枡鏁伴噺鍜岀被鍨嬭鏍�
+const getMaterialStatistics = () => {
+ const statistics: Record<string, { type: string; model: string; count: number }> = {};
+
+ goodsList.value.forEach((item) => {
+ const type = item.type || "鏈煡绫诲瀷";
+ const model = item.model || "鏈煡瑙勬牸";
+ const key = `${type}_${model}`;
+
+ if (!statistics[key]) {
+ statistics[key] = {
+ type,
+ model,
+ count: 0,
+ };
+ }
+ statistics[key].count++;
+ });
+
+ return Object.values(statistics);
+};
+
+// 澶勭悊鍑哄簱
+const handleOutbound = async () => {
+ if (goodsList.value.length === 0) {
+ toast.error("鏆傛棤璐х墿鏁版嵁");
+ return;
+ }
+
+ // 缁熻鐗╂枡鏁伴噺鍜岀被鍨嬭鏍�
+ const statistics = getMaterialStatistics();
+
+ // 鏋勫缓缁熻淇℃伅鏂囨湰
+ let statisticsText = "鍑哄簱鐗╂枡缁熻锛歕n\n";
+ statistics.forEach((item, index) => {
+ statisticsText += `${index + 1}. ${item.type} - ${item.model}锛�${item.count}浠禱n`;
+ });
+ statisticsText += `\n鎬昏锛�${goodsList.value.length}浠禱n\n纭鍑哄簱鍚楋紵`;
+
+ // 鏄剧ず纭寮规
+ uni.showModal({
+ title: "纭鍑哄簱",
+ content: statisticsText,
+ confirmText: "纭",
+ cancelText: "鍙栨秷",
+ confirmColor: "#0d867f",
+ success: async (res) => {
+ if (res.confirm) {
+ // 鏋勫缓璇锋眰鏁版嵁鏁扮粍
+ const requestData = goodsList.value.map((item) => ({
+ outPutId: item.id,
+ projectId: item.projectId || "",
+ }));
+
+ // 鎸夊嚭搴撳崟鏄庣粏鏋勫缓璇锋眰浣�
+ const payload = {
+ finishedOutDtos: requestData,
+ cdeliveryid: currentMaterial.value?.cdeliveryid || "",
+ cdeliverybid: currentMaterial.value?.cdeliverybid || "",
+ materialcode: currentMaterial.value?.materialcode || "",
+ };
+
+ try {
+ uni.showLoading({
+ title: "鍑哄簱涓�...",
+ mask: true,
+ });
+
+ console.log("request payload", payload);
+ const { code, msg } = await OutboundApi.finishedOutboundByOutboundId(payload);
+
+ uni.hideLoading();
+
+ if (code === 200) {
+ toast.success("鍑哄簱鎴愬姛");
+ // 娓呯┖鍒楄〃
+ goodsList.value = [];
+ // 杩斿洖涓婁竴椤�
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 1500);
+ } else {
+ toast.error(msg || "鍑哄簱澶辫触");
+ }
+ } catch (error: any) {
+ uni.hideLoading();
+ console.error("鍑哄簱澶辫触:", error);
+ toast.error(error.msg || "鍑哄簱澶辫触");
+ }
+ }
+ },
+ });
+};
+
+// 璁剧疆鎵爜鐩戝惉
+const setupScanListener = () => {
+ uni.$off("scanMaterial", getScanCode);
+ uni.$on("scanMaterial", getScanCode);
+};
+
+onLoad((options: any) => {
+ // 浠庤矾鐢卞弬鏁颁腑鑾峰彇鐗╂枡鍩烘湰淇℃伅銆佸嚭搴撳崟淇℃伅鍜� vsrccode
+ currentMaterial.value = {
+ materialname: options.materialname || "-",
+ materialspec: options.materialspec || "-",
+ shippedQuantity: Number(options.shippedQuantity || 0),
+ cdeliveryid: options.cdeliveryid || "",
+ cdeliverybid: options.cdeliverybid || "",
+ materialcode: options.materialcode || "",
+ };
+ vsrccode.value = options.vsrccode || "";
+});
+
+onMounted(() => {
+ setupScanListener();
+});
+
+onUnmounted(() => {
+ uni.$off("scanMaterial", getScanCode);
+});
+</script>
+
+<style lang="scss" scoped>
+.material-page {
+ min-height: 100vh;
+ background: #f3f9f8;
+ padding-bottom: 200rpx;
+ display: flex;
+ flex-direction: column;
+}
+
+.material-header {
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ background: #f3f9f8;
+ /* 璁╁ご閮ㄦ暣浣撴洿绱у噾 */
+ padding-bottom: 8rpx;
+}
+
+.material-info {
+ /* 鍑忓皯涓婁笅鐣欑櫧锛岃鍗$墖鏇磋创杩戝鑸爮 */
+ padding: 4rpx 16rpx 0 16rpx;
+}
+
+.info-card {
+ border-radius: 16rpx;
+ background: linear-gradient(135deg, #ffffff, #f2fbfa);
+ /* 鍑忓急闃村奖锛屾暣浣撴洿鎵佸钩绱у噾 */
+ box-shadow: 0 4rpx 10rpx rgba(3, 112, 102, 0.05);
+ overflow: hidden;
+}
+
+.info-row {
+ /* 鏀剁揣姣忚楂樺害 */
+ padding: 6rpx 0;
+}
+
+.info-compact {
+ display: flex;
+ align-items: center;
+ padding: 8rpx 12rpx;
+}
+
+.info-text {
+ flex: 1;
+ display: flex;
+ flex-wrap: wrap;
+ row-gap: 4rpx;
+}
+
+.info-line {
+ display: flex;
+ font-size: 24rpx;
+ margin-right: 24rpx;
+}
+
+.info-line .label {
+ color: #646874;
+}
+
+.info-line .value {
+ color: #252525;
+ max-width: 260rpx;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.icon_box {
+ /* 缂╁皬鍥炬爣瀹瑰櫒灏哄 */
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 10rpx;
+ background: rgba(13, 134, 127, 0.08);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ margin-right: 8rpx;
+}
+
+.list_content {
+ flex: 1;
+ overflow-y: auto;
+ padding: 24rpx;
+ padding-bottom: 220rpx;
+}
+
+.empty_tip {
+ margin-top: 120rpx;
+ display: flex;
+ justify-content: center;
+}
+
+.empty_text {
+ color: #999;
+ font-size: 28rpx;
+}
+
+.outbound_item {
+ display: flex;
+ justify-content: space-between;
+ padding: 20rpx 24rpx;
+ background: #fff;
+ border-radius: 16rpx;
+ margin-bottom: 20rpx;
+ box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
+}
+
+.outbound_item_left {
+ flex: 1;
+}
+
+.outbound_item_content {
+ display: flex;
+ flex-direction: column;
+ gap: 6rpx;
+}
+
+.outbound_item_row {
+ display: flex;
+ font-size: 26rpx;
+ line-height: 1.6;
+}
+
+.outbound_item_label {
+ color: #646874;
+ min-width: 160rpx;
+}
+
+.outbound_item_value {
+ color: #252525;
+}
+
+.outbound_item_action {
+ margin-left: 16rpx;
+ display: flex;
+ align-items: flex-start;
+}
+
+.delete-btn {
+ --wd-button-default-border-color: #f5f5f5;
+}
+
+.outbound_footer {
+ position: fixed;
+ bottom: 20rpx;
+ left: 0;
+ right: 0;
+ padding: 0 30rpx;
+ padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
+ z-index: 100;
+ background: transparent;
+}
+</style>
--
Gitblit v1.9.3