From 921f8d86a89fb6164d8ba0977100ee431fde84f9 Mon Sep 17 00:00:00 2001 From: yms Date: Fri, 19 Jul 2024 14:31:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- src/components/ArrowTag/index.module.css | 1 + src/components/BasicModal/index.tsx | 7 +- .../FormComponentRender/renderComponent.tsx | 24 +- src/config/dev.ts | 3 + src/config/util.ts | 5 + src/customForm/components/Checkbox/index.tsx | 5 +- .../components/DatePicker/index.tsx | 34 ++ .../components/FileUpload/index.tsx | 87 +++- src/customForm/components/List/index.tsx | 30 +- src/customForm/components/Radio/index.tsx | 8 +- src/customForm/components/Select/index.tsx | 42 ++ .../components/UserSelect/index.module.css | 11 +- .../components/UserSelect/index.tsx | 160 ++++-- .../components/imageUpload/index.tsx | 63 ++- src/customForm/entity/base.ts | 74 +-- src/customForm/entity/branch.ts | 1 + src/customForm/entity/date-picker.ts | 36 +- src/customForm/entity/file-upload.ts | 32 +- src/customForm/entity/img-upload.ts | 23 +- src/customForm/entity/number.ts | 32 +- src/customForm/entity/phone.ts | 33 +- src/customForm/entity/radio.ts | 22 + src/customForm/entity/select.ts | 40 +- src/customForm/entity/text-input.ts | 42 +- src/customForm/entity/textarea.ts | 26 +- src/customForm/eventBus.ts | 32 ++ src/customForm/registry.ts | 16 - src/customForm/utils.ts | 72 ++- src/main.tsx | 16 +- .../ApplicationMaterial/attachment.module.css | 40 +- src/pages/ApplicationMaterial/attachment.tsx | 105 +++- .../components/card.module.css | 6 + .../ApplicationMaterial/components/card.tsx | 10 +- src/pages/ApplicationMaterial/content.tsx | 110 ++-- src/pages/ApplicationMaterial/index.tsx | 146 +++++- .../ApplicationMaterial/review.module.css | 51 +- src/pages/ApplicationMaterial/review.tsx | 308 +++++++++-- .../ApplicationMaterial/timeLine.module.css | 12 + src/pages/ApplicationMaterial/timeLine.tsx | 202 ++++---- ...index.module.css => adminLogin.module.css} | 0 src/pages/Login/adminLogin.tsx | 143 ++++++ src/pages/Login/index.tsx | 97 ---- src/pages/Login/login.module.css | 22 + src/pages/Login/login.tsx | 217 ++++++++ src/pages/Management/Main/index.tsx | 60 ++- src/pages/Management/Main/itemCard.tsx | 83 +-- .../PendingReviewList/index.module.css | 26 +- .../Management/PendingReviewList/index.tsx | 80 ++- .../PendingReviewList/listTable.module.css | 7 +- .../PendingReviewList/listTable.tsx | 227 ++++---- .../Flow/applyForNodeSetting.module.css | 10 - .../Setting/Flow/applyForNodeSetting.tsx | 44 +- .../Flow/components/formSelect.module.css | 2 +- .../Setting/Flow/components/formSelect.tsx | 43 +- .../Flow/examineNodeSetting.module.css | 10 - src/pages/Setting/Flow/examineNodeSetting.tsx | 76 ++- src/pages/Setting/Flow/index.module.css | 60 ++- src/pages/Setting/Flow/index.tsx | 273 ++++++++-- .../Flow/transactNodeSetting.module.css | 10 - .../Setting/Flow/transactNodeSetting.tsx | 36 +- src/pages/Setting/FormMatch/complex-table.tsx | 172 ++++++- .../Setting/FormMatch/formView.module.css | 14 + src/pages/Setting/FormMatch/formView.tsx | 87 ++++ src/pages/Setting/FormMatch/index.module.css | 25 +- src/pages/Setting/FormMatch/index.tsx | 136 ++++- src/pages/Setting/FormMatch/menu.tsx | 18 +- src/pages/Setting/basic.module.css | 3 + src/pages/Setting/basic.tsx | 483 ++++++++++++------ src/pages/Setting/index.tsx | 151 ++++-- src/pages/Setting/interface.ts | 8 + src/pages/Setting/util.ts | 208 ++++++++ src/pages/User/Main/index.module.css | 2 +- src/pages/User/Main/index.tsx | 32 +- src/pages/User/Main/list-item.tsx | 57 ++- src/pages/User/Main/subExtend.tsx | 57 ++- src/pages/User/ReviewProcess/index.tsx | 106 ++-- .../ReviewProcess/progress-item.module.css | 69 ++- .../User/ReviewProcess/progress-item.tsx | 126 ++--- src/pages/User/SubmitApplication/index.tsx | 256 ++++++---- src/router/index.tsx | 35 +- src/router/root.tsx | 39 ++ src/service/applyController.ts | 47 ++ src/service/commonController.ts | 25 + src/service/core/request.ts | 55 +- src/service/index.ts | 13 + src/service/loginController.ts | 37 ++ src/service/managementController.ts | 50 ++ src/service/settingController.ts | 53 ++ src/service/type.d.ts | 117 +++++ src/store/useUserStore.ts | 24 + vite.config.ts | 9 +- yarn.lock | 12 + 93 files changed, 4561 insertions(+), 1461 deletions(-) create mode 100644 src/config/dev.ts create mode 100644 src/config/util.ts create mode 100644 src/customForm/components/DatePicker/index.tsx create mode 100644 src/customForm/eventBus.ts rename src/pages/Login/{index.module.css => adminLogin.module.css} (100%) create mode 100644 src/pages/Login/adminLogin.tsx delete mode 100644 src/pages/Login/index.tsx create mode 100644 src/pages/Login/login.module.css create mode 100644 src/pages/Login/login.tsx create mode 100644 src/pages/Setting/FormMatch/formView.module.css create mode 100644 src/pages/Setting/FormMatch/formView.tsx create mode 100644 src/pages/Setting/util.ts create mode 100644 src/router/root.tsx create mode 100644 src/service/applyController.ts create mode 100644 src/service/commonController.ts create mode 100644 src/service/loginController.ts create mode 100644 src/service/managementController.ts create mode 100644 src/service/settingController.ts create mode 100644 src/service/type.d.ts create mode 100644 src/store/useUserStore.ts diff --git a/package.json b/package.json index e958a94..86a6ec2 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "reflect-metadata": "^0.2.2", "type-fest": "^4.20.0", "umi-request": "^1.4.0", - "uuid": "^10.0.0" + "uuid": "^10.0.0", + "zustand": "^4.5.4" }, "devDependencies": { "@types/react": "^18.2.66", diff --git a/src/components/ArrowTag/index.module.css b/src/components/ArrowTag/index.module.css index 62131bc..ffd3c53 100644 --- a/src/components/ArrowTag/index.module.css +++ b/src/components/ArrowTag/index.module.css @@ -16,4 +16,5 @@ font-weight: 600; font-size: 16px; padding: 0 10px 0 5px; + transform: translateX(-1px); } diff --git a/src/components/BasicModal/index.tsx b/src/components/BasicModal/index.tsx index 9e6e54a..ee61a4f 100644 --- a/src/components/BasicModal/index.tsx +++ b/src/components/BasicModal/index.tsx @@ -28,7 +28,12 @@ const BasicModal: React.FC> = (props) => { } return ( -
+
e.stopPropagation()} + >
{ const componentsRegister = useMemo(() => { const composeProps = { ...newProps, ...config }; + switch (componentType) { case "TextInput": return ; + case "NumberInput": + return ; case "Branch": return ""; case "DatePicker": - return ; + return ( + { + console.log(str); + }} + > + ); case "TextAreaInput": return ; case "Radio": return ; case "Select": - return ; default: return ""; } diff --git a/src/config/dev.ts b/src/config/dev.ts new file mode 100644 index 0000000..d81d703 --- /dev/null +++ b/src/config/dev.ts @@ -0,0 +1,3 @@ +export default { + imgHost: "http://192.168.2.24:9000", +}; diff --git a/src/config/util.ts b/src/config/util.ts new file mode 100644 index 0000000..bf1bbca --- /dev/null +++ b/src/config/util.ts @@ -0,0 +1,5 @@ +import dev from "./dev"; + +export function composeImgUrl(imgStr: string) { + return `${dev.imgHost}${imgStr}`; +} diff --git a/src/customForm/components/Checkbox/index.tsx b/src/customForm/components/Checkbox/index.tsx index 3aa5a41..466964f 100644 --- a/src/customForm/components/Checkbox/index.tsx +++ b/src/customForm/components/Checkbox/index.tsx @@ -17,7 +17,7 @@ const Checkbox = ({ value, onChange, options }: CheckboxProps) => { const [selected, setSelected] = useState([]); useEffect(() => { - if (typeof value === "object" && isEqual(value, selected)) { + if (typeof value === "object" && !isEqual(value, selected)) { setSelected(value); } }, [value]); @@ -53,6 +53,9 @@ const Checkbox = ({ value, onChange, options }: CheckboxProps) => {
); } + if (options && options.length === 0) { + return
没有可供选择的选项
; + } return (
void; + value?: any; + isRange: boolean; +} + +const HnDatePicker: React.FC = (props) => { + const { isRange, value, picker, onChange } = props; + + if (isRange) { + return ( + + ); + } + return ( + + ); +}; + +export default HnDatePicker; diff --git a/src/customForm/components/FileUpload/index.tsx b/src/customForm/components/FileUpload/index.tsx index 84ac5c0..a7635f2 100644 --- a/src/customForm/components/FileUpload/index.tsx +++ b/src/customForm/components/FileUpload/index.tsx @@ -1,37 +1,70 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; import { InboxOutlined } from "@ant-design/icons"; import type { UploadProps } from "antd"; import { message, Upload } from "antd"; +import { isEqual } from "lodash"; const { Dragger } = Upload; -const props: UploadProps = { - name: "file", - multiple: true, - action: "https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload", - onChange(info) { - const { status } = info.file; - if (status !== "uploading") { - console.log(info.file, info.fileList); - } - if (status === "done") { - message.success(`${info.file.name} file uploaded successfully.`); - } else if (status === "error") { - message.error(`${info.file.name} file upload failed.`); +interface FileUploadProps { + onChange: (params: string) => void; + value: string; + placeholder?: string; +} + +const FileUpload: React.FC = (props) => { + const { placeholder, value, onChange } = props; + const [fileList, setFilList] = useState([]); + useEffect(() => { + if (typeof value === "string") { + const list = value?.split(","); + if (list && list.length > 0 && isEqual(fileList, list)) { + setFilList(list); + } } - }, - onDrop(e) { - console.log("Dropped files", e.dataTransfer.files); - }, -}; + }, [value]); -const FileUpload: React.FC = () => ( - -

- -

-

单击或拖动文件到此区域进行上传

-
-); + const DraggerProps: UploadProps = { + name: "file", + multiple: true, + action: "/apis/oss/upload?bucketName=cgtf", + maxCount: 1, + accept: ".pdf", + onChange(info) { + const { status } = info.file; + if (status === "done") { + const imgStr = info.fileList.map((item) => { + return item.response.data; + }) as string[]; + setFilList(imgStr); + onChange(imgStr.join(",")); + message.success(`${info.file.name}上传成功.`); + } else if (status === "error") { + message.error(`${info.file.name}上传失败.`); + } + }, + defaultFileList: fileList.map((v, i) => { + return { + uid: (i + 1).toString(), + name: v, + status: "done", + url: v, + }; + }), + onDrop(e) { + console.log("Dropped files", e.dataTransfer.files); + }, + }; + return ( + +

+ +

+

+ {placeholder ?? "单击或拖动文件到此区域进行上传"} +

+
+ ); +}; export default FileUpload; diff --git a/src/customForm/components/List/index.tsx b/src/customForm/components/List/index.tsx index 1736ffa..96db624 100644 --- a/src/customForm/components/List/index.tsx +++ b/src/customForm/components/List/index.tsx @@ -1,33 +1,29 @@ import { MinusOutlined, PlusOutlined } from "@ant-design/icons"; -import { Button, Flex, Input, Space } from "antd"; -import { cloneDeep, isEqual } from "lodash"; +import { Button, Flex, Input } from "antd"; +import { cloneDeep } from "lodash"; import { useEffect, useState } from "react"; interface ListProps { - value: { label: string; value: string }[]; - onChange: (params: { label: string; value: string }[]) => void; + value: string[]; + onChange: (params: string[]) => void; } const List = (props: ListProps) => { const { value, onChange } = props; - const [data, setData] = useState([ - { - label: "", - value: "", - }, - ]); + const [data, setData] = useState([""]); useEffect(() => { - if (!value || isEqual(data, value)) { - return; - } else { + if (value && Array.isArray(value) && value.length > 0) { setData(value); + } else { + setData([""]); } + console.log(value); }, [value]); const add = (index: number) => { const temp = cloneDeep(data); - temp.splice(index + 1, 0, { label: "", value: "" }); + temp.splice(index + 1, 0, ""); setData(temp); }; @@ -39,9 +35,9 @@ const List = (props: ListProps) => { const LabelChange = (e: any, index: number) => { const v = e.target.value; const temp = cloneDeep(data); - temp[index].label = v; - temp[index].value = v; + temp[index] = v; setData(temp); + onChange(temp); }; return ( @@ -51,7 +47,7 @@ const List = (props: ListProps) => { LabelChange(e, i)} >