Commit c0664a65ae3b53c02d501ca4daa885c2d53c7abc

Authored by Min
1 parent cab86592

1.主页导航树形缓存根据公司+语言+登录账号 共同形成key

src/components/IndexCenter/IndexCenter.js
... ... @@ -139,8 +139,10 @@ class IndexCenter extends Component {
139 139 const commonThirdApp = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType === 'LargeScreen' : item.sFormUrl?.includes('http'));
140 140 const { modelCenter: modelCenterOld } = this.props;
141 141  
142   - const { sUserNo } = userinfo;
143   - const xlybusinessActiveTree = localStorage.getItem(`xlybusinessActiveTree_${sUserNo}`);
  142 + const { sUserNo, sLanguage = 'sChinese', sBrandsId } = userinfo;
  143 +
  144 + const sUserKey = sUserNo + sLanguage + sBrandsId;
  145 + const xlybusinessActiveTree = localStorage.getItem(`xlybusinessActiveTree_${sUserKey}`);
144 146 if (xlybusinessActiveTree) {
145 147 [this.curActiveTree, this.tableTreeScrollTop, this.kpiTableScrollTop] = xlybusinessActiveTree.split(',');
146 148 }
... ... @@ -247,19 +249,19 @@ class IndexCenter extends Component {
247 249 // this.tableTree.scrollTop = 0;
248 250 // }
249 251 const addState = {};
250   - Object.keys(model).sort((a, b) => {
251   - const targetKey = "所有部门";
252   - // 核心修改:优先让 targetKey 排在第一位
253   - if (a?.includes(targetKey) ) {
254   - return -1;
255   - }
256   - if (b?.includes(targetKey)) {
257   - return 1;
258   - }
259   - const firstA = model[a][0]?.iJsOrder || 0;
260   - const firstB = model[b][0]?.iJsOrder || 0;
261   - return firstA - firstB;
262   - }).forEach((child, index) => {
  252 + const targetTexts = ['所有部门', 'All Departments'];
  253 + const isTopKey = str => targetTexts.some(text => str?.includes(text));
  254 +
  255 + Object.keys(model)
  256 + .sort((a, b) => {
  257 + const aTop = isTopKey(a);
  258 + const bTop = isTopKey(b);
  259 + if (aTop !== bTop) return aTop ? -1 : 1;
  260 +
  261 + const orderA = model[a]?.[0]?.iJsOrder ?? 0;
  262 + const orderB = model[b]?.[0]?.iJsOrder ?? 0;
  263 + return orderA - orderB;
  264 + }).forEach((child, index) => {
263 265 const name = child.split('_')[0];
264 266 // const num = child.split('_')[1];
265 267 let num = 0;
... ... @@ -567,7 +569,7 @@ class IndexCenter extends Component {
567 569 addState.columns = columns;
568 570 this.tableTreeScrollTop = 0;
569 571 this.kpiTableScrollTop = 0;
570   - localStorage.removeItem(`xlybusinessActiveTree_${sUserNo}`);
  572 + localStorage.removeItem(`xlybusinessActiveTree_${sUserKey}`);
571 573 }
572 574 }
573 575 this.setState({
... ... @@ -638,8 +640,9 @@ class IndexCenter extends Component {
638 640 }
639 641  
640 642 recordTableTreeState = () => {
641   - const { sUserNo } = this.props.app.userinfo;
642   - localStorage.setItem(`xlybusinessActiveTree_${sUserNo}`, `${this.activeTree},${this.tableTreeScrollTop || 0},${this.kpiTableScrollTop || 0}`);
  643 + const { sUserNo, sLanguage = 'sChinese', sBrandsId } = this.props.app.userinfo;
  644 + const sUserKey = sUserNo + sLanguage + sBrandsId;
  645 + localStorage.setItem(`xlybusinessActiveTree_${sUserKey}`, `${this.activeTree},${this.tableTreeScrollTop || 0},${this.kpiTableScrollTop || 0}`);
643 646 }
644 647  
645 648 handleSaveExpandState = () => {
... ...