From cb52ff0fd9fdf3ebfbde2314539998f3fedd9854 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 九月 2024 10:16:46 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/custom/components/editor/braft-editor/index.jsx |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx
index bac965b..d5a8cea 100644
--- a/src/tabviews/custom/components/editor/braft-editor/index.jsx
+++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx
@@ -21,14 +21,14 @@
     BID: '',                   // 涓婄骇ID
     config: null,              // 鍥捐〃閰嶇疆淇℃伅
     loading: false,            // 鏁版嵁鍔犺浇鐘舵��
-    data: {}                   // 鏁版嵁
+    data: []                   // 鏁版嵁
   }
 
   UNSAFE_componentWillMount () {
     const { config } = this.props
 
     let _config = fromJS(config).toJS()
-    let _data = { $$empty: true }
+    let _data = []
 
     let BID = ''
     let BData = ''
@@ -47,8 +47,6 @@
 
       if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) {
         _data = window.GLOB.SyncData.get(_config.dataName) || []
-        _data = _data[0] || {$$empty: true}
-
         _config.setting.sync = 'false'
   
         window.GLOB.SyncData.delete(_config.dataName)
@@ -56,6 +54,11 @@
     } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.has(_config.wrap.publicId)) {
       _data = window.GLOB.CacheData.get(_config.wrap.publicId)
       _data = fromJS(_data).toJS()
+      if (_data.$$empty) {
+        _data = []
+      } else {
+        _data = [_data]
+      }
     }
 
     if (_config.wrap.minHeight) {
@@ -122,7 +125,6 @@
     if (config.$syncId !== syncId) return
 
     let _data = window.GLOB.SyncData.get(config.dataName) || []
-    _data = _data[0] || {$$empty: true}
 
     this.setState({data: _data})
 
@@ -146,6 +148,11 @@
 
     if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) {
       let _data = fromJS(data).toJS()
+      if (_data.$$empty) {
+        _data = []
+      } else {
+        _data = [_data]
+      }
 
       this.setState({data: _data})
     }
@@ -180,13 +187,13 @@
     
     if (config.wrap.datatype === 'static') {
       this.setState({
-        data: {$$empty: true},
+        data: [],
         loading: false
       })
       return
     } else if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
-        data: {$$empty: true},
+        data: [],
         loading: false
       })
       return
@@ -210,11 +217,8 @@
 
     let result = await Api.genericInterface(param)
     if (result.status) {
-      let _data = result.data || []
-      _data = _data[0] || {$$empty: true}
-
       this.setState({
-        data: _data,
+        data: result.data || [],
         loading: false
       })
       
@@ -231,7 +235,7 @@
   render() {
     const { config, loading, data } = this.state
 
-    if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null
+    if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null
 
     return (
       <div className={'custom-braft-editor-box ' + (config.wrap.tbStyle || '')} id={'anchor' + config.uuid} style={config.style}>
@@ -242,10 +246,14 @@
           </div> : null
         }
         <NormalHeader config={config}/>
-        <BraftContent
-          value={config.wrap.datatype !== 'static' ? (data[config.wrap.field] || '') : config.html}
-          encryption={config.wrap.datatype !== 'static' ? config.wrap.encryption : 'false'}
-        />
+        {config.wrap.datatype === 'static' ? <BraftContent
+          value={config.html}
+          encryption={'false'}
+        /> : data.map((item, index) => <BraftContent
+          key={index}
+          value={item[config.wrap.field] || ''}
+          encryption={config.wrap.encryption}
+        />)}
       </div>
     )
   }

--
Gitblit v1.8.0