Browse Source

uas手机版
通用表单,附件上传逻辑基础处理

RaoMeng 5 years ago
parent
commit
0292589686

+ 1 - 0
uas-office-web/uas-mobile/src/components/common/currencyDetail/CurrencyDetail.jsx

@@ -884,6 +884,7 @@ class CurrencyDetail extends Component {
 
   onSubmitClick = () => {
     const { billGroupList } = this.state
+    console.log(billGroupList)
     if (!isObjEmpty(billGroupList)) {
       let formFields = [], gridGroupFields = []
       for (let i = 0; i < billGroupList.length; i++) {

+ 49 - 31
uas-office-web/uas-mobile/src/components/common/formNew/FormEnclosure.jsx

@@ -10,6 +10,7 @@ import { getBracketStr, isObjNull } from '../../../utils/common/common.util'
 import { Toast } from 'antd-mobile'
 import { UploadOutlined } from '@ant-design/icons'
 import BillModel, { billReadOnly } from '../../../model/common/BillModel'
+import store from '../../../redux/store/store'
 
 let uploadFail = false
 
@@ -42,10 +43,7 @@ export default class FormEnclosure extends Component {
     const { billModel } = this.state
 
     let valueItem = this.getEnclosureCom(billModel)
-    return (
-      this.renderTwoLines(
-        billModel,
-        valueItem))
+    return (valueItem)
   }
 
   /**
@@ -77,26 +75,43 @@ export default class FormEnclosure 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}
-        disabled={billReadOnly(billModel)}
-        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'}
-      >
+    return <Upload
+      action={this.props.baseUrl + '/mobile/uploadAttachs.action'}
+      listType={'picture'}
+      multiple={true}
+      disabled={billReadOnly(billModel)}
+      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 className='form-common-layout'
+           style={{
+             borderBottom: 'none',
+             width: '100vw',
+           }}>
+        <div style={{
+          display: 'flex',
+          flex: 1,
+        }}>
+          <div style={{
+            minWidth: '90px',
+            fontSize: '14px',
+            color: '#333333',
+          }}>{billModel.caption}</div>
+          <div className={!billModel.allowBlank
+            ? 'form-input-fill'
+            : 'visibleHidden'}>*
+          </div>
+        </div>
+
         {
           billReadOnly(billModel) ||
           <div style={{ display: 'flex', alignItems: 'center' }}>
@@ -104,20 +119,21 @@ export default class FormEnclosure extends Component {
               className={'uploadBtn'}>
               <UploadOutlined
                 style={{ color: 'white' }}/>
-              <span style={{ fontSize: '12px', marginLeft: '6px' }}>选择文件</span>
+              <span
+                style={{ fontSize: '12px', marginLeft: '6px' }}>选择文件</span>
             </div>
             <span className='promptText'>(不能超过100MB)</span>
           </div>
         }
-      </Upload>
-    </div>
+      </div>
+    </Upload>
   }
 
   handleChange = ({ fileList }) => {
     if (uploadFail) {
       return
     }
-    const { count } = this.props
+    const { count, onTextChange, groupIndex, childIndex } = this.props
     const { billModel } = this.state
     if (isObjNull(count) || fileList.length <= count) {
       //{"success":true,"id":"[52650]"}
@@ -129,14 +145,16 @@ export default class FormEnclosure extends Component {
             : file.enclosureId
           if (file.enclosureId) {
             value = value + file.enclosureId + ';'
+            file.url = this.props.baseUrl + '/common/downloadbyId.action?id=' +
+              file.enclosureId
+              + '&master=' + store.getState().userState.accountCode
           }
         })
       }
+      console.log(fileList)
       billModel.fileList = fileList
       this.setState({ billModel })
-      this.props.onTextChange &&
-      this.props.onTextChange(this.props.groupIndex, this.props.childIndex,
-        value)
+      onTextChange && onTextChange(groupIndex, childIndex, value)
     }
   }
 

+ 1 - 0
uas-office-web/uas-mobile/src/components/common/formNew/formCommon.less

@@ -165,6 +165,7 @@
 
 .upload-list-inline .ant-upload-list-item {
   /*附件列表格式*/
+  margin: 8px;
 }
 
 .uploadBtn {