From 3659f0773a14b54c18ed0af8b64de4afe8227489 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 04 十二月 2020 19:31:12 +0800 Subject: [PATCH] 2020-12-04 --- src/tabviews/zshare/normalTable/index.jsx | 104 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 66 insertions(+), 38 deletions(-) diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 640c6ff..23a8e27 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -26,12 +26,11 @@ pageSize: PropTypes.any, // 姣忛〉鏁版嵁 MenuName: PropTypes.any, // 鑿滃崟鍚嶇О dict: PropTypes.object, // 瀛楀吀椤� - config: PropTypes.object, // 椤甸潰閰嶇疆 MenuID: PropTypes.string, // 鑿滃崟Id setting: PropTypes.object, // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乧olumnfixed锛堝垪鍥哄畾锛夈�乤ctionfixed锛堟寜閽浐瀹氾級 pickup: PropTypes.any, // 鏁版嵁鏀惰捣 columns: PropTypes.array, // 琛ㄦ牸鍒� - logcolumns: PropTypes.array, // 瀛楁鍒� + fields: PropTypes.array, // 缁勪欢瀛楁闆� BID: PropTypes.any, // 涓昏〃Id ContainerId: PropTypes.any, // 鏍囩椤靛灞侷d BData: PropTypes.any, // 涓昏〃鏁版嵁 @@ -57,8 +56,8 @@ } UNSAFE_componentWillMount () { - const { menuType, config, memberLevel, pageSize } = this.props - let columns = JSON.parse(JSON.stringify(this.props.columns)) + const { menuType, memberLevel, pageSize } = this.props + let columns = fromJS(this.props.columns).toJS() let lineMarks = [] let _columns = [] let radio = 5 // 铏氬寲姣斾緥 @@ -75,45 +74,28 @@ } } - // 鑾峰彇琛屾爣璁� - config.columns.forEach(col => { - if (!col.field) return - - col.marks && col.marks.forEach(mark => { - if (mark.signType === 'line') { - lineMarks.push(mark) - } - }) - }) - columns.forEach((item, index) => { if (item.hidden === true || item.Hide === 'true') return - - if (_format && !Math.floor(Math.random() * radio)) { - item.blur = true - } - - if (item.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 - item.marks = item.marks.filter(mark => mark.signType !== 'line' && mark.signType !== 'card') - - if (item.marks.length === 0) { - item.marks = '' - } - } - let cell = null - if (item.type === 'colspan' && item.unfold === 'true') { + if (item.type === 'colspan') { cell = {title: item.label, children: []} item.subcols.forEach(col => { - if (col.rowspan === 'true') { rowspan = col } + if (_format && !Math.floor(Math.random() * radio)) { + col.blur = true + } if (col.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 - col.marks = col.marks.filter(mark => mark.signType !== 'line' && mark.signType !== 'card') + col.marks = col.marks.filter(mark => { + if (mark.signType === 'line') { + lineMarks.push(mark) + } + return mark.signType !== 'line' && mark.signType !== 'card' + }) if (col.marks.length === 0) { col.marks = '' @@ -131,9 +113,51 @@ } }) }) + } else if (item.type === 'old_colspan') { + item.subcols.forEach(col => { + if (col.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 + col.marks = col.marks.filter(mark => { + if (mark.signType === 'line') { + lineMarks.push(mark) + } + return mark.signType !== 'line' && mark.signType !== 'card' + }) + + if (col.marks.length === 0) { + col.marks = '' + } + } + }) + + cell = { + align: item.Align, + dataIndex: item.field || item.uuid, + title: item.label, + sorter: item.field && item.IsSort === 'true', + width: item.Width || 120, + render: (text, record) => { + return this.getContent(item, record) + } + } } else { if (item.rowspan === 'true') { rowspan = item + } + if (_format && !Math.floor(Math.random() * radio)) { + item.blur = true + } + + if (item.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 + item.marks = item.marks.filter(mark => { + if (mark.signType === 'line') { + lineMarks.push(mark) + } + return mark.signType !== 'line' && mark.signType !== 'card' + }) + + if (item.marks.length === 0) { + item.marks = '' + } } cell = { @@ -426,11 +450,13 @@ } if (content !== '') { + let decimal = item.decimal || 0 if (item.format === 'percent') { content = content * 100 + decimal = decimal > 2 ? decimal - 2 : 0 } - content = content.toFixed(item.decimal || 0) + content = content.toFixed(decimal) if (item.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') @@ -569,7 +595,7 @@ BData={this.props.BData} setting={this.props.setting} MenuName={this.props.MenuName} - columns={this.props.logcolumns} + columns={this.props.fields || this.props.columns} ContainerId={this.props.ContainerId} updateStatus={this.updateStatus} /> @@ -612,7 +638,7 @@ })} </div> ) - } else if (item.type === 'colspan') { + } else if (item.type === 'old_colspan') { if (item.subcols.length === 0) return '' let ordertype = item.order let contents = [] @@ -633,11 +659,13 @@ } if (content !== '') { + let decimal = col.decimal || 0 if (col.format === 'percent') { content = content * 100 + decimal = decimal > 2 ? decimal - 2 : 0 } - - content = content.toFixed(col.decimal || 0) + + content = content.toFixed(decimal) if (col.format === 'thdSeparator') { content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') @@ -686,7 +714,7 @@ 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 || '') + content = (col.prefix || '') + content + (col.postfix || '') } if (col.marks) { @@ -890,7 +918,7 @@ changeRow = (record, index) => { if (!this.props.setting.tableType || this.props.pickup) return - let newkeys = JSON.parse(JSON.stringify(this.state.selectedRowKeys)) + let newkeys = fromJS(this.state.selectedRowKeys).toJS() if (this.props.setting.tableType === 'radio') { newkeys = [index] -- Gitblit v1.8.0