From 40436544f55558d2c8d1c14c68cce79546c60dff Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 16:59:41 +0800
Subject: [PATCH] 2021-01-15

---
 src/tabviews/zshare/fileupload/index.jsx |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx
index 7578173..925ef09 100644
--- a/src/tabviews/zshare/fileupload/index.jsx
+++ b/src/tabviews/zshare/fileupload/index.jsx
@@ -18,6 +18,7 @@
 class FileUpload extends Component {
   static propTpyes = {
     value: PropTypes.array,    // 鏂囦欢鏁扮粍
+    accept: PropTypes.any,     // 鏂囦欢鏍煎紡
     maxFile: PropTypes.any,    // 鏈�澶ф枃浠舵暟
     fileType: PropTypes.string // 鏂囦欢鏄剧ず绫诲瀷
   }
@@ -122,6 +123,27 @@
   }
 
   beforeUpload = (file) => {
+    const { accept } = this.props
+
+    if (accept && file.name) {
+      let types = accept.split(',')
+      let pass = false
+      types.forEach(type => {
+        if (new RegExp(type + '$', 'ig').test(file.name)) {
+          pass = true
+        }
+      })
+      
+      if (!pass) {
+        notification.warning({
+          top: 92,
+          message: '鏂囦欢鏍煎紡閿欒锛�',
+          duration: 5
+        })
+        return
+      }
+    }
+
     this.setState({
       showprogress: true,
       percent: 0
@@ -231,7 +253,7 @@
   }
 
   render() {
-    const { value, maxFile, fileType } = this.props
+    const { value, maxFile, fileType, accept } = this.props
     const { showprogress, percent } = this.state
 
     let uploadable = 'fileupload-form-container '
@@ -246,6 +268,7 @@
       listType: fileType,
       fileList: value,
       action: null,
+      accept: accept || '',
       method: 'post',
       multiple: false,
       onChange: this.onChange,

--
Gitblit v1.8.0