Pārlūkot izejas kodu

uas手机版
订阅数据缓存逻辑

RaoMeng 5 gadi atpakaļ
vecāks
revīzija
ef239b0295

+ 1 - 1
uas-office-web/uas-mobile/src/components/private/subscribe/SubAlreadyItem.jsx

@@ -26,7 +26,7 @@ export default class SubAlreadyItem extends Component {
     const { subObj } = this.props
     return (
       <div className='comp-sub-already-item-root'>
-        <div className='comp-sub-already-item-title'>{subObj.name}</div>
+        <div className='comp-sub-already-item-title'>{subObj.title}</div>
         {
           subObj.type === SUBSCRIBE_ITEM_NOT ? (
             <div className='comp-sub-already-item-func'>+订阅</div>

+ 2 - 1
uas-office-web/uas-mobile/src/components/private/subscribe/SubLeftMenu.jsx

@@ -4,6 +4,7 @@
  */
 
 import React, { Component } from 'react'
+import './comp-subscrive.less'
 
 export default class SubLeftMenu extends Component {
 
@@ -27,7 +28,7 @@ export default class SubLeftMenu extends Component {
         className={subClass.select
           ? 'comp-sub-left-menu-select'
           : 'comp-sub-left-menu'}
-        onClick={this.onLeftClick}>{this.props.subClass.name}</div>
+        onClick={this.onLeftClick}>{this.props.subClass.className}</div>
     )
   }
 

+ 1 - 0
uas-office-web/uas-mobile/src/components/private/subscribe/comp-subscrive.less

@@ -141,6 +141,7 @@
 .comp-sub-left-menu-select {
   .comp-sub-left-menu;
   background-color: white;
+  color: red;
   border-right: 1px solid @com-color-divide-gray-line;
 }
 

+ 2 - 0
uas-office-web/uas-mobile/src/pages/private/homePage/HomePage.jsx

@@ -8,6 +8,7 @@ import MainRoot from './MainRoot'
 import ReportRoot from './ReportRoot'
 import DocRoot from './DocRoot'
 import MineRoot from './MineRoot'
+import { clearListState } from '../../../redux/actions/listState'
 
 /**
  * Created by RaoMeng on 2020/11/9
@@ -26,6 +27,7 @@ class HomePage extends Component {
 
   componentDidMount () {
     document.title = 'UAS系统'
+    clearListState()
   }
 
   componentWillUnmount () {

+ 7 - 7
uas-office-web/uas-mobile/src/pages/private/subscribe/SubscribeAlready.jsx

@@ -27,13 +27,13 @@ class SubscribeAlready extends Component {
   render () {
     return (
       <div className='subscribe-already-root'>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
-        <SubAlreadyItem subObj={{ name: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
+        <SubAlreadyItem subObj={{ title: '任务达成准时率' }}/>
       </div>
     )
   }

+ 196 - 22
uas-office-web/uas-mobile/src/pages/private/subscribe/SubscribeNot.jsx

@@ -9,6 +9,157 @@ import SubAlreadyItem
   from '../../../components/private/subscribe/SubAlreadyItem'
 import { SUBSCRIBE_ITEM_NOT } from '../../../configs/constans.config'
 import SubLeftMenu from '../../../components/private/subscribe/SubLeftMenu'
+import { saveListState } from '../../../redux/actions/listState'
+import { isObjEmpty } from '../../../utils/common.util'
+
+const subMenuList = [
+  {
+    className: '财务管理',
+    subList: [
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3126,
+        'title': '我的事业部应收款统计(华商龙)',
+        'status': 2,
+      },
+      {
+        'img': null,
+        'kind': 'public',
+        'id': 3140,
+        'title': '风控周报',
+        'status': 2,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3107,
+        'title': '上月利润统计(华商龙)',
+        'status': 2,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3127,
+        'title': '我的事业部逾期应收统计(华商龙)',
+        'status': 2,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3102,
+        'title': '应收款统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': '',
+        'kind': 'private',
+        'id': 8806,
+        'title': '逾期应收统计(英唐集团)',
+        'status': 3,
+      },
+      {
+        'img': '',
+        'kind': 'private',
+        'id': 8809,
+        'title': '应付款统计(英唐集团)',
+        'status': 3,
+      },
+    ],
+  },
+  {
+    className: '数据统计',
+    subList: [
+      {
+        'img': null,
+        'kind': 'public',
+        'id': 17143,
+        'title': '优软云流量统计',
+        'status': 3,
+      },
+    ],
+  },
+  {
+    className: '销售管理',
+    subList: [
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3080,
+        'title': '当月毛利润统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3122,
+        'title': '我的事业部当月销售额统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': '',
+        'kind': 'private',
+        'id': 8811,
+        'title': '当月毛利润统计(英唐集团)',
+        'status': 3,
+      },
+      {
+        'img': '',
+        'kind': 'private',
+        'id': 8812,
+        'title': '当月销售额统计(英唐集团)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3100,
+        'title': '当月销售额统计(华商龙)',
+        'status': 3,
+      },
+    ],
+  },
+  {
+    className: '库存管理',
+    subList: [
+      {
+        'img': '',
+        'kind': 'private',
+        'id': 8810,
+        'title': '总库存统计(英唐集团)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3124,
+        'title': '我的事业部呆滞库存统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3123,
+        'title': '我的事业部总库存统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3120,
+        'title': '呆滞库存统计(华商龙)',
+        'status': 3,
+      },
+      {
+        'img': null,
+        'kind': 'private',
+        'id': 3125,
+        'title': '我的事业部死库存统计(华商龙)',
+        'status': 3,
+      },
+    ],
+  },
+]
 
 class SubscribeNot extends Component {
 
@@ -19,7 +170,11 @@ class SubscribeNot extends Component {
   }
 
   componentDidMount () {
-
+    saveListState({
+      listData: subMenuList,
+      leftSelect: 0,
+      scrollTop: 0,
+    })
   }
 
   componentWillUnmount () {
@@ -27,37 +182,56 @@ class SubscribeNot extends Component {
   }
 
   render () {
+    const { listState: { listData, leftSelect } } = this.props
+    const leftItems = [], rightItems = []
+    if (!isObjEmpty(listData)) {
+      listData.forEach((item, index) => {
+        leftItems.push(
+          <SubLeftMenu
+            subClass={{
+              className: item.className,
+              classIndex: index,
+              select: leftSelect === index,
+            }}
+            onLeftClick={this.onLeftClick.bind(this)}
+          />,
+        )
+      })
+
+      const sublist = listData[leftSelect] && listData[leftSelect].subList
+      if (!isObjEmpty(sublist)) {
+        sublist.forEach((item, index) => {
+          rightItems.push(
+            <SubAlreadyItem subObj={{
+              ...item,
+              type: SUBSCRIBE_ITEM_NOT,
+            }}/>,
+          )
+        })
+      }
+    }
     return (
       <div className='subscribe-not-root'>
         <div className='subscribe-not-left-menu'>
-          <SubLeftMenu subClass={{ name: '项目数据' }}/>
-          <SubLeftMenu subClass={{ name: '项目数据', select: true }}/>
-          <SubLeftMenu subClass={{ name: '项目数据' }}/>
-          <SubLeftMenu subClass={{ name: '项目数据' }}/>
+          {leftItems}
         </div>
         <div className='subscribe-not-right-list'>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
-          <SubAlreadyItem subObj={{ name: '超期任务', type: SUBSCRIBE_ITEM_NOT }}/>
+          {rightItems}
         </div>
       </div>
     )
   }
+
+  onLeftClick = (subClass) => {
+    saveListState({
+      leftSelect: subClass.classIndex,
+      scrollTop: 0,
+    })
+  }
 }
 
-let mapStateToProps = (state) => ({})
+let mapStateToProps = (state) => ({
+  listState: state.listState,
+})
 
 export default connect(mapStateToProps)(SubscribeNot)