From bf8467516b08a9c1345b591d5a12174cb006b023 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期六, 17 一月 2026 11:23:12 +0800
Subject: [PATCH] fix: 报工功能调整

---
 src/pages/index.vue |  266 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 157 insertions(+), 109 deletions(-)

diff --git a/src/pages/index.vue b/src/pages/index.vue
index f1e1f22..44595f9 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -38,77 +38,77 @@
     <!--			</view>-->
     <!--		</view>-->
     <!-- 钀ラ攢绠$悊妯″潡 -->
-<!--    <view class="common-module marketing-module">-->
-<!--      <view class="module-header">-->
-<!--        <view class="module-title-container">-->
-<!--          <text class="module-title">钀ラ攢绠$悊</text>-->
-<!--        </view>-->
-<!--      </view>-->
-<!--      <view class="module-content">-->
-<!--        <up-grid :border="false"-->
-<!--                 col="4">-->
-<!--          <up-grid-item v-for="(item, index) in marketingItems"-->
-<!--                        :key="index"-->
-<!--                        @click="handleCommonItemClick(item)">-->
-<!--            <view class="icon-container"-->
-<!--                  :style="{ background: item.bgColor }">-->
-<!--              <up-icon :name="item.icon"-->
-<!--                       :size="58"-->
-<!--                       color="#ffffff"></up-icon>-->
-<!--            </view>-->
-<!--            <text class="item-label">{{item.label}}</text>-->
-<!--          </up-grid-item>-->
-<!--        </up-grid>-->
-<!--      </view>-->
-<!--    </view>-->
-<!--    &lt;!&ndash; 閲囪喘绠$悊妯″潡 &ndash;&gt;-->
-<!--    <view class="common-module purchase-module">-->
-<!--      <view class="module-header">-->
-<!--        <view class="module-title-container">-->
-<!--          <text class="module-title">閲囪喘绠$悊</text>-->
-<!--        </view>-->
-<!--      </view>-->
-<!--      <view class="module-content">-->
-<!--        <up-grid :border="false"-->
-<!--                 col="4">-->
-<!--          <up-grid-item v-for="(item, index) in purchaseItems"-->
-<!--                        :key="index"-->
-<!--                        @click="handleCommonItemClick(item)">-->
-<!--            <view class="icon-container"-->
-<!--                  :style="{ background: item.bgColor }">-->
-<!--              <up-icon :name="item.icon"-->
-<!--                       :size="58"-->
-<!--                       color="#ffffff"></up-icon>-->
-<!--            </view>-->
-<!--            <text class="item-label">{{item.label}}</text>-->
-<!--          </up-grid-item>-->
-<!--        </up-grid>-->
-<!--      </view>-->
-<!--    </view>-->
-<!--    &lt;!&ndash; 鍗忓悓鍔炲叕妯″潡 &ndash;&gt;-->
-<!--    <view class="common-module collaboration-module">-->
-<!--      <view class="module-header">-->
-<!--        <view class="module-title-container">-->
-<!--          <text class="module-title">鍗忓悓鍔炲叕</text>-->
-<!--        </view>-->
-<!--      </view>-->
-<!--      <view class="module-content">-->
-<!--        <up-grid :border="false"-->
-<!--                 col="4">-->
-<!--          <up-grid-item v-for="(item, index) in collaborationItems"-->
-<!--                        :key="index"-->
-<!--                        @click="handleCommonItemClick(item)">-->
-<!--            <view class="icon-container"-->
-<!--                  :style="{ background: item.bgColor }">-->
-<!--              <up-icon :name="item.icon"-->
-<!--                       :size="58"-->
-<!--                       color="#ffffff"></up-icon>-->
-<!--            </view>-->
-<!--            <text class="item-label">{{item.label}}</text>-->
-<!--          </up-grid-item>-->
-<!--        </up-grid>-->
-<!--      </view>-->
-<!--    </view>-->
+    <!--    <view class="common-module marketing-module">-->
+    <!--      <view class="module-header">-->
+    <!--        <view class="module-title-container">-->
+    <!--          <text class="module-title">钀ラ攢绠$悊</text>-->
+    <!--        </view>-->
+    <!--      </view>-->
+    <!--      <view class="module-content">-->
+    <!--        <up-grid :border="false"-->
+    <!--                 col="4">-->
+    <!--          <up-grid-item v-for="(item, index) in marketingItems"-->
+    <!--                        :key="index"-->
+    <!--                        @click="handleCommonItemClick(item)">-->
+    <!--            <view class="icon-container"-->
+    <!--                  :style="{ background: item.bgColor }">-->
+    <!--              <up-icon :name="item.icon"-->
+    <!--                       :size="58"-->
+    <!--                       color="#ffffff"></up-icon>-->
+    <!--            </view>-->
+    <!--            <text class="item-label">{{item.label}}</text>-->
+    <!--          </up-grid-item>-->
+    <!--        </up-grid>-->
+    <!--      </view>-->
+    <!--    </view>-->
+    <!--    &lt;!&ndash; 閲囪喘绠$悊妯″潡 &ndash;&gt;-->
+    <!--    <view class="common-module purchase-module">-->
+    <!--      <view class="module-header">-->
+    <!--        <view class="module-title-container">-->
+    <!--          <text class="module-title">閲囪喘绠$悊</text>-->
+    <!--        </view>-->
+    <!--      </view>-->
+    <!--      <view class="module-content">-->
+    <!--        <up-grid :border="false"-->
+    <!--                 col="4">-->
+    <!--          <up-grid-item v-for="(item, index) in purchaseItems"-->
+    <!--                        :key="index"-->
+    <!--                        @click="handleCommonItemClick(item)">-->
+    <!--            <view class="icon-container"-->
+    <!--                  :style="{ background: item.bgColor }">-->
+    <!--              <up-icon :name="item.icon"-->
+    <!--                       :size="58"-->
+    <!--                       color="#ffffff"></up-icon>-->
+    <!--            </view>-->
+    <!--            <text class="item-label">{{item.label}}</text>-->
+    <!--          </up-grid-item>-->
+    <!--        </up-grid>-->
+    <!--      </view>-->
+    <!--    </view>-->
+    <!--    &lt;!&ndash; 鍗忓悓鍔炲叕妯″潡 &ndash;&gt;-->
+    <!--    <view class="common-module collaboration-module">-->
+    <!--      <view class="module-header">-->
+    <!--        <view class="module-title-container">-->
+    <!--          <text class="module-title">鍗忓悓鍔炲叕</text>-->
+    <!--        </view>-->
+    <!--      </view>-->
+    <!--      <view class="module-content">-->
+    <!--        <up-grid :border="false"-->
+    <!--                 col="4">-->
+    <!--          <up-grid-item v-for="(item, index) in collaborationItems"-->
+    <!--                        :key="index"-->
+    <!--                        @click="handleCommonItemClick(item)">-->
+    <!--            <view class="icon-container"-->
+    <!--                  :style="{ background: item.bgColor }">-->
+    <!--              <up-icon :name="item.icon"-->
+    <!--                       :size="58"-->
+    <!--                       color="#ffffff"></up-icon>-->
+    <!--            </view>-->
+    <!--            <text class="item-label">{{item.label}}</text>-->
+    <!--          </up-grid-item>-->
+    <!--        </up-grid>-->
+    <!--      </view>-->
+    <!--    </view>-->
     <!-- 鐢熶骇绠℃帶妯″潡 -->
     <!--		<view class="common-module production-module">-->
     <!--			<view class="module-header">-->
