From 5be3d301aa72ff158d3cd225e2c7dead1259cdcb Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 10 Oct 2023 17:26:01 +0800 Subject: [PATCH] proof --- src/components/FileList.js | 211 +++++++----- src/layout/MainLayout/Header/index.js | 2 +- src/pages/ManageOrgUserPage/index.js | 125 +++---- .../ProofReply_Public/ApplicationDetails.js | 245 +++++++++++++ src/pages/ProofReply_Public/ProofForm.js | 256 ++++++++++++++ .../ProofReply_Public/UploadFileTable.js | 111 ++++++ src/pages/ProofReply_Public/index.js | 122 +++++++ src/pages/ProofSearch_Public/DataGrid.js | 144 ++++++++ src/pages/ProofSearch_Public/SearchForm.js | 322 ++++++++++++++++++ src/pages/ProofSearch_Public/index.js | 127 +++++++ .../UserInformationCard_Individual.js | 2 + src/routes/PublicUserRoutes.js | 10 + src/utils/ApiPathConst.js | 4 +- src/utils/DateUtils.js | 8 + 14 files changed, 1541 insertions(+), 148 deletions(-) create mode 100644 src/pages/ProofReply_Public/ApplicationDetails.js create mode 100644 src/pages/ProofReply_Public/ProofForm.js create mode 100644 src/pages/ProofReply_Public/UploadFileTable.js create mode 100644 src/pages/ProofReply_Public/index.js create mode 100644 src/pages/ProofSearch_Public/DataGrid.js create mode 100644 src/pages/ProofSearch_Public/SearchForm.js create mode 100644 src/pages/ProofSearch_Public/index.js diff --git a/src/components/FileList.js b/src/components/FileList.js index 8aa648c..b44d711 100644 --- a/src/components/FileList.js +++ b/src/components/FileList.js @@ -1,16 +1,16 @@ // material-ui import * as React from 'react'; import { - DataGrid, GridActionsCellItem, } from "@mui/x-data-grid"; import * as Icon from '../utils/IconUtils'; import * as HttpUtils from "../utils/HttpUtils" import * as UrlUtils from "../utils/ApiPathConst" import * as DateUtils from "../utils/DateUtils" +import { FiDataGrid } from './FiDataGrid'; // ==============================|| EVENT TABLE ||============================== // -export default function FileList({refType, refId, allowDelete, sx}) { +export default function FileList({ refType, refId, allowDelete, sx, dateHideable, ...props }) { const [rows, setRows] = React.useState([]); const [rowModesModel] = React.useState({}); @@ -22,12 +22,12 @@ export default function FileList({refType, refId, allowDelete, sx}) { HttpUtils.get( { url: UrlUtils.GET_FILE_DELETE, - params:{ + params: { fileId: fileId, - skey:skey, + skey: skey, filename: filename }, - onSuccess: function(){ + onSuccess: function () { loadData(); } } @@ -36,84 +36,124 @@ export default function FileList({refType, refId, allowDelete, sx}) { const onDownloadClick = (fileId, skey, filename) => () => { HttpUtils.fileDownload({ - fileId:fileId, - skey:skey, - filename:filename, + fileId: fileId, + skey: skey, + filename: filename, }); }; - const loadData = ()=>{ - HttpUtils.post( - { - url: UrlUtils.POST_FILE_LIST, - params:{ - refType: refType, - refId: refId, - }, - onSuccess: function(responseData){ - setRows(responseData.records); + const loadData = () => { + + HttpUtils.post( + { + url: UrlUtils.POST_FILE_LIST, + params: { + refType: refType, + refId:refId, + }, + onSuccess: function (responseData) { + setRows(responseData.records); + } } - } - ); + ); }; - const convertToStr=(bytes,decimals)=>{ - if(bytes == 0) return '0 Bytes'; + const convertToStr = (bytes, decimals) => { + if (bytes == 0) return '0 Bytes'; var dm = decimals || 2, sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - let i = 0; - i = Math.floor(Math.log(bytes) / Math.log(1024)); + let i = 0; + i = Math.floor(Math.log(bytes) / Math.log(1024)); return parseFloat((bytes / Math.pow(1024, i)).toFixed(dm)) + ' ' + sizes[i]; } - const columns = [ - { - id: 'created', - field: 'created', - headerName: 'created', - flex: 1, - valueGetter:(params)=>{ - return DateUtils.datetimeStr(params.value); - } - }, - { - field: 'actions', - type: 'actions', - headerName: '', - width: 50, - cellClassName: 'actions', - getActions: (params) => { - return [ - } - label="Download" - className="textPrimary" - onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} - color="primary" - />] + const columns = (dateHideable ? + [ + { + field: 'actions', + type: 'actions', + headerName: '', + width: 50, + cellClassName: 'actions', + getActions: (params) => { + return [ + } + label="Download" + className="textPrimary" + onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} + color="primary" + />] + }, }, - },{ - id: 'filename', - field: 'filename', - headerName: 'filename', - flex: 3, - }, - { - id: 'filesize', - field: 'filesize', - headerName: 'filesize', - flex: 1, - valueGetter:(params)=>{ - return convertToStr(params.value); + { + id: 'filename', + field: 'filename', + headerName: 'filename', + flex: 3, + }, + { + id: 'filesize', + field: 'filesize', + headerName: 'filesize', + flex: 1, + valueGetter: (params) => { + return convertToStr(params.value); + } } - }, - ]; + ] + : + [ + { + id: 'created', + field: 'created', + headerName: 'created', + flex: 1, + valueGetter: (params) => { + return DateUtils.datetimeStr(params.value); + } + }, + { + field: 'actions', + type: 'actions', + headerName: '', + width: 50, + cellClassName: 'actions', + getActions: (params) => { + return [ + } + label="Download" + className="textPrimary" + onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} + color="primary" + />] + }, + }, + { + id: 'filename', + field: 'filename', + headerName: 'filename', + flex: 3, + }, + { + id: 'filesize', + field: 'filesize', + headerName: 'filesize', + flex: 1, + valueGetter: (params) => { + return convertToStr(params.value); + } + }, + ] + ); + - - if(allowDelete){ + if (allowDelete) { columns.push({ field: 'actions', type: 'actions', @@ -124,7 +164,7 @@ export default function FileList({refType, refId, allowDelete, sx}) { return [ } + icon={} label="Delete" className="textPrimary" onClick={onDeleteClick(params.id, params.row.skey, params.row.filename)} @@ -135,22 +175,23 @@ export default function FileList({refType, refId, allowDelete, sx}) { } return ( -
- -
+ //
+ + //
); } diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index f97636d..2fbc26f 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -118,7 +118,7 @@ function Header(props) { 我的公共啟事
  • - 校對記錄 + 校對記錄
  • 付款記錄 diff --git a/src/pages/ManageOrgUserPage/index.js b/src/pages/ManageOrgUserPage/index.js index 4a47da4..698ddfb 100644 --- a/src/pages/ManageOrgUserPage/index.js +++ b/src/pages/ManageOrgUserPage/index.js @@ -1,13 +1,11 @@ // material-ui -import { - DataGrid, - //GridActionsCellItem -} from "@mui/x-data-grid"; +import {FiDataGrid} from "components/FiDataGrid"; import { - Typography, Button, Grid -}from '@mui/material'; + Typography, Button, Grid, Stack +} from '@mui/material'; +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import Checkbox from '@mui/material/Checkbox'; import MainCard from "../../components/MainCard"; @@ -17,6 +15,15 @@ import * as HttpUtils from "../../utils/HttpUtils"; import * as UrlUtils from "../../utils/ApiPathConst"; import * as DateUtils from "../../utils/DateUtils"; +const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: '100%', + height: '100%', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' +} // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -24,65 +31,64 @@ import * as DateUtils from "../../utils/DateUtils"; const ManageOrgUserPage = () => { const [rows, setRows] = React.useState([]); - const [rowModesModel] = React.useState({}); React.useEffect(() => { loadData(); }, []); - function loadData(){ + function loadData() { HttpUtils.get( { url: UrlUtils.GET_PUBLIC_ORG_USER_LIST, - onSuccess: function(responseData){ + onSuccess: function (responseData) { setRows(responseData); } } ); } - function onActiveClick(params){ + function onActiveClick(params) { HttpUtils.get({ - url: UrlUtils.GET_USER_UNLOCK+"/"+params.row.id, - onSuccess:()=>{ - loadData(); + url: UrlUtils.GET_USER_UNLOCK + "/" + params.row.id, + onSuccess: () => { + loadData(); } }); } - function getHeader(headerStr){ + function getHeader(headerStr) { return {headerStr}; } - function getStatus(params){ - if(params.row.locked){ + function getStatus(params) { + if (params.row.locked) { return ( <> - {getStatusTag({color:"#525150", text: "鎖定"})} - + {getStatusTag({ color: "#525150", text: "鎖定" })} + - ) - }else if(!params.row.verifiedBy){ - return getStatusTag({color:"#fca503", text: "待批核"}) - }else if(params.row.status == "active"){ - return getStatusTag({color:"#73AD21", text: "生效中"}) + ) + } else if (!params.row.verifiedBy) { + return getStatusTag({ color: "#fca503", text: "待批核" }) + } else if (params.row.status == "active") { + return getStatusTag({ color: "#73AD21", text: "生效中" }) } - return getStatusTag({text: params.row.status}) + return getStatusTag({ text: params.row.status }) } - function getStatusTag({color="#000", textColor="#FFF",text=""}){ - return ( -
    {text}
    + function getStatusTag({ color = "#000", textColor = "#FFF", text = "" }) { + return ( +
    {text}
    ) } - const setPrimaryUser=(params)=>{ + const setPrimaryUser = (params) => { HttpUtils.get( { - url: (!params.row.primaryUser?UrlUtils.GET_SET_PRIMARY_USER:UrlUtils.GET_SET_UN_PRIMARY_USER)+"/"+params.row.id, - onSuccess:function(){ + url: (!params.row.primaryUser ? UrlUtils.GET_SET_PRIMARY_USER : UrlUtils.GET_SET_UN_PRIMARY_USER) + "/" + params.row.id, + onSuccess: function () { loadData(); } } @@ -97,23 +103,23 @@ const ManageOrgUserPage = () => { field: 'username', headerName: getHeader('登錄名稱'), flex: 1, - + }, { id: 'contactPerson', field: 'contactPerson', headerName: getHeader('用戶名稱'), flex: 1, - + }, { id: 'contactTel', field: 'contactTel', headerName: getHeader('聯絡電話'), flex: 1, - valueGetter:(params)=>{ + valueGetter: (params) => { let contactTel = JSON.parse(params.value) - return contactTel?.countryCode+" "+contactTel?.phoneNumber; + return contactTel?.countryCode + " " + contactTel?.phoneNumber; } }, { @@ -127,7 +133,7 @@ const ManageOrgUserPage = () => { field: 'lastLogin', headerName: getHeader('最後登入日期'), flex: 1, - valueGetter:(params)=>{ + valueGetter: (params) => { return DateUtils.datetimeStr(params.value); } }, @@ -136,7 +142,7 @@ const ManageOrgUserPage = () => { field: 'lastApply', headerName: getHeader('最後提交申請日期'), flex: 1, - valueGetter:()=>{ + valueGetter: () => { return "--"; } }, @@ -159,9 +165,9 @@ const ManageOrgUserPage = () => { renderCell: (params) => { console.log(params); return ( - {setPrimaryUser(params)}} - checked={params.row.primaryUser} + { setPrimaryUser(params) }} + checked={params.row.primaryUser} /> ); }, @@ -169,30 +175,27 @@ const ManageOrgUserPage = () => { ]; return ( - - - Setting - - - 公司/機構用戶記錄 - + + + +
    + + 公司/機構用戶記錄 + +
    - - - + + +
    ); diff --git a/src/pages/ProofReply_Public/ApplicationDetails.js b/src/pages/ProofReply_Public/ApplicationDetails.js new file mode 100644 index 0000000..fed44a5 --- /dev/null +++ b/src/pages/ProofReply_Public/ApplicationDetails.js @@ -0,0 +1,245 @@ +// material-ui +import { + FormControl, + Grid, + Typography, + FormLabel, + TextField, + Stack +} from '@mui/material'; + +import { useFormik } from 'formik'; +import * as React from "react"; +import * as DateUtils from "utils/DateUtils" +import { useParams } from "react-router-dom"; +import Loadable from 'components/Loadable'; +const MainCard = Loadable(React.lazy(() => import('components/MainCard'))); +import * as StatusUtils from "../PublicNotice/ListPanel/PublicNoteStatusUtils"; +import FileList from "components/FileList" +// ==============================|| DASHBOARD - DEFAULT ||============================== // +const ApplicationDetailCard = ({ formData,}) => { + + const params = useParams(); + + const [data, setData] = React.useState({}); + //const [proofId, setProofId] = React.useState(); + + React.useEffect(() => { + if (formData){ + setData(formData); + //setProofId(formData.id); + } + }, [formData]); + + const formik = useFormik({ + enableReinitialize: true, + initialValues: data, + }); + + const DisplayField = ({ name, width }) => { + return ; + } + + function currencyFormat(num) { + let val = num?num:0; + return val.toLocaleString('en-US', { + minimumFractionDigits: 2 + }); + } + + + return ( + + + 公共啟事:校對資料 + +
    + + + + + + + 申請編號: + + + + + + + + + + + 申請狀態: + + + + + {StatusUtils.getStatusByText(data.appStatus)} + + + + + + + + + + 申請人: + + + + + {data.orgId === null ? + + : + + } + + + + + + + + 憲報期數: + + + + + + + + + + + + + 聯絡人: + + + + + + + + + + + + 刊出日期: + + + + + + + + + + + + + 我的備注: + + + + + + + + + + + + + + + + + 請下載下列印刷稿檔案,並仔細校對: + + + + + + + + + 繳費及返稿最後限期: + + + {DateUtils.dateStr_Cht(data.returnBeforeDate)} 下午 2:00前 + + + 應繳費用: + + + {currencyFormat(data.fee)} + + + { + formik.values.groupType == "A" + ? + ( {data.length} 頁 x $6,552 ) + : + ( {data.length} cm x {data.colCount==2?"$364 二格位":"$182 一格位"} ) + } + + + + + + + +
    +
    + ); +}; + +export default ApplicationDetailCard; diff --git a/src/pages/ProofReply_Public/ProofForm.js b/src/pages/ProofReply_Public/ProofForm.js new file mode 100644 index 0000000..42b89ab --- /dev/null +++ b/src/pages/ProofReply_Public/ProofForm.js @@ -0,0 +1,256 @@ +// material-ui +import { + Dialog, DialogTitle, DialogContent, DialogActions, + Typography, + Grid, + Stack, + TextField, + FormLabel, + Button, + RadioGroup, Radio, + FormControlLabel +} from '@mui/material'; +import * as UrlUtils from "utils/ApiPathConst"; +import * as HttpUtils from "utils/HttpUtils"; +import FileList from "components/FileList" +import MainCard from "components/MainCard"; +import * as React from "react"; +import * as yup from 'yup'; +import { useParams } from "react-router-dom"; +import { useFormik } from 'formik'; +import { useNavigate } from "react-router-dom"; +import * as DateUtils from "utils/DateUtils" +import Loadable from 'components/Loadable'; +const UploadFileTable = Loadable(React.lazy(() => import('./UploadFileTable'))); + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const FormPanel = ({ formData }) => { + + const [data, setData] = React.useState({}); + const [attachments, setAttachments] = React.useState([]); + + const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); + const [warningText, setWarningText] = React.useState(""); + + const navigate = useNavigate() + const params = useParams(); + + React.useEffect(() => { + if (formData) { + setData(formData); + } + }, [formData]); + + const formik = useFormik({ + enableReinitialize: true, + initialValues: data, + validationSchema: yup.object().shape({ + vaild: yup.string().max(255, "請輸入你的登入密碼").required('請輸入你的登入密碼'), + }), + onSubmit: values => { + if (!values.action) { + if (!attachments || attachments.length <= 0) { + setWarningText("請選擇上傳檔案"); + setIsWarningPopUp(true); + return; + } + } + // console.log(values); + HttpUtils.postWithFiles({ + url: UrlUtils.REPLY_PROOF, + params: { + id: data.id, + action: values.action, + vaild: values.vaild, + }, + files: attachments ? attachments : [], + onSuccess: function () { + navigate("/proof/search"); + }, + onFail: function (response) { + setWarningText("行動失敗: 請檢查內容並再次提交回覆"); + setIsWarningPopUp(true); + console.log(response); + }, + onError: function (error) { + setWarningText("行動失敗: 請檢查內容並再次提交回覆"); + setIsWarningPopUp(true); + console.log(error); + } + }); + } + }); + + const readFile = (event) => { + let file = event.target.files[0]; + if (file) { + if (!file.name.toLowerCase().substr(file.name.length - 4).includes(".pdf")) { + setWarningText("請上傳有效檔案 (檔案格式: .pdf)"); + setIsWarningPopUp(true); + document.getElementById("uploadFileBtn").value = ""; + return; + } + if (file.size >= (10 * 1024 * 1034)) { + setWarningText("上傳檔案大小應<10MB"); + setIsWarningPopUp(true); + return; + } + + file['id'] = attachments.length; + setAttachments([ + ...attachments, + file + ]); + document.getElementById("uploadFileBtn").value = ""; + } + } + + + + return ( + + + + 公共啟事:校對回覆 + + +
    + + { + formik.values.replyDate ? + + + 校對回覆日期: {DateUtils.datetimeStr_Cht(formik.values.replyDate)} + + + 校對回覆: {formik.values.action? "可以付印(稿件正確)":"未能付印(需要修改)"} + + + + + + : + + + + + } label="可以付印(稿件正確)" /> + } label="未能付印(需要修改)" /> + + + + + 請上載稿件修改的檔案: + + + + = (formik.values.groupType == "A" ? 2 : 1)} + onChange={(event) => { + readFile(event) + }} + /> + + + + + + + + + + + + + 簽署: + + + + + + + + + + + + + } + + + +
    +
    + setIsWarningPopUp(false)} > + 注意 + + {warningText} + + + + + +
    +
    + ); +}; + +export default FormPanel; diff --git a/src/pages/ProofReply_Public/UploadFileTable.js b/src/pages/ProofReply_Public/UploadFileTable.js new file mode 100644 index 0000000..9090721 --- /dev/null +++ b/src/pages/ProofReply_Public/UploadFileTable.js @@ -0,0 +1,111 @@ +// material-ui +import * as React from 'react'; +import { + DataGrid, + GridActionsCellItem, + GridRowModes +} from "@mui/x-data-grid"; +import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline'; +import {useEffect} from "react"; +// import {useNavigate} from "react-router-dom"; +// import { useTheme } from '@mui/material/styles'; +import { + Box, + Stack +} from '@mui/material'; +// ==============================|| EVENT TABLE ||============================== // + +export default function UploadFileTable({recordList, setRecordList,}) { + + const [rows, setRows] = React.useState(recordList); + const [rowModesModel,setRowModesModel] = React.useState({}); + // const theme = useTheme(); + + // const navigate = useNavigate() + + useEffect(() => { + setRows(recordList); + // console.log(disableDelete); + }, [recordList]); + + function NoRowsOverlay() { + return ( + + No File Record + {/*
    (rows={[]})
    */} +
    + ); + } + + const handleCancelClick = (id) => () => { + setRowModesModel({ + ...rowModesModel, + [id]: { mode: GridRowModes.View, ignoreModifications: true }, + }); + console.log("Starting Delete") + const editedRow = rows.find((row) => row.id === id); + console.log(editedRow) + console.log(editedRow.isNew) + setRecordList(rows.filter((row) => row.id !== id)); + setRows(rows.filter((row) => row.id !== id)); + } + + const columns = [ + { + field: 'actions', + type: 'actions', + headerName: '', + width: 30, + cellClassName: 'actions', + // hide:true, + getActions: ({id}) => { + return [ + } + label="delete" + className="textPrimary" + onClick={handleCancelClick(id)} + color="error" + />] + }, + }, + { + id: 'name', + field: 'name', + headerName: '檔案名稱', + flex: 1, + }, + { + id: 'size', + field: 'size', + headerName: '檔案大小', + valueGetter: (params) => { + // console.log(params) + return Math.ceil(params.value/1024)+" KB"; + }, + flex: 1, + }, + ]; + + return ( + + + + ); +} diff --git a/src/pages/ProofReply_Public/index.js b/src/pages/ProofReply_Public/index.js new file mode 100644 index 0000000..de29ffd --- /dev/null +++ b/src/pages/ProofReply_Public/index.js @@ -0,0 +1,122 @@ +// material-ui +import { + Grid, + Typography, + Stack, + Box +} from '@mui/material'; +import * as UrlUtils from "utils/ApiPathConst"; +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import * as DateUtils from "utils/DateUtils"; +import { useParams } from "react-router-dom"; + +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); +const ApplicationDetails = Loadable(React.lazy(() => import('./ApplicationDetails'))); +const ProofForm = Loadable(React.lazy(() => import('./ProofForm'))); +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' +const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: '100%', + height: '100%', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' +} + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const Index = () => { + const params = useParams(); + + const [record, setRecord] = React.useState(); + const [onReady, setOnReady] = React.useState(false); + + React.useEffect(() => { + loadForm(); + }, []); + + React.useEffect(() => { + setOnReady(true); + }, [record]); + + + const loadForm = () => { + if (params.id > 0) { + + HttpUtils.get({ + url: UrlUtils.GET_PROOF + "/" + params.id, + onSuccess: (responseData) => { + responseData.data["phoneNumber"] = JSON.parse(responseData.data.contactTelNo).phoneNumber; + responseData.data["tel_countryCode"] = JSON.parse(responseData.data.contactTelNo).countryCode; + + responseData.data["faxNumber"] = JSON.parse(responseData.data.contactFaxNo).faxNumber; + responseData.data["fax_countryCode"] = JSON.parse(responseData.data.contactFaxNo).countryCode; + + responseData.data["issueNoStr"] = responseData.data.issueYear + +" Vol. "+zeroPad(responseData.data.issueVolume,3) + +", No. "+zeroPad(responseData.data.issueNo,2); + + responseData.data["issueDate"] = DateUtils.dateFormat(responseData.data.issueDate, "D MMM YYYY (ddd)"); + + responseData.data["groupType"] = responseData.data.groupNo.charAt(0); + responseData.data["action"] = responseData.data.replyDate?responseData.data.action:true; + setRecord(responseData.data); + } + }); + } + } + + function zeroPad(num, places) { + num=num?num:0; + var zero = places - num.toString().length + 1; + return Array(+(zero > 0 && zero)).join("0") + num; + } + + + return ( + !onReady ? + + : + + +
    + + 校對記錄 + +
    +
    + {/*row 1*/} + + +
    + + + + + + + + + + +
    +
    +
    + {/*row 2*/} +
    + ); +}; + +export default Index; diff --git a/src/pages/ProofSearch_Public/DataGrid.js b/src/pages/ProofSearch_Public/DataGrid.js new file mode 100644 index 0000000..b70343b --- /dev/null +++ b/src/pages/ProofSearch_Public/DataGrid.js @@ -0,0 +1,144 @@ +// material-ui +import * as React from 'react'; +import { + Button +} from '@mui/material'; +import * as DateUtils from "utils/DateUtils"; +import {useNavigate} from "react-router-dom"; +import {FiDataGrid} from "components/FiDataGrid"; +// ==============================|| EVENT TABLE ||============================== // + +export default function SearchPublicNoticeTable({ recordList }) { + const [rows, setRows] = React.useState(recordList); + const navigate = useNavigate() + + React.useEffect(() => { + setRows(recordList); + }, [recordList]); + + const handleEditClick = (params) => () => { + navigate('/proof/reply/'+ params.row.appId); + }; + + + const columns = [ + { + field: 'actions', + headerName: 'Proof No.', + width: 150, + cellClassName: 'actions', + renderCell: (params) => { + return ; + }, + }, + { + id: 'appId', + field: 'appId', + headerName: 'Application No./ Gazette Code/ Gazette Issue', + flex: 1, + renderCell: (params) => { + let appNo = params.row.appNo; + let code = params.row.groupNo; + let isssue = params.row.issueYear + +" Vol. "+zeroPad(params.row.issueVolume,3) + +", No. "+zeroPad(params.row.issueNo,2) + +", "+DateUtils.dateFormat(params.row.issueDate, "D MMM YYYY (ddd)"); + + return
    App No: {appNo}
    Gazette Code: {code}
    Issue: {isssue}
    + }, + }, + { + id: 'created', + field: 'created', + headerName: 'Proof Date', + flex: 1, + valueGetter: (params) => { + return DateUtils.datetimeStr(params?.value); + } + }, + { + id: 'replyDate', + field: 'replyDate', + headerName: 'Confirmed/Return Date', + flex: 1, + valueGetter: (params) => { + return params?.value?DateUtils.datetimeStr(params?.value):""; + } + }, + { + id: 'contactPerson', + field: 'contactPerson', + headerName: 'Contact Person', + flex: 1, + renderCell: (params) => { + let company = params.row.enCompanyName!= null ?" ("+(params.row.enCompanyName)+")":""; + + let phone = JSON.parse(params.row.contactTelNo); + let faxNo = JSON.parse(params.row.contactFaxNo); + + let contact = ""; + if (phone) { + contact = "Phone No.: " + phone?.countryCode + " " + phone?.phoneNumber + } + + if (faxNo && faxNo?.faxNumber) { + if (contact != "") + contact = contact + ", " + contact = contact + "Fax No.:" + faxNo?.countryCode + " " + faxNo?.faxNumber + } + + return (<> + {params?.value + company}
    + {contact} + ); + } + }, + { + id: 'groupTitle', + field: 'groupTitle', + headerName: 'Gazette Group', + flex: 1, + valueGetter: (params) => { + return (params?.value)?(params?.value):""; + } + }, + { + id: 'fee', + field: 'fee', + headerName: 'Fee', + flex: 1, + valueGetter: (params) => { + return (params?.value)?"$ "+currencyFormat(params?.value):""; + } + }, + ]; + + function currencyFormat(num) { + return num.toLocaleString('en-US', { + minimumFractionDigits: 2 + }); + } + + + function zeroPad(num, places) { + num=num?num:0; + var zero = places - num.toString().length + 1; + return Array(+(zero > 0 && zero)).join("0") + num; + } + + return ( +
    + + +
    + ); +} diff --git a/src/pages/ProofSearch_Public/SearchForm.js b/src/pages/ProofSearch_Public/SearchForm.js new file mode 100644 index 0000000..706191c --- /dev/null +++ b/src/pages/ProofSearch_Public/SearchForm.js @@ -0,0 +1,322 @@ +// material-ui +import { + Button, + CardContent, + Grid, TextField, + Autocomplete +} from '@mui/material'; +import MainCard from "components/MainCard"; +import { useForm } from "react-hook-form"; +import * as React from "react"; +import * as ComboData from "utils/ComboData"; +import * as DateUtils from "utils/DateUtils"; +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issueComboData + }) => { + + const [type, setType] = React.useState([]); + const [status, setStatus] = React.useState({ key: 0, label: 'All', type: 'all' }); + const [orgSelected, setOrgSelected] = React.useState({}); + const [orgCombo, setOrgCombo] = React.useState(); + const [issueSelected, setIssueSelected] = React.useState({}); + const [issueCombo, setIssueCombo] = React.useState([]); + const [groupSelected, setGroupSelected] = React.useState({}); + + const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); + const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); + + + const { reset, register, handleSubmit } = useForm() + const onSubmit = (data) => { + + let typeArray = []; + + for (let i = 0; i < type.length; i++) { + typeArray.push(type[i].label); + } + + const temp = { + refNo: data.refNo, + code: data.code, + issueId: issueSelected?.id, + gazettGroup: groupSelected?.type, + dateFrom: data.dateFrom, + dateTo: data.dateTo, + contact: data.contact, + replyed: (status?.type && status?.type != 'all') ? status?.type : "", + orgId: (orgSelected?.key && orgSelected?.key > 0) ? orgSelected?.key : "", + + }; + applySearch(temp); + }; + + React.useEffect(() => { + if (orgComboData && orgComboData.length > 0) { + setOrgCombo(orgComboData); + } + }, [orgComboData]); + + React.useEffect(() => { + if (issueComboData && issueComboData.length > 0) { + setIssueCombo(issueComboData); + } + }, [issueComboData]); + + function resetForm() { + setType([]); + setStatus({ key: 0, label: 'All', type: 'all' }); + setOrgSelected({}); + setIssueSelected({}); + setGroupSelected({}); + reset(); + } + + function getIssueLabel(data){ + if(data=={}) return ""; + return data.year + +" Vol. "+zeroPad(data.volume,3) + +", No. "+zeroPad(data.issueNo,2) + +", "+DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + } + + function zeroPad(num, places) { + num=num?num:0; + var zero = places - num.toString().length + 1; + return Array(+(zero > 0 && zero)).join("0") + num; + } + + return ( + + +
    + {/*row 1*/} + + + 搜尋 + + + + {/*row 2*/} + + + + + + + + + + + getIssueLabel(option)} + onChange={(event, newValue) => { + if (newValue !== null) { + setIssueSelected(newValue); + } + }} + renderInput={(params) => ( + + )} + /> + + + + option.label} + onChange={(event, newValue) => { + if (newValue !== null) { + setGroupSelected(newValue); + } + }} + renderInput={(params) => ( + + )} + /> + + + + { + setMinDate(DateUtils.dateStr(newValue)); + }} + InputLabelProps={{ + shrink: true + }} + /> + + + + { + setMaxDate(DateUtils.dateStr(newValue)); + }} + id="dateTo" + type="date" + label="校對日期(To)" + defaultValue={searchCriteria.dateTo} + /> + + + + + + + + + options} + options={ComboData.proofStatus} + value={status} + inputValue={status?.label?status?.label:""} + onChange={(event, newValue) => { + if (newValue !== null) { + setStatus(newValue); + } + }} + renderInput={(params) => ( + + )} + InputLabelProps={{ + shrink: true + }} + /> + + + { + orgCombo ? + + { + if (newValue !== null) { + setOrgSelected(newValue); + } + }} + renderInput={(params) => ( + + )} + /> + + : <> + } + + + + + + {/*last row*/} + + + + + + + + + + +
    +
    + ); +}; + +export default SearchPublicNoticeForm; diff --git a/src/pages/ProofSearch_Public/index.js b/src/pages/ProofSearch_Public/index.js new file mode 100644 index 0000000..95082e4 --- /dev/null +++ b/src/pages/ProofSearch_Public/index.js @@ -0,0 +1,127 @@ +// material-ui +import { + Grid, + Typography, + Stack +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as UrlUtils from "utils/ApiPathConst"; +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import * as DateUtils from "utils/DateUtils"; + +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); +const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); +const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' + +const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: '100%', + height: '100%', + backgroundSize:'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' +} + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const UserSearchPage_Individual = () => { + + const [record,setRecord] = React.useState([]); + const [orgCombo,setOrgCombo] = React.useState([]); + const [issueCombo,setIssueCombo] = React.useState([]); + const [searchCriteria, setSearchCriteria] = React.useState({ + dateTo: DateUtils.dateStr(new Date()), + dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)), + }); + const [onReady, setOnReady] = React.useState(false); + + React.useEffect(() => { + getUserList(); + getOrgCombo(); + getIssueCombo(); + }, []); + + React.useEffect(() => { + setOnReady(true); + }, [record]); + + React.useEffect(() => { + getUserList(); + }, [searchCriteria]); + + function getUserList(){ + HttpUtils.get({ + url: UrlUtils.LIST_PROOF, + params: searchCriteria, + onSuccess: function(responseData){ + setRecord(responseData); + } + }); + } + + function getOrgCombo(){ + HttpUtils.get({ + url: UrlUtils.GET_ORG_COMBO, + onSuccess: function(responseData){ + let combo = responseData; + setOrgCombo(combo); + } + }); + } + + function getIssueCombo(){ + HttpUtils.get({ + url: UrlUtils.GET_ISSUE_COMBO, + onSuccess: function(responseData){ + let combo = responseData; + setIssueCombo(combo); + } + }); + } + + + function applySearch(input) { + setSearchCriteria(input); + } + + return ( + !onReady ? + + : + + +
    + + 校對記錄 + +
    +
    + {/*row 1*/} + + + + {/*row 2*/} + + + + + +
    + ); +}; + +export default UserSearchPage_Individual; diff --git a/src/pages/pnspsUserDetailPage_Individual/UserInformationCard_Individual.js b/src/pages/pnspsUserDetailPage_Individual/UserInformationCard_Individual.js index 3087526..c7f3191 100644 --- a/src/pages/pnspsUserDetailPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/pnspsUserDetailPage_Individual/UserInformationCard_Individual.js @@ -390,6 +390,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
    + {FieldUtils.getComboField({ label: "Country:", valueName: "country", @@ -479,6 +480,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { + {FieldUtils.getComboField({ label: "District:", valueName: "district", diff --git a/src/routes/PublicUserRoutes.js b/src/routes/PublicUserRoutes.js index 9e3aa05..27aba9b 100644 --- a/src/routes/PublicUserRoutes.js +++ b/src/routes/PublicUserRoutes.js @@ -11,6 +11,8 @@ const ManageOrgUser = Loadable(lazy(() => import('pages/ManageOrgUserPage'))); const PublicNotice = Loadable(lazy(() => import('pages/PublicNotice/ListPanel'))); const PublicNoticeApplyForm = Loadable(lazy(() => import('pages/PublicNotice/ApplyForm'))); const PublicNoticeDetail = Loadable(lazy(() => import('pages/PublicNoticeDetail'))); +const ProofReply = Loadable(lazy(() => import('pages/ProofReply_Public'))); +const ProofSearch = Loadable(lazy(() => import('pages/ProofSearch_Public'))); // ==============================|| MAIN ROUTING ||============================== // @@ -45,6 +47,14 @@ const PublicDashboard = { path: 'publicNotice/:id', element: }, + { + path: 'proof/reply/:id', + element: + }, + { + path: 'proof/search', + element: + }, ] }, ] diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 5848ccb..e22e4bc 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -70,8 +70,10 @@ export const UPDATE_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/save'; export const GET_ISSUE_COMBO = apiPath+'/gazette-issue/combo'; export const LIST_PROOF = apiPath+'/proof/list';//GET -export const GET_PROOF_APP = apiPath+'/proof/create-from-app';//GET +export const GET_PROOF_APP = apiPath+'/proof/create-from-app';//GLD export const CREATE_PROOF = apiPath+'/proof/create';//POST +export const GET_PROOF = apiPath+'/proof/details';//GET +export const REPLY_PROOF = apiPath+'/proof/reply';//GET //User Group export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save'; \ No newline at end of file diff --git a/src/utils/DateUtils.js b/src/utils/DateUtils.js index 52d55e0..9ec9e2d 100644 --- a/src/utils/DateUtils.js +++ b/src/utils/DateUtils.js @@ -9,6 +9,14 @@ export const dateStr = (date) =>{ return dateFormat(date,"YYYY-MM-DD") }; +export const datetimeStr_Cht = (date) =>{ + return dateFormat(date,"YYYY年MM月DD日 HH:mm:ss") +}; + +export const dateStr_Cht = (date) =>{ + return dateFormat(date,"YYYY年MM月DD日") +}; + export const convertToDate = (date)=>{ if(typeof date == 'number'){ return dayjs(date);