index.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React, { Component } from "react";
  2. import styles from "../index.less";
  3. import $ from 'jquery';
  4. import { windowEventHandler,setFontColorSize } from '@utils/tools';
  5. class AssistName extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. };
  10. this.$assistName = React.createRef();
  11. this.splitName = this.splitName.bind(this);
  12. }
  13. splitName(name){
  14. let wid = this.props.winWidth;
  15. if(name.length>15 && wid>1150){
  16. let tmpStr = name.substr(0,15)
  17. return tmpStr+'...'
  18. }else{
  19. return name
  20. }
  21. }
  22. render() {
  23. const { winWidth, name, getInfomation,normal } = this.props;
  24. return (
  25. <span className={`${styles.assistName} ${setFontColorSize(2)}`} style={{ width: winWidth < 1150 ? '120px' : 'auto',fontWeight:normal?'normal':'bold' }} ref={this.$assistName}>
  26. <span className={styles.tagSpan} title={name}>
  27. {name&&this.splitName(name)}:
  28. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={() => getInfomation({ name: name, position: 1, type: 6 })}></span>
  29. </span>
  30. </span>
  31. );
  32. }
  33. }
  34. export default AssistName;