| | |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <div style="margin-bottom: 10px; text-align: left;"> |
| | | <el-button type="primary" |
| | | @click="handleBatchReport">一键报工</el-button> |
| | | </div> |
| | | <PIMTable rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | | :isSelection="true" |
| | | @selection-change="handleSelectionChange" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination"> |
| | | <template #completionStatus="{ row }"> |
| | |
| | | ]); |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const selectedRows = ref([]); |
| | | const transferCardVisible = ref(false); |
| | | const transferCardData = ref([]); |
| | | const transferCardQrUrl = ref(""); |
| | |
| | | toQuantity(planQuantity - completeQuantity) |
| | | ); |
| | | reportForm.planQuantity = remainingQuantity; |
| | | reportForm.quantity = |
| | | row.quantity !== undefined && row.quantity !== null ? row.quantity : null; |
| | | reportForm.quantity = remainingQuantity; |
| | | reportForm.productProcessRouteItemId = row.productProcessRouteItemId; |
| | | reportForm.workOrderId = row.id; |
| | | reportForm.reportWork = row.reportWork; |
| | |
| | | reportForm.userName = user ? user.nickName : ""; |
| | | }; |
| | | |
| | | // 表格选择变化 |
| | | const handleSelectionChange = selection => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | // 一键报工:勾选数据后,生产合格数量默认等于待生产数量,直接提交 |
| | | const handleBatchReport = async () => { |
| | | if (selectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning("请先勾选要报工的工单"); |
| | | return; |
| | | } |
| | | |
| | | // 过滤出可报工的工单:未完工且待生产数量 > 0 |
| | | const validRows = selectedRows.value.filter(row => { |
| | | if (row.endOrder) return false; |
| | | const planQuantity = Number(row.planQuantity || 0); |
| | | const completeQuantity = Number(row.completeQuantity || 0); |
| | | return toQuantity(planQuantity - completeQuantity) > 0; |
| | | }); |
| | | |
| | | if (validRows.length === 0) { |
| | | proxy.$modal.msgWarning("所选工单均无待生产数量,无法报工"); |
| | | return; |
| | | } |
| | | |
| | | const buildSubmitParams = (row, quantity) => ({ |
| | | quantity, |
| | | scrapQty: 0, |
| | | userId: 329, |
| | | userName: "孙立松", |
| | | productionOperationTaskId: row.id, |
| | | productProcessRouteItemId: row.productProcessRouteItemId, |
| | | reportWork: row.reportWork, |
| | | productMainId: row.productMainId, |
| | | productionOrderRoutingOperationId: row.productionOrderRoutingOperationId, |
| | | productionOrderId: row.productionOrderId, |
| | | workHour: row.type == 0 ? row.workHour || 0 : 0, |
| | | productionOperationParamList: [], |
| | | }); |
| | | |
| | | // 待生产数量超过一万时,每次只报 5000,拆分成多笔提交 |
| | | const tasks = []; |
| | | validRows.forEach(row => { |
| | | const planQuantity = Number(row.planQuantity || 0); |
| | | const completeQuantity = Number(row.completeQuantity || 0); |
| | | let remaining = Math.max(0, toQuantity(planQuantity - completeQuantity)); |
| | | while (remaining > 10000) { |
| | | tasks.push(buildSubmitParams(row, 5000)); |
| | | remaining = toQuantity(remaining - 5000); |
| | | } |
| | | if (remaining > 0) { |
| | | tasks.push(buildSubmitParams(row, remaining)); |
| | | } |
| | | }); |
| | | |
| | | const results = await Promise.allSettled( |
| | | tasks.map(params => addProductMain(params)) |
| | | ); |
| | | |
| | | const successCount = results.filter(r => r.status === "fulfilled").length; |
| | | const failCount = results.filter(r => r.status === "rejected").length; |
| | | |
| | | if (failCount === 0) { |
| | | proxy.$modal.msgSuccess(`一键报工成功,共 ${successCount} 笔`); |
| | | } else { |
| | | proxy.$modal.msgWarning( |
| | | `一键报工完成:成功 ${successCount} 笔,失败 ${failCount} 笔` |
| | | ); |
| | | } |
| | | selectedRows.value = []; |
| | | getList(); |
| | | }; |
| | | |
| | | const getDictOptions = async dictType => { |
| | | if (!dictType) return []; |
| | | if (dictOptions.value[dictType]) return dictOptions.value[dictType]; |