Skip to content

Commit d2b32e9

Browse files
author
yanjun.zsj
committed
4、连线的样式可以通过样式覆盖的方式修改,但是关闭按钮是图片,修改不了,现增加一个icon属性可以覆盖原图片,img url
1 parent 15a2be6 commit d2b32e9

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/drawLines.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class DrawLines extends Component {
146146
}
147147
render() {
148148
const { startX, startY, drawing, endX, endY } = this.state;
149-
const { relation, currentRelation, edit } = this.props;
149+
const { relation, currentRelation, edit, closeIcon } = this.props;
150150
return <div className="lines-area" ref={me => {this.drawEle = me;}}>
151151
<svg width="100%" height="100%" version="1.1"
152152
xmlns="http://www.w3.org/2000/svg">
@@ -173,6 +173,7 @@ class DrawLines extends Component {
173173
endY={item.target.y}
174174
data={item}
175175
edit={edit}
176+
closeIcon={closeIcon}
176177
toTop={this.topLine.bind(this)}
177178
currentRelation={currentRelation}
178179
removeRelation={this.removeRelation.bind(this)}
@@ -204,7 +205,8 @@ DrawLines.propTypes = {
204205
edit: PropTypes.bool.isRequired,
205206
currentRelation: PropTypes.object.isRequired,
206207
onChange: PropTypes.func.isRequired,
207-
changeIconStatus: PropTypes.func.isRequired
208+
changeIconStatus: PropTypes.func.isRequired,
209+
closeIcon: PropTypes.string
208210
};
209211
DrawLines.defaultProps = {
210212
onDrawStart: () => {},

src/fieldMapping.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class FieldMapping extends Component {
117117
onDrawStart,
118118
onDrawing,
119119
onDrawEnd,
120-
edit
120+
edit,
121+
closeIcon
121122
} = this.props;
122123
const sourceOpt = {
123124
ref: (me) => {this.sourceCom = me;},
@@ -153,6 +154,7 @@ class FieldMapping extends Component {
153154
onDrawEnd,
154155
relation,
155156
edit,
157+
closeIcon,
156158
currentRelation,
157159
onChange: this.changeRelation.bind(this),
158160
changeIconStatus: this.changeIconStatus.bind(this)
@@ -206,7 +208,8 @@ FieldMapping.propTypes = {
206208
onDrawStart: PropTypes.func,// function(params=source, relation)
207209
onDrawing: PropTypes.func,// function(params=source, relation)
208210
onDrawEnd: PropTypes.func,// function(params=source, relation)
209-
edit: PropTypes.bool // 是否能操作线条编辑 default true
211+
edit: PropTypes.bool, // 是否能操作线条编辑 default true
212+
closeIcon: PropTypes.string // 关闭线条的icon url,不传用默认的关闭按钮
210213
};
211214
FieldMapping.defaultProps = {
212215
relation: [],

src/line.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class Line extends Component {
2020
endY = 0,
2121
currentRelation,
2222
data,
23-
edit
23+
edit,
24+
closeIcon
2425
} = this.props;
2526
return <g className={`path-end ${(currentRelation === data) ? "active" : ""} ${edit ? '' : 'disabled'}`} onMouseOver={() => {
2627
edit && this.props.toTop(this.props.data);
@@ -38,7 +39,7 @@ class Line extends Component {
3839
y={(endY + startY - iconSize[1])/2}
3940
width={iconSize[0]}
4041
height={iconSize[1]}
41-
xlinkHref="//img.alicdn.com/tfs/TB1laCNsXYqK1RjSZLeXXbXppXa-200-200.png" />
42+
xlinkHref={closeIcon || "//img.alicdn.com/tfs/TB1laCNsXYqK1RjSZLeXXbXppXa-200-200.png"} />
4243
</g>;
4344
}
4445
}
@@ -51,6 +52,7 @@ Line.propTypes = {
5152
edit: PropTypes.bool.isRequired,
5253
toTop: PropTypes.func.isRequired,
5354
currentRelation: PropTypes.object.isRequired,
54-
removeRelation: PropTypes.func.isRequired
55+
removeRelation: PropTypes.func.isRequired,
56+
closeIcon: PropTypes.string
5557
};
5658
export default Line;

0 commit comments

Comments
 (0)