From 437c6d72f76072e5ab1b09e78101370805113c4b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 01 十月 2023 18:46:37 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/zshare/fileupload/index.jsx |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx
index cb0be7b..704ea1e 100644
--- a/src/tabviews/zshare/fileupload/index.jsx
+++ b/src/tabviews/zshare/fileupload/index.jsx
@@ -5,7 +5,9 @@
 import { Upload, Button, Progress, notification } from 'antd'
 import { UploadOutlined } from '@ant-design/icons'
 import SparkMD5 from 'spark-md5'
+
 import Api from '@/api'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 class FileUpload extends Component {
@@ -129,7 +131,9 @@
     this.props.onChange(vals.join(','))
   }
 
-  onUpdate = (url) => {
+  onUpdate = (url, file_name) => {
+    const { config } = this.props
+
     let filelist = fromJS(this.state.filelist).toJS()
 
     if (filelist[filelist.length -1]) {
@@ -151,7 +155,20 @@
     })
 
     this.setState({filelist})
-    this.props.onChange(vals.join(','))
+
+    if (config.subFields && file_name) {
+      let other = {}
+      config.subFields.forEach((n, i) => {
+        other[n.field] = file_name
+        setTimeout(() => {
+          MKEmitter.emit('mkFC', 'input', n.uuid, file_name)
+        }, i * 5)
+      })
+
+      this.props.onChange(vals.join(','), other)
+    } else {
+      this.props.onChange(vals.join(','))
+    }
   }
 
   onFail = (msg) => {
@@ -171,7 +188,7 @@
     })
   }
 
-  shardupload = (param) => {
+  shardupload = (param, file_name) => {
     let form = new FormData()
 
     form.append('file', param.binary)
@@ -189,7 +206,7 @@
     Api.getLargeFileUpload(form).then(res => {
       if (res.status) {
         if (res.urlPath) {
-          this.onUpdate(res.urlPath)
+          this.onUpdate(res.urlPath, file_name)
         } else {
           this.onFail()
         }
@@ -253,6 +270,8 @@
       percent: 0
     })
 
+    let file_name = file.name.replace(/\.{1}[^.]*$/ig, '')
+
     if (compress === 'true' || compress === 'base64') {
       let reader = new FileReader()
       let fileSize = file.size / 1024 / 1024
@@ -292,7 +311,7 @@
           let param = {Base64Img: cvs.toDataURL('image/jpeg', compressRate)}
 
           if (this.props.config.compress === 'base64') {
-            this.onUpdate(param.Base64Img)
+            this.onUpdate(param.Base64Img, file_name)
   
             this.setState({
               percent: 100
@@ -317,7 +336,7 @@
                   url = rduri.replace(/webapi(.*)$/, '') + result.Images
                 }
   
-                this.onUpdate(url)
+                this.onUpdate(url, file_name)
   
                 this.setState({
                   percent: 100
@@ -358,7 +377,7 @@
         if (res.status) {
           if (res.urlPath) {
             let path = (/^\/\//.test(res.urlPath) ? 'https:' : '') + res.urlPath
-            this.onUpdate(path)
+            this.onUpdate(path, file_name)
             this.setState({
               percent: 100
             }, () => {
@@ -403,7 +422,7 @@
       
       Api.getFilePreUpload(_param).then(res => {
         if (res.status && res.urlPath) {
-          this.onUpdate(res.urlPath)
+          this.onUpdate(res.urlPath, file_name)
           this.setState({
             percent: 100
           }, () => {
@@ -415,7 +434,7 @@
             }, 200)
           })
         } else {
-          this.shardupload(param)
+          this.shardupload(param, file_name)
         }
       })
     }

--
Gitblit v1.8.0