@@ -163,35 +163,36 @@
       </view>
     </view>
     <!-- 璁惧绠$悊妯″潡 -->
-<!--    <view class="common-module equipment-module">-->
-<!--      <view class="module-header">-->
-<!--        <view class="module-title-container">-->
-<!--          <text class="module-title">璁惧绠$悊</text>-->
-<!--        </view>-->
-<!--      </view>-->
-<!--      <view class="module-content">-->
-<!--        <up-grid :border="false"-->
-<!--                 col="4">-->
-<!--          <up-grid-item v-for="(item, index) in equipmentItems"-->
-<!--                        :key="index"-->
-<!--                        @click="handleCommonItemClick(item)">-->
-<!--            <view class="icon-container"-->
-<!--                  :style="{ background: item.bgColor }">-->
-<!--              <up-icon :name="item.icon"-->
-<!--                       :size="58"-->
-<!--                       color="#ffffff"></up-icon>-->
-<!--            </view>-->
-<!--            <text class="item-label">{{item.label}}</text>-->
-<!--          </up-grid-item>-->
-<!--        </up-grid>-->
-<!--      </view>-->
-<!--    </view>-->
+    <!--    <view class="common-module equipment-module">-->
+    <!--      <view class="module-header">-->
+    <!--        <view class="module-title-container">-->
+    <!--          <text class="module-title">璁惧绠$悊</text>-->
+    <!--        </view>-->
+    <!--      </view>-->
+    <!--      <view class="module-content">-->
+    <!--        <up-grid :border="false"-->
+    <!--                 col="4">-->
+    <!--          <up-grid-item v-for="(item, index) in equipmentItems"-->
+    <!--                        :key="index"-->
+    <!--                        @click="handleCommonItemClick(item)">-->
+    <!--            <view class="icon-container"-->
+    <!--                  :style="{ background: item.bgColor }">-->
+    <!--              <up-icon :name="item.icon"-->
+    <!--                       :size="58"-->
+    <!--                       color="#ffffff"></up-icon>-->
+    <!--            </view>-->
+    <!--            <text class="item-label">{{item.label}}</text>-->
+    <!--          </up-grid-item>-->
+    <!--        </up-grid>-->
+    <!--      </view>-->
+    <!--    </view>-->
   </view>
 </template>
 
 <script setup>
   import { ref, onMounted, nextTick, reactive } from "vue";
   import { userLoginFacotryList } from "@/api/login";
