From cafa9dc47fd195d7434f555b52efc5db769a25c1 Mon Sep 17 00:00:00 2001 From: pengm <674192343@qq.com> Date: Wed, 11 Jun 2025 15:03:44 +0800 Subject: [PATCH] 1.多列头下拉 根据用户的语言,选择对应的json字符串语言配置作为列标题 --- src/components/Common/CommonComponent/index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index c1fa3f1..e8623e9 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -635,7 +635,15 @@ export default class CommonComponent extends Component { /* 返回值 */ return obj; }; - + getLocalizedString = (jsonStr, language) =>{ + try { + const data = JSON.parse(jsonStr); + return data[language] || ''; + } catch (e) { + console.error('Error parsing JSON:', e); + return ''; + } + } getSelectTableProps = () => { const { currentPage, tempCurrentPage, searchValue } = this.state; const pageNum = searchValue === '' ? currentPage : tempCurrentPage; @@ -828,8 +836,13 @@ export default class CommonComponent extends Component { getSelectTableOption = () => { const { selectTableData, selectTableIndex = 0 } = this.state; - const { showConfig } = this.props; - const { sTableTitleSql } = showConfig; + const { showConfig , app} = this.props; + const { userinfo } = app; + let { sTableTitleSql } = showConfig; + /* 根据用户配置语言 设置表格标题 */ + if(commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes('Chinese')) { + sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage); + } const tempColumnArr = sTableTitleSql.split(','); let scrollX = 0; const columns = tempColumnArr.map((item, index) => { -- libgit2 0.22.2