Commit cafa9dc47fd195d7434f555b52efc5db769a25c1
1 parent
af7ee863
1.多列头下拉 根据用户的语言,选择对应的json字符串语言配置作为列标题
Showing
1 changed file
with
16 additions
and
3 deletions
src/components/Common/CommonComponent/index.js
| ... | ... | @@ -635,7 +635,15 @@ export default class CommonComponent extends Component { |
| 635 | 635 | /* 返回值 */ |
| 636 | 636 | return obj; |
| 637 | 637 | }; |
| 638 | - | |
| 638 | + getLocalizedString = (jsonStr, language) =>{ | |
| 639 | + try { | |
| 640 | + const data = JSON.parse(jsonStr); | |
| 641 | + return data[language] || ''; | |
| 642 | + } catch (e) { | |
| 643 | + console.error('Error parsing JSON:', e); | |
| 644 | + return ''; | |
| 645 | + } | |
| 646 | + } | |
| 639 | 647 | getSelectTableProps = () => { |
| 640 | 648 | const { currentPage, tempCurrentPage, searchValue } = this.state; |
| 641 | 649 | const pageNum = searchValue === '' ? currentPage : tempCurrentPage; |
| ... | ... | @@ -828,8 +836,13 @@ export default class CommonComponent extends Component { |
| 828 | 836 | |
| 829 | 837 | getSelectTableOption = () => { |
| 830 | 838 | const { selectTableData, selectTableIndex = 0 } = this.state; |
| 831 | - const { showConfig } = this.props; | |
| 832 | - const { sTableTitleSql } = showConfig; | |
| 839 | + const { showConfig , app} = this.props; | |
| 840 | + const { userinfo } = app; | |
| 841 | + let { sTableTitleSql } = showConfig; | |
| 842 | + /* 根据用户配置语言 设置表格标题 */ | |
| 843 | + if(commonUtils.isJSON(sTableTitleSql) && sTableTitleSql.includes('Chinese')) { | |
| 844 | + sTableTitleSql = this.getLocalizedString(sTableTitleSql, userinfo.sLanguage); | |
| 845 | + } | |
| 833 | 846 | const tempColumnArr = sTableTitleSql.split(','); |
| 834 | 847 | let scrollX = 0; |
| 835 | 848 | const columns = tempColumnArr.map((item, index) => { | ... | ... |