From 9f94189f8f6e34fd5be40ab6ef5d4e7b1dade069 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 19 一月 2026 11:53:35 +0800
Subject: [PATCH] fix: 报工待生产数量调整
---
src/pages/productionManagement/productionReport/index.vue | 128 ++++++++++++++++++++++++++++--------------
1 files changed, 85 insertions(+), 43 deletions(-)
diff --git a/src/pages/productionManagement/productionReport/index.vue b/src/pages/productionManagement/productionReport/index.vue
index 4117f82..c528611 100644
--- a/src/pages/productionManagement/productionReport/index.vue
+++ b/src/pages/productionManagement/productionReport/index.vue
@@ -12,27 +12,32 @@
<!-- 鍩烘湰淇℃伅 -->
<view class="form-section">
<u-form-item label="寰呯敓浜ф暟閲�"
- prop="remainingQuantity"
+ prop="planQuantity"
required>
- <u-input v-model="form.remainingQuantity"
+ <u-input v-model="form.planQuantity"
placeholder="鑷姩濉厖"
disabled />
</u-form-item>
<u-form-item label="鏈鐢熶骇鏁伴噺"
prop="quantity"
required>
- <u-number-box v-model="form.quantity"
+ <u-input v-model="form.quantity"
+ placeholder="璇疯緭鍏�"
+ type="number" />
+ <!-- <u-number-box v-model="form.quantity"
step="0.1"
bgColor="#fff"
decimal-length="1"
- :min="0"></u-number-box>
+ :min="0"></u-number-box> -->
</u-form-item>
<u-form-item label="鐝粍淇℃伅"
prop="schedulingUserId"
required>
<u-input v-model="form.userName"
placeholder="璇烽�夋嫨鐢熶骇浜�"
- readonly />
+ readonly
+ @click="openProducerPicker"
+ suffix-icon="arrow-down" />
</u-form-item>
</view>
<!-- 浣跨敤FooterButtons缁勪欢 -->
@@ -52,7 +57,8 @@
</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";
const showToast = message => {
@@ -61,40 +67,54 @@
icon: "none",
});
};
-
- import { formatDateToYMD } from "@/utils/ruoyi";
- import { userListNoPageByTenantId } from "@/api/system/user";
- import { productionReport } from "@/api/productionManagement/productionReporting";
+ import { addProductMain } from "@/api/productionManagement/productionReporting";
import { getInfo } from "@/api/login";
+ import { userListNoPageByTenantId } from "@/api/system/user";
// 琛ㄥ崟寮曠敤
const formRef = ref();
// 琛ㄥ崟鏁版嵁
let form = ref({
- remainingQuantity: 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;
};
@@ -105,7 +125,6 @@
const goBack = () => {
uni.navigateBack();
};
- const parsedOrderRow = ref({});
// 鎻愪氦琛ㄥ崟
const submitForm = async () => {
submitting.value = true;
@@ -115,17 +134,34 @@
showToast("璇疯緭鍏ユ湰娆$敓浜ф暟閲�");
return;
}
- if (form.value.quantity > form.value.remainingQuantity) {
+ 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;
}
+ // 鍑嗗鎻愪氦鏁版嵁锛岀‘淇濇暟閲忓瓧娈典负鏁板瓧绫诲瀷
+ const submitData = {
+ ...form.value,
+ quantity: Number(form.value.quantity),
+ planQuantity: Number(form.value.planQuantity) || 0,
+ };
+ console.log(submitData, "submitData");
- addProductMain(reportForm).then(res => {
+ addProductMain(submitData).then(res => {
if (res.code === 200) {
showToast("鎶ュ伐鎴愬姛");
submitting.value = false;
- goBack();
+ setTimeout(() => {
+ goBack();
+ }, 1000);
} else {
showToast(res.msg || "鎶ュ伐澶辫触");
submitting.value = false;
@@ -134,26 +170,32 @@
};
// 椤甸潰鍔犺浇鏃跺垵濮嬪寲鏁版嵁
- onMounted(() => {
- // 鑾峰彇浼犻�掕繃鏉ョ殑orderRow鍙傛暟
- const pages = getCurrentPages();
- const currentPage = pages[pages.length - 1];
- const orderRow = currentPage.options.orderRow;
- form.value.remainingQuantity = 1;
- if (orderRow) {
- parsedOrderRow.value = JSON.parse(orderRow);
-
- form.value.quantity = parsedOrderRow.value.quantity;
- form.value.productProcessRouteItemId =
- parsedOrderRow.value.productProcessRouteItemId;
- form.value.workOrderId = parsedOrderRow.value.id;
- form.value.reportWork = parsedOrderRow.value.reportWork;
- form.value.productMainId = parsedOrderRow.value.productMainId;
+ onLoad(options => {
+ console.log(options, "options");
+ try {
+ const orderRow = JSON.parse(options.orderRow);
+ console.log("鏋勯�犵殑orderRow:", orderRow);
+ console.log(orderRow, "orderRow======########");
+ // 纭繚 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) {
+ console.error("璁㈠崟瑙f瀽澶辫触:", error);
+ showToast("璁㈠崟瑙f瀽澶辫触");
+ goBack();
+ return;
}
- getInfo().then(res => {
- form.value.userId = res.user.userId;
- form.value.userName = res.user.userName;
- });
});
</script>
--
Gitblit v1.9.3