|
@@ -1,5 +1,5 @@ |
|
|
// material-ui |
|
|
// material-ui |
|
|
import * as React from 'react'; |
|
|
|
|
|
|
|
|
import { useState, useEffect, useMemo } from 'react'; |
|
|
import { |
|
|
import { |
|
|
Grid, |
|
|
Grid, |
|
|
Typography, |
|
|
Typography, |
|
@@ -14,27 +14,33 @@ import * as StatusUtils from "utils/statusUtils/DnStatus"; |
|
|
import { useNavigate } from "react-router-dom"; |
|
|
import { useNavigate } from "react-router-dom"; |
|
|
import { FiDataGrid } from "components/FiDataGrid"; |
|
|
import { FiDataGrid } from "components/FiDataGrid"; |
|
|
import { notifyDownloadSuccess } from 'utils/CommonFunction'; |
|
|
import { notifyDownloadSuccess } from 'utils/CommonFunction'; |
|
|
|
|
|
|
|
|
import * as UrlUtils from "utils/ApiPathConst"; |
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
DEMAND_NOTE_EXPORT, |
|
|
|
|
|
DEMAND_NOTE_SEND, |
|
|
|
|
|
DEMAND_NOTE_ATTACH, |
|
|
|
|
|
DEMAND_NOTE_MARK_PAID, |
|
|
|
|
|
DEMAND_NOTE_LIST_ALL |
|
|
|
|
|
} from "utils/ApiPathConst"; |
|
|
import * as HttpUtils from "utils/HttpUtils"; |
|
|
import * as HttpUtils from "utils/HttpUtils"; |
|
|
import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst"; |
|
|
|
|
|
import {ThemeProvider} from "@emotion/react"; |
|
|
|
|
|
|
|
|
import { PNSPS_BUTTON_THEME } from "themes/buttonConst"; |
|
|
|
|
|
import { ThemeProvider } from "@emotion/react"; |
|
|
|
|
|
import { isGrantedAny } from "auth/utils"; |
|
|
// ==============================|| EVENT TABLE ||============================== // |
|
|
// ==============================|| EVENT TABLE ||============================== // |
|
|
|
|
|
|
|
|
export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
|
|
|
|
|
|
const [isConfirmPopUp, setConfirmPopUp] = React.useState(false); |
|
|
|
|
|
const [isSendPopUp, setSendPopUp] = React.useState(false); |
|
|
|
|
|
const [isErrorPopUp, setIsErrorPopUp] = React.useState(false); |
|
|
|
|
|
const [selectonWarning, setSelectonWarning] = React.useState(false); |
|
|
|
|
|
const [wait, setWait] = React.useState(false); |
|
|
|
|
|
|
|
|
const [isConfirmPopUp, setConfirmPopUp] = useState(false); |
|
|
|
|
|
const [isSendPopUp, setSendPopUp] = useState(false); |
|
|
|
|
|
const [isErrorPopUp, setIsErrorPopUp] = useState(false); |
|
|
|
|
|
const [selectonWarning, setSelectonWarning] = useState(false); |
|
|
|
|
|
const [wait, setWait] = useState(false); |
|
|
|
|
|
|
|
|
const [rows, setRows] = React.useState([]); |
|
|
|
|
|
const [_searchCriteria, set_searchCriteria] = React.useState(searchCriteria); |
|
|
|
|
|
const [selectedRowItems, setSelectedRowItems] = React.useState([]); |
|
|
|
|
|
|
|
|
const [rows, setRows] = useState([]); |
|
|
|
|
|
const [_searchCriteria, set_searchCriteria] = useState(searchCriteria); |
|
|
|
|
|
const [selectedRowItems, setSelectedRowItems] = useState([]); |
|
|
const navigate = useNavigate() |
|
|
const navigate = useNavigate() |
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
set_searchCriteria(searchCriteria); |
|
|
set_searchCriteria(searchCriteria); |
|
|
}, [searchCriteria]); |
|
|
}, [searchCriteria]); |
|
|
|
|
|
|
|
@@ -42,7 +48,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
navigate('/paymentPage/demandNote/details/' + params.id); |
|
|
navigate('/paymentPage/demandNote/details/' + params.id); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const findReadyToSend=()=>{ |
|
|
|
|
|
|
|
|
const findReadyToSend = () => { |
|
|
const temp = { |
|
|
const temp = { |
|
|
readySend: true |
|
|
readySend: true |
|
|
}; |
|
|
}; |
|
@@ -66,7 +72,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
} |
|
|
} |
|
|
HttpUtils.fileDownload({ |
|
|
HttpUtils.fileDownload({ |
|
|
method: 'post', |
|
|
method: 'post', |
|
|
url: UrlUtils.DEMAND_NOTE_EXPORT, |
|
|
|
|
|
|
|
|
url: DEMAND_NOTE_EXPORT, |
|
|
params: { |
|
|
params: { |
|
|
dnIdList: idList |
|
|
dnIdList: idList |
|
|
}, |
|
|
}, |
|
@@ -98,7 +104,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
idList.push(datas[i].id); |
|
|
idList.push(datas[i].id); |
|
|
} |
|
|
} |
|
|
HttpUtils.post({ |
|
|
HttpUtils.post({ |
|
|
url: UrlUtils.DEMAND_NOTE_SEND, |
|
|
|
|
|
|
|
|
url: DEMAND_NOTE_SEND, |
|
|
params: { |
|
|
params: { |
|
|
dnIdList: idList |
|
|
dnIdList: idList |
|
|
}, |
|
|
}, |
|
@@ -121,7 +127,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
} |
|
|
} |
|
|
let file = event.target.files[0]; |
|
|
let file = event.target.files[0]; |
|
|
HttpUtils.postWithFiles({ |
|
|
HttpUtils.postWithFiles({ |
|
|
url: UrlUtils.DEMAND_NOTE_ATTACH, |
|
|
|
|
|
|
|
|
url: DEMAND_NOTE_ATTACH, |
|
|
params: { |
|
|
params: { |
|
|
dnMap: dnMap |
|
|
dnMap: dnMap |
|
|
}, |
|
|
}, |
|
@@ -148,7 +154,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
idList.push(datas[i].id); |
|
|
idList.push(datas[i].id); |
|
|
} |
|
|
} |
|
|
HttpUtils.post({ |
|
|
HttpUtils.post({ |
|
|
url: UrlUtils.DEMAND_NOTE_MARK_PAID, |
|
|
|
|
|
|
|
|
url: DEMAND_NOTE_MARK_PAID, |
|
|
params: { |
|
|
params: { |
|
|
dnIdList: idList |
|
|
dnIdList: idList |
|
|
}, |
|
|
}, |
|
@@ -173,9 +179,9 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
field: 'contactPerson', |
|
|
field: 'contactPerson', |
|
|
headerName: 'Organisation', |
|
|
headerName: 'Organisation', |
|
|
minWidth: 300, |
|
|
minWidth: 300, |
|
|
flex:1, |
|
|
|
|
|
|
|
|
flex: 1, |
|
|
renderCell: (params) => { |
|
|
renderCell: (params) => { |
|
|
let company = params.row.enCompanyName != null?params.row.enCompanyName: params.row.chCompanyName; |
|
|
|
|
|
|
|
|
let company = params.row.enCompanyName != null ? params.row.enCompanyName : params.row.chCompanyName; |
|
|
company = company != null ? company : ""; |
|
|
company = company != null ? company : ""; |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@@ -224,7 +230,7 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
headerName: 'DN No.', |
|
|
headerName: 'DN No.', |
|
|
width: 250, |
|
|
width: 250, |
|
|
renderCell: (params) => { |
|
|
renderCell: (params) => { |
|
|
return <Button sx={{fontSize: '8px'}} onClick={handleDnClick(params)}><u>{params.row.dnNo}</u></Button>; |
|
|
|
|
|
|
|
|
return <Button sx={{ fontSize: '8px' }} onClick={handleDnClick(params)}><u>{params.row.dnNo}</u></Button>; |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
@@ -235,8 +241,8 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
renderCell: (params) => { |
|
|
renderCell: (params) => { |
|
|
return (<table> |
|
|
return (<table> |
|
|
<tr><td>Issue:</td><td>{DateUtils.dateStr(params?.row.issueDate)}</td></tr> |
|
|
<tr><td>Issue:</td><td>{DateUtils.dateStr(params?.row.issueDate)}</td></tr> |
|
|
<tr><td>Due:</td><td>{params?.value? DateUtils.dateStr(params?.value):"--"}</td></tr> |
|
|
|
|
|
<tr><td>Sent:</td><td>{params.row.sentDate ? <> {DateUtils.datetimeStr(params.row.sentDate)} - {params.row.sentBy} </>: <> To be sent</>}</td></tr> |
|
|
|
|
|
|
|
|
<tr><td>Due:</td><td>{params?.value ? DateUtils.dateStr(params?.value) : "--"}</td></tr> |
|
|
|
|
|
<tr><td>Sent:</td><td>{params.row.sentDate ? <> {DateUtils.datetimeStr(params.row.sentDate)} - {params.row.sentBy} </> : <> To be sent</>}</td></tr> |
|
|
</table>); |
|
|
</table>); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@@ -263,74 +269,78 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div style={{ width: '100%' }}> |
|
|
<div style={{ width: '100%' }}> |
|
|
<Grid container maxWidth justifyContent="flex-start"> |
|
|
|
|
|
<ThemeProvider theme={PNSPS_BUTTON_THEME}> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<input |
|
|
|
|
|
id="uploadFileBtn" |
|
|
|
|
|
name="file" |
|
|
|
|
|
type="file" |
|
|
|
|
|
accept=".pdf" |
|
|
|
|
|
style={{ display: 'none' }} |
|
|
|
|
|
onChange={(event) => { |
|
|
|
|
|
const datas = rows?.filter((row) => |
|
|
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
|
|
); |
|
|
|
|
|
if (datas.length == 0) { |
|
|
|
|
|
setSelectonWarning(true); |
|
|
|
|
|
document.getElementById("uploadFileBtn").value = ""; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
doUploadFile(event) |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
<label htmlFor="uploadFileBtn"> |
|
|
|
|
|
<Button |
|
|
|
|
|
component="span" |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
> |
|
|
|
|
|
Attach DN |
|
|
|
|
|
</Button> |
|
|
|
|
|
</label> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={findReadyToSend} |
|
|
|
|
|
> |
|
|
|
|
|
Ready Send |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => setSendPopUp(true)} |
|
|
|
|
|
> |
|
|
|
|
|
Send DN |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
{isGrantedAny(["MAINTAIN_DEMANDNOTE"]) ? |
|
|
|
|
|
<Grid container maxWidth justifyContent="flex-start"> |
|
|
|
|
|
<ThemeProvider theme={PNSPS_BUTTON_THEME}> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<input |
|
|
|
|
|
id="uploadFileBtn" |
|
|
|
|
|
name="file" |
|
|
|
|
|
type="file" |
|
|
|
|
|
accept=".pdf" |
|
|
|
|
|
style={{ display: 'none' }} |
|
|
|
|
|
onChange={(event) => { |
|
|
|
|
|
const datas = rows?.filter((row) => |
|
|
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
|
|
); |
|
|
|
|
|
if (datas.length == 0) { |
|
|
|
|
|
setSelectonWarning(true); |
|
|
|
|
|
document.getElementById("uploadFileBtn").value = ""; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
doUploadFile(event) |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
<label htmlFor="uploadFileBtn"> |
|
|
|
|
|
<Button |
|
|
|
|
|
component="span" |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
> |
|
|
|
|
|
Attach DN |
|
|
|
|
|
</Button> |
|
|
|
|
|
</label> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={findReadyToSend} |
|
|
|
|
|
> |
|
|
|
|
|
Ready Send |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => setSendPopUp(true)} |
|
|
|
|
|
> |
|
|
|
|
|
Send DN |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => exportXml()}> |
|
|
|
|
|
Export GDNS |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => exportXml()}> |
|
|
|
|
|
Export GDNS |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => setConfirmPopUp(true)} |
|
|
|
|
|
> |
|
|
|
|
|
Mark as Paid |
|
|
|
|
|
</Button> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
|
|
<Button |
|
|
|
|
|
variant="contained" |
|
|
|
|
|
onClick={() => setConfirmPopUp(true)} |
|
|
|
|
|
> |
|
|
|
|
|
Mark as Paid |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
</ThemeProvider> |
|
|
</Grid> |
|
|
</Grid> |
|
|
</ThemeProvider> |
|
|
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
: <></> |
|
|
|
|
|
} |
|
|
<Box sx={{ backgroundColor: "#fff", ml: 2 }} width="98%"> |
|
|
<Box sx={{ backgroundColor: "#fff", ml: 2 }} width="98%"> |
|
|
<FiDataGrid |
|
|
<FiDataGrid |
|
|
checkboxSelection |
|
|
|
|
|
|
|
|
checkboxSelection = {isGrantedAny(["MAINTAIN_DEMANDNOTE"])} |
|
|
disableRowSelectionOnClick |
|
|
disableRowSelectionOnClick |
|
|
onRowSelectionModelChange={(newSelection) => { |
|
|
onRowSelectionModelChange={(newSelection) => { |
|
|
setSelectedRowItems(newSelection); |
|
|
setSelectedRowItems(newSelection); |
|
@@ -339,8 +349,8 @@ export default function SearchDemandNote({ searchCriteria, applySearch }) { |
|
|
customPageSize={100} |
|
|
customPageSize={100} |
|
|
getRowHeight={() => 'auto'} |
|
|
getRowHeight={() => 'auto'} |
|
|
onRowDoubleClick={handleRowDoubleClick} |
|
|
onRowDoubleClick={handleRowDoubleClick} |
|
|
doLoad={React.useMemo(() => ({ |
|
|
|
|
|
url: UrlUtils.DEMAND_NOTE_LIST_ALL, |
|
|
|
|
|
|
|
|
doLoad={useMemo(() => ({ |
|
|
|
|
|
url: DEMAND_NOTE_LIST_ALL, |
|
|
params: _searchCriteria, |
|
|
params: _searchCriteria, |
|
|
callback: function (responseData) { |
|
|
callback: function (responseData) { |
|
|
setRows(responseData?.records); |
|
|
setRows(responseData?.records); |
|
|