Commit 5daa86ca authored by 周宏民's avatar 周宏民

fix: 富文本组件服务修改

parent 48f48f4d
Pipeline #53993 failed with stages
in 4 seconds
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"*.less" "*.less"
], ],
"module": "es/index.js", "module": "es/index.js",
"main": "lib/index.js", "main": "es/index.js",
"files": [ "files": [
"lib", "lib",
"es", "es",
......
import { Image, message, Spin } from 'antd'; import { Image, message, Spin } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'; import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
// import { request } from '@wisdom-utils/utils';
import request from 'umi-request'; import request from 'umi-request';
import WangEditor from './wangEditor.js';
// import { API } from '@/api/service/workflow';
const API = {};
// import { appWork, projectManageService } from '@/api';
import FileListItem from './fileListItem'; import FileListItem from './fileListItem';
import styles from './index.less'; import styles from './index.less';
import WangEditor from './wangEditor.js';
const baseUrl = '';
const API = {
POST_UPLOADERFILES: `${baseUrl}/PandaWorkFlow/WorkFlow/AccountManage/UploaderFiles`,
GET_DOWNLOADFILES: `${baseUrl}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles`,
GET_GETALLPERSONNELS: `${baseUrl}/PandaInformatization/PandaWork/MeetingTask/GetAllPersonnels`, // 获取人员
GET_WORKHOURUSERLIST: `${baseUrl}/PandaInformatization/PandaWork/ProjectManage/GetWorkHourUserList`, //根据项目id获取项目参与人员
};
let editor = null; let editor = null;
let range; let range;
const selection = window.getSelection(); const selection = window.getSelection();
...@@ -20,7 +24,6 @@ let selectPerson = []; ...@@ -20,7 +24,6 @@ let selectPerson = [];
const RichText = forwardRef((props, ref) => { const RichText = forwardRef((props, ref) => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [zIndex, setZIndex] = useState(500); const [zIndex, setZIndex] = useState(500);
// const [inputValue, setInputValue] = useState('');
const [selectIndex, setSelectIndex] = useState(null); const [selectIndex, setSelectIndex] = useState(null);
const [selectList, setSelectList] = useState([]); const [selectList, setSelectList] = useState([]);
const [selectSearchList, setSelectSearchList] = useState([]); const [selectSearchList, setSelectSearchList] = useState([]);
...@@ -30,27 +33,37 @@ const RichText = forwardRef((props, ref) => { ...@@ -30,27 +33,37 @@ const RichText = forwardRef((props, ref) => {
const richTextRef = useRef(); const richTextRef = useRef();
const selectBoxRef = useRef(); const selectBoxRef = useRef();
const fileInputRef = useRef(); const fileInputRef = useRef();
const getData = async () => { const getData = () => {
// const { data } = await projectManageService.GetWorkHourUserList({ projectId: props.projectId }); request(API.GET_WORKHOURUSERLIST, {
// setSelectList(data); method: 'get',
params: { projectId: props.projectId },
}).then((res) => {
setSelectList(res.data || []);
});
}; };
// 获取全部人员信息 // 获取全部人员信息
const getAllPeople = async () => { const getAllPeople = async () => {
// const res = await appWork.GetAllPersonnels(); request(API.GET_GETALLPERSONNELS, {
// allPeople = res?.data?.data || []; method: 'get',
params: {},
}).then((res) => {
setSelectList(res?.data?.data || []);
});
}; };
// 图片上传 // 图片上传
const uploadImg = (file) => { const uploadImg = (file) => {
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
setLoading(true); setLoading(true);
request({ request(API.POST_UPLOADERFILES, {
url: API.POST_UPLOADERFILES,
method: 'POST', method: 'POST',
data: formData, data: formData,
}) })
.then((res) => { .then((res) => {
if (!res.data) return; if (!res.data) {
setLoading(false);
return;
}
const img = res.data.replace(/[\\ \/=]/g, '/'); const img = res.data.replace(/[\\ \/=]/g, '/');
const imgHtml = ` const imgHtml = `
<img contenteditable="false" style="display: block;" width="50%" src="${API.GET_DOWNLOADFILES}?filePath=${img}" > <img contenteditable="false" style="display: block;" width="50%" src="${API.GET_DOWNLOADFILES}?filePath=${img}" >
...@@ -243,7 +256,6 @@ const RichText = forwardRef((props, ref) => { ...@@ -243,7 +256,6 @@ const RichText = forwardRef((props, ref) => {
getAllPeople(); getAllPeople();
return () => { return () => {
richTextRef.current && richTextRef.current.removeEventListener('input', (e) => {}); richTextRef.current && richTextRef.current.removeEventListener('input', (e) => {});
editor && editor.destroy(); editor && editor.destroy();
editor = null; editor = null;
}; };
...@@ -281,11 +293,7 @@ const RichText = forwardRef((props, ref) => { ...@@ -281,11 +293,7 @@ const RichText = forwardRef((props, ref) => {
tempList = arr; tempList = arr;
setSelectSearchList(arr); setSelectSearchList(arr);
}, [selectList, props.personList]); }, [selectList, props.personList]);
// useEffect(() => {
// if (!props.projectId) {
// setSelectList(props.personList || []);
// }
// }, [props.personList]);
useEffect(() => { useEffect(() => {
setFileList(props.fileList); setFileList(props.fileList);
}, [props.fileList]); }, [props.fileList]);
...@@ -322,10 +330,6 @@ const RichText = forwardRef((props, ref) => { ...@@ -322,10 +330,6 @@ const RichText = forwardRef((props, ref) => {
selection.collapseToEnd(); selection.collapseToEnd();
} }
}; };
// const onChange = val => {
// setInputValue(val.currentTarget.value);
// handleChange(val.currentTarget.value);
// };
let timer = null; let timer = null;
const filterList = (val, list) => { const filterList = (val, list) => {
if (!val) { if (!val) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment