From a6b6c20ffee891235a8c0abdd17152c4916e6c4c Mon Sep 17 00:00:00 2001 From: Lhk0001 <2406661616@qq.com> Date: Thu, 23 Nov 2023 13:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A4=A7=E8=87=B4=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8=EF=BC=88=E5=9B=A0?= =?UTF-8?q?=E4=B8=BA=E6=9C=AC=E5=9C=B0=E4=B8=8B=E8=BD=BD=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E5=87=BA=E9=94=99=EF=BC=8C=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E5=85=88=E7=94=A8=E4=BA=91=E5=8A=A0=E8=BD=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/system/notice/publish/index.scss | 3 + src/view/system/notice/publish/index.tsx | 210 +++++++++++++++------- 2 files changed, 149 insertions(+), 64 deletions(-) diff --git a/src/view/system/notice/publish/index.scss b/src/view/system/notice/publish/index.scss index 6b4f8f6..d233156 100644 --- a/src/view/system/notice/publish/index.scss +++ b/src/view/system/notice/publish/index.scss @@ -58,4 +58,7 @@ height: 20px; margin-right: 10px; } +} +.tox,.tox-tinymce{ + width: 700px; } \ No newline at end of file diff --git a/src/view/system/notice/publish/index.tsx b/src/view/system/notice/publish/index.tsx index def0a7d..c9fdaf2 100644 --- a/src/view/system/notice/publish/index.tsx +++ b/src/view/system/notice/publish/index.tsx @@ -3,7 +3,6 @@ import { Button, Input, Select, - DatePicker, message, Table, Tag, @@ -16,6 +15,7 @@ import { Col, TreeSelect, } from "antd"; +import { Editor } from "@tinymce/tinymce-react"; import type { ColumnsType } from "antd/es/table"; import { SyncOutlined, @@ -59,7 +59,18 @@ interface TableDataType { key?: number; total?: number; } - +interface dataType { + senders: string[]; + cluster?: string | null; + createBy?: string | null; + contentType?: string | null; + noticeContent: string; + noticeId?: number | null; + noticeTitle?: string | null; + noticeType?: string | null; + sendType?: string | null; + state?: string | null; +} //当前选择的角色信息 interface queryParamsType { cluster?: string; @@ -73,6 +84,32 @@ interface queryParamsType { } let thisrole: any = {}; export default function Inform() { + const editorInit = { + // selector:'textarea', + min_width: 600, + min_height: 500, + language: "zh_CN", + plugins: + "print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template code codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount imagetools textpattern help emoticons autosave bdmap indent2em autoresize formatpainter axupimgs", + toolbar: + ["code undo redo restoredraft | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link | anchor | alignleft aligncenter alignright alignjustify outdent indent | \ + styleselect formatselect fontselect fontsizeselect | bullist numlist | blockquote subscript superscript removeformat | \ + table image media charmap emoticons hr pagebreak insertdatetime print preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs"], + + importcss_append: true, + //自定义文件选择器的回调内容 + // file_picker_callback: function (callback, value, meta) { + // if (meta.filetype === 'file') { + // callback('https://www.baidu.com/img/bd_logo1.png', { text: 'My text' }); + // } + // if (meta.filetype === 'image') { + // callback('https://www.baidu.com/img/bd_logo1.png', { alt: 'My alt text' }); + // } + // if (meta.filetype === 'media') { + // callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.baidu.com/img/bd_logo1.png' }); + // } + // } + }; const { confirm } = Modal; //提示组件 const [messageApi, contextHolder] = message.useMessage(); @@ -86,7 +123,12 @@ export default function Inform() { endTime: undefined, }); - const [thisNotice,setThisNotice]=useState({}) + const [thisNotice, setThisNotice] = useState({ + noticeContent: "", + senders: [], + }); + + const [allDisplay,setAllDisplay]=useState('block') //Modal const [isModalOpen, setIsModalOpen] = useState(false); const [isDetailModalOpen, setIsDetailModalOpen] = useState(false); @@ -103,6 +145,7 @@ export default function Inform() { //发送对象数据 const [senderIds, setSenderIds] = useState(undefined); + const [editorValue,setEditorValue]=useState('') //表格数据总条数 let [total, setTotal] = useState(0); //表格格式 @@ -197,15 +240,27 @@ export default function Inform() { console.log(value); if (value === "user") { getUserList(); + setAllDisplay('block') } else if (value === "role") { getRolesList(); + setAllDisplay('block') } else if (value === "dept") { getDeptsList(); + setAllDisplay('block') + } + else { + setAllDisplay('none') } }; + const onEditorChange=(Value:string)=>{ + setEditorValue(Value) + + } // let thisrole: any = {roleId:'s'}; - const handleDetail = (text:any) => { - getData(text.noticeId) + const handleDetail = (text: any) => { + getData(text.noticeId); + + // console.log(thisNotice.); setIsDetailModalOpen(true); }; const handleDelete = (text: any) => { @@ -240,14 +295,14 @@ export default function Inform() { }; const handleSerach = () => { searchValue = formSearch.getFieldsValue(); - setSearchValue(searchValue) + setSearchValue(searchValue); count = 1; setQueryTableDataParams({ ...searchValue }); }; const handleReset = () => { formSearch.resetFields(); searchValue = formSearch.getFieldsValue(); - setSearchValue(searchValue) + setSearchValue(searchValue); setQueryTableDataParams({ ...searchValue }); }; //Modal区域 @@ -256,9 +311,11 @@ export default function Inform() { .validateFields() .then((values) => { // form.resetFields(); - console.log("add", values); if (modalTitle == "新增公告") { - postAdd({ ...values, cluster: "notice", action: "SEND" }); + if(values.sendType==='all') values.senderIds=['0'] + console.log(values); + + postAdd({ ...values, cluster: "notice", action: "SEND" ,noticeContent:editorValue}); } }) .catch((info) => { @@ -283,6 +340,8 @@ export default function Inform() { senderIds: undefined, contentType: "html", }); + setAllDisplay('block'); + setEditorValue('') setIsModalOpen(true); }; const filterOption = ( @@ -328,17 +387,16 @@ export default function Inform() { } } catch (error) {} }; - const getData =async(noticeId:number)=>{ + const getData = async (noticeId: number) => { try { - const {data,code}=await getDataAPI(noticeId); - if(code===1000){ - setThisNotice({...data}) + const { data, code } = await getDataAPI(noticeId); + if (code === 1000) { + setThisNotice({ ...data }); } } catch (error) { console.log(error); - } - } + }; const getTree = function (tree: any) { tree.title = tree.deptName; tree.value = tree.deptId; @@ -390,7 +448,6 @@ export default function Inform() { } console.log(data); setSenderIds([...data]); - // setTotal(data.total); } } catch (err: any) { console.log("555", err); @@ -415,6 +472,7 @@ export default function Inform() { console.log("555", err); } }; + useEffect(() => { // setQueryParams({...queryParams,...valueSch}) queryTableDataParams = { @@ -626,8 +684,8 @@ export default function Inform() { /> - - { + allDisplay==='block'? )} + :null + } + + + + + + 富文本 + + 文本 + + + - - - - 富文本 - - 文本 - + + +
+ onEditorChange(Value)} + > +
+ +
- - {thisNotice.noticeTitle} - - {thisNotice.sendType==='user'?'用户':thisNotice.sendType==='role'?'角色': - thisNotice.sendType==='dept'?'部门':'全发'} + + {" "} + {thisNotice.sendType === "user" + ? "用户" + : thisNotice.sendType === "role" + ? "角色" + : thisNotice.sendType === "dept" + ? "部门" + : "全发"} + - - + + {thisNotice.senders.join(",")} - - {thisNotice.noticeType==='1'?通知:公告} + + + {thisNotice.noticeType === "1" ? ( + 通知 + ) : ( + 公告 + )} + - - {thisNotice.contentType==='html'?富文本:文本} + + + {thisNotice.contentType === "html" ? ( + 富文本 + ) : ( + 文本 + )} + - - + +