| | |
| | | width: item.Width || 120, |
| | | render: (text, record) => { |
| | | return this.getContent(item, record) |
| | | // let content = '' |
| | | // if (item.field) { |
| | | // content = record[item.field] || '' |
| | | // } |
| | | // return ( |
| | | // <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | // {content} |
| | | // </div> |
| | | // ) |
| | | } |
| | | } |
| | | _columns.push(cell) |
| | |
| | | } |
| | | |
| | | getContent = (item, record) => { |
| | | if (item.type === 'operation') { |
| | | if (item.type === 'text') { |
| | | let content = '' |
| | | let match = false |
| | | if (item.field && record.hasOwnProperty(item.field)) { |
| | | content = `${record[item.field]}` |
| | | } |
| | | |
| | | if (content && item.matchVal && content.indexOf(item.matchVal) > 0) { |
| | | match = true |
| | | } |
| | | |
| | | content = (item.prefix || '') + content + (item.postfix || '') |
| | | |
| | | return ( |
| | | <div className={match ? item.color : ''}> |
| | | <div className="background"></div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content} |
| | | </div> |
| | | </div> |
| | | ) |
| | | } else if (item.type === 'number') { |
| | | let content = '' |
| | | let match = false |
| | | if (item.field && record.hasOwnProperty(item.field)) { |
| | | content = +record[item.field] |
| | | } |
| | | |
| | | if (content && item.match && item.matchVal) { |
| | | if (item.match === '>') { |
| | | if (content > item.matchVal) { |
| | | match = true |
| | | } |
| | | } else if (item.match === '<') { |
| | | if (content < item.matchVal) { |
| | | match = true |
| | | } |
| | | } else if (item.match === '>=') { |
| | | if (content >= item.matchVal) { |
| | | match = true |
| | | } |
| | | } else if (item.match === '<=') { |
| | | if (content <= item.matchVal) { |
| | | match = true |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (content && item.format === 'thdSeparator') { |
| | | |
| | | } |
| | | |
| | | content = (item.prefix || '') + content + (item.postfix || '') |
| | | |
| | | return ( |
| | | <div className={match ? item.color : ''}> |
| | | <div className={'background'}></div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content} |
| | | </div> |
| | | </div> |
| | | ) |
| | | } else if (item.type === 'operation') { |
| | | return ( |
| | | <div className={item.style} style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {item.operations.map(btn => { |
| | |
| | | })} |
| | | </div> |
| | | ) |
| | | } else { |
| | | } else if (item.type === 'colspan') { |
| | | let contents = '' |
| | | if (item.subColumn.length > 0) { |
| | | contents = item.subColumn.map(col => { |
| | | let content = '' |
| | | if (item.field) { |
| | | content = record[item.field] || '' |
| | | if (col.type === 'text' || col.type === 'textarea') { |
| | | if (col.field && record.hasOwnProperty(col.field)) { |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | 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 = (col.prefix || '') + content + (col.postfix || '') |
| | | } |
| | | return content |
| | | }) |
| | | } |
| | | |
| | | return ( |
| | | // <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | <div> |
| | | <div className={'background'}></div> |
| | | <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> |
| | | {content} |
| | | {contents && item.order === 'vertical' && contents.map((content, index) => { |
| | | return (<p key={index}>{content}</p>) |
| | | })} |
| | | {contents && item.order === 'horizontal' && contents.map((content, index) => { |
| | | return (<span key={index}>{content}</span>) |
| | | })} |
| | | </div> |
| | | </div> |
| | | ) |