From 0ee1e26ce0e58cba9d23321bb4ec691b97bd88e5 Mon Sep 17 00:00:00 2001 From: Xloar <2539907177@qq.com> Date: Thu, 27 Jun 2024 00:51:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?aloar:=E5=87=BA=E5=BA=93=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/inbound.js | 3 +- src/api/outbound.js | 24 +++++-- src/views/receiptorder/InWarehouse.vue | 4 +- src/views/shipmentorder/IndexView.vue | 25 ++++---- src/views/shipmentorder/OutItemList.vue | 55 +++++++++------- src/views/shipmentorder/OutWarehouse.vue | 11 ++-- src/views/shipmentorder/OutWarehouseEntry.vue | 63 ++++++++++++------- 7 files changed, 114 insertions(+), 71 deletions(-) diff --git a/src/api/inbound.js b/src/api/inbound.js index e80d8d3..4d585d5 100644 --- a/src/api/inbound.js +++ b/src/api/inbound.js @@ -1,6 +1,7 @@ import axios from "axios"; -const API_BASE_URL = "http://192.168.43.128:8000"; +// const API_BASE_URL = "http://192.168.43.128:8000"; +const API_BASE_URL = "http://localhost:8000"; //const API_BASE_URL = "https://e1797793-87d4-4690-b69a-a91ae37d8a0e.mock.pstmn.io"; export const getInboundList = () => { diff --git a/src/api/outbound.js b/src/api/outbound.js index 7f1dc44..03baf54 100644 --- a/src/api/outbound.js +++ b/src/api/outbound.js @@ -1,15 +1,15 @@ import axios from "axios"; -const API_BASE_URL = "http://192.168.43.128:8000"; +const API_BASE_URL = "http://localhost:8000"; //const API_BASE_URL ="https://e1797793-87d4-4690-b69a-a91ae37d8a0e.mock.pstmn.io"; export const getOutboundList = () => { return axios.get(`${API_BASE_URL}/wmsOutbound/getOutbound`); }; -export const getclientNames = () => { - return axios.get(`${API_BASE_URL}/wmsclient/getclientName`); -}; +// export const getclientNames = () => { +// return axios.get(`${API_BASE_URL}/wmsclient/getclientName`); +// }; export const deleteOutboundItem = (id) => { return axios.delete(`${API_BASE_URL}/wmsOutbound/deleteOutboundById`, { @@ -63,12 +63,24 @@ export const getItemsBySupplier = async (supplierId) => { throw error; // 重新抛出错误,以便调用方处理 } }; +// 此处获取的是物料编号不重复的所有items +export const getItems = async () => { + try { + const response = await axios.get( + `${API_BASE_URL}/wmsItem/getItems` + ); + return response.data; + } catch (error) { + console.error("Error fetching item by ID:", error); + throw error; // 重新抛出错误,以便调用方处理 + } +}; export const getBox1 = async (formData) => { try { console.log("SavOutg form data:", formData); const response = await axios.get( - `${API_BASE_URL}/wmsContaOuter/contaOuterCount`, + `${API_BASE_URL}/wmsContainer/containerCount`, { params: formData, } @@ -120,7 +132,7 @@ export const getSupplierIdByName = async (supplierName) => { export const saveForm1 = async (formData) => { try { - const response = await axios.post(`${API_BASE_URL}/Outbound`, formData); + const response = await axios.post(`${API_BASE_URL}/wmsOutbound/outbound`, formData); return response.data; } catch (error) { console.error("Error Out save", error); diff --git a/src/views/receiptorder/InWarehouse.vue b/src/views/receiptorder/InWarehouse.vue index 665ba54..abde76e 100644 --- a/src/views/receiptorder/InWarehouse.vue +++ b/src/views/receiptorder/InWarehouse.vue @@ -26,7 +26,7 @@ export default { const fetchPartsById = async (inboundID) => { try { - const response = await axios.post('http://192.168.43.128:8000/wmsInboundDetail/inboundItemsInfo', { id: inboundID }); + const response = await axios.post('http://localhost:8000/wmsInboundDetail/inboundItemsInfo', { id: inboundID }); parts.value = response.data; console.log('Response from server:', response.data); } catch (error) { @@ -38,7 +38,7 @@ export default { const saveForm2 = async () => { for (const singleDetail of parts.value) { try { - const response = await axios.post(`http://192.168.43.128:8000/wmsInboundDetail/addRealQuantity?ibdId=${singleDetail.id}&quantity=${singleDetail.realQuantity}`); + const response = await axios.post(`http://localhost:8000/wmsInboundDetail/addRealQuantity?ibdId=${singleDetail.id}&quantity=${singleDetail.realQuantity}`); console.log(`Data saved successfully for id ${singleDetail.id}`); // 可以在保存成功后进行一些反馈或页面跳转 } catch (error) { diff --git a/src/views/shipmentorder/IndexView.vue b/src/views/shipmentorder/IndexView.vue index fb019b2..bbaf0ec 100644 --- a/src/views/shipmentorder/IndexView.vue +++ b/src/views/shipmentorder/IndexView.vue @@ -125,7 +125,8 @@ + diff --git a/src/views/receiptorder/WarehouseEntry.vue b/src/views/receiptorder/WarehouseEntry.vue index 6f3b76f..804b0ae 100644 --- a/src/views/receiptorder/WarehouseEntry.vue +++ b/src/views/receiptorder/WarehouseEntry.vue @@ -48,12 +48,18 @@ import { ref, onMounted } from 'vue'; import { getBox, getNames, getSupplierIdByName, saveForm } from '@/api/inbound.js'; import ItemList from './ItemList.vue'; +import { useRouter, useRoute } from 'vue-router'; +import { ElMessageBox, ElMessage } from 'element-plus' +import useTabs from '@/utils/useTabs'; +const { addTab, removeTab } = useTabs(); export default { components: { ItemList }, setup() { + const router = useRouter(); + const route = useRoute(); const generateEntryNumber = () => { const date = new Date(); const year = date.getFullYear(); @@ -172,14 +178,31 @@ export default { // 调用后端保存数据的函数 const response = await saveForm(postData); console.log('Form data saved:', response); + ElMessage({ + type: 'success', + message: '保存成功!', + }); + //addTab('/receiptorder', '入库单'); + console.log("删除路由名字", route.path) + removeTab(route.path); + //addTab('/receiptorder', '入库单'); + router.replace('/receiptorder').catch(err => { + console.error('导航到 /receiptorder 失败:', err) + }); } catch (error) { console.error('Error saving form data:', error); + ElMessage({ + type: 'error', + message: '保存失败!', + }); } + }; const cancelForm = () => { console.log('Cancelled'); + }; onMounted(() => { diff --git a/src/views/shipmentorder/IndexView.vue b/src/views/shipmentorder/IndexView.vue index bbaf0ec..74af7bb 100644 --- a/src/views/shipmentorder/IndexView.vue +++ b/src/views/shipmentorder/IndexView.vue @@ -4,22 +4,13 @@ - - - + + + - - - - - - - - - @@ -29,8 +20,9 @@ - + 华南理工大学 + 中山大学 + 华南师范大学 @@ -68,8 +60,8 @@ @@ -84,16 +76,17 @@ - + - - + diff --git a/src/views/shipmentorder/OutWarehouse.vue b/src/views/shipmentorder/OutWarehouse.vue index d7f74c4..317b380 100644 --- a/src/views/shipmentorder/OutWarehouse.vue +++ b/src/views/shipmentorder/OutWarehouse.vue @@ -20,6 +20,7 @@ import { ref, onMounted } from 'vue'; import { useRoute } from 'vue-router'; import axios from 'axios'; +import { fetchPartsByid, saveform2 } from '@/api/outbound.js' export default { setup() { @@ -28,7 +29,7 @@ export default { const fetchPartsById = async (outboundID) => { try { - const response = await axios.post('http://localhost:8000//wmsOutboundDetail/outboundItemsInfo', { id: outboundID }); + const response = await fetchPartsByid(outboundID); parts.value = response.data; console.log('Response from server:', response.data); } catch (error) { @@ -37,19 +38,37 @@ export default { } }; + // const saveForm2 = async () => { + // for (const singleDetail of parts.value) { + // try { + // const response = await saveform2(singleDetail) + // console.log(response.data); + + // alert(JSON.stringify(response.data)); + // // console.log(`Data saved successfully for id ${singleDetail.id}`); + // // 可以在保存成功后进行一些反馈或页面跳转 + // } catch (error) { + // // console.error(`Error saving data for id ${singleDetail.id}:`, error); + // // 可以显示错误消息或者进行其他处理 + // } + // } + // }; const saveForm2 = async () => { - for (const singleDetail of parts.value) { - try { - const response = await axios.post(`http://localhost:8000/wmsOutboundDetail/addRealQuantity?obdId=${singleDetail.id}&quantity=${singleDetail.realQuantity}`); - console.log(response.data); - - alert(JSON.stringify(response.data)); - // console.log(`Data saved successfully for id ${singleDetail.id}`); - // 可以在保存成功后进行一些反馈或页面跳转 - } catch (error) { - // console.error(`Error saving data for id ${singleDetail.id}:`, error); - // 可以显示错误消息或者进行其他处理 - } + try { + const savePromises = parts.value.map(singleDetail => saveform2(singleDetail)); + + const responses = await Promise.all(savePromises); + + const responseData = responses.map(response => response.data); + + // 所有请求完成后进行alert + alert(JSON.stringify(responseData)); + + // 在这里可以进行其他操作,比如页面跳转 + console.log('Data saved successfully for all parts.'); + } catch (error) { + console.error('Error saving data:', error); + // 可以显示错误消息或者进行其他处理 } }; diff --git a/src/views/shipmentorder/OutWarehouseEntry.vue b/src/views/shipmentorder/OutWarehouseEntry.vue index 2ffe15c..efbf09f 100644 --- a/src/views/shipmentorder/OutWarehouseEntry.vue +++ b/src/views/shipmentorder/OutWarehouseEntry.vue @@ -7,7 +7,7 @@ - + @@ -18,7 +18,7 @@ @@ -41,7 +41,7 @@ + @cancel="handleItemListCancel"> @@ -50,6 +50,10 @@ import { ref, onMounted } from 'vue'; // import { getBox1, getNames1, getSupplierIdByName, saveForm1 } from '@/api/outbound.js'; import { saveForm1 } from '@/api/outbound.js'; import ItemList from './OutItemList.vue'; +import { useRouter, useRoute } from 'vue-router'; +import { ElMessageBox, ElMessage } from 'element-plus' +import useTabs from '@/utils/useTabs'; +const { addTab, removeTab } = useTabs(); export default { components: { @@ -98,7 +102,7 @@ export default { console.log(clientName); // supplierId.value = await getSupplierIdByName(supplierName); form.value.wmsOutbound.client = clientName; - + } catch (error) { console.error('Error fetching client', error); } @@ -113,7 +117,7 @@ export default { if (Array.isArray(selectedItemsData.selectedItems)) { for (const item of selectedItemsData.selectedItems) { // const packageQtyOptions = await getBox1({ itemNo: item.itemNo, supplier: selectedItemsData.supplier }); - const packageQtyOptions = [50,100,150];// 此处设置了出货物料包装只能选择这几种 + const packageQtyOptions = [50, 100, 150];// 此处设置了出货物料包装只能选择这几种 form.value.parts.push({ partNumber: item.itemNo, quantity: selectedItemsData.quantity, @@ -180,9 +184,24 @@ export default { // 调用后端保存数据的函数 const response = await saveForm1(postData); console.log('Form data saved:', response); + ElMessage({ + type: 'success', + message: '保存成功!', + }); + //addTab('/receiptorder', '入库单'); + console.log("删除路由名字", route.path) + removeTab(route.path); + //addTab('/receiptorder', '入库单'); + router.replace('/receiptorder').catch(err => { + console.error('导航到 /receiptorder 失败:', err) + }); } catch (error) { console.error('Error saving form data:', error); + ElMessage({ + type: 'error', + message: '保存失败!', + }); } }; -- Gitee