From 8d172bf41d2b802d5782df559e236a71a3d31c2c Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 29 四月 2026 16:20:42 +0800
Subject: [PATCH] 扫码报工模块重构
---
src/pages/works.vue | 9 -
src/pages/productionManagement/productionReport/index.vue | 322 +++++++++++++++++++++++++++++++++++++++++++++-------
src/api/productionManagement/productionReporting.js | 3
src/api/productionManagement/productProcessRoute.js | 11 +
4 files changed, 288 insertions(+), 57 deletions(-)
diff --git a/src/api/productionManagement/productProcessRoute.js b/src/api/productionManagement/productProcessRoute.js
new file mode 100644
index 0000000..6584473
--- /dev/null
+++ b/src/api/productionManagement/productProcessRoute.js
@@ -0,0 +1,11 @@
+// 鐢熶骇鎶ュ伐椤甸潰鎺ュ彛
+import request from "@/utils/request";
+
+// 鑾峰彇宸ュ簭鍙傛暟鍒楄〃-鐢熶骇璁㈠崟
+export function findProcessParamListOrder(query) {
+ return request({
+ url: `/productionOrderRoutingOperationParam/list`,
+ method: "get",
+ params: query,
+ });
+}
diff --git a/src/api/productionManagement/productionReporting.js b/src/api/productionManagement/productionReporting.js
index 33faadb..be352d5 100644
--- a/src/api/productionManagement/productionReporting.js
+++ b/src/api/productionManagement/productionReporting.js
@@ -20,9 +20,8 @@
// 鏍规嵁ID鑾峰彇宸ュ崟璇︽儏
export function getProductWorkOrderById(query) {
return request({
- url: "/productWorkOrder/getProductWorkOrderById",
+ url: "/productionOperationTask/" + query.id,
method: "get",
- params: query,
});
}
// 鐢熶骇鎶ュ伐
diff --git a/src/pages/productionManagement/productionReport/index.vue b/src/pages/productionManagement/productionReport/index.vue
index dcd0fd7..ac0249b 100644
--- a/src/pages/productionManagement/productionReport/index.vue
+++ b/src/pages/productionManagement/productionReport/index.vue
@@ -41,6 +41,58 @@
suffix-icon="arrow-down" />
</u-form-item>
</view>
+ <!-- 鍔ㄦ�佸弬鏁板尯鍩� -->
+ <view class="form-section"
+ v-if="params.length > 0">
+ <view class="section-title">宸ュ簭鍙傛暟</view>
+ <u-form-item v-for="param in params"
+ :key="param.id"
+ :label="param.paramName"
+ :label-width="110"
+ :required="param.required === '1'">
+ <!-- 鏁板瓧绫诲瀷 -->
+ <template v-if="param.paramType == '1'">
+ <u-input v-model="form.paramGroups[param.id]"
+ type="number"
+ :placeholder="'璇疯緭鍏�' + param.paramName"
+ :key="param.id" />
+ <text v-if="param.unit && param.unit != '/'"
+ class="param-unit">{{ param.unit }}</text>
+ </template>
+ <!-- 鏂囨湰绫诲瀷 -->
+ <template v-else-if="param.paramType == '2'">
+ <u-input v-model="form.paramGroups[param.id]"
+ :placeholder="'璇疯緭鍏�' + param.paramName"
+ :key="param.id" />
+ <text v-if="param.unit && param.unit != '/'"
+ class="param-unit">{{ param.unit }}</text>
+ </template>
+ <!-- 閫夋嫨绫诲瀷 -->
+ <template v-else-if="param.paramType == '3'">
+ <u-input v-model="form.paramGroups[param.id]"
+ readonly
+ :placeholder="'璇烽�夋嫨' + param.paramName"
+ @click="openParamSelect(param)"
+ suffix-icon="arrow-down" />
+ </template>
+ <!-- 鏃ユ湡绫诲瀷 -->
+ <template v-else-if="param.paramType == '4'">
+ <u-input v-model="form.paramGroups[param.id]"
+ readonly
+ :placeholder="'璇烽�夋嫨' + param.paramName"
+ @click="openDateParamPicker(param)"
+ suffix-icon="arrow-down" />
+ <text v-if="param.unit && param.unit != '/'"
+ class="param-unit">{{ param.unit }}</text>
+ </template>
+ <!-- 榛樿鏂囨湰 -->
+ <template v-else>
+ <u-input v-model="form.paramGroups[param.id]"
+ :placeholder="'璇疯緭鍏�' + param.paramName"
+ :key="param.id" />
+ </template>
+ </u-form-item>
+ </view>
<!-- 浣跨敤FooterButtons缁勪欢 -->
<FooterButtons @cancel="goBack"
@confirm="submitForm"
@@ -54,6 +106,18 @@
title="閫夋嫨鐢熶骇浜�"
@select="onProducerConfirm"
@close="showProducerPicker = false" />
+ <!-- 鍙傛暟閫夋嫨鍣� -->
+ <up-action-sheet :show="showParamSelect"
+ :actions="paramOptions"
+ :title="currentParam?.paramName || '閫夋嫨'"
+ @select="onParamConfirm"
+ @close="showParamSelect = false" />
+ <!-- 鏃ユ湡閫夋嫨鍣� -->
+ <up-datetime-picker :show="showDatePicker"
+ v-model="datePickerValue"
+ :mode="datePickerMode"
+ @confirm="onDateConfirm"
+ @cancel="showDatePicker = false" />
</view>
</template>
@@ -71,11 +135,12 @@
import { addProductMain } from "@/api/productionManagement/productionReporting";
import { getInfo } from "@/api/login";
import { userListNoPageByTenantId } from "@/api/system/user";
+ import { findProcessParamListOrder } from "@/api/productionManagement/productProcessRoute.js";
+ import { getDicts } from "@/api/system/dict/data";
+ import { formatDateToYMD, parseTime } from "@/utils/ruoyi";
- // 琛ㄥ崟寮曠敤
const formRef = ref();
- // 琛ㄥ崟鏁版嵁
let form = ref({
planQuantity: "",
quantity: "",
@@ -85,20 +150,32 @@
productProcessRouteItemId: "",
userId: "",
schedulingUserId: "",
+ reportWork: "",
+ productMainId: null,
+ productionOrderRoutingOperationId: "",
+ productionOrderId: "",
+ paramGroups: {},
});
- // 鐢熶骇浜洪�夋嫨鍣ㄧ姸鎬�
const showProducerPicker = ref(false);
const producerList = ref([]);
- // 鎵撳紑鐢熶骇浜洪�夋嫨鍣�
+ const params = ref([]);
+ const dictOptions = ref({});
+ const showParamSelect = ref(false);
+ const currentParam = ref(null);
+ const paramOptions = ref([]);
+
+ const showDatePicker = ref(false);
+ const datePickerValue = ref(Date.now());
+ const datePickerMode = ref("date");
+ const currentDateParam = ref(null);
+
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,
@@ -112,102 +189,236 @@
showProducerPicker.value = true;
};
- // 鐢熶骇浜洪�夋嫨纭
const onProducerConfirm = e => {
form.value.schedulingUserId = e.value;
form.value.userName = e.name;
- form.value.userId = e.value; // 鍚屾椂鏇存柊 userId
+ form.value.userId = e.value;
showProducerPicker.value = false;
};
- // 鎻愪氦鐘舵��
+ const openParamSelect = async param => {
+ currentParam.value = param;
+ if (param.paramType == "3" && param.paramFormat) {
+ const options = await getDictOptions(param.paramFormat);
+ paramOptions.value = options.map(opt => ({
+ name: opt.dictLabel,
+ value: opt.dictLabel,
+ }));
+ }
+ showParamSelect.value = true;
+ };
+
+ const onParamConfirm = e => {
+ if (currentParam.value) {
+ form.value.paramGroups[currentParam.value.id] = e.value;
+ }
+ showParamSelect.value = false;
+ };
+
+ const openDateParamPicker = param => {
+ currentDateParam.value = param;
+ const currentValue = form.value.paramGroups[param.id];
+ datePickerValue.value = currentValue
+ ? new Date(currentValue).getTime()
+ : Date.now();
+ // 鍙傜収 PC 绔�昏緫锛氬鏋滄牸寮忔槸 yyyy-MM-dd 鍒欎负 date 妯″紡锛屽惁鍒欎负 datetime 妯″紡
+ datePickerMode.value =
+ param.paramFormat === "yyyy-MM-dd" ? "date" : "datetime";
+ showDatePicker.value = true;
+ };
+
+ const onDateConfirm = e => {
+ if (currentDateParam.value) {
+ const format =
+ currentDateParam.value.paramFormat === "yyyy-MM-dd"
+ ? "{y}-{m}-{d}"
+ : "{y}-{m}-{d} {h}:{i}:{s}";
+ form.value.paramGroups[currentDateParam.value.id] = parseTime(
+ e.value,
+ format
+ );
+ }
+ showDatePicker.value = false;
+ };
+
+ const getDictOptions = async dictType => {
+ if (!dictType) return [];
+ if (dictOptions.value[dictType]) return dictOptions.value[dictType];
+ try {
+ const res = await getDicts(dictType);
+ if (res.code === 200) {
+ dictOptions.value[dictType] = res.data;
+ return res.data;
+ }
+ return [];
+ } catch (error) {
+ console.error("鑾峰彇瀛楀吀鏁版嵁澶辫触:", error);
+ return [];
+ }
+ };
+
+ const loadParams = (productionOrderRoutingOperationId, productionOrderId) => {
+ findProcessParamListOrder({
+ productionOrderRoutingOperationId,
+ productionOrderId,
+ })
+ .then(res => {
+ if (res.code === 200) {
+ console.log(res.data, "res.data========");
+
+ const paramList = res.data || [];
+ params.value = paramList;
+ form.value.paramGroups = {};
+ paramList.forEach(param => {
+ if (!form.value.paramGroups[param.id]) {
+ form.value.paramGroups[param.id] = "";
+ }
+ if (param.paramType == "3" && param.paramFormat) {
+ getDictOptions(param.paramFormat);
+ }
+ });
+ }
+ })
+ .catch(err => {
+ console.error("鑾峰彇宸ュ簭鍙傛暟澶辫触:", err);
+ });
+ };
+
const submitting = ref(false);
- // 杩斿洖涓婁竴椤�
const goBack = () => {
uni.navigateBack();
};
- // 鎻愪氦琛ㄥ崟
+
const submitForm = async () => {
submitting.value = true;
- // 鏍¢獙琛ㄥ崟
+
if (!form.value.quantity) {
submitting.value = false;
showToast("璇疯緭鍏ユ湰娆$敓浜ф暟閲�");
return;
}
+
if (!form.value.schedulingUserId) {
submitting.value = false;
showToast("璇烽�夋嫨鐢熶骇浜�");
return;
}
- // 杞崲涓烘暟瀛楄繘琛屾瘮杈�
+
const quantity = Number(form.value.quantity) || 0;
const scrapQty = Number(form.value.scrapQty) || 0;
const planQuantity = Number(form.value.planQuantity);
- // 楠岃瘉鐢熶骇鏁伴噺鍜屾姤搴熸暟閲忕殑鍜屼笉鑳借秴杩囧緟鐢熶骇鏁伴噺
+
+ if (quantity <= 0) {
+ submitting.value = false;
+ showToast("鏈鐢熶骇鏁伴噺蹇呴』澶т簬0");
+ return;
+ }
+
if (quantity + scrapQty > planQuantity) {
submitting.value = false;
showToast("鐢熶骇鏁伴噺鍜屾姤搴熸暟閲忕殑鍜屼笉鑳借秴杩囧緟鐢熶骇鏁伴噺");
return;
}
- if (quantity > planQuantity) {
+
+ if (scrapQty < 0) {
submitting.value = false;
- showToast("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬寰呯敓浜ф暟閲�");
+ showToast("鎶ュ簾鏁伴噺涓嶈兘灏忎簬0");
return;
}
- // 鍑嗗鎻愪氦鏁版嵁锛岀‘淇濇暟閲忓瓧娈典负鏁板瓧绫诲瀷
+
+ if (scrapQty > quantity) {
+ submitting.value = false;
+ showToast("鎶ュ簾鏁伴噺涓嶈兘澶т簬鏈鐢熶骇鏁伴噺");
+ return;
+ }
+
+ const productionOperationParamList = params.value.map(param => ({
+ ...param,
+ inputValue: form.value.paramGroups[param.id] ?? "",
+ }));
+
const submitData = {
- ...form.value,
- quantity: Number(form.value.quantity),
- scrapQty: Number(form.value.scrapQty) || 0,
- planQuantity: Number(form.value.planQuantity) || 0,
+ quantity: quantity,
+ scrapQty: scrapQty,
+ userId: form.value.userId,
+ userName: form.value.userName,
+ productionOperationTaskId: form.value.workOrderId,
+ productProcessRouteItemId: form.value.productProcessRouteItemId,
+ reportWork: form.value.reportWork,
+ productMainId: form.value.productMainId,
+ productionOrderRoutingOperationId:
+ form.value.productionOrderRoutingOperationId,
+ productionOrderId: form.value.productionOrderId,
+ productionOperationParamList: productionOperationParamList,
};
+
console.log(submitData, "submitData");
- addProductMain(submitData).then(res => {
- if (res.code === 200) {
- showToast("鎶ュ伐鎴愬姛");
+ addProductMain(submitData)
+ .then(res => {
+ if (res.code === 200) {
+ showToast("鎶ュ伐鎴愬姛");
+ submitting.value = false;
+ setTimeout(() => {
+ goBack();
+ }, 1000);
+ } else {
+ showToast(res.msg || "鎶ュ伐澶辫触");
+ submitting.value = false;
+ }
+ })
+ .catch(() => {
+ showToast("鎶ュ伐澶辫触");
submitting.value = false;
- setTimeout(() => {
- goBack();
- }, 1000);
- } else {
- showToast(res.msg || "鎶ュ伐澶辫触");
- submitting.value = false;
- }
- });
+ });
};
- // 椤甸潰鍔犺浇鏃跺垵濮嬪寲鏁版嵁
onLoad(options => {
console.log(options, "options");
- // 濡傛灉娌℃湁 orderRow 鍙傛暟锛岃鏄庢槸浠庨椤电洿鎺ヨ烦杞紝闇�瑕佺敤鎴锋墜鍔ㄩ�夋嫨璁㈠崟
if (!options.orderRow) {
console.log("浠庨椤佃烦杞紝鏃犺鍗曟暟鎹�");
getInfo().then(res => {
- // 榛樿浣跨敤褰撳墠鐧诲綍鐢ㄦ埛
form.value.userId = res.user.userId;
- form.value.userName = res.user.userName;
+ form.value.userName = res.user.nickName || res.user.userName;
form.value.schedulingUserId = res.user.userId;
});
return;
}
try {
- const orderRow = JSON.parse(options.orderRow);
+ const orderRow = JSON.parse(decodeURIComponent(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.planQuantity =
+ orderRow.planQuantity != null ? String(orderRow.planQuantity) : "";
+ form.value.productProcessRouteItemId =
+ orderRow.productProcessRouteItemId || "";
form.value.workOrderId = orderRow.id || "";
+ form.value.reportWork = orderRow.reportWork || "";
+ form.value.productMainId = orderRow.productMainId || null;
+ form.value.productionOrderRoutingOperationId =
+ orderRow.productionOrderRoutingOperationId || "";
+ form.value.productionOrderId = orderRow.productionOrderId || "";
+
getInfo().then(res => {
- // 榛樿浣跨敤褰撳墠鐧诲綍鐢ㄦ埛锛屼絾鍏佽鐢ㄦ埛淇敼
form.value.userId = res.user.userId;
- form.value.userName = res.user.userName;
+ form.value.userName = res.user.nickName || res.user.userName;
form.value.schedulingUserId = res.user.userId;
});
- // 浣跨敤 nextTick 纭繚 DOM 鏇存柊
+ console.log(orderRow, "orderRow=====");
+
+ if (
+ orderRow.productionOrderRoutingOperationId &&
+ orderRow.productionOrderId
+ ) {
+ nextTick(() => {
+ loadParams(
+ orderRow.productionOrderRoutingOperationId,
+ orderRow.productionOrderId
+ );
+ });
+ }
+
nextTick(() => {
console.log("form.value after assignment:", form.value);
});
@@ -215,13 +426,30 @@
console.error("璁㈠崟瑙f瀽澶辫触:", error);
showToast("璁㈠崟瑙f瀽澶辫触");
goBack();
- return;
}
});
</script>
<style scoped lang="scss">
@import "@/static/scss/form-common.scss";
+
+ .form-section {
+ background: #fff;
+ margin-bottom: 12px;
+ padding: 0 16px;
+ }
+
+ .section-title {
+ font-size: 28rpx;
+ font-weight: bold;
+ color: #303133;
+ padding: 24rpx 0 16rpx;
+ border-bottom: 1px solid #f0f0f0;
+ }
+
+ .param-unit {
+ margin-left: 8rpx;
+ color: #909399;
+ font-size: 24rpx;
+ }
</style>
-
-
diff --git a/src/pages/works.vue b/src/pages/works.vue
index 71c1721..ab089c5 100644
--- a/src/pages/works.vue
+++ b/src/pages/works.vue
@@ -1062,14 +1062,7 @@
const workData = workRes.data;
console.log("宸ュ崟鏁版嵁:", workData);
- orderRow = JSON.stringify({
- id: workData.id || workOrderId,
- planQuantity: workData.planQuantity - workData.completeQuantity,
- productProcessRouteItemId:
- workData.productProcessRouteItemId ||
- workData.浜у搧宸ヨ壓璺嚎椤笽D ||
- "",
- });
+ orderRow = JSON.stringify(workData);
console.log("鏋勯�犵殑orderRow:", orderRow);
} else {
--
Gitblit v1.9.3