diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index d830513..864758d 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -4548,9 +4548,9 @@ class CommonTableRc extends React.Component { } const cellChild = ( - {sValue} + >{this.formatThousands(sValue)} ); cells.push(cellChild); @@ -4602,11 +4602,12 @@ class CommonTableRc extends React.Component { } } } + // 金额 数量 价格 千分位处理 cell = ( - {sValue} + >{this.formatThousands(sValue)} ); cells.push(cell); @@ -4633,9 +4634,9 @@ class CommonTableRc extends React.Component { let sValue = totalData1[0][itemChild.dataIndex]; const cellChild = ( - {sValue} + >{this.formatThousands(sValue)} ); cells1.push(cellChild); @@ -4646,9 +4647,9 @@ class CommonTableRc extends React.Component { let sValue = totalData1[0][item.dataIndex]; cell = ( - {sValue} + >{this.formatThousands(sValue)} ); cells1.push(cell); @@ -5351,6 +5352,8 @@ class CommonTableRc extends React.Component { /** 绑定showType控件 */ bindShowType = (props, text, record, sName, index, isSlaveInfo) => { record.iRowNum = index + 1; + // 金额 数量 价格 千分位处理 + const isAmount = sName.includes('Price') || sName.includes('Money') || sName.includes('Qty'); /* 如果从表没有数据就返回一个默认的input text,不返回showType了 */ let res = ''; const idx = index; @@ -5540,7 +5543,7 @@ class CommonTableRc extends React.Component { {(commonUtils.isNotEmptyObject(sName) && sName.substring(0, 1) === 'b') || (imgBox !== '') ? '' :
this.onKeyDownDiv(e, sName)} onCut={e => e.preventDefault()} @@ -5548,7 +5551,7 @@ class CommonTableRc extends React.Component { // suppressContentEditableWarning // contentEditable="true" onClick={commonUtils.isNotEmptyObject(linkStyle) ? this.handleViewClick.bind(this, isSlaveInfo ? 'slaveInfo' : this.props.name, showConfig.sName, record, index, showConfig) : null} - > {sValue}
} + > {isAmount ? this.formatThousands(sValue) : sValue}} {bShow}{imgBox} ); } else { @@ -5566,7 +5569,7 @@ class CommonTableRc extends React.Component { placement='bottomLeft' overlayClassName="commonTitle" mouseEnterDelay={0.8} - title={{sValue}} + title={{isAmount ? this.formatThousands(sValue) : sValue}} > {sValue} + > {isAmount ? this.formatThousands(sValue) : sValue} } {bShow}{imgBox}{this.handleGetFastSearchBtn({ record, sName, isSlaveInfo })} @@ -5832,7 +5835,7 @@ class CommonTableRc extends React.Component { placement={bSpecialTitle ? 'right' : 'bottomLeft'} overlayClassName={bSpecialTitle ? 'commonSpecialTitle' : 'commonTitle'} mouseEnterDelay={0.8} - title={{commonUtils.isNotEmptyObject(specialTitle) ? specialTitle : sValue}} + title={{commonUtils.isNotEmptyObject(specialTitle) ? specialTitle : isAmount ? this.formatThousands(sValue) : sValue}} > {sValue} - - }{bShow}{imgBox}{showQty} + > {isAmount ? this.formatThousands(sValue) : sValue} + + }{bShow}{imgBox}{showQty} ); // 人检-质检代码特殊处理 @@ -5883,6 +5886,40 @@ class CommonTableRc extends React.Component { } }; + formatThousands = (value) => { + if (value == null || value === '') return ''; + + let str = String(value).trim(); + + // 清理:只保留数字、小数点和开头的负号 + const cleaned = str.replace(/[^\d.-]/g, ''); + const parts = cleaned.split('.'); + + // 多个小数点只保留第一个 + if (parts.length > 2) { + str = parts[0] + '.' + parts.slice(1).join(''); + } else { + str = cleaned; + } + + // 最终验证(允许 -.(数字) 和 数字. 格式) + if (!/^-?(\d+|\d*\.\d+)$/.test(str)) return ''; + + // 分离并格式化 + const [integerPart, decimalPart] = str.split('.'); + + const formatWithCommas = (num) => + num.replace(/\B(?=(\d{3})+(?!\d))/g, ','); + + const formattedInteger = integerPart.startsWith('-') + ? '-' + formatWithCommas(integerPart.slice(1)) + : formatWithCommas(integerPart); + + return decimalPart !== undefined + ? `${formattedInteger}.${decimalPart}` + : formattedInteger; + }; + /** willProps赋值 * */ assignmentWillProps = (props) => { // 重构修改 去除filteredData; diff --git a/src/components/login/Login.js b/src/components/login/Login.js index 4720654..6601885 100644 --- a/src/components/login/Login.js +++ b/src/components/login/Login.js @@ -191,9 +191,7 @@ class LoginForm extends Component { // decimals.dNetPrice = dNetPrice !== undefined && dNetPrice.sValue !== undefined ? (dNetPrice.sValue) * 1 : 6; // decimals.dNetMoney = dNetMoney !== undefined && dNetMoney.sValue !== undefined ? (dNetMoney.sValue) * 1 : 6; decimals.dNumAlign = dNumAlign !== undefined && dNumAlign.sValue !== undefined ? dNumAlign.sValue : 0; - // commonUtils.setNetPrice(decimals.dNetPrice); - // commonUtils.setNetMoney(decimals.dNetMoney); - // commonUtils.setDateFormat(commonFunc.getDateFormat(systemData)); + decimals.bThousandth = !!(commonUtils.isNotEmptyObject(bThousandthObj) && bThousandthObj.sValue === '1'); } // 判断是否是初始密码 if (values.username !== "zhangz") {