瀏覽代碼

uas手机版
常用应用添加删除逻辑

RaoMeng 5 年之前
父節點
當前提交
ef1bebaaef

+ 39 - 3
uas-office-web/uas-mobile/src/components/common/func/FuncGroup.jsx

@@ -8,6 +8,10 @@ import './common-func.less'
 import FuncTitle from './FuncTitle'
 import { isObjEmpty } from '../../../utils/common.util'
 import FuncItem from './FuncItem'
+import {
+  FUNC_OPERATION_ADD,
+  FUNC_OPERATION_ADD_DISABLE,
+} from '../../../configs/constans.config'
 
 export default class FuncGroup extends Component {
 
@@ -26,7 +30,17 @@ export default class FuncGroup extends Component {
   }
 
   render () {
-    let { funcGroup, line, onRightClick, onFuncClick, operation, rightIcon } = this.props
+    let {
+      funcGroup,
+      line,
+      onRightClick,
+      onFuncClick,
+      operation,
+      rightIcon,
+      operable,
+      onOperationClick,
+    } = this.props
+
     let funcItems = []
     if (!isObjEmpty(funcGroup.funcList)) {
       funcGroup.funcList.forEach((funcItem, funcIndex) => {
@@ -34,12 +48,26 @@ export default class FuncGroup extends Component {
           <FuncItem
             funcObj={funcItem}
             line={line}
-            operation={operation || funcItem.operation}
+            operation={
+              operation
+              || (operable &&
+                (funcItem.often
+                  ? FUNC_OPERATION_ADD
+                  : FUNC_OPERATION_ADD_DISABLE))
+            }
             onFuncClick={onFuncClick}
+            onOperationClick={onOperationClick}
             key={funcIndex}/>,
         )
       })
     }
+    if (line) {
+      if (funcItems.length >= 4) {
+        this.topLineWidth = 100
+      } else {
+        this.topLineWidth = 25 * funcItems.length
+      }
+    }
 
     return (
       <div
@@ -52,8 +80,16 @@ export default class FuncGroup extends Component {
         <div
           style={{
             marginRight: line ? '-1px' : '0px',
-            borderTop: line ? '1px solid lightgray' : '',
           }}>
+          {/*上边框*/}
+          {
+            line && <div
+              className={'func-group-top-line'}
+              style={{
+                width: this.topLineWidth + '%',
+              }}
+            ></div>
+          }
           {funcItems}
         </div>
       </div>

+ 9 - 2
uas-office-web/uas-mobile/src/components/common/func/FuncItem.jsx

@@ -7,6 +7,7 @@ import React, { Component } from 'react'
 import './common-func.less'
 import { isObjEmpty } from '../../../utils/common.util'
 import { Icon } from 'antd-mobile'
+import { FUNC_OPERATION_ADD_DISABLE } from '../../../configs/constans.config'
 
 export default class FuncItem extends Component {
 
@@ -51,10 +52,16 @@ export default class FuncItem extends Component {
   }
 
   onFuncClick = () => {
-    this.props.onFuncClick && this.props.onFuncClick(this.props.funcObj)
+    this.props.onFuncClick &&
+    this.props.onFuncClick(this.props.funcObj)
   }
 
   onOperationClick = () => {
-
+    const { funcObj, operation } = this.props
+    // if (operation === FUNC_OPERATION_ADD_DISABLE) {
+    //   return
+    // }
+    this.props.onOperationClick &&
+    this.props.onOperationClick(this.props.funcObj)
   }
 }

+ 1 - 1
uas-office-web/uas-mobile/src/components/common/func/FuncTitle.jsx

@@ -31,7 +31,7 @@ export default class FuncTitle extends Component {
           leftIcon &&
           <Icon className='func-group-icon' type={leftIcon}/>
         }
-        <span className='func-group-text'>{funcTitle.groupText}</span>
+        <span className='func-group-text'>{funcTitle.groupTitle}</span>
         {
           rightIcon &&
           <Icon

+ 5 - 0
uas-office-web/uas-mobile/src/components/common/func/common-func.less

@@ -21,6 +21,11 @@
   font-weight: bold;
 }
 
+.func-group-top-line {
+  height: 1px;
+  background-color: lightgray;
+}
+
 .func-func-root {
   width: 25%;
   position: relative;

+ 2 - 2
uas-office-web/uas-mobile/src/configs/constans.config.js

@@ -14,8 +14,8 @@ export const SUBSCRIBE_ITEM_ALREADY = 'SUBSCRIBE_ITEM_ALREADY'
  * 应用操作类型
  */
 export const FUNC_OPERATION_CANCEL = 'uas-cancel'
-export const FUNC_OPERATION_ADD = 'uas-add'
-export const FUNC_OPERATION_ADD_DISABLE = 'uas-add-disable'
+export const FUNC_OPERATION_ADD = 'uas-select'
+export const FUNC_OPERATION_ADD_DISABLE = 'uas-select-disable'
 
 
 

+ 1 - 1
uas-office-web/uas-mobile/src/configs/iconfont.conig.js

@@ -5,7 +5,7 @@ import { createFromIconfontCN } from '@ant-design/icons'
  * Desc: iconfont图标库
  */
 const UasIcon = createFromIconfontCN({
-  scriptUrl: '///at.alicdn.com/t/font_2183203_4acr6qjbroc.js',
+  scriptUrl: '//at.alicdn.com/t/font_2183203_zfqu3nugpe.js',
 })
 
 export default UasIcon

+ 16 - 2
uas-office-web/uas-mobile/src/pages/private/homePage/DocRoot.jsx

@@ -5,6 +5,8 @@
 
 import React, { Component } from 'react'
 import { connect } from 'react-redux'
+import { isObjEmpty } from '../../../utils/common.util'
+import FuncGroup from '../../../components/common/func/FuncGroup'
 
 class DocRoot extends Component {
 
@@ -16,7 +18,6 @@ class DocRoot extends Component {
 
   componentDidMount () {
     console.log('DocRoot')
-
   }
 
   componentWillUnmount () {
@@ -24,9 +25,22 @@ class DocRoot extends Component {
   }
 
   render () {
+    const { docState } = this.props
+    const funcGroupItems = []
+    if (!isObjEmpty(docState, docState.docFuncGroupList)) {
+      docState.docFuncGroupList.forEach((item, index) => {
+        funcGroupItems.push(
+          <FuncGroup
+            funcGroup={item}
+            line
+          />,
+        )
+      })
+    }
+
     return (
       <div>
-        应用
+        {funcGroupItems}
       </div>
     )
   }

+ 29 - 4
uas-office-web/uas-mobile/src/pages/private/homePage/MainRoot.jsx

@@ -10,7 +10,7 @@ import MainHeader from '../../../components/common/mainHeader/MainHeader'
 import './main-root.less'
 import { withRouter } from 'react-router-dom'
 import FuncGroup from '../../../components/common/func/FuncGroup'
-import OftenFuncGrid from '../oftenFunc/OftenFuncGrid'
+import { isObjEmpty, isObjNull } from '../../../utils/common.util'
 
 class MainRoot extends Component {
 
@@ -30,6 +30,23 @@ class MainRoot extends Component {
   }
 
   render () {
+    const { docState } = this.props
+    let oftenFunc = {
+      groupTitle: '常用',
+      funcList: [],
+    }
+    if (!isObjEmpty(docState, docState.docFuncGroupList)) {
+      docState.docFuncGroupList.forEach((groupItem, index) => {
+        const docFuncGroupList = groupItem.funcList
+        if (!isObjEmpty(docFuncGroupList)) {
+          docFuncGroupList.forEach((childItem, childIndex) => {
+            if (!isObjNull(childItem) && childItem.often) {
+              oftenFunc.funcList.push(childItem)
+            }
+          })
+        }
+      })
+    }
     return (
       <div>
         {/* 首页固定头部 */}
@@ -37,12 +54,16 @@ class MainRoot extends Component {
           <MainHeader/>
         </div>
         {/* 首页常用功能模块 */}
-        <OftenFuncGrid rightIcon='uas-edit'/>
+        <FuncGroup
+          funcGroup={oftenFunc}
+          rightIcon={'uas-edit'}
+          onRightClick={this.onOftenManage}
+        />
         {/* 首页看板展示 */}
         <div className="main-kanban">
           <FuncTitle
             funcTitle={{
-              groupText: '数据看板',
+              groupTitle: '数据看板',
             }}
             rightIcon='uas-edit'
             onRightClick={this.onKanbanManage}/>
@@ -51,14 +72,18 @@ class MainRoot extends Component {
     )
   }
 
+  onOftenManage = () => {
+    this.props.history.push('/oftenFuncManage')
+  }
+
   onKanbanManage = () => {
     this.props.history.push('/subscribeManage')
   }
-
 }
 
 let mapStateToProps = (state) => ({
   mainState: state.mainState,
+  docState: state.docState,
 })
 
 export default connect(mapStateToProps)(withRouter(MainRoot))

+ 14 - 45
uas-office-web/uas-mobile/src/pages/private/homePage/ReportRoot.jsx

@@ -11,6 +11,7 @@ import {
   FUNC_OPERATION_ADD, FUNC_OPERATION_ADD_DISABLE,
   FUNC_OPERATION_CANCEL,
 } from '../../../configs/constans.config'
+import { isObjEmpty, isObjNull } from '../../../utils/common.util'
 
 class ReportRoot extends Component {
 
@@ -30,54 +31,22 @@ class ReportRoot extends Component {
   }
 
   render () {
-    let funcGroup = {
-      groupText: '销售管理',
-      funcList: [
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-      ],
-    }
-    let funcGroup1 = {
-      groupText: '采购管理',
-      funcList: [
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-        { name: '报表' },
-      ],
+    const { reportState } = this.props
+    const funcGroupItems = []
+    if (!isObjEmpty(reportState, reportState.reportFuncList)) {
+      reportState.reportFuncList.forEach((item, index) => {
+        funcGroupItems.push(
+          <FuncGroup
+            funcGroup={item}
+            line
+          />,
+        )
+      })
     }
+
     return (
       <div>
-        <FuncGroup
-          funcGroup={funcGroup}
-          line
-        />
-        <FuncGroup
-          funcGroup={funcGroup1}
-          line
-        />
-        <FuncGroup
-          funcGroup={funcGroup}
-          line
-        />
-        <FuncGroup
-          funcGroup={funcGroup1}
-          line
-        />
-        <FuncGroup
-          funcGroup={funcGroup}
-          line
-        />
-        <FuncGroup
-          funcGroup={funcGroup1}
-          line
-        />
+        {funcGroupItems}
       </div>
     )
   }

+ 0 - 61
uas-office-web/uas-mobile/src/pages/private/oftenFunc/OftenFuncGrid.jsx

@@ -1,61 +0,0 @@
-/**
- * Created by RaoMeng on 2020/11/12
- * Desc: 常用应用 网格列表
- */
-
-import React, { Component } from 'react'
-import { connect } from 'react-redux'
-import FuncGroup from '../../../components/common/func/FuncGroup'
-import { withRouter } from 'react-router-dom'
-
-class OftenFuncGrid extends Component {
-
-  constructor () {
-    super()
-
-    this.state = {}
-  }
-
-  componentDidMount () {
-  }
-
-  componentWillUnmount () {
-
-  }
-
-  render () {
-    const { operation, rightIcon } = this.props
-    let oftenFunc = {
-      groupText: '常用',
-      funcList: [
-        { name: '销售订单' },
-        { name: '出货通知单' },
-        { name: '退货申请' },
-        { name: '销售订单' },
-        { name: '出货通知单' },
-        { name: '退货申请' },
-        { name: '销售订单' },
-        { name: '出货通知单' },
-        { name: '退货申请' },
-        { name: '销售订单' },
-      ],
-    }
-
-    return (
-      <FuncGroup
-        funcGroup={oftenFunc}
-        operation={operation}
-        rightIcon={rightIcon}
-        onRightClick={this.onOftenManage}
-      />
-    )
-  }
-
-  onOftenManage = () => {
-    this.props.history.push('/oftenFuncManage')
-  }
-}
-
-let mapStateToProps = (state) => ({})
-
-export default connect(mapStateToProps)(withRouter(OftenFuncGrid))

+ 79 - 33
uas-office-web/uas-mobile/src/pages/private/oftenFunc/OftenFuncManage.jsx

@@ -5,25 +5,37 @@
 
 import React, { Component } from 'react'
 import { connect } from 'react-redux'
-import OftenFuncGrid from './OftenFuncGrid'
 import { Button } from 'antd-mobile'
 import './often-func.less'
 import {
-  FUNC_OPERATION_ADD, FUNC_OPERATION_ADD_DISABLE,
   FUNC_OPERATION_CANCEL,
 } from '../../../configs/constans.config'
 import FuncGroup from '../../../components/common/func/FuncGroup'
+import { isObjEmpty, isObjNull } from '../../../utils/common.util'
+import { refreshDocList } from '../../../redux/actions/docState'
+import { message } from 'antd'
+import { withRouter } from 'react-router-dom'
+import { Toast } from 'antd-mobile'
 
 class OftenFuncManage extends Component {
 
   constructor () {
     super()
-
-    this.state = {}
+    this.oftenSize = 0
+    this.state = {
+      docFuncGroupList: [],
+    }
   }
 
   componentDidMount () {
     document.title = '常用管理'
+
+    const { docState } = this.props
+    if (!isObjEmpty(docState, docState.docFuncGroupList)) {
+      this.setState({
+        docFuncGroupList: docState.docFuncGroupList,
+      })
+    }
   }
 
   componentWillUnmount () {
@@ -31,47 +43,81 @@ class OftenFuncManage extends Component {
   }
 
   render () {
-    let funcGroup = {
-      groupText: '采购管理',
-      funcList: [
-        { name: '报表', operation: FUNC_OPERATION_ADD },
-        { name: '报表', operation: FUNC_OPERATION_ADD },
-        { name: '报表', operation: FUNC_OPERATION_ADD_DISABLE },
-        { name: '报表', operation: FUNC_OPERATION_ADD },
-        { name: '报表', operation: FUNC_OPERATION_ADD },
-        { name: '报表', operation: FUNC_OPERATION_ADD_DISABLE },
-      ],
+    const { docFuncGroupList } = this.state
+    const funcGroupItems = []
+    let oftenFunc = {
+      groupTitle: '常用(' + this.oftenSize + '/9)',
+      funcList: [],
+    }
+    if (!isObjEmpty(docFuncGroupList)) {
+      docFuncGroupList.forEach((groupItem, groupIndex) => {
+        funcGroupItems.push(
+          <FuncGroup
+            funcGroup={groupItem}
+            operable
+            onOperationClick={this.onOperationClick.bind(this)}
+          />,
+        )
+        const docFuncChildList = groupItem.funcList
+        if (!isObjEmpty(docFuncChildList)) {
+          docFuncChildList.forEach((childItem, childIndex) => {
+            if (!isObjNull(childItem) && childItem.often) {
+              oftenFunc.funcList.push(childItem)
+            }
+          })
+          this.oftenSize = oftenFunc.funcList.length
+          oftenFunc.groupTitle = '常用(' + this.oftenSize + '/9)'
+        }
+      })
     }
+
     return (
       <div className='often-func-root'>
         <div className='often-func-header'>
-          <OftenFuncGrid operation={FUNC_OPERATION_CANCEL}/>
-        </div>
-        <div className='often-func-all-list'>
-          <FuncGroup
-            funcGroup={funcGroup}
-          />
-          <FuncGroup
-            funcGroup={funcGroup}
-          />
-          <FuncGroup
-            funcGroup={funcGroup}
-          />
           <FuncGroup
-            funcGroup={funcGroup}
-          />
-          <FuncGroup
-            funcGroup={funcGroup}
+            funcGroup={oftenFunc}
+            operation={FUNC_OPERATION_CANCEL}
+            onOperationClick={this.onOperationClick.bind(this)}
           />
         </div>
+        <div className='often-func-all-list'>
+          {funcGroupItems}
+        </div>
         <div className='often-func-save-btn'>
-          <Button type={'primary'}>保存</Button>
+          <Button
+            type={'primary'}
+            onClick={this.onSaveOften}>保存</Button>
         </div>
       </div>
     )
   }
+
+  onOperationClick = (funcObj) => {
+    let { docFuncGroupList } = this.state
+    if (!isObjNull(docFuncGroupList[funcObj.groupIndex])
+      && !isObjNull(
+        docFuncGroupList[funcObj.groupIndex].funcList[funcObj.childIndex])) {
+      if (!docFuncGroupList[funcObj.groupIndex].funcList[funcObj.childIndex].often &&
+        this.oftenSize >= 12) {
+        Toast.fail('最多添加 12 个常用应用')
+      } else {
+        docFuncGroupList[funcObj.groupIndex].funcList[funcObj.childIndex].often = !docFuncGroupList[funcObj.groupIndex].funcList[funcObj.childIndex].often
+        this.setState({ docFuncGroupList })
+      }
+    }
+  }
+
+  onSaveOften = () => {
+    refreshDocList({
+      docFuncGroupList: this.state.docFuncGroupList,
+    })
+    message.success('保存成功')
+    this.props.history.goBack()
+  }
 }
 
-let mapStateToProps = (state) => ({})
+let mapStateToProps = (state) => ({
+  docState: state.docState,
+})
 
-export default connect(mapStateToProps)(OftenFuncManage)
+export default connect(mapStateToProps)(withRouter(OftenFuncManage))

+ 29 - 0
uas-office-web/uas-mobile/src/redux/actions/docState.js

@@ -0,0 +1,29 @@
+/**
+ * Created by RaoMeng on 2020/11/19
+ * Desc:操作应用数据缓存
+ */
+
+import store from '../store/store'
+import { CLEAR_DOC_STATE, REFRESH_DOC_LIST } from '../constants/actionTypes'
+
+/**
+ * 保存列表状态
+ * @param data
+ * @returns {Function}
+ */
+export const refreshDocList = (data) => {
+  return store.dispatch({
+    type: REFRESH_DOC_LIST,
+    ...data,
+  })
+}
+
+/**
+ * 清除列表状态
+ * @returns {Function}
+ */
+export const clearDocState = () => {
+  return store.dispatch({
+    type: CLEAR_DOC_STATE,
+  })
+}

+ 3 - 1
uas-office-web/uas-mobile/src/redux/constants/actionTypes.js

@@ -11,4 +11,6 @@ export const FRESH_HOME_STATE = 'FRESH_HOME_STATE'
 export const SAVE_LIST_STATE = 'SAVE_LIST_STATE'
 export const CLEAR_LIST_STATE = 'CLEAR_LIST_STATE'
 
-
+/**********************************应用********************************************/
+export const REFRESH_DOC_LIST = 'REFRESH_DOC_LIST'
+export const CLEAR_DOC_STATE = 'CLEAR_DOC_STATE'

+ 154 - 1
uas-office-web/uas-mobile/src/redux/reducers/redDocState.js

@@ -3,7 +3,160 @@
  * Desc: 应用数据缓存
  */
 
-const initDocState = {}
+const initDocState = {
+  docFuncGroupList: [
+    {
+      groupTitle: '销售管理',
+      groupIndex: 0,
+      funcList: [
+        {
+          name: '客户资料',
+          caller: '',
+          img: '',
+          often: true,
+          url: '',
+          groupIndex: 0,
+          childIndex: 0,
+        },
+        {
+          name: '客户拜访',
+          caller: '',
+          groupIndex: 0,
+          img: '',
+          often: false,
+          url: '',
+          childIndex: 1,
+        },
+      ],
+    },
+    {
+      groupTitle: '采购管理',
+      groupIndex: 1,
+      funcList: [
+        {
+          name: '供应商',
+          groupIndex: 1,
+          caller: '',
+          img: '',
+          often: false,
+          url: '',
+          childIndex: 0,
+        },
+        {
+          name: '物料资料',
+          caller: '',
+          groupIndex: 1,
+          img: '',
+          often: true,
+          url: '',
+          childIndex: 1,
+        },
+      ],
+    },
+    {
+      groupTitle: '人事考勤',
+      groupIndex: 2,
+      funcList: [
+        {
+          name: '请假',
+          caller: '',
+          img: '',
+          groupIndex: 2,
+          often: false,
+          url: '',
+          childIndex: 0,
+        },
+        {
+          name: '出差',
+          caller: '',
+          groupIndex: 2,
+          img: '',
+          often: true,
+          url: '',
+          childIndex: 1,
+        },
+        {
+          name: '加班',
+          caller: '',
+          img: '',
+          groupIndex: 2,
+          often: false,
+          url: '',
+          childIndex: 2,
+        },
+        {
+          name: '补卡',
+          caller: '',
+          groupIndex: 2,
+          img: '',
+          often: false,
+          url: '',
+          childIndex: 3,
+        },
+      ],
+    },
+    {
+      groupTitle: '行政办公',
+      groupIndex: 3,
+      funcList: [
+        {
+          name: '销售日报',
+          caller: '',
+          img: '',
+          groupIndex: 3,
+          often: false,
+          url: '',
+          childIndex: 0,
+        },
+        {
+          name: '周报',
+          caller: '',
+          img: '',
+          often: true,
+          groupIndex: 3,
+          url: '',
+          childIndex: 1,
+        },
+        {
+          name: '月报',
+          caller: '',
+          groupIndex: 3,
+          img: '',
+          often: true,
+          url: '',
+          childIndex: 2,
+        },
+        {
+          name: '季报',
+          caller: '',
+          groupIndex: 3,
+          img: '',
+          often: false,
+          url: '',
+          childIndex: 3,
+        },
+        {
+          name: '半年报',
+          caller: '',
+          groupIndex: 3,
+          img: '',
+          often: true,
+          url: '',
+          childIndex: 4,
+        },
+        {
+          name: '会议申请',
+          caller: '',
+          groupIndex: 3,
+          img: '',
+          often: false,
+          url: '',
+          childIndex: 5,
+        },
+      ],
+    },
+  ],
+}
 
 const redDocState = (state = initDocState, action) => {
   if (action === undefined) {

+ 140 - 1
uas-office-web/uas-mobile/src/redux/reducers/redReportState.js

@@ -3,7 +3,146 @@
  * Desc: 报表数据缓存
  */
 
-const initReportState = {}
+const initReportState = {
+  reportFuncList: [
+    {
+      groupTitle: '考勤报表',
+      groupIndex: 0,
+      funcList: [
+        {
+          name: '请假',
+          caller: '',
+          img: '',
+          groupIndex: 0,
+          often: false,
+          url: '',
+        },
+        {
+          name: '出差',
+          caller: '',
+          groupIndex: 0,
+          img: '',
+          often: true,
+          url: '',
+        },
+        {
+          name: '加班',
+          caller: '',
+          groupIndex: 0,
+          img: '',
+          often: false,
+          url: '',
+        },
+        {
+          name: '补卡',
+          caller: '',
+          groupIndex: 0,
+          img: '',
+          often: false,
+          url: '',
+        },
+      ],
+    },
+    {
+      groupTitle: '行政报表',
+      groupIndex: 1,
+      funcList: [
+        {
+          name: '销售日报',
+          caller: '',
+          img: '',
+          groupIndex: 1,
+          often: false,
+          url: '',
+        },
+        {
+          name: '周报',
+          caller: '',
+          img: '',
+          groupIndex: 1,
+          often: true,
+          url: '',
+        },
+        {
+          name: '月报',
+          caller: '',
+          groupIndex: 1,
+          img: '',
+          often: true,
+          url: '',
+        },
+        {
+          name: '季报',
+          caller: '',
+          groupIndex: 1,
+          img: '',
+          often: false,
+          url: '',
+        },
+        {
+          name: '半年报',
+          caller: '',
+          groupIndex: 1,
+          img: '',
+          often: true,
+          url: '',
+        },
+        {
+          name: '会议申请',
+          caller: '',
+          img: '',
+          groupIndex: 1,
+          often: false,
+          url: '',
+        },
+      ],
+    },
+    {
+      groupTitle: '采购报表',
+      groupIndex: 2,
+      funcList: [
+        {
+          name: '供应商',
+          caller: '',
+          img: '',
+          often: false,
+          groupIndex: 2,
+          url: '',
+        },
+        {
+          name: '物料资料',
+          caller: '',
+          img: '',
+          often: true,
+          groupIndex: 2,
+          url: '',
+        },
+      ],
+    },
+    {
+      groupTitle: '销售报表',
+      groupIndex: 3,
+      funcList: [
+        {
+          name: '客户资料',
+          caller: '',
+          groupIndex: 3,
+          img: '',
+          often: true,
+          url: '',
+        },
+        {
+          name: '客户拜访',
+          caller: '',
+          img: '',
+          groupIndex: 3,
+          often: false,
+          url: '',
+        },
+      ],
+    },
+  ],
+}
 
 const redReportState = (state = initReportState, action) => {
   if (action === undefined) {

+ 296 - 124
uas-office-web/uas-mobile/src/utils/common.util.js

@@ -1,11 +1,38 @@
+/**
+ * 对象是否为null或undefined
+ * @param obj
+ * @returns {boolean}
+ */
 export function isObjNull (obj) {
   return (obj == null || obj == undefined)
 }
 
-export function isObjEmpty (obj) {
-  return isObjNull(obj) || obj.length == 0
+/**
+ * 对象是否为null或undefined或长度为0
+ * @param obj
+ * @returns {boolean}
+ */
+export function isObjEmpty () {
+  let args = arguments
+  if (isObjNull(args) || (args.length == 0)) {
+    return true
+  } else {
+    for (let i = 0; i < args.length; i++) {
+      let arg = args[i]
+      if (isObjNull(arg) ||
+        (typeof arg === 'string' ? arg.trim().length == 0 : arg.length == 0)) {
+        return true
+      }
+    }
+    return false
+  }
 }
 
+/**
+ * 是否为空object
+ * @param obj
+ * @returns {boolean}
+ */
 export function isEmptyObject (obj) {
   if (isObjNull(obj)) {
     return false
@@ -19,6 +46,12 @@ export function isEmptyObject (obj) {
   return true
 }
 
+/**
+ * 字符串是否包含另一字符串
+ * @param parent
+ * @param child
+ * @returns {boolean}
+ */
 export function strContain (parent, child) {
   if (isObjEmpty(parent)) {
     return false
@@ -26,6 +59,12 @@ export function strContain (parent, child) {
   return (parent.indexOf(child) != -1)
 }
 
+/**
+ * 根据key取某对象中的String值
+ * @param object
+ * @param key
+ * @returns {*}
+ */
 export function getStrValue (object, key) {
   if (isObjNull(object)) {
     return ''
@@ -36,6 +75,12 @@ export function getStrValue (object, key) {
   return object[key]
 }
 
+/**
+ * 根据key取某对象中的Number值
+ * @param object
+ * @param key
+ * @returns {*}
+ */
 export function getIntValue (object, key) {
   if (isObjNull(object)) {
     return 0
@@ -46,6 +91,12 @@ export function getIntValue (object, key) {
   return object[key]
 }
 
+/**
+ * 根据key取某对象中的日期long值
+ * @param object
+ * @param key
+ * @returns {*}
+ */
 export function getTimeValue (object, key) {
   if (isObjNull(object)) {
     return 0
@@ -66,6 +117,12 @@ export function getTimeValue (object, key) {
   }
 }
 
+/**
+ * 根据key取某对象中的Array值
+ * @param object
+ * @param key
+ * @returns {*}
+ */
 export function getArrayValue (object, key) {
   if (isObjNull(object)) {
     return []
@@ -76,6 +133,12 @@ export function getArrayValue (object, key) {
   return object[key]
 }
 
+/**
+ * 根据key取某对象中的Object值
+ * @param object
+ * @param key
+ * @returns {*}
+ */
 export function getObjValue (object, key) {
   if (isObjNull(object)) {
     return {}
@@ -116,8 +179,6 @@ export function getParenthesesStr (text) {
   if (isObjEmpty(text))
     return result
   let regex = /\((.+?)\)/g
-  //去除转义字符
-  text = text.replace(/[\'\"\b\f\n\r\t]/g, '')
   let options = text.match(regex)
   if (!isObjEmpty(options)) {
     let option = options[0]
@@ -128,6 +189,64 @@ export function getParenthesesStr (text) {
   return result
 }
 
+/**
+ * 是否以某一字符串开头
+ * @param s
+ * @returns {boolean}
+ */
+String.prototype.startWith = function (s) {
+  if (s == null || s == '' || this.length == 0 || s.length > this.length)
+    return false
+  if (this.substr(0, s.length) == s)
+    return true
+  else
+    return false
+  return true
+}
+
+/**
+ * 是否以某一字符串结尾
+ * @param s
+ * @returns {boolean}
+ */
+String.prototype.endWith = function (s) {
+  if (s == null || s == '' || this.length == 0 || s.length > this.length)
+    return false
+  if (this.substring(this.length - s.length) == s)
+    return true
+  else
+    return false
+  return true
+}
+
+/**
+ * 是否存在于参数字符串列表中
+ * @returns {boolean}
+ */
+String.prototype.isStrEquals = function () {
+  let args = arguments
+  if (isObjNull(args) || args.length == 0) {
+    return false
+  } else {
+    for (let i = 0; i < args.length; i++) {
+      let arg = args[i]
+      if (isObjNull(arg)) {
+        return false
+      }
+      if (this === arg) {
+        return true
+      }
+    }
+    return false
+  }
+}
+
+/**
+ * 字符串全局替换
+ * @param reg
+ * @param s
+ * @returns {string}
+ */
 String.prototype.replaceAll = function (reg, s) {
   if (isObjEmpty(this)) {
     return ''
@@ -135,6 +254,28 @@ String.prototype.replaceAll = function (reg, s) {
   return this.replace(new RegExp(reg, 'gm'), s)
 }
 
+//yyyy-MM-dd hh:mm:ss
+Date.prototype.format = function (fmt) {
+  let o = {
+    'M+': this.getMonth() + 1,                 //月份
+    'd+': this.getDate(),                    //日
+    'h+': this.getHours(),                   //小时
+    'm+': this.getMinutes(),                 //分
+    's+': this.getSeconds(),                 //秒
+    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
+    'S': this.getMilliseconds(),             //毫秒
+  }
+  if (/(y+)/.test(fmt))
+    fmt = fmt.replace(RegExp.$1,
+      (this.getFullYear() + '').substr(4 - RegExp.$1.length))
+  for (var k in o)
+    if (new RegExp('(' + k + ')').test(fmt))
+      fmt = fmt.replace(RegExp.$1,
+        (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(
+          ('' + o[k]).length)))
+  return fmt
+}
+
 /**
  * Map转json
  * @param m
@@ -158,31 +299,6 @@ export function MapToJson (m) {
   return str
 }
 
-export function strMapToObj (m) {
-  if (isObjEmpty(m)) {
-    return ''
-  }
-  var str = '['
-  if (isObjEmpty(m)) {
-    return ''
-  }
-  m.forEach(function (item, key) {
-    var obj = JSON.stringify(_strMapToObj(item))
-    str += obj + ','
-  })
-  str = str.slice(0, str.length - 1)
-  str += ']'
-  return str
-}
-
-export function _strMapToObj (item) {
-  let obj = Object.create(null)
-  for (let [k, v] of item) {
-    obj[k] = v
-  }
-  return obj
-}
-
 /**
  * require.context(directory, useSubdirectories = false, regExp = /^\.\//);
  * 获取目标目录下符合条件的所有文件
@@ -196,120 +312,136 @@ export function getDirFiles (directory, useSubdirectories, regExp) {
   return context.keys().map(context)
 }
 
-/**
- * 获取当前操作系统
- * @returns {string}
- */
-export function getOS () {
-  let os, navigator = window.navigator
-  if (navigator.userAgent.indexOf('Android') > -1 ||
-    navigator.userAgent.indexOf('Linux') > -1) {
-    os = 'Android'
-  } else if (navigator.userAgent.indexOf('iPhone') > -1 ||
-    navigator.userAgent.indexOf('iPad') > -1) {
-    os = 'iOS'
-  } else if (navigator.userAgent.indexOf('Windows Phone') > -1) {
-    os = 'WP'
-  } else {
-    os = 'Others'
+export const getCheckedNodes = (extra) => {
+  let checkedNodes = extra.allCheckedNodes || [extra.triggerNode]
+  // let count = getCheckedCount(checkedNodes)
+  if (isObjEmpty(checkedNodes)) {
+    checkedNodes = []
   }
-  return os
+  checkedNodes = getNodes(checkedNodes)
+  console.log('checkNodes', checkedNodes)
+  return { checkedNodes, count: checkedNodes.length }
 }
 
-/**
- * 网页是否运行在移动端
- * @returns {boolean}
- */
-export function isMobile () {
-  if ((navigator.userAgent.match(
-    /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
-    return true
+export const getCheckedCount = (checkedNodes) => {
+  if (!isObjEmpty(checkedNodes)) {
+    let quantity = 0
+    for (let i = 0; i < checkedNodes.length; i++) {
+      let checkedNode = checkedNodes[i]
+      if (checkedNode) {
+        if (checkedNode.node) {
+          if (checkedNode.children) {
+            checkedNode = checkedNode.children
+            quantity = quantity + getCheckedCount(checkedNode)
+          } else {
+            quantity = quantity + 1
+            continue
+          }
+        } else {
+          if (checkedNode.props) {
+            if (checkedNode.props.children.length > 0) {
+              checkedNode = checkedNode.props.children
+              quantity = quantity + getCheckedCount(checkedNode)
+            } else {
+              quantity = quantity + 1
+              continue
+            }
+          }
+        }
+      } else {
+        continue
+      }
+    }
+    return quantity
   } else {
-    return false
+    return 0
   }
 }
 
-/**
- * 获取sessionId
- * @returns {string}
- */
-export function getSessionId () {
-  let c_name = 'JSESSIONID'
-  if (document.cookie.length > 0) {
-    let c_start = document.cookie.indexOf(c_name + '=')
-    if (c_start != -1) {
-      let c_start = c_start + c_name.length + 1
-      let c_end = document.cookie.indexOf(';', c_start)
-      if (c_end == -1) c_end = document.cookie.length
-      return unescape(document.cookie.substring(c_start, c_end))
+export const getNodes = (checkedNodes) => {
+  if (!isObjEmpty(checkedNodes)) {
+    let childNodes = []
+    for (let i = 0; i < checkedNodes.length; i++) {
+      let checkedNode = checkedNodes[i]
+      if (checkedNode) {
+        if (checkedNode.node && checkedNode.node.props) {
+          const checkProps = checkedNode.node.props
+          if (!isObjEmpty(checkProps.children)) {
+            checkedNode = checkProps.children
+            childNodes = childNodes.concat(getNodes(checkedNode))
+          } else {
+            let exist = false
+            for (let j = 0; j < childNodes.length; j++) {
+              if (checkProps && checkProps.value == childNodes[j].value) {
+                exist = true
+                break
+              }
+            }
+            if (!exist) {
+              childNodes.push(checkProps)
+            }
+            continue
+          }
+        } else {
+          if (checkedNode.props) {
+            const checkProps = checkedNode.props
+            if (!isObjEmpty(checkProps.children)) {
+              checkedNode = checkProps.children
+              childNodes = childNodes.concat(getNodes(checkedNode))
+            } else {
+              let exist = false
+              for (let j = 0; j < childNodes.length; j++) {
+                if (checkProps && checkProps.value == childNodes[j].value) {
+                  exist = true
+                  break
+                }
+              }
+              if (!exist) {
+                childNodes.push(checkProps)
+              }
+              continue
+            }
+          }
+        }
+      } else {
+        continue
+      }
     }
+    return childNodes
+  } else {
+    return []
   }
 }
 
-//yyyy-MM-dd hh:mm:ss
-Date.prototype.format = function (fmt) {
-  let o = {
-    'M+': this.getMonth() + 1,                 //月份
-    'd+': this.getDate(),                    //日
-    'h+': this.getHours(),                   //小时
-    'm+': this.getMinutes(),                 //分
-    's+': this.getSeconds(),                 //秒
-    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
-    'S': this.getMilliseconds(),             //毫秒
+export const getFileType = (filePath) => {
+  var startIndex = filePath.lastIndexOf('.')
+  if (startIndex != -1) {
+    return filePath.substring(startIndex + 1, filePath.length).toLowerCase()
+  } else {
+    return ''
   }
-  if (/(y+)/.test(fmt))
-    fmt = fmt.replace(RegExp.$1,
-      (this.getFullYear() + '').substr(4 - RegExp.$1.length))
-  for (var k in o)
-    if (new RegExp('(' + k + ')').test(fmt))
-      fmt = fmt.replace(RegExp.$1,
-        (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(
-          ('' + o[k]).length)))
-  return fmt
 }
 
-String.prototype.endWith = function (s) {
-  if (s == null || s == '' || this.length == 0 || s.length > this.length)
-    return false
-  if (this.substring(this.length - s.length) == s)
-    return true
-  else
-    return false
-  return true
-}
-
-String.prototype.startWith = function (s) {
-  if (s == null || s == '' || this.length == 0 || s.length > this.length)
-    return false
-  if (this.substr(0, s.length) == s)
-    return true
-  else
-    return false
-  return true
+export const getVisibleObj = (obj1, obj2) => {
+  return isObjNull(obj1) ? obj2 : obj1
 }
 
-/**
- * 数字字符串添加千分位符
- * @param num
- * @returns {string}
- */
-export function numFormat (num) {
-  if (isObjEmpty(num)) {
-    return ''
+//生成从minNum到maxNum的随机数
+export function randomNum (minNum, maxNum) {
+  switch (arguments.length) {
+    case 1:
+      return parseInt(Math.random() * minNum + 1, 10)
+      break
+    case 2:
+      return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
+      break
+    default:
+      return 0
+      break
   }
-  var res = num.toString().replace(/\d+/, function (n) { // 先提取整数部分
-    return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) {
-      return $1 + ','
-    })
-  })
-  return res
 }
 
-/**
- * 解析url的search参数
- * @param searchStr
- * @returns {Object}
- */
+//解析url的search参数
 export function getSearchParams (searchStr) {
   let params = new Object()
   if (!isObjEmpty(searchStr) && searchStr.indexOf('?') != -1) {
@@ -322,3 +454,43 @@ export function getSearchParams (searchStr) {
   }
   return params
 }
+
+//阿拉伯数字转中文数字
+export function NoToChinese (num) {
+  if (!/^\d*(\.\d*)?$/.test(num)) {
+    alert('Number is wrong!')
+    return 'Number is wrong!'
+  }
+  var AA = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九')
+  var BB = new Array('', '十', '百', '千', '万', '亿', '点', '')
+  var a = ('' + num).replace(/(^0*)/g, '').split('.'),
+    k = 0,
+    re = ''
+  for (var i = a[0].length - 1; i >= 0; i--) {
+    switch (k) {
+      case 0:
+        re = BB[7] + re
+        break
+      case 4:
+        if (!new RegExp('0{4}\\d{' + (a[0].length - i - 1) + '}$').test(a[0]))
+          re = BB[4] + re
+        break
+      case 8:
+        re = BB[5] + re
+        BB[7] = BB[5]
+        k = 0
+        break
+    }
+    if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) ==
+      0) re = AA[0] + re
+    if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re
+    k++
+  }
+  if (a.length > 1) //加上小数部分(如果有小数部分)
+  {
+    re += BB[6]
+    for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)]
+  }
+  return re
+}
+