| @@ -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" }, | |||
| @@ -15,6 +15,7 @@ import { | |||
| GridCellParams, | |||
| GridColDef, | |||
| GridEventListener, | |||
| GridPaginationModel, | |||
| GridRowEditStopReasons, | |||
| GridRowId, | |||
| GridRowIdGetter, | |||
| @@ -75,6 +76,7 @@ export interface InputDataGridProps<T, V, E> { | |||
| columns: GridColDef[]; | |||
| validateRow: (newRow: GridRowModel<TableRow<V, E>>) => E; | |||
| needAdd?: boolean; | |||
| needActions?: boolean; | |||
| showRemoveBtn?: boolean; | |||
| addRowDefaultValue?: Partial<V>; | |||
| _setRowModesModel?: Dispatch<SetStateAction<GridRowModesModel>>; | |||
| @@ -89,6 +91,7 @@ export interface SelectionInputDataGridProps<T, V, E> { | |||
| columns: GridColDef[]; | |||
| validateRow: (newRow: GridRowModel<TableRow<V, E>>) => E; | |||
| needAdd?: boolean; | |||
| needActions?: boolean; | |||
| showRemoveBtn?: boolean; | |||
| addRowDefaultValue?: Partial<V>; | |||
| _setRowModesModel?: Dispatch<SetStateAction<GridRowModesModel>>; | |||
| @@ -119,6 +122,7 @@ function InputDataGrid<T, V, E>({ | |||
| columns, | |||
| validateRow, | |||
| needAdd, | |||
| needActions = true, | |||
| showRemoveBtn = true, | |||
| addRowDefaultValue = {}, | |||
| _setRowModesModel = undefined, | |||
| @@ -364,10 +368,11 @@ function InputDataGrid<T, V, E>({ | |||
| 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", | |||
| @@ -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<Props> = ({ 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); | |||
| } | |||
| @@ -98,7 +98,6 @@ const PutAwayForm: React.FC<Props> = ({ itemDetail, warehouse, disabled, setRowM | |||
| setError, | |||
| clearErrors, | |||
| } = useFormContext<PutAwayInput>(); | |||
| 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<Props> = ({ 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<Props> = ({ itemDetail, warehouse, disabled, setRowM | |||
| const columns = useMemo<GridColDef[]>( | |||
| () => [ | |||
| { | |||
| 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<Props> = ({ 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<Props> = ({ 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<Props> = ({ itemDetail, warehouse, disabled, setRowM | |||
| columns={columns} | |||
| validateRow={validation} | |||
| needAdd={false} | |||
| needActions={false} | |||
| showRemoveBtn={false} | |||
| addRowDefaultValue={addRowDefaultValue} | |||
| _setRowModesModel={setRowModesModel} | |||
| @@ -99,6 +99,7 @@ const PoQcStockInModalVer2: React.FC<Props> = ({ | |||
| // Select Printer | |||
| const [selectedPrinter, setSelectedPrinter] = useState(printerCombo[0]); | |||
| const [printQty, setPrintQty] = useState(1); | |||
| const [tabIndex, setTabIndex] = useState(0); | |||
| const handleTabChange = useCallback<NonNullable<TabsProps["onChange"]>>( | |||
| @@ -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} | |||
| > | |||
| <PutAwayForm | |||
| itemDetail={itemDetail} | |||
| warehouse={warehouse!} | |||
| disabled={viewOnly} | |||
| setRowModesModel={setPafRowModesModel} | |||
| setRowSelectionModel={setPafRowSelectionModel} | |||
| /> | |||
| <Grid item xs={12}> | |||
| <PutAwayForm | |||
| itemDetail={itemDetail} | |||
| warehouse={warehouse!} | |||
| disabled={viewOnly} | |||
| setRowModesModel={setPafRowModesModel} | |||
| setRowSelectionModel={setPafRowSelectionModel} | |||
| /> | |||
| </Grid> | |||
| {/* <PutAwayGrid | |||
| itemDetail={itemDetail} | |||
| warehouse={warehouse!} | |||
| disabled={viewOnly} | |||
| /> */} | |||
| <Stack direction="row" justifyContent="flex-end" gap={1}> | |||
| <Autocomplete | |||
| disableClearable | |||
| options={printerCombo} | |||
| defaultValue={selectedPrinter} | |||
| onChange={(event, value) => { | |||
| setSelectedPrinter(value) | |||
| }} | |||
| renderInput={(params) => ( | |||
| <TextField | |||
| {...params} | |||
| variant="outlined" | |||
| label={t("Printer")} | |||
| sx={{ width: 300}} | |||
| /> | |||
| )} | |||
| /> | |||
| <Button | |||
| id="printButton" | |||
| type="button" | |||
| variant="contained" | |||
| color="primary" | |||
| sx={{ mt: 1 }} | |||
| onClick={handlePrint} | |||
| disabled={isPrinting || printerCombo.length <= 0 || pafSubmitDisable} | |||
| > | |||
| {isPrinting ? t("Printing") : t("print")} | |||
| </Button> | |||
| {/* <Button | |||
| id="putawaySubmit" | |||
| type="submit" | |||
| variant="contained" | |||
| color="primary" | |||
| sx={{ mt: 1 }} | |||
| onClick={formProps.handleSubmit(onSubmitPutaway)} | |||
| disabled={pafSubmitDisable} | |||
| > | |||
| {t("confirm putaway")} | |||
| </Button> */} | |||
| </Stack> | |||
| <Grid item xs={12}> | |||
| <Stack direction="row" justifyContent="flex-end" gap={1}> | |||
| <Autocomplete | |||
| disableClearable | |||
| options={printerCombo} | |||
| defaultValue={selectedPrinter} | |||
| onChange={(event, value) => { | |||
| setSelectedPrinter(value) | |||
| }} | |||
| renderInput={(params) => ( | |||
| <TextField | |||
| {...params} | |||
| variant="outlined" | |||
| label={t("Printer")} | |||
| sx={{ width: 300}} | |||
| /> | |||
| )} | |||
| /> | |||
| <TextField | |||
| variant="outlined" | |||
| label={t("Print Qty")} | |||
| defaultValue={printQty} | |||
| onChange={(event) => { | |||
| event.target.value = event.target.value.replace(/[^0-9]/g, '') | |||
| setPrintQty(Number(event.target.value)) | |||
| }} | |||
| sx={{ width: 300}} | |||
| /> | |||
| <Button | |||
| id="printButton" | |||
| type="button" | |||
| variant="contained" | |||
| color="primary" | |||
| sx={{ mt: 1 }} | |||
| onClick={handlePrint} | |||
| disabled={isPrinting || printerCombo.length <= 0 || pafSubmitDisable} | |||
| > | |||
| {isPrinting ? t("Printing") : t("print")} | |||
| </Button> | |||
| {/* <Button | |||
| id="putawaySubmit" | |||
| type="submit" | |||
| variant="contained" | |||
| color="primary" | |||
| sx={{ mt: 1 }} | |||
| onClick={formProps.handleSubmit(onSubmitPutaway)} | |||
| disabled={pafSubmitDisable} | |||
| > | |||
| {t("confirm putaway")} | |||
| </Button> */} | |||
| </Stack> | |||
| </Grid> | |||
| </Grid> | |||
| </Box> | |||
| } | |||
| @@ -148,5 +148,6 @@ | |||
| "QC Record": "品檢記錄", | |||
| "value must be integer": "請輸入整數", | |||
| "dn and qc info": "來貨及品檢詳情", | |||
| "Qc Decision": "品檢詳情" | |||
| "Qc Decision": "品檢詳情", | |||
| "Print Qty": "列印數量" | |||
| } | |||