| | |
| | | elements: PropTypes.array, // 元素集 |
| | | } |
| | | |
| | | state = { |
| | | card: null, // 编辑中元素 |
| | | elements: null, // 按钮组 |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件初始化 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { elements } = this.props |
| | | |
| | | this.setState({ |
| | | elements: fromJS(elements).toJS() |
| | | }) |
| | | } |
| | | state = {} |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps)) |
| | |
| | | return color |
| | | } |
| | | |
| | | getContent = (card) => { |
| | | const { data, cards } = this.props |
| | | getContent = () => { |
| | | const { data, cards, elements } = this.props |
| | | |
| | | let contents = [] |
| | | |
| | | elements.forEach(card => { |
| | | if (card.eleType === 'sequence') { |
| | | let _style = {} |
| | | if (card.marks) { |
| | |
| | | |
| | | _style = mark.style |
| | | } |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | <div className="ant-mk-text"><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div> |
| | |
| | | _style.backgroundImage = `url('${data[card.bgImage]}')` |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | |
| | | } |
| | | |
| | | if (typeof(val) === 'number') { |
| | | if (card.round) { |
| | | val = Math.round(val * card.round) / card.round |
| | | } |
| | | if (card.format === 'percent') { |
| | | val = val * 100 |
| | | } else if (card.format === 'abs') { |
| | | val = Math.abs(val) |
| | | } |
| | | |
| | | if (typeof(card.decimal) === 'number') { |
| | | let decimal = card.decimal |
| | | |
| | | if (card.format === 'percent') { |
| | | decimal = decimal - 2 |
| | | } |
| | | if (decimal < 0) { |
| | | decimal = 0 |
| | | } |
| | | |
| | | val = val.toFixed(decimal) |
| | | if (card.round) { |
| | | val = val.toFixed(card.decimal) |
| | | } else { |
| | | val = '' + val |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | |
| | | val = data[card.field] |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | {val ? <Tooltip title={val}> |
| | |
| | | color = _color ? _color : color |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | <MkProgress value={val} config={card} color={color}/> |
| | |
| | | return null |
| | | } |
| | | |
| | | if (url) { |
| | | _imagestyle = {backgroundImage: `url('${url}')`} |
| | | } else { |
| | | _imagestyle = {backgroundImage: `url(${LostPng})`, backgroundSize: 'contain'} |
| | | } |
| | | |
| | | if (_style.borderRadius) { |
| | | _imagestyle.borderRadius = _style.borderRadius |
| | | } |
| | |
| | | } |
| | | |
| | | let scale = url && card.scale === 'true' |
| | | let urls = url ? url.split(',').filter(Boolean) : [LostPng] |
| | | |
| | | return ( |
| | | <Col key={card.uuid} span={card.width}> |
| | | if (!url) { |
| | | _imagestyle = {backgroundSize: 'contain'} |
| | | } |
| | | |
| | | urls.forEach((u, i) => { |
| | | contents.push(<Col key={card.uuid + i} span={card.width}> |
| | | <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> |
| | | <div |
| | | className={'ant-mk-picture' + (scale ? ' scale' : '')} |
| | | onClick={(e) => { |
| | | if (scale) { |
| | | e.stopPropagation() |
| | | } else { |
| | | return |
| | | } |
| | | if (!scale) return |
| | | |
| | | MKEmitter.emit('mkImageScale', url) |
| | | e.stopPropagation() |
| | | |
| | | MKEmitter.emit('mkImageScale', url, urls) |
| | | }} |
| | | style={_imagestyle} |
| | | style={{..._imagestyle, backgroundImage: `url('${u}')`}} |
| | | ></div> |
| | | </div> |
| | | </Col> |
| | | ) |
| | | </Col>) |
| | | }) |
| | | } else if (card.eleType === 'splitline') { |
| | | let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width} style={{minHeight: _borderWidth}}> |
| | | <div style={card.style}> |
| | | <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div> |
| | |
| | | return null |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | <div style={{height: card.innerHeight || 25}}> |
| | |
| | | poster = card.posterUrl || '' |
| | | } |
| | | |
| | | return ( |
| | | <Col key={card.uuid} span={card.width}> |
| | | let urls = url.split(',').filter(Boolean) |
| | | |
| | | urls.forEach((u, i) => { |
| | | contents.push( |
| | | <Col key={card.uuid + i} span={card.width}> |
| | | <div className="video-wrap" style={card.style}> |
| | | <Video card={card} poster={poster} value={url}/> |
| | | <Video card={card} poster={poster} value={u}/> |
| | | </div> |
| | | </Col> |
| | | ) |
| | | }) |
| | | } else if (card.eleType === 'qrcode') { |
| | | let val = '' |
| | | |
| | |
| | | return null |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | <div style={{minHeight: card.qrWidth || 50}}> |
| | |
| | | val = `${card.prefix || ''}${val}${card.postfix || ''}` |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className="ant-mk-date" style={card.style}> |
| | | {val} |
| | |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | |
| | | } |
| | | |
| | | if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <NormalButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.OpenType === 'excelIn') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <ExcelInButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.OpenType === 'excelOut') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <ExcelOutButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.OpenType === 'popview') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <PopupButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.OpenType === 'tab') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <TabButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.OpenType === 'innerpage') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <NewPageButton |
| | | btn={card} |
| | |
| | | ) |
| | | } else if (card.OpenType === 'funcbutton') { |
| | | if (card.funcType === 'changeuser' || card.funcType === 'closetab') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <ChangeUserButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.funcType === 'print') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <PrintButton |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.funcType === 'megvii') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <FuncMegvii |
| | | btn={card} |
| | |
| | | </Col> |
| | | ) |
| | | } else if (card.funcType === 'filezip') { |
| | | return ( |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <FuncZip |
| | | btn={card} |
| | |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | |
| | | return null |
| | | return contents |
| | | } |
| | | |
| | | render() { |
| | | const { elements } = this.state |
| | | |
| | | return ( |
| | | <div className="card-cell-list"> |
| | | {elements.map(item => this.getContent(item))} |
| | | {this.getContent()} |
| | | </div> |
| | | ) |
| | | } |