|
|
@@ -7,8 +7,11 @@ import { |
|
|
|
Box, |
|
|
|
Dialog, DialogTitle, DialogContent, DialogActions, |
|
|
|
} from '@mui/material'; |
|
|
|
import DownloadIcon from '@mui/icons-material/Download'; |
|
|
|
import * as DateUtils from "utils/DateUtils"; |
|
|
|
import * as FormatUtils from "utils/FormatUtils"; |
|
|
|
import * as StatusUtils from "utils/statusUtils/DnStatus"; |
|
|
|
import * as PublicNoteStatusUtils from "utils/statusUtils/PublicNoteStatusUtils"; |
|
|
|
import { useNavigate } from "react-router-dom"; |
|
|
|
import { FiDataGrid } from "components/FiDataGrid"; |
|
|
|
import { notifyDownloadSuccess } from 'utils/CommonFunction'; |
|
|
@@ -17,7 +20,7 @@ import * as UrlUtils from "utils/ApiPathConst"; |
|
|
|
import * as HttpUtils from "utils/HttpUtils"; |
|
|
|
// ==============================|| EVENT TABLE ||============================== // |
|
|
|
|
|
|
|
export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
export default function SearchDemandNote({ recordList, reloadFun, applySearch }) { |
|
|
|
|
|
|
|
const [isConfirmPopUp, setConfirmPopUp] = React.useState(false); |
|
|
|
const [isSendPopUp, setSendPopUp] = React.useState(false); |
|
|
@@ -37,15 +40,22 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
navigate('/paymentPage/demandNote/details/' + params.id); |
|
|
|
}; |
|
|
|
|
|
|
|
const findReadyToSend=()=>{ |
|
|
|
const temp = { |
|
|
|
status: 'pending', |
|
|
|
}; |
|
|
|
applySearch(temp); |
|
|
|
} |
|
|
|
|
|
|
|
const exportXml = () => { |
|
|
|
let idList = []; |
|
|
|
const datas = rows?.filter((row) => |
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
); |
|
|
|
if(datas?.length<1){ |
|
|
|
if (datas?.length < 1) { |
|
|
|
setSelectonWarning(true); |
|
|
|
return; |
|
|
|
}else if (datas?.length >= 100) { |
|
|
|
} else if (datas?.length >= 100) { |
|
|
|
setIsErrorPopUp(true); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -53,10 +63,10 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
idList.push(datas[i].id); |
|
|
|
} |
|
|
|
HttpUtils.fileDownload({ |
|
|
|
method:'post', |
|
|
|
method: 'post', |
|
|
|
url: UrlUtils.DEMAND_NOTE_EXPORT, |
|
|
|
params: { |
|
|
|
dnIdList:idList |
|
|
|
dnIdList: idList |
|
|
|
}, |
|
|
|
onSuccess: function () { |
|
|
|
notifyDownloadSuccess(); |
|
|
@@ -78,7 +88,7 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
const datas = rows?.filter((row) => |
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
); |
|
|
|
if(datas?.length<1){ |
|
|
|
if (datas?.length < 1) { |
|
|
|
setSelectonWarning(true); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -104,16 +114,16 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
); |
|
|
|
for (var i = 0; i < datas?.length; i++) { |
|
|
|
let dnNo = datas[i].dnNo.replaceAll("-",""); |
|
|
|
let dnNo = datas[i].dnNo.replaceAll("-", ""); |
|
|
|
dnMap[dnNo] = datas[i].id |
|
|
|
} |
|
|
|
let file = event.target.files[0]; |
|
|
|
HttpUtils.postWithFiles({ |
|
|
|
url:UrlUtils.DEMAND_NOTE_ATTACH, |
|
|
|
params:{ |
|
|
|
dnMap:dnMap |
|
|
|
url: UrlUtils.DEMAND_NOTE_ATTACH, |
|
|
|
params: { |
|
|
|
dnMap: dnMap |
|
|
|
}, |
|
|
|
files:[file], |
|
|
|
files: [file], |
|
|
|
onSuccess() { |
|
|
|
setWait(false); |
|
|
|
if (reloadFun) reloadFun(); |
|
|
@@ -128,7 +138,7 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
const datas = rows?.filter((row) => |
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
); |
|
|
|
if(datas?.length<1){ |
|
|
|
if (datas?.length < 1) { |
|
|
|
setSelectonWarning(true); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -151,18 +161,10 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
} |
|
|
|
|
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
field: 'dnNo', |
|
|
|
headerName: 'DN No.', |
|
|
|
width: 200, |
|
|
|
renderCell: (params) => { |
|
|
|
return <Button onClick={handleDnClick(params)}><u>{params.row.dnNo}</u></Button>; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'appNo', |
|
|
|
headerName: 'App No.', |
|
|
|
width: 150, |
|
|
|
width: 120, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 'contactPerson', |
|
|
@@ -170,7 +172,8 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
headerName: 'Client', |
|
|
|
width: 300, |
|
|
|
renderCell: (params) => { |
|
|
|
let company = params.row.enCompanyName != null ? " (" + (params.row.enCompanyName) + ")" : ""; |
|
|
|
let company = params.row.enCompanyName != null ? params.row.enCompanyName : params.row.chCompanyName; |
|
|
|
company = company != null ? " (" + (company) + ")" : ""; |
|
|
|
|
|
|
|
let phone = JSON.parse(params.row.contactTelNo); |
|
|
|
let faxNo = JSON.parse(params.row.contactFaxNo); |
|
|
@@ -193,38 +196,76 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 'issueDate', |
|
|
|
field: 'issueDate', |
|
|
|
headerName: 'Submit Date', |
|
|
|
width: 175, |
|
|
|
field: 'cm', |
|
|
|
headerName: 'Length(cm)', |
|
|
|
width: 100, |
|
|
|
renderCell: (params) => { |
|
|
|
return (<> |
|
|
|
{params?.value + "cm"}<br /> |
|
|
|
{params.row.column} |
|
|
|
</>); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'amount', |
|
|
|
headerName: 'Amount($)', |
|
|
|
width: 100, |
|
|
|
valueGetter: (params) => { |
|
|
|
return DateUtils.dateStr(params?.value); |
|
|
|
return FormatUtils.currencyFormat(params?.value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'status', |
|
|
|
headerName: 'Status', |
|
|
|
width: 175, |
|
|
|
field: 'dnNo', |
|
|
|
headerName: 'DN No.', |
|
|
|
width: 200, |
|
|
|
renderCell: (params) => { |
|
|
|
return [StatusUtils.getStatus_Eng(params)] |
|
|
|
return <Button onClick={handleDnClick(params)}><u>{params.row.dnNo}</u></Button>; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 'issueDate', |
|
|
|
field: 'issueDate', |
|
|
|
headerName: 'DN Issue/Due Date', |
|
|
|
width: 175, |
|
|
|
valueGetter: (params) => { |
|
|
|
return DateUtils.dateStr(params?.value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'sentDate', |
|
|
|
headerName: 'DN Sent Date', |
|
|
|
flex: 1, |
|
|
|
width: 175, |
|
|
|
valueGetter: (params) => { |
|
|
|
return params?.value ? DateUtils.datetimeStr(params?.value) + " - " + params.row.sentBy : ""; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'filename', |
|
|
|
headerName: 'DN File', |
|
|
|
flex: 1, |
|
|
|
//headerName: 'DN File', |
|
|
|
renderHeader: () => ( |
|
|
|
<><DownloadIcon />DN File</> |
|
|
|
), |
|
|
|
width: 250, |
|
|
|
renderCell: (params) => { |
|
|
|
return <Button onClick={onDownloadClick(params)}><u>{params.row.filename}</u></Button>; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'appStatus', |
|
|
|
headerName: 'App Status', |
|
|
|
width: 175, |
|
|
|
renderCell: (params) => { |
|
|
|
return [PublicNoteStatusUtils.getStatusByTextEng(params?.value, true)] |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'status', |
|
|
|
headerName: 'Status', |
|
|
|
width: 175, |
|
|
|
renderCell: (params) => { |
|
|
|
return [StatusUtils.getStatus_Eng(params)] |
|
|
|
}, |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
return ( |
|
|
@@ -241,7 +282,7 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
const datas = rows?.filter((row) => |
|
|
|
selectedRowItems.includes(row.id) |
|
|
|
); |
|
|
|
if(datas.length==0){ |
|
|
|
if (datas.length == 0) { |
|
|
|
setSelectonWarning(true); |
|
|
|
document.getElementById("uploadFileBtn").value = ""; |
|
|
|
return; |
|
|
@@ -259,6 +300,18 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
</Button> |
|
|
|
</label> |
|
|
|
</Grid> |
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
onClick={findReadyToSend} |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}}> |
|
|
|
<Typography variant="h5">Ready Send</Typography> |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
<Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
@@ -276,12 +329,12 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
onClick={()=>exportXml()} |
|
|
|
onClick={() => exportXml()} |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}}> |
|
|
|
<Typography variant="h5">Export</Typography> |
|
|
|
<Typography variant="h5">Export XML</Typography> |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
|
|
|
@@ -317,16 +370,16 @@ export default function SearchDemandNote({ recordList, reloadFun }) { |
|
|
|
/> |
|
|
|
</Box> |
|
|
|
<div> |
|
|
|
<Dialog open={isErrorPopUp} onClose={() => setIsErrorPopUp(false)} > |
|
|
|
<DialogTitle><Typography variant="h3">Action Fail</Typography></DialogTitle> |
|
|
|
<DialogContent style={{ display: 'flex', }}> |
|
|
|
<Typography variant="h4" style={{ padding: '16px' }}>Number of DN record must less than 100.<br/>Please edit search form.</Typography> |
|
|
|
</DialogContent> |
|
|
|
<DialogActions> |
|
|
|
<Button onClick={() => setIsErrorPopUp(false)}><Typography variant="h5">OK</Typography></Button> |
|
|
|
</DialogActions> |
|
|
|
</Dialog> |
|
|
|
</div> |
|
|
|
<Dialog open={isErrorPopUp} onClose={() => setIsErrorPopUp(false)} > |
|
|
|
<DialogTitle><Typography variant="h3">Action Fail</Typography></DialogTitle> |
|
|
|
<DialogContent style={{ display: 'flex', }}> |
|
|
|
<Typography variant="h4" style={{ padding: '16px' }}>Number of DN record must less than 100.<br />Please edit search form.</Typography> |
|
|
|
</DialogContent> |
|
|
|
<DialogActions> |
|
|
|
<Button onClick={() => setIsErrorPopUp(false)}><Typography variant="h5">OK</Typography></Button> |
|
|
|
</DialogActions> |
|
|
|
</Dialog> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<Dialog open={selectonWarning} onClose={() => setSelectonWarning(false)} > |
|
|
|
<DialogTitle><Typography variant="h3">Warning</Typography></DialogTitle> |
|
|
|