| | |
| | | let contents = [] |
| | | let images = [] |
| | | |
| | | item.subColumn.forEach(col => { |
| | | item.subColumn.forEach((col, index) => { |
| | | if (!col.field || !record.hasOwnProperty(col.field)) return |
| | | if (index) { |
| | | col.Align = 'right' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | let content = '' |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } else if (col.type === 'picture') { |
| | | let photos = [] |
| | | try { |
| | |
| | | } |
| | | |
| | | photos.forEach(photo => { |
| | | images.push({url: photo, scale: col.scale === 'true', maxHeight: col.maxHeight || 128}) |
| | | images.push({url: photo, align: col.Align, scale: col.scale === 'true', maxHeight: col.maxHeight || 128}) |
| | | }) |
| | | } else if (col.type === 'text') { |
| | | let content = record[col.field] |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } else if (col.type === 'link') { |
| | | let content = col.nameField ? record[col.nameField] : '' |
| | | let _href = record[col.field] || '' |
| | |
| | | |
| | | content = _href ? <a href={_href} target="_blank" rel="noopener noreferrer">{content}</a> : null |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } else { |
| | | let content = record[col.field] |
| | | |
| | |
| | | content = md5(content) |
| | | } |
| | | |
| | | contents.push(content) |
| | | contents.push({content, align: col.Align}) |
| | | } |
| | | }) |
| | | |
| | |
| | | |
| | | getCospanContent = (type, contents, images) => { |
| | | if (type === 'vertical') { |
| | | return contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | return contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | }) |
| | | } else if (type === 'horizontal') { |
| | | return contents.map((content, index) => { |
| | |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-left"> |
| | | {contents.map((content, index) => { |
| | | {contents.map((cont, index) => { |
| | | if (index % 2 === 0) { |
| | | return (<p key={index}>{content}</p>) |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | } else { |
| | | return '' |
| | | } |
| | | })} |
| | | </div> |
| | | <div className="content-fence-right"> |
| | | {contents.map((content, index) => { |
| | | {contents.map((cont, index) => { |
| | | if (index % 2 === 1) { |
| | | return (<p key={index}>{content}</p>) |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | } else { |
| | | return '' |
| | | } |
| | |
| | | } else if (type === 'topPicBottomText') { |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-top"> |
| | | <div className="content-fence-top" style={images[0] ? {textAlign: images[0].align} : null}> |
| | | {images.map((_img, index) => { |
| | | if (!_img.url) return '' |
| | | if (_img.scale) { |
| | |
| | | })} |
| | | </div> |
| | | <div className="content-fence-bottom"> |
| | | {contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | {contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | })} |
| | | </div> |
| | | </div> |
| | |
| | | } else if (type === 'leftPicRightText') { |
| | | return ( |
| | | <div className="content-fence"> |
| | | <div className="content-fence-left"> |
| | | <div className="content-fence-left" style={images[0] ? {textAlign: images[0].align} : null}> |
| | | {images.map((_img, index) => { |
| | | if (!_img.url) return '' |
| | | if (_img.scale) { |
| | |
| | | })} |
| | | </div> |
| | | <div className="content-fence-right"> |
| | | {contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | {contents.map((cont, index) => { |
| | | return (<p key={index} style={{textAlign: cont.align}}>{cont.content}</p>) |
| | | })} |
| | | </div> |
| | | </div> |