Browse Source

明细表的新增与删除

RaoMeng 6 years ago
parent
commit
c5cb4a9121

+ 167 - 0
uas-office-web/wxuasapproval/src/components/approvalAdd/FormEnclosure.jsx

@@ -0,0 +1,167 @@
+/**
+ * Created by RaoMeng on 2020/2/19
+ * Desc: 通用表单附件类型
+ */
+
+import React, { Component } from 'react'
+import './formCommon.css'
+import BillModel from '../../model/BillModel'
+import { Upload, Button, Icon } from 'antd'
+import { isObjNull } from '../../utils/common'
+import { Toast } from 'antd-mobile'
+
+let uploadFail = false
+
+export default class FormEnclosure extends Component {
+
+  constructor () {
+    super()
+    this.state = {
+      billModel: new BillModel(),
+    }
+  }
+
+  componentDidMount () {
+    let { billModel } = this.props
+
+    this.setState({
+      billModel: billModel,
+    })
+  }
+
+  componentWillUnmount () {
+
+  }
+
+  componentWillReceiveProps () {
+    this.componentDidMount()
+  }
+
+  render () {
+    const { billModel } = this.state
+
+    let valueItem = this.getEnclosureCom(billModel)
+    return (
+      this.renderTwoLines(
+        billModel,
+        valueItem))
+  }
+
+  /**
+   * 加载标题和内容单独分行
+   * @param billModel
+   * @param valueItem
+   * @returns {*}
+   */
+  renderTwoLines (billModel, valueItem) {
+    return <div className={'form-textarea-layout'}>
+      <div className='form-common-layout'
+           style={{ borderBottom: 'none' }}>
+        <div style={{
+          minWidth: '90px',
+          fontSize: '14px',
+          color: '#333333',
+        }}>{billModel.caption}</div>
+        <div className={billModel.allowBlank == 'F'
+          ? 'form-input-fill'
+          : 'visibleHidden'}>*
+        </div>
+      </div>
+      {valueItem}
+    </div>
+  }
+
+  /**
+   * 附件类型
+   * @param billModel
+   */
+  getEnclosureCom = (billModel) => {
+    return <div style={{
+      margin: '4px 10px 10px',
+    }}>
+      <Upload
+        action={this.props.baseUrl + '/mobile/uploadAttachs.action'}
+        listType={'picture'}
+        multiple={true}
+        fileList={billModel.fileList ? billModel.fileList : []}
+        showUploadList={true}
+        withCredentials={true}
+        beforeUpload={this.beforeUpload}
+        onChange={this.handleChange}
+        // onPreview={this.handlePreview}
+        // onRemove={this.handleRemove}
+        // onDownload={() => {}}
+        // data={''}
+        method={'post'}
+        className={'upload-list-inline'}
+      >
+        <div style={{ display: 'flex', alignItems: 'center' }}>
+          <div
+            className={'uploadBtn'}>
+            <Icon type="upload"
+                  style={{ color: 'white' }}/>
+            <span style={{ fontSize: '12px', marginLeft: '6px' }}>选择文件</span>
+          </div>
+          <span className='promptText'>(不能超过100MB)</span>
+        </div>
+      </Upload>
+    </div>
+  }
+
+  handleChange = ({ fileList }) => {
+    console.log('filelist', fileList)
+    if (uploadFail) {
+      return
+    }
+    const { count } = this.props
+    const { billModel } = this.state
+    if (isObjNull(count) || fileList.length <= count) {
+      //{"success":true,"id":"[52650]"}
+      /*let value = ''
+      if (fileList) {
+        fileList.forEach((file, index) => {
+          file.enclosureId = (file.response && file.response.id)
+            ? file.response.id
+            : ''
+        })
+      }
+      billModel.fileList = fileList
+      this.setState({ billModel })
+      this.props.onTextChange &&
+      this.props.onTextChange(this.props.groupIndex, this.props.childIndex,
+        value)*/
+    }
+  }
+
+  handleRemove = (file) => {
+    if (this.props.handleRemove) {
+      return this.props.handleRemove(file)
+    }
+  }
+
+  beforeUpload = (file, fileList) => {
+    uploadFail = false
+    if (file.size && file.size > 100 * 1024 * 1024) {
+      uploadFail = false
+      Toast.fail('文件大小不能超过100M')
+      return false
+    }
+    const { count } = this.props
+    const { billModel } = this.state
+    if (count && billModel.fileList &&
+      ((billModel.fileList.length + fileList.length) > count)) {
+      Toast.fail(`上传失败,附件数量不能超过${count}`)
+      uploadFail = true
+      return false
+    } else {
+      return this.props.beforeUpload
+        ? this.props.beforeUpload(file, fileList)
+        : true
+    }
+  }
+
+  handlePreview = (file) => {
+
+  }
+
+}

