From e6a6fb8d27b14581ae771325c1b99ee26d6618dd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 19 三月 2020 18:19:06 +0800 Subject: [PATCH] 2020-03-19 --- src/tabviews/zshare/actionList/index.jsx | 32 +++++-- src/tabviews/zshare/normalTable/index.jsx | 129 ++++++++++++++++++++++--------- src/tabviews/zshare/normalTable/index.scss | 50 ++++++++++++ 3 files changed, 162 insertions(+), 49 deletions(-) diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 4832c00..282ad5d 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -675,6 +675,26 @@ } execPrint = (item, list, template) => { + let _documents = [] + + Object.keys(template).forEach(key => { + let _data = list.filter(cell => cell.TemplateID === key) + + if (_data.length > 0) { + let _cell = { + documentID: Utils.getuuid(), + contents: [ + { + data: _data, + templateURL: JSON.stringify(template[key]) + } + ] + } + + _documents.push(_cell) + } + }) + let printdata = { cmd: 'print', requestID: '', @@ -683,17 +703,7 @@ taskID: Utils.getuuid(), preview: false, printer: item.printer, - documents: list.map(cell => { - return { - documentID: Utils.getuuid(), - contents: [ - { - data: cell, - templateURL: JSON.stringify(template[cell.TemplateID]) - } - ] - } - }) + documents: _documents } } diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index ec02ca6..47e52ca 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -165,60 +165,113 @@ ) } else if (item.type === 'colspan') { if (item.subColumn.length === 0) return '' + let ordertype = item.order + let contents = [] + let images = [] - let 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]}` - } + item.subColumn.forEach(col => { + if (!col.field || !record.hasOwnProperty(col.field)) return + + if (col.type === 'number' && typeof(record[col.field]) === 'number') { + let 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') { + if (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> - } - return content + content = (col.prefix || '') + content + (col.postfix || '') + + contents.push(content) + } else if (col.type === 'picture') { + let photos = [] + try { + photos = record[col.field].split(',') + } catch { + photos = [] + } + + images.push(...photos) + } else { + contents.push((col.prefix || '') + record[col.field] + (col.postfix || '')) + } }) - if (contents && item.order === 'vertical2') { - let _contents = [] - for(let i = 0; i < contents.length; i += 2) { - _contents.push(contents.slice(i, i + 2).join(' ')) - } - contents = _contents + if (images.length > 0 && ['vertical2', 'horizontal', 'vertical'].includes(ordertype)) { + ordertype = 'topPicBottomText' } return ( <div> <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> - {contents && item.order === 'vertical' && contents.map((content, index) => { + {this.getCospanContent(ordertype, contents, images)} + </div> + </div> + ) + } + } + + getCospanContent = (type, contents, images) => { + if (type === 'vertical') { + return contents.map((content, index) => { + return (<p key={index}>{content}</p>) + }) + } else if (type === 'horizontal') { + return contents.map((content, index) => { + return (<span key={index}>{content}</span>) + }) + } else if (type === 'vertical2') { + return ( + <div className="content-fence"> + <div className="content-fence-left"> + {contents.map((content, index) => { + if (index % 2 === 0) { + return (<p key={index}>{content}</p>) + } else { + return '' + } + })} + </div> + <div className="content-fence-right"> + {contents.map((content, index) => { + if (index % 2 === 1) { + return (<p key={index}>{content}</p>) + } else { + return '' + } + })} + </div> + </div> + ) + } else if (type === 'topPicBottomText') { + return ( + <div className="content-fence"> + <div className="content-fence-top"> + {images.map((url, index) => { + return (<img key={`${index}`} src={url} alt=""/>) + })} + {images.map((url, index) => { + return (<img key={`${index}`} src={url} alt=""/>) + })} + </div> + <div className="content-fence-bottom"> + {contents.map((content, index) => { return (<p key={index}>{content}</p>) })} - {contents && item.order === 'vertical2' && contents.map((content, index) => { - return (<p key={index}>{content}</p>) + </div> + </div> + ) + } else if (type === 'leftPicRightText') { + return ( + <div className="content-fence"> + <div className="content-fence-left"> + {images.map((url, index) => { + return (<img key={`${index}`} src={url} alt=""/>) })} - {contents && item.order === 'horizontal' && contents.map((content, index) => { - return (<span key={index}>{content}</span>) + </div> + <div className="content-fence-right"> + {contents.map((content, index) => { + return (<p key={index}>{content}</p>) })} </div> </div> diff --git a/src/tabviews/zshare/normalTable/index.scss b/src/tabviews/zshare/normalTable/index.scss index 53cb0f4..b3e2535 100644 --- a/src/tabviews/zshare/normalTable/index.scss +++ b/src/tabviews/zshare/normalTable/index.scss @@ -40,6 +40,56 @@ z-index: 1; word-wrap: break-word; word-break: break-word; + + .content-fence { + position: relative; + width: 100%; + word-wrap: break-word; + word-break: break-word; + + .content-fence-top { + position: relative; + word-wrap: break-word; + word-break: break-word; + width: 100%; + text-align: center; + margin-bottom: 5px; + + img { + max-width: 100%; + } + img + img { + margin-left: 10px; + } + } + .content-fence-bottom { + position: relative; + word-wrap: break-word; + word-break: break-word; + width: 100%; + } + .content-fence-left { + position: relative; + display: inline-block; + word-wrap: break-word; + word-break: break-word; + width: calc(50% - 5px); + + img { + max-width: 100%; + } + img + img { + margin-top: 10px; + } + } + .content-fence-right { + position: relative; + float: right; + word-wrap: break-word; + word-break: break-word; + width: calc(50% - 5px); + } + } } .picture-col { img { -- Gitblit v1.8.0