From 68f28efd7c0c09b3ea8a2a1876c956c17d1a8d37 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 19 一月 2020 15:13:39 +0800 Subject: [PATCH] 2020-01-19 --- src/tabviews/subtable/subTable/index.jsx | 67 ++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/tabviews/subtable/subTable/index.jsx b/src/tabviews/subtable/subTable/index.jsx index f860604..2352786 100644 --- a/src/tabviews/subtable/subTable/index.jsx +++ b/src/tabviews/subtable/subTable/index.jsx @@ -160,31 +160,51 @@ </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(' ')) @@ -204,6 +224,9 @@ {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> ) -- Gitblit v1.8.0