diff --git a/package.json b/package.json index f45c57fcb869601a30b6339c9e12d40f151a4f40..6d0e6ba7c0e727396ae9b1b299c9d605196170cf 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,8 @@ "@types/reactcss": "^1.2.6", "@types/styled-components": "^5.1.24", "@umijs/route-utils": "^1.0.36", - "@wangeditor/editor": "^0.15.15", + "@wangeditor/editor": "^5.0.1", + "@wangeditor/plugin-md": "^1.0.0", "ahooks": "^3.1.13", "antd": "^4.19.3", "bizcharts": "^3.5.3-beta.0", diff --git a/src/components/Public/ButtonModal.tsx b/src/components/Public/ButtonModal.tsx new file mode 100644 index 0000000000000000000000000000000000000000..c27d29d3e3ca629777c3976fe8e4c3fbf7684118 --- /dev/null +++ b/src/components/Public/ButtonModal.tsx @@ -0,0 +1,115 @@ +import React from "react" +import { Button , Modal , Form } from "antd" +import type { ButtonProps , ModalProps , FormProps , FormInstance } from "antd" + +type IProps = { + onOk?: (_: any) => void + +} & ButtonProps & ModalProps & FormProps + +type TModalProps = { + +} & FormProps & ModalProps + +type TModalRefs = { + show: (_: any) => void; + cancel: () => void; + form: FormInstance; +} + +const ModalComponent: React.ForwardRefRenderFunction = (props , ref) => { + const { basicTitle , modalBodyRender , hasForm , layout , onCancel } = props + + const [ source ,setSource ] = React.useState(undefined) + const [ visible ,setVisible ] = React.useState(false) + + const [form] = Form.useForm() + + React.useImperativeHandle(ref , () => ({ + show (_) { + if (_) { + setSource(_) + } + setVisible(true) + }, + form, + cancel: handleCancel + })) + + const handleOk = () => { + onOk && onOk(source , cancel) + } + + const handleCancel = useCallback(() => { + setVisible(false) + setSource(false) + form.resetFields() + onCancel && onCancel() + } , []) + + React.useEffect(() => { + return () => { + handleCancel() + } + } , []) + + return ( + + + + + } + > + { + modalBodyRender && hasForm ? +
+ { modalBodyRender() } +
: + modalBodyRender() + } +
+ ) +} + +const TModal = React.forwardRef(ModalComponent) + +const ButtonModal: React.FC = (props) => { + const { onOk , onCancel } = props + + const ref = React.useRef(null) + + const handleOk = (vals: any) => { + console.log(vals) + ref.current.cancel() + } + + const handleCancel = () => { + onCancel && onCancel() + } + + return ( + <> + + + + ) +} + +export default ButtonModal \ No newline at end of file diff --git a/src/components/Public/OverflowText.tsx b/src/components/Public/OverflowText.tsx new file mode 100644 index 0000000000000000000000000000000000000000..da378acf92e98c4c5f6194f1e2ed29f2ece39c00 --- /dev/null +++ b/src/components/Public/OverflowText.tsx @@ -0,0 +1,49 @@ +import React from "react" +import { Typography , Tooltip } from "antd" + +type IProps = { + title: string; + [k: string]: any; +} + +const OverflowText: React.FC = (props) => { + const { children , style , rows = 1 ,...rest } = props + console.log(style) + + const [showTooltip, setShowTooltip] = React.useState(false) + + React.useEffect(() => { + return () => { + setShowTooltip(false) + } + } , []) + + if (showTooltip ) + return ( + + + {children} + + + ) + + return ( + setShowTooltip(true) + }} + > + {children || "-"} + + ) +} + +export default OverflowText \ No newline at end of file diff --git a/src/components/RichTextEditor/index.tsx b/src/components/RichTextEditor/index.tsx index 7cb1a3b7068016f080e8b0137a0eb2c98e127d75..18a14662458b90c07be00c42685dbb6e74a03307 100644 --- a/src/components/RichTextEditor/index.tsx +++ b/src/components/RichTextEditor/index.tsx @@ -1,14 +1,19 @@ +import React from "react" + +import { createEditor, createToolbar, SlateTransforms, IDomEditor, IEditorConfig, Boot } from '@wangeditor/editor' +import markdownModule from '@wangeditor/plugin-md' -import '@wangeditor/editor/dist/css/style.css' -import { createEditor, createToolbar, SlateTransforms, IDomEditor, IEditorConfig } from '@wangeditor/editor' import toolbarConfig from './toolbar.config' -import React from "react" import { message } from "antd" import { useSize } from "ahooks" -import styles from "./index.less" import { uploadOss } from '@/services' +import '@wangeditor/editor/dist/css/style.css' +import styles from "./index.less" + +Boot.registerModule(markdownModule) + type IProps = { onEditorChange?: (vm?: any) => void; defaultValue?: any[]; @@ -31,7 +36,7 @@ const RichTextEditor: React.FC = (props) => { const toolbar = React.useRef(null) const editor = React.useRef(null) as any - + React.useEffect(() => { const riceEditor = createEditor({ selector: editor.current, @@ -51,7 +56,7 @@ const RichTextEditor: React.FC = (props) => { selector: toolbar.current as any, config: toolbarConfig }) - + onEditorChange && onEditorChange(vm) }, onChange(vm) { diff --git a/src/pages/Outline/index.tsx b/src/pages/Outline/index.tsx index ef348e11fa7827d22ce7776009c926ca8074e612..c11dd37c1d2c79b56f7f10135df88a3e0037791b 100644 --- a/src/pages/Outline/index.tsx +++ b/src/pages/Outline/index.tsx @@ -6,6 +6,7 @@ import AddModal from './components/AddModal'; import DeleteModal from './components/DeleteModal'; import { ColumnProps } from 'antd/lib/table'; import { deleteOutline } from './services'; +import OverflowText from "@/components/Public/OverflowText" const DEFAULT_PAGE_QUERY = { page_size: 20, page_num: 1 }; @@ -37,7 +38,9 @@ const TestDemand: React.FC = () => { const data = await download(row.id); const fileContent = row.name.split('.'); const fileSuffix = fileContent[fileContent.length - 1]; + let fileAppType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + if (fileSuffix === 'doc') { fileAppType = 'application/msword'; } else if (fileSuffix == 'pdf') { @@ -46,15 +49,19 @@ const TestDemand: React.FC = () => { fileAppType = 'text/plain'; } else { } + const blob = new Blob([data], { type: fileAppType, }); + const objectURL = URL.createObjectURL(blob); const btn = document.createElement('a'); + btn.download = row.name; btn.href = objectURL; btn.click(); URL.revokeObjectURL(objectURL); + message.success('下载成功'); }; @@ -70,8 +77,10 @@ const TestDemand: React.FC = () => { { title: '备注', dataIndex: 'remark', + ellipsis: true, + width: 200, render(_, row) { - return _ || "-" + return } }, { @@ -133,6 +142,7 @@ const TestDemand: React.FC = () => { columns={columns} dataSource={dataSource?.data || []} size="small" + rowkey="id" pagination={{ total: dataSource?.total ?? 1, current: pageQuery.page_num, diff --git a/src/pages/Plan/CreatePage.tsx b/src/pages/Plan/CreatePage.tsx index 602fb869ba86d5a092cb90db3442fb80817fc64b..1ac4924f843744f70b25a2c32d96d5d1166cc812 100644 --- a/src/pages/Plan/CreatePage.tsx +++ b/src/pages/Plan/CreatePage.tsx @@ -9,6 +9,7 @@ import SuiteTable from "@/pages/Plan/components/ContentTable/Suite.table" import TaskTable from "@/pages/Plan/components/ContentTable/Task.table" import { CustomForm } from "@/components/CustomStyled" import { usePlanProvider } from "./hooks" + /** * * 测试方案 diff --git a/src/pages/Plan/hooks.ts b/src/pages/Plan/hooks.ts index e842d1198ff22caae573c5ad7ad3d0434b0516b7..4b53d1c49ac84ffce17bc0efd4e6dda7667901b4 100644 --- a/src/pages/Plan/hooks.ts +++ b/src/pages/Plan/hooks.ts @@ -10,6 +10,5 @@ export const Provider = React.createContext( ) export const usePlanProvider = () => { - const provider = React.useContext(Provider) - return provider + return React.useContext(Provider) } \ No newline at end of file