diff --git a/frontend/src/axios/receiveItemUpdateAxios.js b/frontend/src/axios/receiveItemUpdateAxios.js index 8fc1527..0cc0b2a 100644 --- a/frontend/src/axios/receiveItemUpdateAxios.js +++ b/frontend/src/axios/receiveItemUpdateAxios.js @@ -1,7 +1,14 @@ import axios from "axios"; import swal from "sweetalert2"; axios.defaults.withCredentials = true; -const receiveItemUpdateAxios = (receiveCode, receiveItemNo, receiveCounts, selectWarehouse) => { +const receiveItemUpdateAxios = ( + receiveCode, + receiveItemNo, + receiveCounts, + selectWarehouse, + porderCode, + porderItemNo +) => { const modifyCount = receiveCounts.toString().replace(/,/g, "") || ""; const modifyWarehouseNo = selectWarehouse.toString().replace(/,/g, "") || ""; const receiveItems = { @@ -9,6 +16,8 @@ const receiveItemUpdateAxios = (receiveCode, receiveItemNo, receiveCounts, selec receiveItemNo: receiveItemNo, receiveCount: modifyCount, warehouseNo: modifyWarehouseNo, + pOrderCode: porderCode, + pOrderItemNo: porderItemNo, }; axios .patch("http://localhost:8888/api/receive-item/modify", receiveItems) diff --git a/frontend/src/views/dashboard/components/ReceiveComponents.js b/frontend/src/views/dashboard/components/ReceiveComponents.js index da0a3b1..b8dd23c 100644 --- a/frontend/src/views/dashboard/components/ReceiveComponents.js +++ b/frontend/src/views/dashboard/components/ReceiveComponents.js @@ -12,11 +12,12 @@ import { Checkbox, Pagination, styled, + Tooltip, + Chip, } from "@mui/material"; import { IconHammer } from "@tabler/icons"; import DeleteIcon from "@mui/icons-material/Delete"; import PageviewOutlinedIcon from "@mui/icons-material/PageviewOutlined"; -import AutoFixHighOutlinedIcon from "@mui/icons-material/AutoFixHighOutlined"; import AddCircleOutlineOutlinedIcon from "@mui/icons-material/AddCircleOutlineOutlined"; import { tableCellClasses } from "@mui/material/TableCell"; import DashboardCard from "../../../components/shared/DashboardCard"; @@ -39,6 +40,7 @@ import ReceiveModal from "./modal/ReceiveModal"; import pOrderWaitIngAxios from "src/axios/pOrderWaitIngAxios"; import receiveItemDeleteAxios from "src/axios/receiveItemDeleteAxios"; import receiveUpdateAxios from "src/axios/receiveUpdateAxios"; + const StyledTableCell = styled(TableCell)(({ theme }) => ({ [`&.${tableCellClasses.head}`]: { backgroundColor: "#505e82", @@ -61,6 +63,7 @@ const StyledTableRow = styled(TableRow)(({ theme, receiveCode, modifyReceive }) border: 0, }, })); + axios.defaults.withCredentials = true; const ReceiveComponents = () => { @@ -89,8 +92,10 @@ const ReceiveComponents = () => { const [childReceiveItem, setChildReceiveItem] = useState([]); const products = JSON.parse(JSON.stringify(productsData)); const realProducts = products?.data || []; - const [selectedStartDate, setSelectedStartDate] = useState(null); - const [selectedEndDate, setSelectedEndDate] = useState(null); + const [selectedStartDate, setSelectedStartDate] = useState( + new Date(new Date().getFullYear(), new Date().getMonth(), 1) + ); + const [selectedEndDate, setSelectedEndDate] = useState(new Date()); const receiveModalState = useSelector((state) => state.receiveModal); const [editMode, setEditMode] = useState({}); const [searchManager, setSearchManager] = useState(""); @@ -162,15 +167,6 @@ const ReceiveComponents = () => { } }, [selectedProducts]); - useEffect(() => { - if (selectedStartDate === null) { - setSelectedStartDate(new Date()); - } - if (selectedEndDate === null) { - setSelectedEndDate(new Date()); - } - }, []); - const handleClick = () => { let timerInterval; const findDateStart = new Date(selectedStartDate); @@ -218,40 +214,6 @@ const ReceiveComponents = () => { } }; - const handleModify = () => { - if (selectedProducts.length === 0) { - swal.fire({ - title: "선택 사항 없음", - text: "수정할 입고를 선택해주세요", - icon: "warning", - }); - } else if (selectedProducts.length >= 2) { - swal.fire({ - title: "선택 사항 초과", - text: "수정할 입고를 하나씩 선택해주세요", - icon: "warning", - }); - } else if (selectedProducts.length === 1) { - swal - .fire({ - title: "정말로 수정하시겠습니까?", - text: "해당하는 데이터의 창고재고도 함께 수정됩니다.", - icon: "warning", - showCancelButton: true, - confirmButtonColor: "#d33", - cancelButtonColor: "#3085", - confirmButtonText: "수정", - cancelButtonText: "취소", - }) - .then((result) => { - if (result.isConfirmed) { - setModifyReceiveCode(selectedProducts); - } - }); - } - setModifyReceiveCode("null"); - }; - const handleDelete = () => { swal .fire({ @@ -268,8 +230,10 @@ const ReceiveComponents = () => { if (result.isConfirmed) { if (selectedProducts.length > 0) { receiveDeleteAxios(selectedProducts); - dispatch(receiveListAll()); setReceiveItemData([]); + // dispatch(receiveListAll()); + console.log("삭제프로세스완료"); + window.location.reload(); } if (childReceiveItem.length > 0) { receiveItemDeleteAxios(childReceiveItem); @@ -475,6 +439,8 @@ const ReceiveComponents = () => { renderInput={(props) => } slotProps={{ textField: { size: "small" } }} sx={{ mr: 2 }} + minDate={new Date("2000-01-01")} + maxDate={new Date("2100-12-31")} /> { onChange={(newDate) => setSelectedEndDate(newDate)} renderInput={(props) => } slotProps={{ textField: { size: "small" } }} + minDate={new Date("2000-01-01")} + maxDate={new Date("2100-12-31")} /> @@ -507,16 +475,6 @@ const ReceiveComponents = () => { > 발주적용 - } - onClick={handleModify} - sx={{ mr: 2 }} - > - 수정 - { sx={{ overflow: "auto", maxHeight: "550px", + height: "calc(40vh)", }} > { mb: 0, }} > - - + + @@ -568,24 +534,26 @@ const ReceiveComponents = () => { - {currentItems.map((realProduct) => ( + {currentItems.map((realProduct, index) => ( { - handleCheckboxChange(event, realProduct.receiveCode)} - /> + + + handleCheckboxChange(event, realProduct.receiveCode)} + disabled={realProduct.cmpCount !== 0} + sx={{ + "&.Mui-disabled": { + pointerEvents: "auto", + }, + }} + /> + + - + {realProduct.receiveCode} - + {editMode[`${realProduct.receiveCode}`] ? ( { - + {editMode[`${realProduct.receiveCode}`] ? ( { setEditedDates(newDate); }} renderInput={(params) => } + minDate={new Date("2000-01-01")} + maxDate={new Date("2100-12-31")} /> ) : ( - realProduct.receiveDate.split(" ")[0] + (realProduct.receiveDate?.split(" ") || [])[0] )} - : } - onClick={() => handleEdit(realProduct.receiveCode)} - disabled={String(modifyReceiveCode) !== String(realProduct.receiveCode)} - > - {editMode[`${realProduct.receiveCode}`] ? "Save" : "Edit"} - + {realProduct.cmpCount !== 0 && + realProduct.ingCount === 0 && + realProduct.waitCount === 0 ? ( + + { + return theme.palette.error.main; + }, + }} + /> + + ) : ( + : } + onClick={() => handleEdit(realProduct.receiveCode)} + > + {editMode[`${realProduct.receiveCode}`] ? "저장" : "수정"} + + )} ))} diff --git a/frontend/src/views/dashboard/components/ReceiveComponents2.js b/frontend/src/views/dashboard/components/ReceiveComponents2.js index 8b2fd49..7ab3193 100644 --- a/frontend/src/views/dashboard/components/ReceiveComponents2.js +++ b/frontend/src/views/dashboard/components/ReceiveComponents2.js @@ -15,6 +15,7 @@ import { MenuItem, FormControl, styled, + Chip, } from "@mui/material"; import DeleteIcon from "@mui/icons-material/Delete"; import { Edit, Done, GifBox } from "@mui/icons-material"; @@ -127,7 +128,7 @@ const ReceiveComponents2 = (props) => { } }, [props.modalSelectedProducts]); - const handleEdit = (receiveCode, receiveItemNo) => { + const handleEdit = (receiveCode, receiveItemNo, porderCode, porderItemNo) => { setEditMode((prevState) => ({ ...prevState, [`${receiveCode}-${receiveItemNo}`]: !prevState[`${receiveCode}-${receiveItemNo}`], @@ -152,7 +153,14 @@ const ReceiveComponents2 = (props) => { icon: "warning", }); } else if (receiveCounts !== "" || selectWarehouse !== "") { - receiveItemUpdateAxios(receiveCode, receiveItemNo, receiveCounts, selectWarehouse); + receiveItemUpdateAxios( + receiveCode, + receiveItemNo, + receiveCounts, + selectWarehouse, + porderCode, + porderItemNo + ); setModifyCode(receiveCode); } setModifyReceiveItemData(null); @@ -278,6 +286,7 @@ const ReceiveComponents2 = (props) => { alignItems: "center", mb: 2, padding: "10px", + height: "calc(auto)", }} > {addPOrderProducts.length !== 0 && ( @@ -565,6 +574,8 @@ const ReceiveComponents2 = (props) => { 발주순번: {product.porderItemNo} 발주상태: {product.porderState} + + 발주수량: {product.porderCount} } > @@ -574,26 +585,45 @@ const ReceiveComponents2 = (props) => { - - ) : ( - - ) - } - onClick={() => handleEdit(product.receiveCode, product.receiveItemNo)} - disabled={ - product.porderState === "완료" || - String(modifyReceiveItemData) !== String(product.receiveCode) - } - > - {editMode[`${product.receiveCode}-${product.receiveItemNo}`] - ? "Save" - : "Edit"} - + {product.porderState === "완료" ? ( + + { + return theme.palette.error.main; + }, + }} + /> + + ) : ( + + ) : ( + + ) + } + onClick={() => + handleEdit( + product.receiveCode, + product.receiveItemNo, + product.porderCode, + product.porderItemNo + ) + } + > + {editMode[`${product.receiveCode}-${product.receiveItemNo}`] + ? "저장" + : "수정"} + + )} ))} diff --git a/frontend/src/views/dashboard/components/modal/ReceiveModal.js b/frontend/src/views/dashboard/components/modal/ReceiveModal.js index b26052f..43316dc 100644 --- a/frontend/src/views/dashboard/components/modal/ReceiveModal.js +++ b/frontend/src/views/dashboard/components/modal/ReceiveModal.js @@ -16,6 +16,7 @@ import { Pagination, Checkbox, styled, + Chip, } from "@mui/material"; import { close_Modal } from "../../../../redux/slices/receiveModalDuck"; import pOrderWaitIngAxios from "src/axios/pOrderWaitIngAxios"; @@ -93,7 +94,7 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { : []; useEffect(() => { if (selectedStartDate === null) { - setSelectedStartDate(new Date()); + setSelectedStartDate(new Date(new Date().getFullYear(), new Date().getMonth(), 1)); } if (selectedEndDate === null) { setSelectedEndDate(new Date()); @@ -318,6 +319,8 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { renderInput={(props) => } format="yyyy.MM.dd" slotProps={{ textField: { size: "small" } }} + minDate={new Date("2000-01-01")} + maxDate={new Date("2100-12-31")} /> { renderInput={(props) => } format="yyyy.MM.dd" slotProps={{ textField: { size: "small" } }} + minDate={new Date("2000-01-01")} + maxDate={new Date("2100-12-31")} /> { onClick={handleClick} sx={{ ml: 2 }} > - 조회 + 검색 @@ -378,10 +383,9 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { key={index} sx={{ "&:hover": { - backgroundColor: "#f5f5f5", + backgroundColor: "#c7d4e8", }, - backgroundColor: - selectedRow === porderCode ? "rgba(0, 0, 0, 0.04)" : "transparent", + backgroundColor: selectedRow === porderCode ? "#c7d4e8" : "transparent", }} onClick={() => handleProductClick(porderCode)} > @@ -402,7 +406,26 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { - {state} + { + switch (state) { + case "준비": + return theme.palette.primary.main; + case "진행 중": + return theme.palette.info.main; + case "완료": + return theme.palette.error.main; + default: + return "defaultColor"; // 기본 색상 + } + }, + }} + /> @@ -469,7 +492,7 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { 수량 - + 단가 @@ -479,7 +502,7 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { 총금액 - + 진행상태 @@ -497,7 +520,7 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { key={index} sx={{ "&:hover": { - backgroundColor: "#f5f5f5", + backgroundColor: "#c7d4e8", }, }} > @@ -541,9 +564,26 @@ const ReceiveModal = ({ onSave, modalUpdateSelectedProducts }) => { - - {product.porderState} - + { + switch (product.porderState) { + case "준비": + return theme.palette.primary.main; + case "진행 중": + return theme.palette.info.main; + case "완료": + return theme.palette.error.main; + default: + return "defaultColor"; // 기본 색상 + } + }, + }} + />