Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
c7a930b8
Commit
c7a930b8
authored
Jan 11, 2023
by
周宏民
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 富文本维护
parent
2772dbe2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
72 deletions
+38
-72
Basic.tsx
packages/base-components/RichText/src/demos/Basic.tsx
+0
-69
index.js
packages/base-components/RichText/src/index.js
+38
-3
No files found.
packages/base-components/RichText/src/demos/Basic.tsx
deleted
100644 → 0
View file @
2772dbe2
/*
* @Title:
* @Author: hongmye
* @Date: 2022-06-23 16:03:16
*/
// @ts-ignore
import
Empty
from
'@wisdom-components/empty'
;
import
{
useEffect
,
useState
}
from
'react'
;
// import BasicTable from '../index';
import
request
from
'umi-request'
;
const
Demo
=
()
=>
{
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
useEffect
(()
=>
{
fetchData
();
},
[]);
const
fetchData
=
(
params
=
{})
=>
{
request
(
`
${
baseUrl
}
/AcrossTable/GetEquipmentDataReport`
,
{
method
:
'get'
,
params
:
{},
}).
then
(
function
(
response
)
{
const
data
=
response
.
data
;
let
column
=
data
.
map
((
item
,
index
)
=>
{
return
{
title
:
`
${
item
.
DName
+
item
.
DType
}
(
${
item
.
Unit
}
)`
,
dataIndex
:
`name
${
index
}
`
,
key
:
`name
${
index
}
`
,
};
});
column
.
unshift
({
title
:
'时间'
,
dataIndex
:
'time'
,
key
:
'time'
,
});
let
dataSource
=
data
[
0
].
NameDate
.
map
((
item
,
index
)
=>
({
key
:
index
,
time
:
item
.
Time
}));
data
.
forEach
((
item
,
index
)
=>
{
item
.
NameDate
.
forEach
((
child
)
=>
{
dataSource
.
forEach
((
v
)
=>
{
if
(
child
.
Time
===
v
.
time
)
v
[
`name
${
index
}
`
]
=
child
.
Value
;
});
});
});
setColumns
(
column
);
setDataSource
(
dataSource
);
});
};
// @ts-ignore
return
(
<
div
style=
{
{
height
:
'800px'
}
}
>
{
/* {!!dataSource.length && (
<BasicTable
dataSource={dataSource}
columns={columns}
bordered={false}
pagination={{ pageSize: 20, size: 'default' }}
/>
)} */
}
{
!
dataSource
.
length
&&
<
Empty
description=
{
'暂无数据'
}
/>
}
</
div
>
);
};
export
default
Demo
;
const
baseUrl
=
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api'
;
packages/base-components/RichText/src/index.js
View file @
c7a930b8
/**
* 1.引入组件 import RichText from '@wisdom-components/RichText';
* 示例:<RichText
content={this.state.content}
personList={this.state.personList}
placeholder={'placeholder属性值'}
onChange={val => {
this.setState({ content: val });
}}
onChangeFile={arr => {
this.setState({ fileList: arr });
}}
fileList={this.state.fileList}
projectId={19}
ref={this.myRichText}
/>
*
* 2.传递方法 onChange 每次更改内容回调
*
* 3.传值接收 可选值 projectId 项目id,根据项目id获取项目参与人员,
* 可选值 personList 人员列表 示例:[{userId:1,userName:'xxx'}]
* 可选值 config 框架wangEditor的配置参数
*
* 4.注意事项 projectId和personList只用传一个,projectId优先级高于personList
* content内容如果不是初始有的,可调用setHtml设置内容
*
* 2022-03-21新增图片预览,附件上传功能
* 新增方法:onChangeFile 每次附件更改回调 若不传则不显示附件上传按钮
* fileList 附件列表 示例:[{name:'xxx.jpg',type:'image/jpg',size:8192,path:'xxxx'}]
* 其中name和path是必传的,type为图片可以预览,其它类型文件直接下载
*
* 2022-04-29 修改@人员列表逻辑
* personList 传任务相关人员列表(如 创建、负责、跟进人),同时传入projectId,personList
* 下拉列表默认显示为任务相关人员,加项目人员(做了去重,任务相关人员在最上面)
* @搜索时,搜索全部人员
*/
import
{
Image
,
message
,
Spin
}
from
'antd'
;
import
classNames
from
'classnames'
;
import
{
forwardRef
,
useEffect
,
useImperativeHandle
,
useRef
,
useState
}
from
'react'
;
...
...
@@ -188,7 +226,6 @@ const RichText = forwardRef((props, ref) => {
return
;
}
range
.
setEnd
(
selection
.
getRangeAt
(
0
).
commonAncestorContainer
,
selection
.
focusOffset
);
// console.log('🚀 ~ range', range.toString(), tempList, selectList);
const
str
=
range
.
toString
()
||
''
;
moveListBox
();
handleChange
(
str
,
tempList
);
...
...
@@ -239,7 +276,6 @@ const RichText = forwardRef((props, ref) => {
}
if
(
evet
.
key
===
'Enter'
)
{
// 解决无法回车换行的bug
console
.
log
(
selectBoxRef
.
current
.
style
.
display
===
'block'
);
if
(
selectBoxRef
.
current
.
style
.
display
===
'block'
)
{
evet
.
preventDefault
();
if
(
selectPerson
[
selectPersonIndex
])
{
...
...
@@ -346,7 +382,6 @@ const RichText = forwardRef((props, ref) => {
}
};
const
handleChange
=
(
val
,
list
)
=>
{
console
.
log
(
'🚀 ~ val'
,
val
);
if
(
timer
)
{
clearTimeout
(
timer
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment