Browse Source

uas手机版
通用表单,附件上传、下载、删除

RaoMeng 5 years ago
parent
commit
6386dcfedb

+ 11 - 4
uas-office-web/uas-mobile/src/components/common/formNew/FormEnclosure.jsx

@@ -6,7 +6,11 @@
 import React, { Component } from 'react'
 import './formCommon.less'
 import { Upload } from 'antd'
-import { getBracketStr, isObjNull } from '../../../utils/common/common.util'
+import {
+  getBracketStr,
+  isObjEmpty,
+  isObjNull,
+} from '../../../utils/common/common.util'
 import { Toast } from 'antd-mobile'
 import { UploadOutlined } from '@ant-design/icons'
 import BillModel, { billReadOnly } from '../../../model/common/BillModel'
@@ -145,9 +149,12 @@ 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
+            if (isObjEmpty(file.url)) {
+              file.url = this.props.baseUrl +
+                '/common/downloadbyId.action?id=' +
+                file.enclosureId
+                + '&master=' + store.getState().userState.accountCode
+            }
           }
         })
       }

+ 21 - 0
uas-office-web/uas-mobile/src/model/common/BillModel.js

@@ -124,6 +124,7 @@ export function billIsSelect (billModel) {
   }
   switch (dfType) {
     case 'C':
+    case 'B':
     case 'D':
     case 'DT':
     case 'YM':
@@ -148,6 +149,7 @@ export function billIsCombo (billModel) {
   }
   switch (dfType) {
     case 'C':
+    case 'B':
       return true
   }
   return false
@@ -277,6 +279,24 @@ export function billIsMultiLine (billModel) {
   return false
 }
 
+/**
+ * 字段是否是附件类型
+ * @param billModel
+ * @returns {boolean}
+ */
+export function billIsEnclosure (billModel) {
+  let dfType = billModel.type
+  if (isObjEmpty(dfType)) {
+    return false
+  }
+  switch (dfType) {
+    case 'FF':
+    case 'PF':
+      return true
+  }
+  return false
+}
+
 /**
  * 返回字段布局类型
  * @param dfType
@@ -294,6 +314,7 @@ export function getItemViewType (dfType) {
     case TYPE_TAB:
       return 111
     case 'C':
+    case 'B':
     case 'SF':
     case 'DF':
     case 'S':

+ 0 - 1
uas-office-web/uas-mobile/src/pages/private/service/ServiceList.jsx

@@ -20,7 +20,6 @@ class ServiceList extends Component {
     this.caller = this.props.match.params.caller
     this.title = this.props.match.params.title
     this.readOnly = this.props.match.params.readOnly
-    console.log(typeof this.readOnly)
     document.title = this.title || '单据列表'
   }
 

+ 27 - 1
uas-office-web/uas-mobile/src/utils/common/form.request.js

@@ -6,9 +6,11 @@ import { isObjEmpty, isObjNull } from './common.util'
 import BillGroupModel from '../../model/common/BillGroupModel'
 import BillModel, {
   billGetDisplay,
-  billGetValue,
+  billGetValue, billIsEnclosure,
 } from '../../model/common/BillModel'
 import { message } from 'antd'
+import store from '../../redux/store/store'
+import { _baseURL } from '../../configs/api.config'
 
 export function analysisFormData (formData, isDetail) {
   let billGroupList = []
@@ -104,6 +106,30 @@ export function getBillGroup (groupItem, groupIndex, isDetail) {
         })
       }
 
+      //添加附件
+      let filePaths = fieldItem.filePaths
+      if (billIsEnclosure(billModel)) {
+        let fileList = []
+        if (!isObjEmpty(filePaths)) {
+          filePaths.forEach((item, index) => {
+            let fileObj = {}
+            fileObj.uid = 'rc-upload-' + new Date().getTime() + '-' + index
+            fileObj.enclosureId = item.fp_id
+            fileObj.url = item.pathurl || (_baseURL +
+              '/common/downloadbyId.action?id=' +
+              fileObj.enclosureId
+              + '&master=' + store.getState().userState.accountCode)
+            fileObj.name = item.fp_name
+            fileObj.size = item.fp_size
+            fileObj.status = 'done'
+
+            fileList.push(fileObj)
+          })
+        }
+        billModel.fileList = fileList
+      }
+
+      //是否是显示字段,添加到show或hide列表
       if (billModel.isdefault) {
         showBillFields.push(billModel)
       } else {