Browse Source

uas手机版
应用菜单接口对接

RaoMeng 5 years ago
parent
commit
072788bd2f

+ 1 - 1
uas-office-web/uas-mobile/src/components/common/currencyListItem/CurrencyRow.jsx

@@ -25,7 +25,7 @@ export default class CurrencyRow extends Component {
     return (
       <div className='currency-row-root'>
         <div className='currency-row-caption'>caption</div>
-        <div className='currency-row-value'>value</div>
+        <div className='currency-row-value'>valuevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevalue</div>
       </div>
     )
   }

+ 9 - 2
uas-office-web/uas-mobile/src/components/common/currencyListItem/currency-list-item.less

@@ -1,7 +1,7 @@
 .currency-list-item-root {
   .com-column-flex;
   padding: 8px;
-  width: 100%;
+  width: 100vw;
   background-color: white;
   border-bottom: 1px solid @com-color-divide-gray-line;
 }
@@ -10,17 +10,24 @@
 .currency-row-root {
   .com-row-flex;
   width: 100%;
-  padding: 2px;
+  padding: 1px 2px;
   font-size: @com-form-fontsize-normal;
 
   .currency-row-caption {
     width: 80px;
+    overflow: hidden;
+    word-wrap: break-word;
+    word-break: normal;
     color: @com-caption-text-color;
   }
 
   .currency-row-value {
     flex: 1;
+    max-height: 80px;
     padding-left: 10px;
+    overflow: auto;
+    word-wrap: break-word;
+    word-break: normal;
     color: @com-text-color-normal;
   }
 }

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