+  import { getProductWorkOrderById } from "@/api/productionManagement/productionReporting";
   import modal from "@/plugins/modal";
   import useUserStore from "@/store/modules/user";
 
@@ -527,23 +528,73 @@
   }
   const getcode = () => {
     uni.scanCode({
-      success: res => {
+      success: async res => {
         // 瑙f瀽浜岀淮鐮佸唴瀹�
         const scanResult = res.result;
         let orderRow = "";
 
-        // 灏濊瘯浠庢壂鐮佺粨鏋滀腑鎻愬彇orderRow鍙傛暟
-        try {
-          // 澶勭悊娣峰悎鏍煎紡: http://...?orderRow={...}
-          const orderRowStart = scanResult.indexOf("orderRow={");
-          // 鎻愬彇浠巓rderRow={寮�濮嬬殑JSON鍐呭
-          const jsonPart = scanResult.substring(orderRowStart + 9); // 9鏄�"orderRow=".length
-          // 灏濊瘯鐩存帴浣跨敤杩欎釜JSON閮ㄥ垎
-          orderRow = jsonPart;
-        } catch (e) {
-          console.error(e, "瑙f瀽澶辫触====????=====");
-          orderRow = "";
+        // 鍒ゆ柇鎵弿缁撴灉鏄惁涓虹函鏁板瓧锛坕d锛�
+        const isNumericId = /^\d+$/.test(scanResult.trim());
+        
+        if (isNumericId) {
+          // 濡傛灉鏄函鏁板瓧锛屾牴鎹� id 鑾峰彇宸ュ崟鏁版嵁
+          const workOrderId = scanResult.trim();
+          modal.loading("姝e湪鑾峰彇宸ュ崟淇℃伅...");
+          try {
+            const workRes = await getProductWorkOrderById({ id: workOrderId });
+            modal.closeLoading();
+            
+            console.log("宸ュ崟鏌ヨ缁撴灉:", workRes);
+            
+            if (workRes.code === 200 && workRes.data) {
+              // 鏂版帴鍙h繑鍥炵殑鏄崟涓璞★紝涓嶆槸鏁扮粍
+              const workData = workRes.data;
+              console.log("宸ュ崟鏁版嵁:", workData);
+              
+              orderRow = JSON.stringify({
+                id: workData.id || workOrderId,
+                planQuantity: workData.planQuantity || workData.寰呯敓浜ф暟閲� || 0,
+                productProcessRouteItemId: workData.productProcessRouteItemId || workData.浜у搧宸ヨ壓璺嚎椤笽D || "",
+              });
+              
+              console.log("鏋勯�犵殑orderRow:", orderRow);
+            } else {
+              modal.msgError("鏈壘鍒板搴旂殑宸ュ崟淇℃伅");
+              return;
+            }
+          } catch (error) {
+            modal.closeLoading();
+            console.error("鑾峰彇宸ュ崟淇℃伅澶辫触:", error);
+            modal.msgError("鑾峰彇宸ュ崟淇℃伅澶辫触: " + (error.message || "鏈煡閿欒"));
+            return;
+          }
+        } else {
+          // 濡傛灉涓嶆槸绾暟瀛楋紝灏濊瘯浠庢壂鐮佺粨鏋滀腑鎻愬彇orderRow鍙傛暟
+          try {
+            // 澶勭悊娣峰悎鏍煎紡: http://...?orderRow={...}
+            const orderRowStart = scanResult.indexOf("orderRow={");
+            if (orderRowStart !== -1) {
+              // 鎻愬彇浠巓rderRow={寮�濮嬬殑JSON鍐呭
+              const jsonPart = scanResult.substring(orderRowStart + 9); // 9鏄�"orderRow=".length
+              orderRow = jsonPart;
+            } else {
+              // 濡傛灉鐩存帴鏄疛SON瀛楃涓诧紝灏濊瘯瑙f瀽
+              orderRow = scanResult;
+            }
+          } catch (e) {
+            console.error(e, "瑙f瀽澶辫触====????=====");
+            orderRow = "";
+          }
+          
+          // 楠岃瘉鏄惁涓烘湁鏁堢殑JSON
+          try {
+            JSON.parse(orderRow);
+          } catch (error) {
+            modal.msgError("璁㈠崟瑙f瀽澶辫触锛岃妫�鏌ヤ簩缁寸爜鏍煎紡");
+            return;
+          }
         }
+        
         console.log(orderRow, "orderRow======@@@@@@@@");
         // 鎵爜鎴愬姛鍚庤烦杞埌鐢熶骇鎶ュ伐椤甸潰锛屽苟浼犻�抩rderRow鍙傛暟
         uni.navigateTo({
@@ -554,9 +605,6 @@
         uni.showToast({
           title: "鎵爜澶辫触",
           icon: "none",
-        });
-        uni.navigateTo({
-          url: `/pages/productionManagement/productionReport/index`,
         });
       },
     });

--
Gitblit v1.9.3