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/productionManagement/productionReport/index.vue |   83 ++++++++++++++++++++++++++++++-----------
 1 files changed, 61 insertions(+), 22 deletions(-)

diff --git a/src/pages/productionManagement/productionReport/index.vue b/src/pages/productionManagement/productionReport/index.vue
index f60eba5..c528611 100644
--- a/src/pages/productionManagement/productionReport/index.vue
+++ b/src/pages/productionManagement/productionReport/index.vue
@@ -35,7 +35,9 @@
                      required>
           <u-input v-model="form.userName"
                    placeholder="璇烽�夋嫨鐢熶骇浜�"
-                   readonly />
+                   readonly
+                   @click="openProducerPicker"
+                   suffix-icon="arrow-down" />
         </u-form-item>
       </view>
       <!-- 浣跨敤FooterButtons缁勪欢 -->
@@ -55,7 +57,7 @@
 </template>
 
 <script setup>
-  import { ref, onMounted } from "vue";
+  import { ref, nextTick } from "vue";
   import { onLoad } from "@dcloudio/uni-app";
   import FooterButtons from "@/components/FooterButtons.vue";
 
@@ -67,35 +69,52 @@
   };
   import { addProductMain } from "@/api/productionManagement/productionReporting";
   import { getInfo } from "@/api/login";
+  import { userListNoPageByTenantId } from "@/api/system/user";
 
   // 琛ㄥ崟寮曠敤
   const formRef = ref();
 
   // 琛ㄥ崟鏁版嵁
   let form = ref({
-    planQuantity: 0,
-    quantity: 0,
+    planQuantity: "",
+    quantity: "",
     userName: "",
     workOrderId: "",
-    reportWork: "",
     productProcessRouteItemId: "",
     userId: "",
-    productMainId: null,
+    schedulingUserId: "",
   });
-  let schedulingUserName = ref("");
-
-  // 鏃ユ湡閫夋嫨鍣ㄧ姸鎬�
-  const showEnterDatePicker = ref(false);
-  const enterDateValue = ref(Date.now());
 
   // 鐢熶骇浜洪�夋嫨鍣ㄧ姸鎬�
   const showProducerPicker = ref(false);
   const producerList = ref([]);
 
+  // 鎵撳紑鐢熶骇浜洪�夋嫨鍣�
+  const openProducerPicker = async () => {
+    if (producerList.value.length === 0) {
+      // 濡傛灉鍒楄〃涓虹┖锛屽厛鍔犺浇鐢ㄦ埛鍒楄〃
+      try {
+        const res = await userListNoPageByTenantId();
+        const users = res.data || [];
+        // 杞崲涓� action-sheet 闇�瑕佺殑鏍煎紡
+        producerList.value = users.map(user => ({
+          name: user.nickName || user.userName,
+          value: user.userId,
+        }));
+      } catch (error) {
+        console.error("鍔犺浇鐢ㄦ埛鍒楄〃澶辫触:", error);
+        showToast("鍔犺浇鐢ㄦ埛鍒楄〃澶辫触");
+        return;
+      }
+    }
+    showProducerPicker.value = true;
+  };
+
   // 鐢熶骇浜洪�夋嫨纭
   const onProducerConfirm = e => {
     form.value.schedulingUserId = e.value;
-    schedulingUserName.value = e.name;
+    form.value.userName = e.name;
+    form.value.userId = e.value; // 鍚屾椂鏇存柊 userId
     showProducerPicker.value = false;
   };
 
@@ -115,14 +134,28 @@
       showToast("璇疯緭鍏ユ湰娆$敓浜ф暟閲�");
       return;
     }
-    if (form.value.quantity > form.value.planQuantity) {
+    if (!form.value.schedulingUserId) {
+      submitting.value = false;
+      showToast("璇烽�夋嫨鐢熶骇浜�");
+      return;
+    }
+    // 杞崲涓烘暟瀛楄繘琛屾瘮杈�
+    const quantity = Number(form.value.quantity);
+    const planQuantity = Number(form.value.planQuantity);
+    if (quantity > planQuantity) {
       submitting.value = false;
       showToast("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬寰呯敓浜ф暟閲�");
       return;
     }
-    console.log(form.value, "form.value");
+    // 鍑嗗鎻愪氦鏁版嵁锛岀‘淇濇暟閲忓瓧娈典负鏁板瓧绫诲瀷
+    const submitData = {
+      ...form.value,
+      quantity: Number(form.value.quantity),
+      planQuantity: Number(form.value.planQuantity) || 0,
+    };
+    console.log(submitData, "submitData");
 
-    addProductMain(form.value).then(res => {
+    addProductMain(submitData).then(res => {
       if (res.code === 200) {
         showToast("鎶ュ伐鎴愬姛");
         submitting.value = false;
@@ -141,19 +174,25 @@
     console.log(options, "options");
     try {
       const orderRow = JSON.parse(options.orderRow);
+      console.log("鏋勯�犵殑orderRow:", orderRow);
       console.log(orderRow, "orderRow======########");
-      form.value.planQuantity = orderRow.planQuantity;
-      form.value.quantity = orderRow.quantity;
-      form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId;
-      form.value.workOrderId = orderRow.id;
-      form.value.reportWork = orderRow.reportWork;
-      form.value.productMainId = orderRow.productMainId;
+      // 纭繚 planQuantity 杞崲涓哄瓧绗︿覆锛屼互渚垮湪 u-input 涓纭樉绀�
+      form.value.planQuantity = orderRow.planQuantity != null ? String(orderRow.planQuantity) : "";
+      form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId || "";
+      form.value.workOrderId = orderRow.id || "";
       getInfo().then(res => {
+        // 榛樿浣跨敤褰撳墠鐧诲綍鐢ㄦ埛锛屼絾鍏佽鐢ㄦ埛淇敼
         form.value.userId = res.user.userId;
         form.value.userName = res.user.userName;
+        form.value.schedulingUserId = res.user.userId;
+      });
+      // 浣跨敤 nextTick 纭繚 DOM 鏇存柊
+      nextTick(() => {
+        console.log("form.value after assignment:", form.value);
       });
     } catch (error) {
-      modal.msgError("璁㈠崟瑙f瀽澶辫触");
+      console.error("璁㈠崟瑙f瀽澶辫触:", error);
+      showToast("璁㈠崟瑙f瀽澶辫触");
       goBack();
       return;
     }

--
Gitblit v1.9.3