From b8e1395f02c929eaa96b949cf6027ee2a43856a6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 19:03:37 +0800 Subject: [PATCH] 2022-09-06 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 171 ++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 108 insertions(+), 63 deletions(-) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 6598db5..8651b50 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -14,6 +14,7 @@ import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import CusSwitch from './cusSwitch' +import Encrypts from '@/components/encrypts' import '@/assets/css/table.scss' import './index.scss' @@ -301,9 +302,13 @@ content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` } else if (col.textFormat === '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)}` + } else if (col.textFormat === 'encryption') { + content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span> } - content = (col.prefix || '') + content + (col.postfix || '') + if (col.textFormat !== 'encryption') { + content = (col.prefix || '') + content + (col.postfix || '') + } } if (col.marks) { @@ -313,10 +318,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } @@ -381,21 +388,23 @@ } if (content !== '') { - let decimal = col.decimal || 0 + if (col.round) { + content = Math.round(content * col.round) / col.round + } if (col.format === 'percent') { content = content * 100 - decimal = decimal > 2 ? decimal - 2 : 0 } else if (col.format === 'abs') { content = Math.abs(content) } - - content = content.toFixed(decimal) + if (col.round) { + content = content.toFixed(col.decimal) + } if (col.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } if (col.marks) { @@ -405,10 +414,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } @@ -435,7 +446,7 @@ } if (content) { - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } children = ( @@ -477,10 +488,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } @@ -716,9 +729,13 @@ content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` } else if (col.textFormat === '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)}` + } else if (col.textFormat === 'encryption') { + content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span> } - content = (col.prefix || '') + content + (col.postfix || '') + if (col.textFormat !== 'encryption') { + content = (col.prefix || '') + content + (col.postfix || '') + } } if (col.marks) { @@ -728,10 +745,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } children = content @@ -755,21 +774,23 @@ } if (content !== '') { - let decimal = col.decimal || 0 + if (col.round) { + content = Math.round(content * col.round) / col.round + } if (col.format === 'percent') { content = content * 100 - decimal = decimal > 2 ? decimal - 2 : 0 } else if (col.format === 'abs') { content = Math.abs(content) } - - content = content.toFixed(decimal) + if (col.round) { + content = content.toFixed(col.decimal) + } if (col.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } if (col.marks) { @@ -779,10 +800,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } children = content @@ -794,7 +817,7 @@ } if (content) { - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } children = ( @@ -836,10 +859,12 @@ if (mark.icon) { if (mark.position === 'front') { - content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + content = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {content}</span> } else { - content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + content = <span>{content} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.innerStyle) { + content = <span style={mark.innerStyle}>{content}</span> } } @@ -873,7 +898,6 @@ lineMarks: PropTypes.any, // 琛屾爣璁� fields: PropTypes.array, // 缁勪欢瀛楁闆� BID: PropTypes.any, // 涓昏〃ID - data: PropTypes.any, // 琛ㄦ牸鏁版嵁 total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� @@ -964,12 +988,12 @@ }) } - if (setting.borderColor) { // 杈规棰滆壊 - let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}` - let ele = document.createElement('style') - ele.innerHTML = style - document.getElementsByTagName('head')[0].appendChild(ele) - } + // if (setting.borderColor) { // 杈规棰滆壊 + // let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}` + // let ele = document.createElement('style') + // ele.innerHTML = style + // document.getElementsByTagName('head')[0].appendChild(ele) + // } let size = (setting.pageSize || 10) + '' let pageOptions = ['10', '25', '50', '100', '500', '1000'] @@ -992,6 +1016,12 @@ if (deForms.length > 0) { this.improveActionForm(deForms) } + + const element = document.getElementById(setting.tableId) + element && element.style.setProperty('--mk-table-border-color', setting.borderColor || '#e8e8e8') + element && element.style.setProperty('--mk-table-color', setting.color || 'rgba(0, 0, 0, 0.65)') + element && element.style.setProperty('--mk-table-font-size', setting.fontSize || '14px') + element && element.style.setProperty('--mk-table-font-weight', setting.fontWeight || 'normal') }) } @@ -1182,7 +1212,7 @@ if (!_cell.label && _cell.label !== 0) return if (_map.has(_cell.value)) return - _map.set(_cell.value, true) + _map.set(_cell.value, 0) if (item.linkSubField) { item.linkSubField.forEach(m => { @@ -1239,6 +1269,10 @@ } else if (setting.addable === 'true') { setTimeout(() => { this.plusLine() + }, 10) + } else if (edData[index]) { + setTimeout(() => { + this.subLine(col, edData[index]) }, 10) } } @@ -1878,7 +1912,11 @@ if (pickup && setting.tableType === 'checkbox' && keys.length > 0) { this.setState({ data: data, - edData: fromJS(data).toJS().filter(item => keys.includes(item.$$uuid)) + edData: fromJS(data).toJS().filter(item => { + item.$origin = false + + return keys.includes(item.$$uuid) + }) }) } else { this.setState({ @@ -1944,34 +1982,41 @@ let height = setting.height || false return ( - <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> - <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> - {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> : null} - <Table - rowKey="$$uuid" - components={components} - style={setting.style} - size={setting.size || 'middle'} - bordered={setting.bordered !== 'false'} - rowSelection={rowSelection} - columns={_columns} - dataSource={_data} - loading={this.props.loading} - scroll={{ x: '100%', y: height }} - onRow={(record, index) => { - return { - lineMarks, - data: record, - onClick: () => {this.changeRow(record.$$uuid)}, - } - }} - onChange={this.changeTable} - pagination={_pagination} - /> - {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} - {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null} - {pickup && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null} - </div> + <> + {submit.hasAction && pickup ? <div className="edit-custom-table-leftbtn-wrap"> + <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> + </div> : null} + <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> + {!submit.hasAction && pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> : null} + <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> + </div> + <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}> + <Table + rowKey="$$uuid" + components={components} + // style={setting.style} + size={setting.size || 'middle'} + bordered={setting.bordered !== 'false'} + rowSelection={rowSelection} + columns={_columns} + dataSource={_data} + loading={this.props.loading} + scroll={{ x: '100%', y: height }} + onRow={(record, index) => { + return { + lineMarks, + data: record, + onClick: () => {this.changeRow(record.$$uuid)}, + } + }} + onChange={this.changeTable} + pagination={_pagination} + /> + {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} + {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null} + {pickup && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null} + </div> + </> ) } } -- Gitblit v1.8.0