From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 111 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 70 insertions(+), 41 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 9d7eaf9..19bf7e3 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -6,7 +6,6 @@ import moment from 'moment' import Api from '@/api' -import options from '@/store/options.js' import asyncComponent from '@/utils/asyncComponent' import Utils, { getEditTableSql, getMark } from '@/utils/utils.js' import MkIcon from '@/components/mk-icon' @@ -14,6 +13,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 +301,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 +317,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 +387,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 +413,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 +445,7 @@ } if (content) { - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } children = ( @@ -477,10 +487,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 +728,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 +744,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 +773,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 +799,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 +816,7 @@ } if (content) { - content = col.prefix + content + col.postfix + content = (col.prefix || '') + content + (col.postfix || '') } children = ( @@ -836,10 +858,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> } } @@ -868,7 +892,7 @@ static propTpyes = { statFValue: PropTypes.any, // 鍚堣瀛楁鏁版嵁 MenuID: PropTypes.string, // 鑿滃崟Id - setting: PropTypes.object, // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乧olumnfixed锛堝垪鍥哄畾锛夈�乤ctionfixed锛堟寜閽浐瀹氾級 + setting: PropTypes.object, // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乤ctionfixed锛堟寜閽浐瀹氾級 columns: PropTypes.array, // 琛ㄦ牸鍒� lineMarks: PropTypes.any, // 琛屾爣璁� fields: PropTypes.array, // 缁勪欢瀛楁闆� @@ -913,6 +937,10 @@ if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') { let _option = Utils.getSelectQueryOptions(item) + + if (window.GLOB.debugger === true || window.debugger === true) { + console.info(_option.sql) + } item.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) item.arr_field = _option.field @@ -963,12 +991,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'] @@ -991,6 +1019,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') }) } @@ -1077,11 +1111,6 @@ localItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`) } }) - - if (options.sysType !== 'local') { - localItems = [...localItems, ...mainItems] - mainItems = [] - } // 鏈湴璇锋眰 let param = { @@ -1181,7 +1210,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 => { @@ -1963,7 +1992,7 @@ <Table rowKey="$$uuid" components={components} - style={setting.style} + // style={setting.style} size={setting.size || 'middle'} bordered={setting.bordered !== 'false'} rowSelection={rowSelection} -- Gitblit v1.8.0