2019-11-29 12:51:58 +08:00
|
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
2020-03-11 15:10:08 +08:00
|
|
|
import {isShowThePrdType} from '../../utils/handlePath';
|
2019-11-29 12:51:58 +08:00
|
|
|
|
|
|
|
export default class Text2 extends Group {
|
2020-03-09 17:38:15 +08:00
|
|
|
constructor(model, style) {
|
|
|
|
super();
|
|
|
|
this._code = model.code;
|
|
|
|
this._type = model._type;
|
|
|
|
this.name = model.code;
|
|
|
|
this.zlevel = model.zlevel;
|
|
|
|
this.model = model;
|
|
|
|
this.style = style;
|
|
|
|
this.z = 6;
|
2020-03-11 10:53:09 +08:00
|
|
|
if (isShowThePrdType(model.prdType, model.showConditions) || model.previewOrMapDraw) {
|
2020-03-10 09:49:05 +08:00
|
|
|
this.create();
|
|
|
|
this.setState(model);
|
|
|
|
}
|
2020-03-11 10:53:09 +08:00
|
|
|
if (model.previewOrMapDraw) {
|
|
|
|
this.setShowMode();
|
|
|
|
}
|
2020-03-09 17:38:15 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
create() {
|
|
|
|
var model = this.model;
|
|
|
|
var [direction, content] = model.content.split('::');
|
|
|
|
if (direction == 'V') {
|
|
|
|
content = content.split('').join('\n');
|
|
|
|
} else if (direction != 'H') {
|
|
|
|
content = model.content;
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
this.text = new Text({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
style: {
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
|
|
|
text: content,
|
|
|
|
textFont: model.font,
|
|
|
|
textFill: model.fontColor,
|
|
|
|
textAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.text);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
setState(model) {
|
|
|
|
}
|
2020-03-11 15:10:08 +08:00
|
|
|
// 设置显示模式
|
2020-03-11 10:53:09 +08:00
|
|
|
setShowMode() {
|
|
|
|
const showMode = this.model.showMode;
|
2020-03-11 15:10:08 +08:00
|
|
|
const showConditions = this.model.showConditions;
|
2020-03-11 10:53:09 +08:00
|
|
|
if (!showConditions || showConditions === '01' || showMode === showConditions) {
|
2020-03-11 15:10:08 +08:00
|
|
|
this.text && this.text.show();
|
2020-03-11 10:53:09 +08:00
|
|
|
} else {
|
2020-03-11 15:10:08 +08:00
|
|
|
this.text && this.text.hide();
|
2020-03-11 10:53:09 +08:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|