From 3683e1475e8d74f690172a468518d88d91a69ccc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 20 八月 2020 20:15:48 +0800 Subject: [PATCH] 2020-08-20 --- src/tabviews/zshare/normalTable/index.jsx | 74 +++++++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 913ad26..cddb597 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -299,9 +299,17 @@ if (item.field && record.hasOwnProperty(item.field)) { content = `${record[item.field]}` } - - content = content ? (item.prefix || '') + content + (item.postfix || '') : '' + if (content !== '') { + if (item.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { + content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` + } else if (item.format === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) { + content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}` + } + + content = (item.prefix || '') + content + (item.postfix || '') + } + if (item.marks) { let result = this.getMark(record, item.marks) @@ -504,8 +512,11 @@ 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 = '' @@ -550,7 +561,7 @@ content = md5(content) } - contents.push(content) + contents.push({content, align: col.Align}) } else if (col.type === 'picture') { let photos = [] try { @@ -560,12 +571,18 @@ } 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] if (content !== '') { + if (col.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { + content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` + } else if (col.format === 'YYYY-MM-DD HH:mm:ss' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1]).([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/.test(content)) { + content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}` + } + content = (col.prefix || '') + record[col.field] + (col.postfix || '') } @@ -587,7 +604,7 @@ 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] || '' @@ -617,7 +634,7 @@ 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] @@ -629,7 +646,7 @@ content = md5(content) } - contents.push(content) + contents.push({content, align: col.Align}) } }) @@ -649,8 +666,8 @@ 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) => { @@ -660,18 +677,18 @@ 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 '' } @@ -682,7 +699,7 @@ } 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) { @@ -693,8 +710,8 @@ })} </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> @@ -702,7 +719,7 @@ } 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) { @@ -713,8 +730,8 @@ })} </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> @@ -777,10 +794,11 @@ this.setState({ selectedRowKeys, activeIndex: _activeIndex }) - let selects = [] - selectedRowKeys.forEach(item => { - selects.push(this.props.data[item]) - }) + let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index)) + + // selectedRowKeys.forEach(item => { + // selects.push(this.props.data[item]) + // }) this.props.chgSelectData(selects) } @@ -814,10 +832,10 @@ this.setState({ selectedRowKeys: newkeys, activeIndex: _index !== '' ? _index : null }) } - let selects = [] - newkeys.forEach(item => { - selects.push(this.props.data[item]) - }) + let selects = this.props.data.filter((item, _index) => newkeys.includes(_index)) + // newkeys.forEach(item => { + // selects.push(this.props.data[item]) + // }) this.props.chgSelectData(selects) } -- Gitblit v1.8.0