Commit 9a5c9d78 authored by 周宏民's avatar 周宏民

fix: 富文本组件搜索人员出错

parent 9a46a6e1
Pipeline #54014 failed with stages
in 5 seconds
...@@ -47,7 +47,7 @@ const RichText = forwardRef((props, ref) => { ...@@ -47,7 +47,7 @@ const RichText = forwardRef((props, ref) => {
method: 'get', method: 'get',
params: {}, params: {},
}).then((res) => { }).then((res) => {
setSelectList(res?.data?.data || []); allPeople = res?.data?.data || [];
}); });
}; };
// 图片上传 // 图片上传
...@@ -168,7 +168,7 @@ const RichText = forwardRef((props, ref) => { ...@@ -168,7 +168,7 @@ const RichText = forwardRef((props, ref) => {
} }
}); });
editor.txt.eventHooks.imgClickEvents.push((e) => { }); editor.txt.eventHooks.imgClickEvents.push((e) => {});
// 粘贴图片上传 // 粘贴图片上传
editor.txt.eventHooks.pasteEvents.push((e) => { editor.txt.eventHooks.pasteEvents.push((e) => {
const file = e?.clipboardData?.items[0]?.getAsFile() || null; const file = e?.clipboardData?.items[0]?.getAsFile() || null;
...@@ -220,8 +220,8 @@ const RichText = forwardRef((props, ref) => { ...@@ -220,8 +220,8 @@ const RichText = forwardRef((props, ref) => {
const keyDownEvent = (evet) => { const keyDownEvent = (evet) => {
// 上下方向键 // 上下方向键
if (evet.key === 'ArrowDown' || evet.key === 'ArrowUp') { if (evet.key === 'ArrowDown' || evet.key === 'ArrowUp') {
evet.preventDefault();
if (selectBoxRef.current?.style?.display === 'block') { if (selectBoxRef.current?.style?.display === 'block') {
evet.preventDefault();
const max = selectBoxRef.current.querySelectorAll('.selectItem')?.length || 1000; const max = selectBoxRef.current.querySelectorAll('.selectItem')?.length || 1000;
let val = selectPersonIndex; let val = selectPersonIndex;
if (evet.key === 'ArrowDown') { if (evet.key === 'ArrowDown') {
...@@ -240,7 +240,7 @@ const RichText = forwardRef((props, ref) => { ...@@ -240,7 +240,7 @@ const RichText = forwardRef((props, ref) => {
} }
if (evet.key === 'Enter') { if (evet.key === 'Enter') {
// 解决无法回车换行的bug // 解决无法回车换行的bug
console.log(selectBoxRef.current.style.display === 'block',) console.log(selectBoxRef.current.style.display === 'block');
if (selectBoxRef.current.style.display === 'block') { if (selectBoxRef.current.style.display === 'block') {
evet.preventDefault(); evet.preventDefault();
if (selectPerson[selectPersonIndex]) { if (selectPerson[selectPersonIndex]) {
...@@ -252,11 +252,11 @@ const RichText = forwardRef((props, ref) => { ...@@ -252,11 +252,11 @@ const RichText = forwardRef((props, ref) => {
}; };
useEffect(() => { useEffect(() => {
richTextRef.current && richTextRef.current.removeEventListener('input', (e) => { }); richTextRef.current && richTextRef.current.removeEventListener('input', (e) => {});
init(); init();
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;
}; };
...@@ -347,6 +347,7 @@ const RichText = forwardRef((props, ref) => { ...@@ -347,6 +347,7 @@ const RichText = forwardRef((props, ref) => {
} }
}; };
const handleChange = (val, list) => { const handleChange = (val, list) => {
console.log('🚀 ~ val', val);
if (timer) { if (timer) {
clearTimeout(timer); clearTimeout(timer);
} }
...@@ -377,24 +378,25 @@ const RichText = forwardRef((props, ref) => { ...@@ -377,24 +378,25 @@ const RichText = forwardRef((props, ref) => {
request(API.POST_UPLOADERFILES, { request(API.POST_UPLOADERFILES, {
method: 'POST', method: 'POST',
data: formData, data: formData,
}).then((res) => {
if (res.data) {
const arr = [...fileList];
const url = res.data.replace(/[\\ \/=]/g, '/');
arr.unshift({
name: file.name,
type: file.type ? file.type.toLowerCase() : '',
size: file.size,
path: `${API.GET_DOWNLOADFILES}?filePath=${url}`,
});
// setFileList(arr);
props.onChangeFile(arr);
setLoading(false);
} else {
message.error(res.msg);
setLoading(false);
}
}) })
.then((res) => {
if (res.data) {
const arr = [...fileList];
const url = res.data.replace(/[\\ \/=]/g, '/');
arr.unshift({
name: file.name,
type: file.type ? file.type.toLowerCase() : '',
size: file.size,
path: `${API.GET_DOWNLOADFILES}?filePath=${url}`,
});
// setFileList(arr);
props.onChangeFile(arr);
setLoading(false);
} else {
message.error(res.msg);
setLoading(false);
}
})
.catch((err) => { .catch((err) => {
setLoading(false); setLoading(false);
}); });
......
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