Browse Source

新建页面初步完成

RaoMeng 6 years ago
parent
commit
a08d7d5ca4

+ 7 - 1
uas-office-web/wxuasapproval/src/components/approvalAdd/FormAdd.jsx

@@ -23,9 +23,15 @@ export default class FormAdd extends Component {
 
   render () {
     return (
-      <div className='form-add-text'>
+      <div className='form-add-text' onClick={this.onAddClick}>
         + 添加明细
       </div>
     )
   }
+
+  onAddClick = e => {
+    if (this.props.onAddClick) {
+      this.props.onAddClick(this.props.groupIndex)
+    }
+  }
 }

+ 62 - 14
uas-office-web/wxuasapproval/src/components/approvalAdd/FormInput.jsx

@@ -7,7 +7,7 @@ import React, { Component } from 'react'
 import './formCommon.css'
 import ApprovalBean from '../../model/ApprovalBean'
 import BillModel from '../../model/BillModel'
-import { TextareaItem, InputItem, DatePicker, List } from 'antd-mobile'
+import { TextareaItem, InputItem, DatePicker, List, Modal } from 'antd-mobile'
 import { isObjEmpty } from '../../utils/common'
 import moment from 'moment'
 
@@ -17,11 +17,9 @@ export default class FormInput extends Component {
     super()
 
     this.state = {
-      modalOpen: false,
-      selectList: [],
-      inputValue: '',
-      radioValue: 1,
       billModel: new BillModel(),
+      modalOpen: false,
+      modalList: [],
     }
   }
 
@@ -30,6 +28,7 @@ export default class FormInput extends Component {
 
     this.setState({
       billModel: billModel,
+      modalVisible: false,
     })
   }
 
