| | |
| | | </div> |
| | | ) |
| | | } else if (item.type === 'colspan') { |
| | | let contents = '' |
| | | if (item.subColumn.length > 0) { |
| | | contents = item.subColumn.map(col => { |
| | | let content = '' |
| | | if (col.type === 'text' || col.type === 'textarea') { |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | content = `${record[col.field]}` |
| | | } |
| | | if (item.subColumn.length === 0) return '' |
| | | |
| | | content = (col.prefix || '') + content + (col.postfix || '') |
| | | } else if (col.type === 'number') { |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | content = +record[col.field] |
| | | } |
| | | if (content && col.format === 'thdSeparator') { |
| | | content = `${content}` |
| | | content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') |
| | | } |
| | | content = (col.prefix || '') + content + (col.postfix || '') |
| | | let contents = [] |
| | | // if (item.order === 'leftPicRightText' || item.order === 'topPicBottomText') { |
| | | // contents = { |
| | | // picture: [], |
| | | // texts: [] |
| | | // } |
| | | // } |
| | | |
| | | item.subColumn.forEach(col => { |
| | | let content = '' |
| | | if (col.type === 'text' || col.type === 'textarea') { |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | content = `${record[col.field]}` |
| | | } |
| | | return content |
| | | }) |
| | | } |
| | | |
| | | if (contents && item.order === 'vertical2') { |
| | | content = (col.prefix || '') + content + (col.postfix || '') |
| | | } else if (col.type === 'number') { |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | content = +record[col.field] |
| | | } |
| | | if (content && col.format === 'thdSeparator') { |
| | | content = `${content}` |
| | | content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') |
| | | } |
| | | content = (col.prefix || '') + content + (col.postfix || '') |
| | | } else if (col.type === 'picture') { |
| | | let photos = '' |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | photos = record[col.field].split(',') |
| | | } else { |
| | | photos = '' |
| | | } |
| | | content = <div className="picture-col"> |
| | | {photos && photos.map((url, i) => { |
| | | return <img key={`${i}`} src={url} alt=""/> |
| | | })} |
| | | </div> |
| | | } |
| | | |
| | | contents.push(content) |
| | | }) |
| | | |
| | | if (contents.length > 0 && item.order === 'vertical2') { |
| | | let _contents = [] |
| | | for(let i = 0; i < contents.length; i += 2) { |
| | | _contents.push(contents.slice(i, i + 2).join(' ')) |
| | |
| | | {contents && item.order === 'horizontal' && contents.map((content, index) => { |
| | | return (<span key={index}>{content}</span>) |
| | | })} |
| | | {contents && item.order === 'leftPicRightText' && contents.map((content, index) => { |
| | | return (<span key={index}>{content}</span>) |
| | | })} |
| | | </div> |
| | | </div> |
| | | ) |