Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/uas-office-integration

samhoo 6 years ago
parent
commit
55a71edc63

+ 0 - 1
uas-office-web/wxuasapproval/src/components/approvalAdd/FormInput.jsx

@@ -171,7 +171,6 @@ export default class FormInput extends Component {
     const { billModel } = this.state
     if(this.isSelect(billModel)){
       if (!isObjEmpty(billModel.localDatas)) {
-        console.log('modaldata', billModel.localDatas)
         this.setState({
           modalList: billModel.localDatas,
           modalOpen: true,

+ 2 - 8
uas-office-web/wxuasapproval/src/pages/approval/Approval.jsx

@@ -473,9 +473,6 @@ class Approval extends Component {
                       changeModalOpen: false,
                     })
                   }}
-                  style={{
-                    height: '80vh',
-                  }}
                   title={'变更处理人'}
                   popup
     >
@@ -529,9 +526,6 @@ class Approval extends Component {
       <ListView
         dataSource={this.state.changeDataSource}
         renderRow={(rowData, sectionID, rowID) => {
-          // console.log('raomeng', rowData)
-          // console.log('raomeng', sectionID)
-          // console.log('raomeng', rowID)
           return <List.Item
             key={rowID}
             wrap
@@ -541,10 +535,10 @@ class Approval extends Component {
           </List.Item>
         }}
         style={{
-          height: '80vh',
+          height: '72vh',
           overflow: 'auto',
         }}
-        pageSize={4}
+        pageSize={10}
         onScroll={() => {}}
         scrollRenderAheadDistance={500}
         onEndReachedThreshold={10}

+ 269 - 106
uas-office-web/wxuasapproval/src/pages/approval/ApprovalAdd.jsx

@@ -4,9 +4,22 @@
  */
 
 import React, { Component } from 'react'
-import { isObjEmpty, isObjNull } from '../../utils/common'
+import {
+  getParenthesesStr,
+  isObjEmpty,
+  isObjNull,
+  strContain,
+} from '../../utils/common'
 import { message } from 'antd'
-import { Toast, List, Button, Modal, Checkbox } from 'antd-mobile'
+import {
+  Toast,
+  List,
+  Button,
+  Modal,
+  Checkbox,
+  ListView,
+  SearchBar,
+} from 'antd-mobile'
 import { fetchGet, fetchPost } from '../../utils/fetchRequest'
 import BillModel, {
   TYPE_ADD,
@@ -19,10 +32,13 @@ import FormInput from '../../components/approvalAdd/FormInput'
 import FormTitle from '../../components/approvalAdd/FormTitle'
 import FormAdd from '../../components/approvalAdd/FormAdd'
 import FormImage from '../../components/approvalAdd/FormImage'
+import EmployeeItem from '../../components/employeeItem/EmployeeItem'
 
 const alert = Modal.alert
 const CheckboxItem = Checkbox.CheckboxItem
 
+const SELECT_APPROVAL = 'select_approval'
+
 let mCaller//当前单据的Caller
 let mId//当前单据拥有的id,新增默认为0  如果mid为-1,说明保存时候使用更新的接口
 let mMaster
@@ -33,6 +49,8 @@ let mStatusField//状态字段
 let mDetailMainKeyField//从表
 let mDefaultMap
 
+let mModalList = []
+
 let mShowBillModels, mFormBillModels, mUpdateBillModels, mAllBillModels
 
 let mBaseUrl = window.location.origin
@@ -48,7 +66,9 @@ export default class ApprovalAdd extends Component {
     this.state = {
       billGroupModelList: [],
       modalOpen: false,
-      modalList: [],
+      modalDataSource: new ListView.DataSource({
+        rowHasChanged: (row1, row2) => row1 !== row2,
+      }),
       selectModel: {},
     }
   }
@@ -75,8 +95,7 @@ export default class ApprovalAdd extends Component {
   }
 
   render () {
-    const { billGroupModelList, modalOpen, modalList, selectModel } = this.state
-    let selectType = selectModel.type
+    const { billGroupModelList } = this.state
     let formItems = []
     if (!isObjEmpty(billGroupModelList)) {
       //从表的起始Groupindex
@@ -118,11 +137,6 @@ export default class ApprovalAdd extends Component {
                                  childIndex={i}/>,
                     )
                     break
-                    // case 110:
-                    //   formItems.push(
-                    //     <FormAdd/>,
-                    //   )
-                    break
                   default:
                     break
                 }
@@ -156,71 +170,161 @@ export default class ApprovalAdd extends Component {
                 }}
                 onClick={this.onSubmitClick}>提交</Button>}
 
-        <Modal visible={modalOpen}
-               animationType={'slide-up'}
-               onClose={() => {
-                 this.setState({
-                   modalOpen: false,
-                 })
-               }}
-               title={selectModel.caption}
-               popup
-        >
-          <List className='form-common-modal-root'>
-            {modalList && (
-              modalList.map((modalObj, index) => (
-                (selectType === 'MF')
-                  ? (<CheckboxItem key={index}
-                                   checked={modalObj.isSelected == true}
-                                   onChange={e => {
-                                     let checked = e.target.checked
-                                     modalList[index].isSelected = checked
-                                     this.setState({
-                                       modalList,
-                                     })
-                                   }}>{modalObj.value}</CheckboxItem>)
-                  : (<List.Item key={index}
-                                wrap
-                                onClick={this.onDbfindSelect.bind(this,
-                                  selectModel,
-                                  index)}>{modalObj.value}</List.Item>)
-
-              ))
-            )}
-          </List>
-        </Modal>
+        {this.getDbfindModal()}
       </div>
     )
   }
 
+  /**
+   * 放大镜弹框
+   * @returns {*}
+   */
+  getDbfindModal () {
+    const { modalOpen, modalDataSource, selectModel } = this.state
+    let selectType = selectModel.type
+    return <Modal visible={modalOpen}
+                  animationType={'slide-up'}
+                  onClose={() => {
+                    this.setState({
+                      modalOpen: false,
+                    })
+                  }}
+                  title={selectModel.caption}
+                  popup
+    >
+      <SearchBar
+        placeholder={'搜索'}
+        maxLength={16}
+        onChange={value => {
+          if (isObjEmpty(value)) {
+            this.setState({
+              modalDataSource: modalDataSource.cloneWithRows(
+                mModalList),
+            })
+          } else {
+            let searchList = []
+            if (!isObjEmpty(mModalList)) {
+              mModalList.forEach(item => {
+                if (!isObjNull(item)
+                  && (
+                    strContain(item.value, value)
+                    || strContain(item.display, value)
+                    || strContain(item.name, value)
+                  )) {
+                  searchList.push(item)
+                }
+              })
+            }
+            this.setState({
+              modalDataSource: modalDataSource.cloneWithRows(
+                searchList),
+            })
+          }
+        }}
+        onClear={value => {
+          this.setState({
+            modalDataSource: modalDataSource.cloneWithRows(
+              mModalList),
+          })
+        }}
+        onCancel={() => {
+          this.setState({
+            modalDataSource: modalDataSource.cloneWithRows(
+              mModalList),
+          })
+        }}
+      />
+      <ListView
+        dataSource={modalDataSource}
+        renderRow={(rowData, sectionID, rowID) => {
+          return (selectType === 'MF')
+            ? (<CheckboxItem key={rowID}
+                             checked={rowData.isSelected == true}
+                             onChange={e => {
+                               let checked = e.target.checked
+                               rowData.isSelected = checked
+                               this.setState({
+                                 modalDataSource,
+                               })
+                             }}>{rowData.value}</CheckboxItem>)
+            : (<List.Item key={rowID}
+                          wrap
+                          onClick={this.onDbfindSelect.bind(this,
+                            selectModel,
+                            rowData)}>{rowData.value}</List.Item>)
+        }}
+        style={{
+          height: '72vh',
+          overflow: 'auto',
+        }}
+        pageSize={10}
+        onScroll={() => {}}
+        scrollRenderAheadDistance={500}
+      />
+    </Modal>
+  }
+
   /**
    * 放大镜选项选中
    */
-  onDbfindSelect = (selectModel, index) => {
-    const { billGroupModelList, modalList } = this.state
-    let groupIndex = selectModel.groupIndex
-    let childIndex = selectModel.childIndex
-    let selectData = modalList[index]
-    if (selectModel.type === 'C') {
-      if (!isObjEmpty(billGroupModelList) &&
-        !isObjNull(billGroupModelList[groupIndex])) {
-        let billGroup = billGroupModelList[groupIndex]
-        billGroup[childIndex].value = selectData.value
-        billGroup[childIndex].display = selectData.display
-      }
+  onDbfindSelect = (selectModel, rowData) => {
+    if (selectModel.type == SELECT_APPROVAL) {
       this.setState({
-        billGroupModelList,
         modalOpen: false,
+        modalDataSource: new ListView.DataSource({
+          rowHasChanged: (row1, row2) => row1 !== row2,
+        }),
         selectModel: {},
       })
+      let emcode = getParenthesesStr(rowData.value)
+      let nodeId = rowData.nodeId
+      this.approvalTakeover(emcode, nodeId)
     } else {
-      let dataObj = selectData.obj
-      let isForm = selectModel.isForm
-      if (!isObjEmpty(billGroupModelList) &&
-        !isObjNull(billGroupModelList[groupIndex])) {
-        if (isForm == true) {
-          billGroupModelList.forEach((billGroup, index) => {
-            if (!isObjNull(billGroup) && billGroup.isForm) {
+      const { billGroupModelList } = this.state
+      let groupIndex = selectModel.groupIndex
+      let childIndex = selectModel.childIndex
+      let selectData = rowData
+      if (selectModel.type === 'C') {
+        if (!isObjEmpty(billGroupModelList) &&
+          !isObjNull(billGroupModelList[groupIndex])) {
+          let billGroup = billGroupModelList[groupIndex]
+          billGroup[childIndex].value = selectData.value
+          billGroup[childIndex].display = selectData.display
+        }
+        this.setState({
+          billGroupModelList,
+          modalOpen: false,
+          selectModel: {},
+        })
+      } else {
+        let dataObj = selectData.obj
+        let isForm = selectModel.isForm
+        if (!isObjEmpty(billGroupModelList) &&
+          !isObjNull(billGroupModelList[groupIndex])) {
+          if (isForm == true) {
+            billGroupModelList.forEach((billGroup, index) => {
+              if (!isObjNull(billGroup) && billGroup.isForm) {
+                let showBillFields = billGroup.showBillFields
+                let hideBillFields = billGroup.hideBillFields
+                if (!isObjEmpty(showBillFields)) {
+                  showBillFields.forEach((showModel, index) => {
+                    if (showModel.field in dataObj) {
+                      showModel.value = dataObj[showModel.field]
+                    }
+                  })
+                }
+                if (!isObjEmpty(hideBillFields)) {
+                  hideBillFields.forEach((showModel, index) => {
+                    if (showModel.field in dataObj) {
+                      showModel.value = dataObj[showModel.field]
+                    }
+                  })
+                }
+              }
+            })
+          } else {
+            let billGroup = billGroupModelList[groupIndex]
+            if (!isObjNull(billGroup)) {
               let showBillFields = billGroup.showBillFields
               let hideBillFields = billGroup.hideBillFields
               if (!isObjEmpty(showBillFields)) {
@@ -238,36 +342,41 @@ export default class ApprovalAdd extends Component {
                 })
               }
             }
-          })
-        } else {
-          let billGroup = billGroupModelList[groupIndex]
-          if (!isObjNull(billGroup)) {
-            let showBillFields = billGroup.showBillFields
-            let hideBillFields = billGroup.hideBillFields
-            if (!isObjEmpty(showBillFields)) {
-              showBillFields.forEach((showModel, index) => {
-                if (showModel.field in dataObj) {
-                  showModel.value = dataObj[showModel.field]
-                }
-              })
-            }
-            if (!isObjEmpty(hideBillFields)) {
-              hideBillFields.forEach((showModel, index) => {
-                if (showModel.field in dataObj) {
-                  showModel.value = dataObj[showModel.field]
-                }
-              })
-            }
           }
         }
+        // console.log(billGroupModelList)
+        this.setState({
+          billGroupModelList,
+          modalOpen: false,
+          selectModel: {},
+        })
       }
-      // console.log(billGroupModelList)
-      this.setState({
-        billGroupModelList,
-        modalOpen: false,
-        selectModel: {},
-      })
     }
+
+  }
+
+  //接管单据
+  approvalTakeover = (emcode, nodeId) => {
+    Toast.loading('正在指定审批人', 0)
+    fetchPost(mBaseUrl + '/common/takeOverTask.action', {
+      em_code: emcode,
+      nodeId: nodeId,
+      master: mMaster,
+      _noc: 1,
+    }, {
+      // 'Cookie': 'JSESSIONID=' + mSessionId
+    }).then(response => {
+      Toast.hide()
+      message.success('指定审批人成功')
+      this.toApprovalDetail(nodeId)
+    }).catch(error => {
+      Toast.hide()
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('指定审批人失败')
+      }
+    })
   }
 
   /**
@@ -506,12 +615,13 @@ export default class ApprovalAdd extends Component {
         localData.obj = jsonMap
         dbList.push(localData)
       })
-
+      mModalList = dbList
       if (dbList.length === 0) {
         message.error('选项数据为空')
       } else {
         this.setState({
-          modalList: dbList,
+          modalDataSource: this.state.modalDataSource.cloneWithRows(
+            mModalList),
           modalOpen: true,
         })
       }
@@ -564,11 +674,13 @@ export default class ApprovalAdd extends Component {
           }
           combList.push(comb)
         }
+        mModalList = combList
         if (combList.length === 0) {
           message.error('选项数据为空')
         } else {
           this.setState({
-            modalList: combList,
+            modalDataSource: this.state.modalDataSource.cloneWithRows(
+              mModalList),
             modalOpen: true,
           })
         }
@@ -651,31 +763,21 @@ export default class ApprovalAdd extends Component {
       }).then(response => {
         Toast.hide()
         if (response && response.success == true) {
+          let nodeid = response.nodeId
           if (mId <= 0) {
             mId = response[mKeyField] || response.keyvalue
             let formcode = response.formcode
             let isSave = response.isSave
             if (isSave == true || isSave == 'true') {
-
+              this.toApprovalDetail(nodeid)
             } else {
-
+              this.judgeApproval(nodeid, mId, formcode)
             }
             message.success('单据提交成功')
           } else {
+            this.judgeApproval(nodeid, mId, '')
             message.success('单据提交成功')
           }
-          let nodeid = response.nodeId
-          this.props.history.goBack()
-          if (!isObjEmpty(nodeid)) {
-            setTimeout(() => {
-              this.props.history.push('/approval/%7B%22' +
-                'master%22%3A%22' + mMaster
-                + '%22%2C%22nodeId%22%3A' + nodeid
-                + '%2C%22type%22%3A' + 1
-                + '%2C%22baseUrl%22%3A%22' + encodeURIComponent(mBaseUrl)
-                + '%22%7D')
-            }, 100)
-          }
         } else {
           message.error('单据提交失败')
         }
@@ -694,6 +796,67 @@ export default class ApprovalAdd extends Component {
     }
   }
 
+  toApprovalDetail (nodeid) {
+    if (!isObjEmpty(nodeid)) {
+      this.props.history.replace('/approval/%7B%22' +
+        'master%22%3A%22' + mMaster
+        + '%22%2C%22nodeId%22%3A' + nodeid
+        + '%2C%22type%22%3A' + 1
+        + '%2C%22baseUrl%22%3A%22' + encodeURIComponent(mBaseUrl)
+        + '%22%7D')
+    }
+  }
+
+  judgeApproval = (oldNodeId, keyvalue, formcode) => {
+    Toast.loading('正在触发审批流', 0)
+    fetchGet(mBaseUrl + '/common/getMultiNodeAssigns.action', {
+      condition: '1=1',
+      caller: mCaller,
+      id: keyvalue,
+    }).then(response => {
+      Toast.hide()
+      if (!isObjEmpty(response.assigns)) {
+        let assignArray = response.assigns
+        let assignObj = assignArray[0]
+        let nodeid = assignObj ? (assignObj.JP_NODEID || '') : ''
+        let candidates = assignObj ? (assignObj.JP_CANDIDATES || []) : []
+        if (!isObjEmpty(nodeid) && !isObjEmpty(candidates)) {
+          let candidateList = []
+          candidates.forEach(item => {
+            let candidate = {}
+            candidate.value = item
+            candidate.id = keyvalue
+            candidate.formcode = formcode
+            candidate.nodeId = nodeid
+
+            candidateList.push(candidate)
+          })
+          this.setState({
+            modalDataSource: this.state.modalDataSource.cloneWithRows(
+              candidateList),
+            selectModel: {
+              caption: '选择审批人',
+              type: SELECT_APPROVAL,
+            },
+            modalOpen: true,
+          })
+        } else {
+          message.success('审批流触发成功')
+          this.toApprovalDetail(nodeid)
+        }
+      } else {
+        this.toApprovalDetail(oldNodeId)
+      }
+    }).catch(error => {
+      Toast.hide()
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('审批流触发失败')
+      }
+    })
+  }
+
   /**
    * 判断主表字段必填情况,拼接主表字段
    * @param formFields

+ 6 - 24
uas-office-web/wxuasapproval/src/pages/approval/ApprovalHome.jsx

@@ -64,29 +64,7 @@ class ApprovalHome extends Component {
   }
 
   componentDidMount () {
-    setTimeout(() => {
-      this.setState({
-        pageVisible: true,
-      })
-    }, 100)
-
     mMaster = this.props.match.params.master
-
-    // 用于刷新组建确认高度
-    /*if (ReactDOM.findDOMNode(this.contain)) {
-      const hei = this.state.receiveHeight -
-        ReactDOM.findDOMNode(this.contain).offsetTop - 56
-      this.setState({
-        receiveHeight: hei,
-      })
-    }
-    if (ReactDOM.findDOMNode(this.sendList)) {
-      const hei = this.state.sendHeight -
-        ReactDOM.findDOMNode(this.sendList).offsetTop - 56
-      this.setState({
-        sendHeight: hei,
-      })
-    }*/
     document.title = 'U审批'
 
     const { homeState } = this.props
@@ -226,7 +204,7 @@ class ApprovalHome extends Component {
 
   render () {
     return (
-      <div className={this.state.pageVisible ? 'home-root' : 'visibleHidden'}>
+      <div className={'home-root'}>
         <TabBar
           unselectedTintColor="#949494"
           tintColor="#33A3F4"
@@ -812,10 +790,14 @@ class ApprovalHome extends Component {
     } else {
       currentmaster = mMaster
     }
+    let type = 0
+    if (this.props.homeState.receiveState.tabIndex === 1) {
+      type = 1
+    }
     this.props.history.push('/approval/%7B%22' +
       'master%22%3A%22' + currentmaster
       + '%22%2C%22nodeId%22%3A' + approval.JP_NODEID
-      + '%2C%22type%22%3A' + 0
+      + '%2C%22type%22%3A' + type
       + '%2C%22baseUrl%22%3A%22' + encodeURIComponent(mBaseUrl)
       + '%22%7D')
   }

+ 2 - 2
uas-office-web/wxuasapproval/src/utils/fetchRequest.js

@@ -133,13 +133,13 @@ function fetchResult (request) {
         return resultJson
       } else {
         if (result.exceptionInfo) {
-          if (result.exceptionInfo.length > 50) {
+          if (result.exceptionInfo.length > 80) {
             throw '接口请求异常'
           } else {
             throw result.exceptionInfo.replace(/<[\/\!]*[^<>]*>/ig, '')
           }
         } else if (result.message) {
-          if (result.message.length > 50) {
+          if (result.message.length > 80) {
             throw '接口请求异常'
           } else {
             throw result.message.replace(/<[\/\!]*[^<>]*>/ig, '')