@@ -42,25 +41,26 @@ export default class FormInput extends Component {
   }
 
   render () {
-    const { billModel } = this.state
+    const { billModel, modalOpen, modalList } = this.state
     let valueItem
 
     let type = billModel.type
     if (type === 'N') {
       valueItem =
         <InputItem className='form-input-value' clear
-                   placeholder={this.isSelect(type)
+                   placeholder={this.isSelect(billModel)
                      ? '请选择'
                      : ((billModel.readOnly === 'T' ||
                        billModel.editable === 'F')
                        ? ''
                        : '请输入')}
                    editable={(billModel.readOnly === 'T' ||
-                     billModel.editable === 'F') ? false : (this.isSelect(type)
+                     billModel.editable === 'F') ? false : (this.isSelect(
+                     billModel)
                      ? false
                      : true)}
           // extra={(billModel.readOnly === 'T' &&
-          //   billModel.editable === 'F' && this.isSelect(type))
+          //   billModel.editable === 'F' && this.isSelect(billModel))
           //   ? '>'
           //   : ''}
                    onChange={this.onTextChange}
@@ -96,7 +96,7 @@ export default class FormInput extends Component {
       </DatePicker>
     } else {
       valueItem = <TextareaItem className='form-input-value' autoHeight
-                                placeholder={this.isSelect(type)
+                                placeholder={this.isSelect(billModel)
                                   ? '请选择'
                                   : ((billModel.readOnly === 'T' ||
                                     billModel.editable === 'F')
@@ -106,15 +106,16 @@ export default class FormInput extends Component {
                                 editable={(billModel.readOnly === 'T' ||
                                   billModel.editable === 'F')
                                   ? false
-                                  : (this.isSelect(type)
+                                  : (this.isSelect(billModel)
                                     ? false
                                     : true)}
                                 disabled={false}
         // extra={(billModel.readOnly === 'T' &&
-        //   billModel.editable === 'F' && this.isSelect(type))
+        //   billModel.editable === 'F' && this.isSelect(billModel))
         //   ? '>'
         //   : ''}
                                 onChange={this.onTextChange}
+                                onClick={this.onInputClick}
                                 value={billModel.getValue()}
       />
     }
@@ -129,6 +130,27 @@ export default class FormInput extends Component {
           : 'visibleHidden'}>*
         </div>
         {valueItem}
+        {this.isSelect(billModel) &&
+        <Modal visible={modalOpen}
+               animationType={'slide-up'}
+               onClose={() => {
+                 this.setState({
+                   modalOpen: false,
+                 })
+               }}
+               title={billModel.caption}
+               popup
+        >
+          <List className='form-common-modal-root'>
+            {modalList && (
+              modalList.map((modalObj, index) => (
+                <List.Item key={index}
+                           onClick={this.onModalSelect.bind(this,
+                             index)}>{modalObj.display}</List.Item>
+              ))
+            )}
+          </List>
+        </Modal>}
       </div>
     )
   }
@@ -146,7 +168,29 @@ export default class FormInput extends Component {
   }
 
   onInputClick = e => {
+    // if (this.props.onInputClick) {
+    //   this.props.onInputClick(this.props.groupIndex, this.props.childIndex)
+    // }
+    const { billModel } = this.state
+    if (!isObjEmpty(billModel.localDatas)) {
+      console.log('modaldata', billModel.localDatas)
+      this.setState({
+        modalList: billModel.localDatas,
+        modalOpen: true,
+      })
+    }
+  }
 
+  onModalSelect = index => {
+    const { modalList } = this.state
+    if (!isObjEmpty(modalList) && modalList[index] && this.props.onTextChange) {
+      this.props.onTextChange(this.props.groupIndex, this.props.childIndex,
+        modalList[index].display, modalList[index].value)
+    }
+    this.setState({
+      modalList: [],
+      modalOpen: false,
+    })
   }
 
   onDateChange = date => {
@@ -166,14 +210,18 @@ export default class FormInput extends Component {
     })
   }
 
-  isSelect = dfType => {
+  isSelect = (billModel) => {
+    if (!isObjEmpty(billModel.localDatas)) {
+      return true
+    }
+    let dfType = billModel.type
     if (isObjEmpty(dfType)) {
       return false
     }
     switch (dfType) {
+      case 'C':
       case 'D':
       case 'DT':
-      case 'C':
       case 'MF':
       case 'SF':
       case 'DF':

+ 8 - 1
uas-office-web/wxuasapproval/src/components/approvalAdd/FormTitle.jsx

@@ -33,9 +33,16 @@ export default class FormTitle extends Component {
         <div className='form-title-text'>{billModel.caption}</div>
         <div className={billModel.allowBlank == 'F'
           ? 'displayNone'
-          : 'form-title-delete'}>删除
+          : 'form-title-delete'}
+             onClick={this.onDeleteClick}>删除
         </div>
       </div>
     )
   }
+
+  onDeleteClick = e => {
+    if (this.props.onDeleteClick) {
+      this.props.onDeleteClick(this.props.groupIndex)
+    }
+  }
 }

+ 7 - 0
uas-office-web/wxuasapproval/src/components/approvalAdd/formCommon.css

@@ -104,4 +104,11 @@
     font-size: 14px;
     color: #2F95DD;
     font-weight: bold;
+    background: #efefef;
+}
+
+.form-common-modal-root {
+    min-height: 300px;
+    max-height: 70vh;
+    overflow: auto;
 }

+ 34 - 34
uas-office-web/wxuasapproval/src/model/BillModel.js

@@ -1,32 +1,32 @@
-import { isObjEmpty } from '../utils/common'
+import { isObjEmpty, isObjNull } from '../utils/common'
 
-export default function BillModel () {
-  this.id = 0//id
-  this.groupIndex = 0//所在组索引
-  this.detno = 1000000//序号
-  this.length = 0//字符长度
-  this.appwidth = 0//宽
-  this.isdefault = 0//是否显示
-  this.dbfind = ''//是否是dbfind字段判定
-  this.caption = ''//字段名称
-  this.type = ''//类型(标题类型为Constants.TYPE_TITLE,不触发点击事件等 )
-  this.logicType = ''//logic类型
-  this.readOnly = ''//字段是否只读  T/F
-  this.field = ''//字段
-  this.value = ''//值
-  this.display = ''//上传
-  this.defValue = ''//默认
-  this.findFunctionName = ''//默认值
-  this.allowBlank = ''//是否允许为空(注:当作为标题的时候T:表示可以删除 F:表示不可删除)
-  this.renderer = ''
-  this.enclusureId = ''
-  this.localDatas = []//获取到的本地选择数据
-  this.mBillJump = ''//判断是否需要要跳转字段
-  this.mTabList = []//是否
-  this.updatable = ''//是否可更新
-  this.editable = ''//是否可编辑(临时属性,对某些字段的特殊处理,和字段本身属性无关,在添加明细时,要重置这个值)
-
-  this.BillModel = function (billModel) {
+export default function BillModel (billModel) {
+  if (isObjNull(billModel)) {
+    this.id = 0//id
+    this.groupIndex = 0//所在组索引
+    this.detno = 1000000//序号
+    this.length = 0//字符长
+    this.appwidth = 0//宽度
+    this.isdefault = 0//是否显示
+    this.dbfind = ''//是否是dbfind字段判定
+    this.caption = ''//字段名称
+    this.type = ''//类型(标题类型为Constants.TYPE_TITLE,不触发点击事件等 )
+    this.logicType = ''//logic类型
+    this.readOnly = ''//字段是否只读  T/F
+    this.field = ''//字段
+    this.value = ''//
+    this.display = ''//上传
+    this.defValue = ''//默认值
+    this.findFunctionName = ''//默认值
+    this.allowBlank = ''//是否允许为空(注:当作为标题的时候T:表示可以删除 F:表示不可删除)
+    this.renderer = ''
+    this.enclusureId = ''
+    this.localDatas = []//获取到的本地选择数据
+    this.mBillJump = ''//判断是否需要要跳转字段
+    this.mTabList = []//是否
+    this.updatable = ''//是否可更新
+    this.editable = ''//是否可编辑(临时属性,对某些字段的特殊处理,和字段本身属性无关,在添加明细时,要重置这个值)
+  } else {
     this.id = billModel.id
     this.groupIndex = billModel.groupIndex + 1
     this.length = billModel.length
@@ -49,9 +49,13 @@ export default function BillModel () {
     this.mTabList = billModel.mTabList
     this.updatable = billModel.updatable
     this.editable = ''//复制字段时要重置
-    if (!this.isShow(billModel)
+
+    this.isShow = billModel => (
+      billModel.isdefault === -1 && billModel.type === 'H'
+    )
+    if (this.isShow(billModel) == false
       && !isObjEmpty(billModel.renderer)
-      && billModel.defaultValue.indexOf('defaultValue') != -1) {
+      && billModel.renderer.indexOf('defaultValue') != -1) {
       //隐藏字段,renderer里包含defaultValue,则复制value
       this.value = billModel.value
       this.display = billModel.display
@@ -68,10 +72,6 @@ export default function BillModel () {
   this.getDisplay = () => (
     this.display || this.getValue()
   )
-
-  this.isShow = function (billModel) {
-    return billModel.isdefault === -1 && billModel.type === 'H'
-  }
 }
 
 export const TYPE_TITLE = 'LOCAL_TITLE'

+ 137 - 9
uas-office-web/wxuasapproval/src/pages/approval/ApprovalAdd.jsx

@@ -6,7 +6,7 @@
 import React, { Component } from 'react'
 import { isObjEmpty, isObjNull } from '../../utils/common'
 import { message } from 'antd'
-import { Toast, List, Button } from 'antd-mobile'
+import { Toast, List, Button, Modal } from 'antd-mobile'
 import { fetchGet, fetchPost } from '../../utils/fetchRequest'
 import BillModel, {
   TYPE_ADD,
@@ -20,6 +20,8 @@ import FormTitle from '../../components/approvalAdd/FormTitle'
 import FormAdd from '../../components/approvalAdd/FormAdd'
 import FormImage from '../../components/approvalAdd/FormImage'
 
+const alert = Modal.alert
+
 let mBaseUrl = 'http://29226oq576.qicp.vip/uas/'
 
 let mCaller//当前单据的Caller
@@ -62,6 +64,7 @@ export default class ApprovalAdd extends Component {
 
   componentWillUnmount () {
     Toast.hide()
+    this.deleteAlert && this.deleteAlert.close()
   }
 
   render () {
@@ -77,7 +80,8 @@ export default class ApprovalAdd extends Component {
           if (!isObjNull(showBillFields) &&
             showBillFields.length > 0) {
             //添加组标题
-            this.addGroupTitle(g, billGroup, gridStartIndex, formItems)
+            gridStartIndex = this.addGroupTitle(g, billGroup, gridStartIndex,
+              formItems)
             //添加显示字段
             for (let i = 0; i < showBillFields.length; i++) {
               let billModel = showBillFields[i]
@@ -96,7 +100,8 @@ export default class ApprovalAdd extends Component {
                     formItems.push(
                       <FormInput billModel={billModel} groupIndex={g}
                                  childIndex={i}
-                                 onTextChange={this.onTextChange.bind(this)}/>,
+                                 onTextChange={this.onTextChange.bind(this)}
+                                 onInputClick={this.onInputClick.bind(this)}/>,
                     )
                     break
                   case 2:
@@ -118,7 +123,8 @@ export default class ApprovalAdd extends Component {
             /*if (billGroup.isForm == false && billGroup.lastInType == true) {
               //如果是最后一个从表,则添加【新增】按钮
               formItems.push(
-                <FormAdd billModel={this.getAddModel(g)} groupIndex={g}/>,
+                <FormAdd billModel={this.getAddModel(g)} groupIndex={g}
+                         onAddClick={this.onAddClick.bind(this)}/>,
               )
             }*/
           }
@@ -143,6 +149,58 @@ export default class ApprovalAdd extends Component {
     )
   }
 
+  /**
+   * 添加明细组
+   * @param groupIndex
+   */
+  onAddClick = groupIndex => {
+    const { billGroupModelList } = this.state
+    billGroupModelList[groupIndex].lastInType = false
+
+    let newBillGroup = this.newGridBillGroup(groupIndex,
+      billGroupModelList[groupIndex])
+    billGroupModelList.push(newBillGroup)
+    console.log('newgroup', billGroupModelList)
+    this.setState({
+      billGroupModelList,
+    })
+  }
+
+  newGridBillGroup = (groupIndex, oldBillGroup) => {
+    let oldGridIndex = oldBillGroup.gridIndex
+    let isForm = oldBillGroup.isForm
+
+    let newBillGroup = new BillGroupModel()
+    newBillGroup.isForm = isForm
+    if (isForm == true) {
+      newBillGroup.group = oldBillGroup.group
+    } else {
+      newBillGroup.group = `明细${oldGridIndex + 1}`
+    }
+    newBillGroup.billCaller = oldBillGroup.billCaller
+    newBillGroup.gridIndex = oldGridIndex + 1
+    newBillGroup.isDeleteAble = true
+    newBillGroup.lastInType = true
+    newBillGroup.groupIndex = groupIndex + 1
+
+    let showBillFields = oldBillGroup.showBillFields
+    let hideBillFields = oldBillGroup.hideBillFields
+
+    if (!isObjEmpty(showBillFields)) {
+      for (let i = 0; i < showBillFields.length; i++) {
+        let billModel = showBillFields[i]
+        newBillGroup.addShow(new BillModel(billModel))
+      }
+    }
+    if (!isObjEmpty(hideBillFields)) {
+      for (let i = 0; i < hideBillFields.length; i++) {
+        let billModel = hideBillFields[i]
+        newBillGroup.addHide(new BillModel(billModel))
+      }
+    }
+    return newBillGroup
+  }
+
   /**
    * 添加分组头部
    * @param g
@@ -169,12 +227,74 @@ export default class ApprovalAdd extends Component {
     }
     if (!isObjEmpty(titleBillModel.caption)) {
       formItems.push(
-        <FormTitle billModel={titleBillModel}/>,
+        <FormTitle billModel={titleBillModel} groupIndex={g}
+                   onDeleteClick={this.onDeleteClick.bind(this)}/>,
       )
     }
+    return gridStartIndex
+  }
+
+  onDeleteClick = groupIndex => {
+    this.deleteAlert = alert('提示', '确认删除该明细?', [
+      {
+        text: '取消',
+        onPress: () => {},
+        style: 'default',
+      },
+      {
+        text: '确定', onPress: () => {
+          this.deleteGroup(groupIndex)
+        },
+      },
+    ])
+  }
+
+  /**
+   * 删除分组
+   * @param groupIndex
+   */
+  deleteGroup (groupIndex) {
+    const { billGroupModelList } = this.state
+    let deleteGroup = billGroupModelList[groupIndex]
+    let isLastGroup = deleteGroup.lastInType
+    if (isLastGroup == true && groupIndex - 1 >= 0) {
+      let billGroup = billGroupModelList[groupIndex - 1]
+      if (deleteGroup.isForm == false && (billGroup.isForm == true)) {
+        //明细删除光了,要默认添加一个空明细表
+        deleteGroup.groupIndex = groupIndex - 1
+        deleteGroup.gridIndex = 0
+        let newGridGroup = this.newGridBillGroup(groupIndex - 1, deleteGroup)
+        newGridGroup.isDeleteAble = false
+        billGroupModelList.splice(groupIndex, 1)
+        billGroupModelList.push(newGridGroup)
+      } else {
+        billGroup.lastInType = true
+        billGroupModelList.splice(groupIndex, 1)
+      }
+    } else {
+      billGroupModelList.splice(groupIndex, 1)
+    }
+
+    this.setState({
+      billGroupModelList,
+    })
   }
 
-  onTextChange = (groupIndex, childIndex, value) => {
+  onInputClick = (groupIndex, childIndex) => {
+    /*const { billGroupModelList } = this.state
+    if (!isObjNull(billGroupModelList) &&
+      !isObjNull(billGroupModelList[groupIndex])) {
+      let billGroup = billGroupModelList[groupIndex]
+      if (!isObjNull(billGroup.showBillFields) &&
+        !isObjNull(billGroup.showBillFields[childIndex])) {
+        let billModel = billGroup.showBillFields[childIndex]
+        let localDatas = billModel.localDatas
+
+      }
+    }*/
+  }
+
+  onTextChange = (groupIndex, childIndex, value, display) => {
     const { billGroupModelList } = this.state
     if (!isObjNull(billGroupModelList) &&
       !isObjNull(billGroupModelList[groupIndex])) {
@@ -182,6 +302,9 @@ export default class ApprovalAdd extends Component {
       if (!isObjNull(billGroup.showBillFields) &&
         !isObjNull(billGroup.showBillFields[childIndex])) {
         billGroup.showBillFields[childIndex].value = value
+        if (!isObjNull(display)){
+          billGroup.showBillFields[childIndex].display = display
+        }
       }
     }
     this.setState({
@@ -261,7 +384,12 @@ export default class ApprovalAdd extends Component {
             message.success('单据提交成功')
             this.props.history.goBack()
             setTimeout(() => {
-              this.props.history.push('/approval')
+              this.props.history.push('/approval/%7B%22' +
+                'master%22%3A%22' + mMaster
+                + '%22%2C%22nodeId%22%3A' + mId
+                + '%2C%22type%22%3A' + 1
+                + '%2C%22baseUrl%22%3A%22' + encodeURIComponent(mBaseUrl)
+                + '%22%7D')
             }, 100)
           }
         } else {
@@ -343,8 +471,8 @@ export default class ApprovalAdd extends Component {
    */
   loadFormandGridDetail () {
     fetchPost(mBaseUrl + (mId <= 0
-      ? 'mobile/common/getformandgriddetail.action'
-      : 'mobile/getformandgriddetail.action'), {
+      ? 'mobile/uapproval/getformandgriddetail.action'
+      : 'mobile/getformandgriddetail_uapproval.action'), {
       condition: '1=1',
       caller: mCaller,
       id: mId,

+ 27 - 14
uas-office-web/wxuasapproval/src/pages/approval/ApprovalHome.jsx

@@ -173,6 +173,7 @@ class ApprovalHome extends Component {
           sendState.scrollTop
       })
     } else {
+      mSendIndex = 0
       this.loadSendList()
     }
   }
@@ -365,6 +366,7 @@ class ApprovalHome extends Component {
         this.setState({
           isSendLoading: true,
         })
+        mSendIndex = 0
         this.loadSendList()
       }
     } else {
@@ -372,6 +374,7 @@ class ApprovalHome extends Component {
         this.setState({
           isSendLoading: true,
         })
+        mSendIndex = 0
         this.loadSendList()
       } else {
         this.setState({
@@ -570,7 +573,7 @@ class ApprovalHome extends Component {
 
   onFuncClick = (obj) => {
     this.cacheScrollState()
-    this.props.history.push('/approvalAdd/' + obj.sv_caller+'/'+mMaster)
+    this.props.history.push('/approvalAdd/' + obj.sv_caller + '/' + mMaster)
   }
 
   onReceiveItemClick = (index, approval) => {
@@ -662,6 +665,10 @@ class ApprovalHome extends Component {
   }
 
   loadTodoList = () => {
+    let { homeState: { receiveState: { listData } } } = this.props
+    if (isObjEmpty(listData)) {
+      mTodoIndex = 0
+    }
     mTodoIndex++
     if (!this.state.isReceiveTodoLoading) {
       this.setState({
@@ -669,13 +676,12 @@ class ApprovalHome extends Component {
       })
     }
 
-    let { homeState: { receiveState: { listData } } } = this.props
     if (mTodoIndex === 1) {
       listData.length = 0
     }
 
-    fetchGet(mBaseUrl + 'common/desktop/process/toDo.action', {
-      count: mPageSize,
+    fetchGet(mBaseUrl + 'common/desktop/process/uapproval/toDo.action', {
+      pageSize: mPageSize,
       page: mTodoIndex,
     }).then(response => {
       this.setState({
@@ -715,6 +721,10 @@ class ApprovalHome extends Component {
   }
 
   loadDoneList = () => {
+    let { homeState: { receiveState: { listData2 } } } = this.props
+    if (isObjEmpty(listData2)) {
+      mDoneIndex = 0
+    }
     mDoneIndex++
     if (!this.state.isReceiveDoneLoading) {
       this.setState({
@@ -722,13 +732,12 @@ class ApprovalHome extends Component {
       })
     }
 
-    let { homeState: { receiveState: { listData2 } } } = this.props
     if (mDoneIndex === 1) {
       listData2.length = 0
     }
 
-    fetchGet(mBaseUrl + 'common/desktop/process/alreadyDo.action', {
-      count: mPageSize,
+    fetchGet(mBaseUrl + 'common/desktop/process/uapproval/alreadyDo.action', {
+      pageSize: mPageSize,
       page: mDoneIndex,
       isMobile: 1,
       _do: 1,
@@ -770,6 +779,10 @@ class ApprovalHome extends Component {
   }
 
   loadSendList = () => {
+    let { homeState: { sendState: { sendList } } } = this.props
+    if (isObjEmpty(sendList)) {
+      mSendIndex = 0
+    }
     mSendIndex++
     if (!this.state.isSendLoading) {
       this.setState({
@@ -777,17 +790,17 @@ class ApprovalHome extends Component {
       })
     }
 
-    let { homeState: { sendState: { sendList } } } = this.props
     if (mSendIndex === 1) {
       sendList.length = 0
     }
 
-    fetchGet(mBaseUrl + 'common/desktop/process/alreadyLaunch.action', {
-      count: mPageSize,
-      page: mSendIndex,
-      isMobile: 1,
-      _do: 1,
-    }).then(response => {
+    fetchGet(mBaseUrl + 'common/desktop/process/uapproval/alreadyLaunch.action',
+      {
+        pageSize: mPageSize,
+        page: mSendIndex,
+        isMobile: 1,
+        _do: 1,
+      }).then(response => {
       this.setState({
         isSendLoading: false,
         isSendRefresh: false,