diff --git a/src/app/api/mailTemplate/actions.ts b/src/app/api/mailTemplate/actions.ts index 66a78f2..fa85ae3 100644 --- a/src/app/api/mailTemplate/actions.ts +++ b/src/app/api/mailTemplate/actions.ts @@ -4,9 +4,9 @@ import { serverFetchBlob } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; -export const getMailTemplateForStockInLine = cache(async (stockInLineId: number) => { +export const getMailTemplatePdfForStockInLine = cache(async (stockInLineId: number) => { console.log("stockInLineId", stockInLineId) - return serverFetchBlob(`${BASE_API_URL}/mailTemplates/getMailTemplateForStockInLine/${stockInLineId}`, + return serverFetchBlob(`${BASE_API_URL}/mailTemplates/getMailTemplatePdfForStockInLine/${stockInLineId}`, { method: "GET", headers: { "Content-Type": "application/json" }, diff --git a/src/components/InputDataGrid/InputDataGrid.tsx b/src/components/InputDataGrid/InputDataGrid.tsx index 3f5ff68..74179bd 100644 --- a/src/components/InputDataGrid/InputDataGrid.tsx +++ b/src/components/InputDataGrid/InputDataGrid.tsx @@ -15,6 +15,7 @@ import { GridCellParams, GridColDef, GridEventListener, + GridPaginationModel, GridRowEditStopReasons, GridRowId, GridRowIdGetter, @@ -75,6 +76,7 @@ export interface InputDataGridProps { columns: GridColDef[]; validateRow: (newRow: GridRowModel>) => E; needAdd?: boolean; + needActions?: boolean; showRemoveBtn?: boolean; addRowDefaultValue?: Partial; _setRowModesModel?: Dispatch>; @@ -89,6 +91,7 @@ export interface SelectionInputDataGridProps { columns: GridColDef[]; validateRow: (newRow: GridRowModel>) => E; needAdd?: boolean; + needActions?: boolean; showRemoveBtn?: boolean; addRowDefaultValue?: Partial; _setRowModesModel?: Dispatch>; @@ -119,6 +122,7 @@ function InputDataGrid({ columns, validateRow, needAdd, + needActions = true, showRemoveBtn = true, addRowDefaultValue = {}, _setRowModesModel = undefined, @@ -364,10 +368,11 @@ function InputDataGrid({ apiRef={apiRef} rows={rows} // columns={!checkboxSelection ? _columns : columns} - columns={_columns} + columns={needActions ? _columns : columns} editMode="row" - autoHeight + // autoHeight sx={{ + height: "30vh", "--DataGrid-overlayHeight": "100px", ".MuiDataGrid-row .MuiDataGrid-cell.hasError": { border: "1px solid", diff --git a/src/components/PoDetail/PoDetail.tsx b/src/components/PoDetail/PoDetail.tsx index c49eb57..ea3b7d2 100644 --- a/src/components/PoDetail/PoDetail.tsx +++ b/src/components/PoDetail/PoDetail.tsx @@ -78,7 +78,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import { DatePicker, LocalizationProvider, zhHK } from "@mui/x-date-pickers"; import { debounce } from "lodash"; import LoadingComponent from "../General/LoadingComponent"; -import { getMailTemplateForStockInLine } from "@/app/api/mailTemplate/actions"; +import { getMailTemplatePdfForStockInLine } from "@/app/api/mailTemplate/actions"; import { PrinterCombo } from "@/app/api/settings/printer"; import { EscalationCombo } from "@/app/api/user"; //import { useRouter } from "next/navigation"; @@ -340,7 +340,7 @@ const PoDetail: React.FC = ({ po, qc, warehouse, printerCombo }) => { }, [purchaseOrder.id]); const handleMailTemplateForStockInLine = useCallback(async (stockInLineId: number) => { - const response = await getMailTemplateForStockInLine(stockInLineId) + const response = await getMailTemplatePdfForStockInLine(stockInLineId) if (response) { downloadFile(new Uint8Array(response.blobValue), response.filename); } diff --git a/src/components/PoDetail/PutAwayForm.tsx b/src/components/PoDetail/PutAwayForm.tsx index 6e9334f..be9510b 100644 --- a/src/components/PoDetail/PutAwayForm.tsx +++ b/src/components/PoDetail/PutAwayForm.tsx @@ -98,7 +98,6 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM setError, clearErrors, } = useFormContext(); - console.log(itemDetail); // const [recordQty, setRecordQty] = useState(0); const [warehouseId, setWarehouseId] = useState(itemDetail.defaultWarehouseId); const filteredWarehouse = useMemo(() => { @@ -140,14 +139,13 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM value: number; group: string; }; - console.log(singleNewVal); - console.log("onChange"); + // console.log(singleNewVal); + // console.log("onChange"); // setValue("warehouseId", singleNewVal.value); setWarehouseId(singleNewVal.value); }, [], ); - console.log(watch("putAwayLines")) // const accQty = watch("acceptedQty"); // const validateForm = useCallback(() => { // console.log(accQty); @@ -224,11 +222,20 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM const columns = useMemo( () => [ + { + field: "id", + headerName: t(""), + flex: 0.2, + editable: false, + renderCell(params) { + return `${params.api.getRowIndexRelativeToVisibleRows(params.id) + 1}.` + }, + }, { field: "qty", headerName: t("qty"), - flex: 1, - editable: true, + flex: 0.5, + editable: false, // renderCell(params) { // return <>100 // }, @@ -237,7 +244,7 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM field: "warehouse", headerName: t("warehouse"), flex: 1, - editable: true, + editable: false, renderEditCell: (params) => { const index = params.api.getRowIndexRelativeToVisibleRows(params.row.id) // console.log(index) @@ -268,15 +275,15 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM // return <>{filteredWarehouse[0].name} // }, }, - { - field: "printQty", - headerName: t("printQty"), - flex: 1, - editable: true, + // { + // field: "printQty", + // headerName: t("printQty"), + // flex: 1, + // editable: false, // renderCell(params) { // return <>100 // }, - }, + // }, ], []) const validation = useCallback( @@ -491,6 +498,7 @@ const PutAwayForm: React.FC = ({ itemDetail, warehouse, disabled, setRowM columns={columns} validateRow={validation} needAdd={false} + needActions={false} showRemoveBtn={false} addRowDefaultValue={addRowDefaultValue} _setRowModesModel={setRowModesModel} diff --git a/src/components/PoDetail/QcStockInModal.tsx b/src/components/PoDetail/QcStockInModal.tsx index a5ef1d9..e689a4d 100644 --- a/src/components/PoDetail/QcStockInModal.tsx +++ b/src/components/PoDetail/QcStockInModal.tsx @@ -99,6 +99,7 @@ const PoQcStockInModalVer2: React.FC = ({ // Select Printer const [selectedPrinter, setSelectedPrinter] = useState(printerCombo[0]); + const [printQty, setPrintQty] = useState(1); const [tabIndex, setTabIndex] = useState(0); const handleTabChange = useCallback>( @@ -460,7 +461,7 @@ const [qcItems, setQcItems] = useState(dummyQCData) } // console.log(pafRowSelectionModel) const printList = formProps.watch("putAwayLines")?.filter((line) => ((pafRowSelectionModel ?? []).some((model) => model === line.id))) ?? [] - const printQty = printList.reduce((acc, cur) => acc + cur.printQty, 0) + // const printQty = printList.reduce((acc, cur) => acc + cur.printQty, 0) // console.log(printQty) const data: PrintQrCodeForSilRequest = { stockInLineId: itemDetail.id, @@ -474,7 +475,7 @@ const [qcItems, setQcItems] = useState(dummyQCData) } finally { setIsPrinting(() => false) } - }, [itemDetail.id, pafRowSelectionModel]); + }, [itemDetail.id, pafRowSelectionModel, printQty]); const acceptQty = formProps.watch("acceptedQty") @@ -578,59 +579,75 @@ const [qcItems, setQcItems] = useState(dummyQCData) container justifyContent="flex-start" alignItems="flex-start" + spacing={2} > - + + + {/* */} - - { - setSelectedPrinter(value) - }} - renderInput={(params) => ( - - )} - /> - - {/* */} - + + + { + setSelectedPrinter(value) + }} + renderInput={(params) => ( + + )} + /> + { + event.target.value = event.target.value.replace(/[^0-9]/g, '') + + setPrintQty(Number(event.target.value)) + }} + sx={{ width: 300}} + /> + + {/* */} + + } diff --git a/src/i18n/zh/purchaseOrder.json b/src/i18n/zh/purchaseOrder.json index 79b7835..c4ba915 100644 --- a/src/i18n/zh/purchaseOrder.json +++ b/src/i18n/zh/purchaseOrder.json @@ -148,5 +148,6 @@ "QC Record": "品檢記錄", "value must be integer": "請輸入整數", "dn and qc info": "來貨及品檢詳情", - "Qc Decision": "品檢詳情" + "Qc Decision": "品檢詳情", + "Print Qty": "列印數量" }