From f65558f2fc2502de61aac676d1fb67e1a187e8d5 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 15 Sep 2023 15:41:55 +0800 Subject: [PATCH] add application --- src/pages/PublicNotice/ApplyForm/index.js | 27 +++++-- .../PublicNotice/ListPanel/InProgressTab.js | 17 ++-- .../ListPanel/PendingPaymentTab.js | 14 +--- .../ListPanel/PendingPublishTab.js | 17 ++-- .../PublicNotice/ListPanel/SubmittedTab.js | 27 ++----- src/pages/PublicNotice/ListPanel/index.js | 18 ++--- src/utils/ApiPathConst.js | 2 +- src/utils/FieldUtils.js | 28 ++++++- src/utils/HttpUtils.js | 81 +++++++++++++------ 9 files changed, 134 insertions(+), 97 deletions(-) diff --git a/src/pages/PublicNotice/ApplyForm/index.js b/src/pages/PublicNotice/ApplyForm/index.js index 9e7741e..4708894 100644 --- a/src/pages/PublicNotice/ApplyForm/index.js +++ b/src/pages/PublicNotice/ApplyForm/index.js @@ -40,14 +40,10 @@ const PublicNoticeApplyForm = () => { }), onSubmit:values=>{ console.log(values); - HttpUtils.post({ - url: UrlUtils.POST_PUBLIC_NOTICE_SAVE, + HttpUtils.postWithFiles({ + url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, params: { id: 0, - group: values.chName, - groupTitle: values.groupTitle, - groupNo: values.groupNo, - issueId: values.issueId, contactPerson: values.contactPerson, contactTelNo: { countryCode: values.tel_countryCode, @@ -58,8 +54,8 @@ const PublicNoticeApplyForm = () => { faxNumber: values.faxNumber }, remarks:values.remarks, - file: attachment }, + files: [attachment], onSuccess: function(){ loadDataFun(); } @@ -137,6 +133,23 @@ const PublicNoticeApplyForm = () => { form: formik })} + + {FieldUtils.getPhoneField({ + label:"Issue:", + valueName:{ + code: "issueId", + num:"issueId" + }, + form: formik + })} + + + {FieldUtils.getTextArea({ + label:"備註:", + valueName:"remarks", + form: formik + })} +
{ - return [ - } - label="查看詳細" - className="textPrimary" - onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} - color="primary" - />] + renderCell: () => { + return ; }, } ]; diff --git a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js index e54e691..02ac6aa 100644 --- a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js +++ b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js @@ -2,12 +2,10 @@ import * as React from 'react'; import { DataGrid, - GridActionsCellItem, } from "@mui/x-data-grid"; import { Button } from '@mui/material'; -import * as Icon from 'utils/IconUtils'; import * as DateUtils from "utils/DateUtils" // ==============================|| EVENT TABLE ||============================== // @@ -54,16 +52,8 @@ export default function SubmittedTab({rows}) { headerName: '', width: 50, cellClassName: 'actions', - getActions: (params) => { - return [ - } - label="查看詳細" - className="textPrimary" - onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} - color="primary" - />] + renderCell: () => { + return ; }, } ]; diff --git a/src/pages/PublicNotice/ListPanel/PendingPublishTab.js b/src/pages/PublicNotice/ListPanel/PendingPublishTab.js index 70c60b2..efbdf3b 100644 --- a/src/pages/PublicNotice/ListPanel/PendingPublishTab.js +++ b/src/pages/PublicNotice/ListPanel/PendingPublishTab.js @@ -2,9 +2,10 @@ import * as React from 'react'; import { DataGrid, - GridActionsCellItem, } from "@mui/x-data-grid"; -import * as Icon from 'utils/IconUtils'; +import { + Button +} from '@mui/material'; import * as DateUtils from "utils/DateUtils" // ==============================|| EVENT TABLE ||============================== // @@ -51,16 +52,8 @@ export default function SubmittedTab({rows}) { headerName: '', width: 50, cellClassName: 'actions', - getActions: (params) => { - return [ - } - label="查看詳細" - className="textPrimary" - onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} - color="primary" - />] + renderCell: () => { + return ; }, } ]; diff --git a/src/pages/PublicNotice/ListPanel/SubmittedTab.js b/src/pages/PublicNotice/ListPanel/SubmittedTab.js index 76c3c8e..333e4e2 100644 --- a/src/pages/PublicNotice/ListPanel/SubmittedTab.js +++ b/src/pages/PublicNotice/ListPanel/SubmittedTab.js @@ -2,10 +2,11 @@ import * as React from 'react'; import { DataGrid, - GridActionsCellItem, } from "@mui/x-data-grid"; -import * as Icon from '../../../utils/IconUtils'; -import * as DateUtils from "../../../utils/DateUtils" +import { + Button +} from '@mui/material'; +import * as DateUtils from "utils/DateUtils" // ==============================|| EVENT TABLE ||============================== // export default function SubmittedTab({rows}) { @@ -24,7 +25,7 @@ export default function SubmittedTab({rows}) { headerName: '提交日期', flex: 1, valueGetter:(params)=>{ - return DateUtils.datetimeStr(params.value); + return DateUtils.datetimeStr(params?.value); } }, { @@ -32,18 +33,12 @@ export default function SubmittedTab({rows}) { field: 'remarks', headerName: '我的備註', flex: 1, - valueGetter:(params)=>{ - return DateUtils.datetimeStr(params.value); - } }, { id: 'status', field: 'status', headerName: '狀態', flex: 1, - valueGetter:(params)=>{ - return DateUtils.datetimeStr(params.value); - } }, { field: 'actions', @@ -51,16 +46,8 @@ export default function SubmittedTab({rows}) { headerName: '', width: 50, cellClassName: 'actions', - getActions: (params) => { - return [ - } - label="查看詳細" - className="textPrimary" - onClick={onDownloadClick(params.id, params.row.skey, params.row.filename)} - color="primary" - />] + renderCell: () => { + return ; }, } ]; diff --git a/src/pages/PublicNotice/ListPanel/index.js b/src/pages/PublicNotice/ListPanel/index.js index 4a0e1a1..be46778 100644 --- a/src/pages/PublicNotice/ListPanel/index.js +++ b/src/pages/PublicNotice/ListPanel/index.js @@ -47,12 +47,12 @@ const PublicNotice = () => { const loadData = ()=>{ setLoding(true); HttpUtils.get({ - url: `${UrlUtils.GET_PUBLIC_NOTICE_LIST}`, + url: `${UrlUtils.GET_PUBLIC_NOTICE_LIST_ListByStatus}`, onSuccess: function(response){ - setSubmittedList(response.data["submitted"]); - setInProgressList(response.data["inProgress"]); - setPendingPaymentList(response.data["pendingPayment"]); - setPendingPublishList(response.data["pendingPublish"]); + setSubmittedList(response["submitted"]); + setInProgressList(response["inProgress"]); + setPendingPaymentList(response["pendingPayment"]); + setPendingPublishList(response["pendingPublish"]); } }); }; @@ -85,10 +85,10 @@ const PublicNotice = () => { - - - - + + + + diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index a98a190..0b5ce85 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -50,7 +50,7 @@ export const GET_SET_UN_PRIMARY_USER = apiPath+'/user/un-primary'; export const GET_PUBLIC_NOTICE_LIST = apiPath+'/application/list'; export const GET_PUBLIC_NOTICE_LIST_ListByStatus = apiPath+'/application/status-list'; export const GET_PUBLIC_NOTICE_getApplyUser = apiPath+'/application/get-apply-user'; -export const POST_PUBLIC_NOTICE_SAVE = apiPath+'/application/save'; +export const POST_PUBLIC_NOTICE_APPLY = apiPath+'/application/apply'; //GLD User export const POST_ADMIN_USER_REGISTER = apiPath+'/user/registry'; diff --git a/src/utils/FieldUtils.js b/src/utils/FieldUtils.js index 7ed1c84..a57f9a8 100644 --- a/src/utils/FieldUtils.js +++ b/src/utils/FieldUtils.js @@ -43,6 +43,30 @@ export const getTextField=({label, valueName, form, disabled})=>{ ; } +export const getTextArea=({label, valueName, form, disabled, ...props})=>{ + return + + + {label} + + + {initField({ + type:"text", + valueName:valueName, + form:form, + disabled:disabled, + multiline: true, + row:10, + minRows: 4, + maxRows: 4, + props + })} + + + ; +} + export const getPhoneField=({label, valueName, form, disabled})=>{ return @@ -155,11 +179,12 @@ export const getComboField=({label,dataList, valueName, form, disabled, getOptio ; } -export const initField=({type, valueName, form, disabled, placeholder, inputProps})=>{ +export const initField=({type, valueName, form, disabled, multiline, placeholder, inputProps, ...props})=>{ let err = Boolean(form.errors[valueName]); return } diff --git a/src/utils/HttpUtils.js b/src/utils/HttpUtils.js index cd5b093..64ade39 100644 --- a/src/utils/HttpUtils.js +++ b/src/utils/HttpUtils.js @@ -35,6 +35,29 @@ export const post = ({url, params, onSuccess, onFail, onError, headers}) =>{ }); }; +export const postWithFiles = ({url, params, files, onSuccess, onFail, onError}) =>{ + var formData = new FormData(); + for (let i = 0; i < files.length; i++){ + const file = files[i] + formData.append("multipartFileList", file); + } + for (var key in params) { + if(typeof(params[key]) ==='object'){ + formData.append(key, JSON.stringify(params[key])); + }else{ + formData.append(key, params[key]?params[key]:null); + } + } + + axios.post(url,formData, + {headers: {"Content-Type":"multipart/form-data"}}) + .then( + (response)=>{onResponse(response, onSuccess, onFail);} + ).catch(error => { + return handleError(error,onError); + }); +}; + export const fileDownload = ({fileId, skey, filename, onError}) =>{ axios.get( FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename, { @@ -56,29 +79,41 @@ export const fileDownload = ({fileId, skey, filename, onError}) =>{ }); }; -export const fileUpload = ({ refType, refId, files,refCode, onSuccess, onFail, onError}) =>{ - console.log(files); - var formData = new FormData(); - for (let i = 0; i < files.length; i++){ - const file = files[i] - formData.append("multipartFileList", file); - } - // formData.append("multipartFile", file); - formData.append("refType", refType); - formData.append("refId", refId); - if(refCode){ - formData.append("refCode", refCode); - } - console.log(formData) - axios.post(FILE_UP_POST,formData,{ - headers: { - "Content-Type":"multipart/form-data" - } - }).then( - (response)=>{ - onResponse(response,onSuccess,onFail); - } - ).catch(error => { return handleError(error, onError); }); +export const fileUpload = ({ refType, refId, files, refCode, onSuccess, onFail, onError}) =>{ + // console.log(files); + // var formData = new FormData(); + // for (let i = 0; i < files.length; i++){ + // const file = files[i] + // formData.append("multipartFileList", file); + // } + // // formData.append("multipartFile", file); + // formData.append("refType", refType); + // formData.append("refId", refId); + // if(refCode){ + // formData.append("refCode", refCode); + // } + // console.log(formData) + // axios.post(FILE_UP_POST,formData,{ + // headers: { + // "Content-Type":"multipart/form-data" + // } + // }).then( + // (response)=>{ + // onResponse(response,onSuccess,onFail); + // } + // ).catch(error => { return handleError(error, onError); }); + postWithFiles({ + url: FILE_UP_POST, + params:{ + refType: refType, + refId: refId, + refCode: refCode + }, + files: files, + onSuccess: onSuccess, + onFail:onFail, + onError:onError + }); };