+ 0 - 31
uas-office-web/wxuasapproval/src/components/approvalAdd/FormImage.jsx

@@ -1,31 +0,0 @@
-/**
- * Created by RaoMeng on 2020/2/19
- * Desc: 通用表单附件类型
- */
-
-import React, { Component } from 'react'
-import './formCommon.css'
-
-export default class FormImage extends Component {
-
-  constructor () {
-    super()
-
-    this.state = {}
-  }
-
-  componentDidMount () {
-  }
-
-  componentWillUnmount () {
-
-  }
-
-  render () {
-    return (
-      <div>
-
-      </div>
-    )
-  }
-}

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

@@ -17,9 +17,6 @@ import {
 } from 'antd-mobile'
 import { isObjEmpty, isObjNull } from '../../utils/common'
 import moment from 'moment'
-import { Upload, Button, Icon } from 'antd'
-
-let uploadFail = false
 
 export default class FormInput extends Component {
 
@@ -69,10 +66,6 @@ export default class FormInput extends Component {
         valueItem =
           this.getHtmlcom(billModel)
         break
-      // case 'MF':
-      //   valueItem =
-      //     this.getEnclosureCom(billModel)
-      //   break
       default:
         valueItem =
           this.getTextCom(billModel)
@@ -82,9 +75,7 @@ export default class FormInput extends Component {
       (type === 'DT' || type === 'D' || type === 'T') ? <div>
           {valueItem}
         </div> :
-        (type === 'MS'
-          // || type === 'MF'
-        ) ? (this.renderTwoLines(
+        (type === 'MS') ? (this.renderTwoLines(
           billModel,
           valueItem)) :
           (this.renderNormal(billModel, valueItem, modalOpen, modalList))
@@ -260,100 +251,6 @@ export default class FormInput extends Component {
     />
   }
 
-  /**
-   * 附件类型
-   * @param billModel
-   */
-  getEnclosureCom = (billModel) => {
-    return <div style={{
-      margin: '4px 10px 10px',
-    }}>
-      <Upload
-        action={this.props.baseUrl + '/mobile/uploadAttachs.action'}
-        listType={'picture'}
-        multiple={true}
-        fileList={billModel.fileList ? billModel.fileList : []}
-        showUploadList={true}
-        // withCredentials={false}
-        beforeUpload={this.beforeUpload}
-        onChange={this.handleChange}
-        // onPreview={this.handlePreview}
-        // onRemove={this.handleRemove}
-        // onDownload={() => {}}
-        data={''}
-        method={'post'}
-        className={'upload-list-inline'}
-      >
-        <div style={{ display: 'flex', alignItems: 'center' }}>
-          <div
-            className={'uploadBtn'}>
-            <Icon type="upload"
-                  style={{ color: 'white' }}/>
-            <span style={{ fontSize: '12px', marginLeft: '6px' }}>选择文件</span>
-          </div>
-          <span className='promptText'>(不能超过100MB)</span>
-        </div>
-      </Upload>
-    </div>
-  }
-
-  handleChange = ({ fileList }) => {
-    console.log('filelist', fileList)
-    if (uploadFail) {
-      return
-    }
-    const { count } = this.props
-    const { billModel } = this.state
-    if (isObjNull(count) || fileList.length <= count) {
-      /*if (fileList) {
-        fileList.forEach((value, index) => {
-          value.url = (value.response && value.response.data)
-            ? value.response.data.accessPath
-            : value.url
-          value.picUrl = value.url
-          value.relativeUrl = (value.response && value.response.data)
-            ? value.response.data.fullPath
-            : value.relativeUrl
-        })
-      }*/
-      billModel.fileList = fileList
-      console.log('raomeng', billModel)
-      this.setState({ billModel })
-      this.props.handleChange && this.props.handleChange(fileList)
-    }
-  }
-
-  handleRemove = (file) => {
-    if (this.props.handleRemove) {
-      return this.props.handleRemove(file)
-    }
-  }
-
-  beforeUpload = (file, fileList) => {
-    uploadFail = false
-    if (file.size && file.size > 100 * 1024 * 1024) {
-      uploadFail = false
-      Toast.fail('文件大小不能超过100M')
-      return false
-    }
-    const { count } = this.props
-    const { billModel } = this.state
-    if (count && billModel.fileList &&
-      ((billModel.fileList.length + fileList.length) > count)) {
-      Toast.fail(`上传失败,附件数量不能超过${count}`)
-      uploadFail = true
-      return false
-    } else {
-      return this.props.beforeUpload
-        ? this.props.beforeUpload(file, fileList)
-        : true
-    }
-  }
-
-  handlePreview = (file) => {
-
-  }
-
   onTextChange = value => {
     const { billModel } = this.state
     billModel.value = value

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

@@ -2290,7 +2290,7 @@ class Approval extends Component {
    * 获取下一条审批数据
    */
   loadNextProcess = () => {
-    Toast.loading('正在获取下一条审批据', 0)
+    Toast.loading('正在获取下一条审批据', 0)
     fetchPost(mBaseUrl + '/common/getNextProcess.action', {
       taskId: mNodeId,
       master: mMaster,

+ 10 - 13
uas-office-web/wxuasapproval/src/pages/approval/ApprovalAdd.jsx

@@ -32,7 +32,7 @@ import BillGroupModel from '../../model/BillGroupModel'
 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 FormEnclosure from '../../components/approvalAdd/FormEnclosure'
 import EmployeeItem from '../../components/employeeItem/EmployeeItem'
 
 const alert = Modal.alert
@@ -57,7 +57,7 @@ let mShowBillModels, mFormBillModels, mUpdateBillModels, mAllBillModels
 let mBaseUrl = window.location.origin
   + (process.env.REACT_APP_ROUTER_BASE_NAME || '/ERP')
   // && 'http://yrkj.usoftchina.com:9443/uas'
-  // && 'http://erp.yitoa.com:8888/ERP'
+// && 'http://erp.yitoa.com:8888/ERP'
 // && 'http://29226oq576.qicp.vip/erp'
 
 export default class ApprovalAdd extends Component {
@@ -125,11 +125,6 @@ export default class ApprovalAdd extends Component {
                   itemViewType = 2
                 }
                 switch (itemViewType) {
-                  // case 0:
-                  //   formItems.push(
-                  //     <FormTitle billModel={billModel}/>,
-                  //   )
-                  //   break
                   case 1:
                     formItems.push(
                       <FormInput billModel={billModel} groupIndex={g}
@@ -140,23 +135,25 @@ export default class ApprovalAdd extends Component {
                     )
                     break
                   case 2:
-                    formItems.push(
-                      <FormImage billModel={billModel} groupIndex={g}
-                                 childIndex={i}/>,
-                    )
+                    //附件
+                    /*formItems.push(
+                      <FormEnclosure billModel={billModel} groupIndex={g}
+                                     baseUrl={mBaseUrl}
+                                     childIndex={i}/>,
+                    )*/
                     break
                   default:
                     break
                 }
               }
             }
-            /*if (billGroup.isForm == false && billGroup.lastInType == true) {
+            if (billGroup.isForm == false && billGroup.lastInType == true) {
               //如果是最后一个从表,则添加【新增】按钮
               formItems.push(
                 <FormAdd billModel={this.getAddModel(g)} groupIndex={g}
                          onAddClick={this.onAddClick.bind(this)}/>,
               )
-            }*/
+            }
           }
         }
       }