@@ -33,7 +33,7 @@ export default class FuncItem extends Component {
         onClick={this.onFuncClick.bind(this)}>
         <div className='func-func-layout'>
           <img className='func-func-icon'
-               src={funcObj.imgUrl}/>
+               src={funcObj.img}/>
           <span className='func-func-text'>{funcObj.name}</span>
           {
             (sup || funcObj.sup) &&

+ 55 - 55
uas-office-web/uas-mobile/src/components/common/refreshLayout/RefreshLayout.jsx

@@ -3,70 +3,70 @@
  * Desc: antd刷新组件二次封装
  */
 
-import React, {Component} from 'react'
-import {PullToRefresh} from "antd-mobile";
+import React, { Component } from 'react'
+import { PullToRefresh } from 'antd-mobile'
 import PropTypes from 'prop-types'
 
 export default class RefreshLayout extends Component {
 
-    static propTypes = {
-        direction: PropTypes.string,//刷新方向:up或down,默认up
-        refreshing: PropTypes.bool.isRequired,//是否正在刷新
-        style: PropTypes.object,//样式,有默认样式一般可以不传
-        onRefresh: PropTypes.func.isRequired,//加载方法,必传
-        damping: PropTypes.number,//加载距离,不用传
-        distanceToRefresh: PropTypes.number,//可拉动距离,不用传
-        height:PropTypes.number,//组件高度,一般不用传
-    }
+  static propTypes = {
+    direction: PropTypes.string,//刷新方向:up或down,默认up
+    refreshing: PropTypes.bool.isRequired,//是否正在刷新
+    style: PropTypes.object,//样式,有默认样式一般可以不传
+    onRefresh: PropTypes.func.isRequired,//加载方法,必传
+    damping: PropTypes.number,//加载距离,不用传
+    distanceToRefresh: PropTypes.number,//可拉动距离,不用传
+    height: PropTypes.number,//组件高度,一般不用传
+  }
 
-    static defaultProps = {
-        direction: 'up',
-        damping: 120,
-        distanceToRefresh: 30
-    }
+  static defaultProps = {
+    direction: 'up',
+    damping: 120,
+    distanceToRefresh: 30,
+  }
 
-    constructor() {
-        super()
+  constructor () {
+    super()
 
-        this.state = {
-            height: document.documentElement.clientHeight
-        }
+    this.state = {
+      height: document.documentElement.clientHeight,
     }
+  }
 
-    componentDidMount() {
-        setTimeout(() => {
-            if (this.props.height) {
-                this.setState({
-                    height: this.props.height,
-                })
-            } else {
-                // const hei = this.state.height - ReactDOM.findDOMNode(this.ptr).offsetTop;
-                // this.setState({
-                //     height: hei
-                // })
-            }
-        }, 0);
-    }
+  componentDidMount () {
+    setTimeout(() => {
+      if (this.props.height) {
+        this.setState({
+          height: this.props.height,
+        })
+      } else {
+        // const hei = this.state.height - ReactDOM.findDOMNode(this.ptr).offsetTop;
+        // this.setState({
+        //     height: hei
+        // })
+      }
+    }, 0)
+  }
 
-    render() {
-        const {height} = this.state
-        const {direction, refreshing,style, onRefresh, damping, distanceToRefresh} = this.props
+  render () {
+    const { height } = this.state
+    const { direction, refreshing, style, onRefresh, damping, distanceToRefresh } = this.props
 
-        return (
-            <PullToRefresh
-                direction={direction}
-                refreshing={refreshing}
-                ref={el => this.ptr = el}
-                style={{
-                    height: height,
-                    overflow: 'auto',
-                    ...style
-                }}
-                damping={damping}
-                distanceToRefresh={distanceToRefresh}
-                onRefresh={onRefresh}>
-                {this.props.children}
-            </PullToRefresh>
-        )
-    }
+    return (
+      <PullToRefresh
+        direction={direction}
+        refreshing={refreshing}
+        ref={el => this.ptr = el}
+        style={{
+          height: height,
+          overflow: 'auto',
+          ...style,
+        }}
+        damping={damping}
+        distanceToRefresh={distanceToRefresh}
+        onRefresh={onRefresh}>
+        {this.props.children}
+      </PullToRefresh>
+    )
+  }
 }

+ 8 - 1
uas-office-web/uas-mobile/src/configs/api.config.js

@@ -4,9 +4,16 @@
  */
 
 export const _host = window.location.origin
+  && 'http://usoft.f3322.net:10007/uas'
+  && 'http://10.1.7.104:8080/ERP'
 
 export const _baseURL = _host + (process.env.REACT_APP_ROUTER_BASE_NAME || '')
 
 export const API = {
-  test: _baseURL + '',
+  /*******************************应用*************************************/
+  //应用菜单列表
+  APPCOMMON_GETSERVICE: _baseURL + '/mobile/appcommon/getServices.action',
+  //保存常用应用
+  APPCOMMON_SAVECOMMONSERVICES: _baseURL +
+    '/mobile/appcommon/saveCommonServices.action',
 }

+ 8 - 1
uas-office-web/uas-mobile/src/pages/common/currencyList/CurrencyList.jsx

@@ -108,6 +108,7 @@ class CurrencyList extends Component {
         <UasIcon
           type={'uas-add-doc'}
           className='com-hover-button'
+          onClick={this.onDocAdd}
         />
       </div>
     )
@@ -131,7 +132,9 @@ class CurrencyList extends Component {
   getFilterLayout = () => {
     return (
       <div
-        className='currency-list-content-filter-content'>筛选条件</div>
+        className='currency-list-content-filter-content'>
+        <div>筛选条件</div>
+      </div>
     )
   }
 
@@ -153,6 +156,10 @@ class CurrencyList extends Component {
     })
   }
 
+  onDocAdd = () => {
+
+  }
+
   handlePrompt = (location) => {
     if (this.state.filterOpen) {
       this.setState({

+ 62 - 0
uas-office-web/uas-mobile/src/pages/private/homePage/DocRoot.jsx

@@ -7,6 +7,11 @@ import React, { Component } from 'react'
 import { connect } from 'react-redux'
 import { isObjEmpty } from '../../../utils/common.util'
 import FuncGroup from '../../../components/common/func/FuncGroup'
+import { fetchPostObj } from '../../../utils/fetchRequest'
+import { API } from '../../../configs/api.config'
+import { Toast } from 'antd-mobile'
+import { message } from 'antd'
+import { refreshDocList } from '../../../redux/actions/docState'
 
 class DocRoot extends Component {
 
@@ -18,6 +23,7 @@ class DocRoot extends Component {
 
   componentDidMount () {
     console.log('DocRoot')
+    this.getServices()
   }
 
   componentWillUnmount () {
@@ -45,6 +51,62 @@ class DocRoot extends Component {
       </div>
     )
   }
+
+  getServices = () => {
+    Toast.loading('正在获取应用列表', 0)
+    fetchPostObj(API.APPCOMMON_GETSERVICE, {
+      kind: 'uasapp',
+    }).then(response => {
+      Toast.hide()
+      const data = response.data
+      const docFuncGroupList = []
+      if (!isObjEmpty(data)) {
+        const responseList = data.list
+        if (!isObjEmpty(responseList)) {
+          responseList.forEach((groupItem, groupIndex) => {
+            let docFuncGroup = {
+              groupTitle: groupItem.groupTitle,
+              groupIndex: groupIndex,
+            }
+            const funcList = groupItem.funcList
+            if (!isObjEmpty(funcList)) {
+              let docFuncList = []
+              funcList.forEach((childItem, childIndex) => {
+                const docFunc = {
+                  id: childIndex.fid,
+                  name: childItem.name,
+                  caller: childItem.caller,
+                  img: childItem.icon && childItem.icon.exticon,
+                  often: childItem.often,
+                  url: childItem.url && childItem.url.skipurl,
+                  countUrl: childItem.url && childItem.url.counturl,
+                  groupIndex: groupIndex,
+                  childIndex: childIndex,
+                }
+                docFuncList.push(docFunc)
+              })
+              docFuncGroup.funcList = docFuncList
+            }
+            docFuncGroupList.push(docFuncGroup)
+          })
+        }
+      }
+
+      refreshDocList({
+        docFuncGroupList,
+      })
+    }).catch(error => {
+      Toast.hide()
+      refreshDocList({
+        docFuncGroupList: [],
+      })
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('应用列表获取失败')
+      }
+    })
+  }
 }
 
 let mapStateToProps = (state) => ({

+ 20 - 4
uas-office-web/uas-mobile/src/pages/private/oftenFunc/OftenFuncManage.jsx

@@ -15,6 +15,8 @@ import { isObjEmpty, isObjNull } from '../../../utils/common.util'
 import { refreshDocList } from '../../../redux/actions/docState'
 import { message } from 'antd'
 import { Toast } from 'antd-mobile'
+import { fetchPostObj } from '../../../utils/fetchRequest'
+import { API } from '../../../configs/api.config'
 
 class OftenFuncManage extends Component {
 
@@ -71,6 +73,7 @@ class OftenFuncManage extends Component {
         }
       })
     }
+    this.oftenFuncList = oftenFunc.funcList
 
     return (
       <div className='often-func-root'>
@@ -107,11 +110,24 @@ class OftenFuncManage extends Component {
   }
 
   onSaveOften = () => {
-    refreshDocList({
-      docFuncGroupList: this.state.docFuncGroupStateList,
+    Toast.loading('正在保存', 0)
+    fetchPostObj(API.APPCOMMON_SAVECOMMONSERVICES, {
+      data: this.oftenFuncList,
+    }).then(response => {
+      Toast.hide()
+      refreshDocList({
+        docFuncGroupList: this.state.docFuncGroupStateList,
+      })
+      message.success('保存成功')
+      this.props.history.goBack()
+    }).catch(error => {
+      Toast.hide()
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('常用应用保存失败')
+      }
     })
-    message.success('保存成功')
-    this.props.history.goBack()
   }
 }
 

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

@@ -9,158 +9,7 @@ import {
  */
 
 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,
-        },
-      ],
-    },
-  ],
+  docFuncGroupList: [],
 }
 
 const redDocState = (state = initDocState, action) => {

+ 6 - 5
uas-office-web/uas-mobile/src/utils/common.util.js

@@ -14,13 +14,14 @@ export function isObjNull (obj) {
  */
 export function isObjEmpty () {
   let args = arguments
-  if (isObjNull(args) || (args.length == 0)) {
+  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)) {
+        (typeof arg === 'string' ? arg.trim().length === 0 : arg.length ===
+          0)) {
         return true
       }
     }
@@ -271,7 +272,7 @@ Date.prototype.format = function (fmt) {
   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(
+        (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(
           ('' + o[k]).length)))
   return fmt
 }
@@ -288,7 +289,7 @@ export function MapToJson (m) {
   var str = '{'
   var i = 1
   m.forEach(function (item, key, mapObj) {
-    if (mapObj.size == i) {
+    if (mapObj.size === i) {
       str += '"' + key + '":"' + item + '"'
     } else {
       str += '"' + key + '":"' + item + '",'
@@ -481,7 +482,7 @@ export function NoToChinese (num) {
         k = 0
         break
     }
-    if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) ==
+    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++

+ 9 - 19
uas-office-web/uas-mobile/src/utils/fetchRequest.js

@@ -70,8 +70,8 @@ export function fetchPostObj (url, params, header) {
     // cache: "force-cache",
     headers: new Headers({
       'Accept': 'application/json',
-      // "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
       // "Authorization": userInfo.token,
+      'Content-Type': 'application/json',
       ...header,
     }),
   })
@@ -153,17 +153,12 @@ function fetchResult (request) {
         let resultJson = result.json()
         return resultJson
       } else {
-        if (result.exceptionInfo) {
-          if (result.exceptionInfo.length > 80) {
-            throw '接口请求异常'
-          } else {
-            throw result.exceptionInfo.replace(/<[\/\!]*[^<>]*>/ig, '')
-          }
-        } else if (result.message) {
-          if (result.message.length > 80) {
+        if (result.exceptionInfo || result.message) {
+          if ((result.exceptionInfo || result.message).length > 80) {
             throw '接口请求异常'
           } else {
-            throw result.message.replace(/<[\/\!]*[^<>]*>/ig, '')
+            throw (result.exceptionInfo || result.message).replace(
+              /<[\/\!]*[^<>]*>/ig, '')
           }
         } else {
           throw result
@@ -171,17 +166,12 @@ function fetchResult (request) {
       }
     }).then(result => {
       if (result.hasOwnProperty('success') && result.success === false) {
-        if (result.exceptionInfo) {
-          if (result.exceptionInfo.length > 80) {
-            throw '接口请求异常'
-          } else {
-            throw result.exceptionInfo
-          }
-        } else if (result.message) {
-          if (result.message.length > 80) {
+        if (result.exceptionInfo || result.message) {
+          if ((result.exceptionInfo || result.message).length > 80) {
             throw '接口请求异常'
           } else {
-            throw result.message
+            throw (result.exceptionInfo || result.message).replace(
+              /<[\/\!]*[^<>]*>/ig, '')
           }
         } else {
           throw result