From 06581907104d11d12703c47082350ad3ecd9c31e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 28 四月 2025 14:35:43 +0800
Subject: [PATCH] 2025-04-28

---
 src/menu/replaceField/index.jsx |  433 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 277 insertions(+), 156 deletions(-)

diff --git a/src/menu/replaceField/index.jsx b/src/menu/replaceField/index.jsx
index 81403fe..22bbc54 100644
--- a/src/menu/replaceField/index.jsx
+++ b/src/menu/replaceField/index.jsx
@@ -156,6 +156,130 @@
   exec = (map) => {
     let config = fromJS(this.props.config).toJS()
 
+    let getVal = (val) => {
+      let _val = val.toLowerCase()
+      if (map[_val]) {
+        return map[_val].FieldName
+      }
+      return val
+    }
+
+    let resetForm = (m) => {
+      if (m.field) {
+        m.field = getVal(m.field)
+      }
+      if (m.type === 'split' && m.splitctrl) {
+        m.splitctrl = getVal(m.splitctrl)
+      }
+      if (m.tabField) {
+        m.tabField = getVal(m.tabField)
+      }
+      if (m.linkField) {
+        m.linkField = getVal(m.linkField)
+      }
+      if (m.supField) {
+        m.supField = getVal(m.supField)
+      }
+      if (m.phoneField) {
+        m.phoneField = getVal(m.phoneField)
+      }
+      if (m.linkSubField) {
+        m.linkSubField = m.linkSubField.map(n => getVal(n))
+        m.linkSubField = Array.from(new Set(m.linkSubField))
+      }
+    }
+    let resetMark = (m) => {
+      m.marks = m.marks.map(n => {
+        if (n.field && Array.isArray(n.field)) {
+          if (n.field[1] === 'static') {
+            n.field[0] = getVal(n.field[0])
+          } else {
+            if (n.field[0]) {
+              n.field[0] = getVal(n.field[0])
+            }
+            if (n.field[2]) {
+              n.field[2] = getVal(n.field[2])
+            }
+          }
+        }
+
+        return n
+      })
+    }
+    let resetElement = (m) => {
+      if (m.field) {
+        m.field = getVal(m.field)
+      }
+      if (m.posterField) {
+        m.posterField = getVal(m.posterField)
+      }
+      if (m.bgImage) {
+        m.bgImage = getVal(m.bgImage)
+      }
+      if (m.linkurl && /^[a-zA-Z0-9_]+$/.test(m.linkurl)) {
+        m.linkurl = getVal(m.linkurl)
+      }
+      if (m.modal && m.modal.fields) {
+        if (m.modal.setting && m.modal.setting.focus) {
+          m.modal.setting.focus = getVal(m.modal.setting.focus)
+        }
+        m.modal.fields = m.modal.fields.map(col => {
+          resetForm(col)
+          return col
+        })
+      }
+      if (m.verify) {
+        if (m.verify.columns) {
+          m.verify.columns = m.verify.columns.map(col => {
+            if (col.Column) {
+              col.Column = getVal(col.Column)
+            }
+            return col
+          })
+        }
+        if (m.verify.uniques) {
+          m.verify.uniques = m.verify.uniques.map(col => {
+            if (col.field) {
+              col.field = col.field.split(',').map(_field => {
+                if (_field === 'BID') return _field
+                return getVal(_field)
+              }).join(',')
+            }
+            return col
+          })
+        }
+        if (m.verify.billcodes) {
+          m.verify.billcodes = m.verify.billcodes.map(col => {
+            if (col.field) {
+              col.field = getVal(col.field)
+            }
+            if (col.linkField && col.linkField !== 'BID') {
+              col.linkField = getVal(col.linkField)
+            }
+            return col
+          })
+        }
+
+        if (m.verify.accountfield && m.verify.accountfield !== 'BID') {
+          m.verify.accountfield = getVal(m.verify.accountfield)
+        }
+        if (m.verify.voucher && m.verify.voucher.linkField && m.verify.voucher.linkField !== 'BID') {
+          m.verify.voucher.linkField = getVal(m.verify.voucher.linkField)
+        }
+      }
+      if (m.controlField) {
+        m.controlField = getVal(m.controlField)
+      }
+
+      if (m.marks && m.marks.length) {
+        resetMark(m)
+      }
+
+      if (m.config && m.config.components) {
+        m.config.components = _replace(m.config.components)
+      }
+    }
+    
     let _replace = (components) => {
       return components.map(item => {
         if (item.type === 'tabs') {
@@ -182,8 +306,8 @@
         }
         if (item.search) {
           item.search = item.search.map(col => {
-            if (col.field && map[col.field.toLowerCase()]) {
-              col.field = map[col.field.toLowerCase()].FieldName
+            if (col.field) {
+              col.field = getVal(col.field)
             }
             return col
           })
@@ -191,163 +315,93 @@
 
         if (item.action) {
           item.action.forEach(m => {
-            if (m.modal && m.modal.fields) {
-              m.modal.fields = m.modal.fields.map(col => {
-                if (col.field && map[col.field.toLowerCase()]) {
-                  col.field = map[col.field.toLowerCase()].FieldName
-                }
-                return col
-              })
-            }
-            if (m.verify && m.verify.columns) {
-              m.verify.columns = m.verify.columns.map(col => {
-                if (col.Column && map[col.Column.toLowerCase()]) {
-                  col.Column = map[col.Column.toLowerCase()].FieldName
-                }
-                return col
-              })
-            }
-            if (m.config && m.config.components) {
-              m.config.components = _replace(m.config.components)
-            }
+            resetElement(m)
           })
         }
 
         if (item.subcards) {
           item.subcards.forEach(card => {
+            if (card.setting) {
+              if (card.setting.controlField) {
+                card.setting.controlField = getVal(card.setting.controlField)
+              }
+              if (card.setting.bgField) {
+                card.setting.bgField = getVal(card.setting.bgField)
+              }
+              if (card.setting.menuType) {
+                card.setting.menuType = getVal(card.setting.menuType)
+              }
+            }
+
             if (card.elements) { // 鍗$墖
               card.elements = card.elements.map(m => {
-                if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) {
-                  m.field = map[m.field.toLowerCase()].FieldName
-                }
-                if (m.modal && m.modal.fields) {
-                  m.modal.fields = m.modal.fields.map(col => {
-                    if (col.field && map[col.field.toLowerCase()]) {
-                      col.field = map[col.field.toLowerCase()].FieldName
-                    }
-                    return col
-                  })
-                }
-                if (m.verify && m.verify.columns) {
-                  m.verify.columns = m.verify.columns.map(col => {
-                    if (col.Column && map[col.Column.toLowerCase()]) {
-                      col.Column = map[col.Column.toLowerCase()].FieldName
-                    }
-                    return col
-                  })
-                }
-                if (m.config && m.config.components) {
-                  m.config.components = _replace(m.config.components)
-                }
+                resetElement(m)
                 return m
               })
             }
 
             if (card.backElements) { // 鍗$墖
               card.backElements = card.backElements.map(m => {
-                if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) {
-                  m.field = map[m.field.toLowerCase()].FieldName
-                }
-                if (m.modal && m.modal.fields) {
-                  m.modal.fields = m.modal.fields.map(col => {
-                    if (col.field && map[col.field.toLowerCase()]) {
-                      col.field = map[col.field.toLowerCase()].FieldName
-                    }
-                    return col
-                  })
-                }
-                if (m.verify && m.verify.columns) {
-                  m.verify.columns = m.verify.columns.map(col => {
-                    if (col.Column && map[col.Column.toLowerCase()]) {
-                      col.Column = map[col.Column.toLowerCase()].FieldName
-                    }
-                    return col
-                  })
-                }
-                if (m.config && m.config.components) {
-                  m.config.components = _replace(m.config.components)
-                }
+                resetElement(m)
                 return m
               })
             }
 
             if (card.fields) { // 琛ㄥ崟
               card.fields = card.fields.map(m => {
-                if (m.field && map[m.field.toLowerCase()]) {
-                  m.field = map[m.field.toLowerCase()].FieldName
-                }
+                resetForm(m)
                 return m
               })
+            }
+
+            if (card.subButton) {
+              resetElement(card.subButton)
+
+              if (card.subButton.resetForms) {
+                card.subButton.resetForms = card.subButton.resetForms.map(n => getVal(n))
+              }
             }
           })
         }
 
         if (item.elements) {
           item.elements = item.elements.map(m => {
-            if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) {
-              m.field = map[m.field.toLowerCase()].FieldName
-            }
-            if (m.modal && m.modal.fields) {
-              m.modal.fields = m.modal.fields.map(col => {
-                if (col.field && map[col.field.toLowerCase()]) {
-                  col.field = map[col.field.toLowerCase()].FieldName
-                }
-                return col
-              })
-            }
-            if (m.verify && m.verify.columns) {
-              m.verify.columns = m.verify.columns.map(col => {
-                if (col.Column && map[col.Column.toLowerCase()]) {
-                  col.Column = map[col.Column.toLowerCase()].FieldName
-                }
-                return col
-              })
-            }
-            if (m.config && m.config.components) {
-              m.config.components = _replace(m.config.components)
-            }
+            resetElement(m)
             return m
           })
         }
 
         if (item.plot) {
-          if (item.plot.Xaxis && map[item.plot.Xaxis.toLowerCase()]) {
-            item.plot.Xaxis = map[item.plot.Xaxis.toLowerCase()].FieldName
+          if (item.plot.Xaxis) {
+            item.plot.Xaxis = getVal(item.plot.Xaxis)
           }
           // 缁熻鍥�
-          if (item.plot.InfoValue && map[item.plot.InfoValue.toLowerCase()]) {
-            item.plot.InfoValue = map[item.plot.InfoValue.toLowerCase()].FieldName
+          if (item.plot.InfoValue) {
+            item.plot.InfoValue = getVal(item.plot.InfoValue)
           }
-          if (item.plot.InfoType && map[item.plot.InfoType.toLowerCase()]) {
-            item.plot.InfoType = map[item.plot.InfoType.toLowerCase()].FieldName
+          if (item.plot.InfoType) {
+            item.plot.InfoType = getVal(item.plot.InfoType)
           }
           // 鍗犳瘮鍥�
-          if (item.plot.valueField && map[item.plot.valueField.toLowerCase()]) {
-            item.plot.valueField = map[item.plot.valueField.toLowerCase()].FieldName
+          if (item.plot.valueField) {
+            item.plot.valueField = getVal(item.plot.valueField)
           }
-          if (item.plot.labelField && map[item.plot.labelField.toLowerCase()]) {
-            item.plot.labelField = map[item.plot.labelField.toLowerCase()].FieldName
+          if (item.plot.labelField) {
+            item.plot.labelField = getVal(item.plot.labelField)
           }
           // 楗煎浘
-          if (item.plot.type && map[item.plot.type.toLowerCase()]) {
-            item.plot.type = map[item.plot.type.toLowerCase()].FieldName
+          if (item.plot.type) {
+            item.plot.type = getVal(item.plot.type)
           }
           // 鏁g偣鍥�
-          if (item.plot.gender && map[item.plot.gender.toLowerCase()]) {
-            item.plot.gender = map[item.plot.gender.toLowerCase()].FieldName
+          if (item.plot.gender) {
+            item.plot.gender = getVal(item.plot.gender)
           }
           if (item.Yaxis) {
             if (Array.isArray(item.Yaxis)) {
-              item.Yaxis = item.Yaxis.map(m => {
-                if (map[m.toLowerCase()]) {
-                  return map[m.toLowerCase()].FieldName
-                }
-                return m
-              })
+              item.Yaxis = item.Yaxis.map(m => getVal(m))
             } else {
-              if (item.Yaxis && map[item.Yaxis.toLowerCase()]) {
-                item.Yaxis = map[item.Yaxis.toLowerCase()].FieldName
-              }
+              item.Yaxis = getVal(item.Yaxis)
             }
           }
         }
@@ -357,40 +411,13 @@
             return cols.map(col => {
               if (col.type === 'custom' && col.elements) {
                 col.elements = col.elements.map(m => {
-                  if (m.eleType === 'button') {
-                    if (m.modal && m.modal.fields) {
-                      m.modal.fields = m.modal.fields.map(col => {
-                        if (col.field && map[col.field.toLowerCase()]) {
-                          col.field = map[col.field.toLowerCase()].FieldName
-                        }
-                        return col
-                      })
-                    }
-                    if (m.verify && m.verify.columns) {
-                      m.verify.columns = m.verify.columns.map(col => {
-                        if (col.Column && map[col.Column.toLowerCase()]) {
-                          col.Column = map[col.Column.toLowerCase()].FieldName
-                        }
-                        return col
-                      })
-                    }
-                    if (m.config && m.config.components) {
-                      m.config.components = _replace(m.config.components)
-                    }
-                  } else {
-                    if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) {
-                      m.field = map[m.field.toLowerCase()].FieldName
-                    }
-                  }
-
+                  resetElement(m)
                   return m
                 })
               } else if (col.type === 'colspan') {
                 col.subcols = _update(col.subcols)
               } else if (col.field) {
-                if (map[col.field.toLowerCase()]) {
-                  col.field = map[col.field.toLowerCase()].FieldName
-                }
+                col.field = getVal(col.field)
               }
               
               return col
@@ -398,15 +425,100 @@
           }
 
           item.cols = _update(item.cols)
+
+          if (item.lineMarks) {
+            item.lineMarks = item.lineMarks.map(n => {
+              if (n.field && Array.isArray(n.field)) {
+                if (n.field[1] === 'static') {
+                  n.field[0] = getVal(n.field[0])
+                } else {
+                  if (n.field[0]) {
+                    n.field[0] = getVal(n.field[0])
+                  }
+                  if (n.field[2]) {
+                    n.field[2] = getVal(n.field[2])
+                  }
+                }
+              }
+      
+              return n
+            })
+          }
         }
 
-        if (item.subtype === 'basetable') {
-          item.cols = item.cols.map(col => {
-            if (col.field && map[col.field.toLowerCase()]) {
-              col.field = map[col.field.toLowerCase()].FieldName
+        if (item.subMenus) {
+          item.subMenus = item.subMenus.map(m => {
+            if (m.setting && m.setting.tip) {
+              m.setting.tip = getVal(m.setting.tip)
             }
-            return col
+            return m
           })
+        }
+
+        if (item.wrap) {
+          if (item.wrap.field) {
+            item.wrap.field = getVal(item.wrap.field)
+          }
+          if (item.wrap.tipField) {
+            item.wrap.tipField = getVal(item.wrap.tipField)
+          }
+          if (item.wrap.controlField) {
+            item.wrap.controlField = getVal(item.wrap.controlField)
+          }
+          if (item.wrap.valueField) {
+            item.wrap.valueField = getVal(item.wrap.valueField)
+          }
+          if (item.wrap.labelField) {
+            item.wrap.labelField = getVal(item.wrap.labelField)
+          }
+          if (item.wrap.parentField) {
+            item.wrap.parentField = getVal(item.wrap.parentField)
+          }
+          if (item.wrap.broadcast) {
+            item.wrap.broadcast = getVal(item.wrap.broadcast)
+          }
+          if (item.wrap.jumpField) {
+            item.wrap.jumpField = getVal(item.wrap.jumpField)
+          }
+          if (item.wrap.link) {
+            item.wrap.link = getVal(item.wrap.link)
+          }
+          if (item.wrap.linkField) {
+            item.wrap.linkField = getVal(item.wrap.linkField)
+          }
+          if (item.wrap.focus) {
+            item.wrap.focus = getVal(item.wrap.focus)
+          }
+          if (item.wrap.refocus) {
+            item.wrap.refocus = getVal(item.wrap.refocus)
+          }
+          if (item.wrap.statusControl) {
+            item.wrap.statusControl = getVal(item.wrap.statusControl)
+          }
+          if (item.wrap.timeField) {
+            item.wrap.timeField = getVal(item.wrap.timeField)
+          }
+          if (item.wrap.endField) {
+            item.wrap.endField = getVal(item.wrap.endField)
+          }
+          if (item.wrap.remarkField) {
+            item.wrap.remarkField = getVal(item.wrap.remarkField)
+          }
+          if (item.wrap.colorField) {
+            item.wrap.colorField = getVal(item.wrap.colorField)
+          }
+          if (item.wrap.menuType) {
+            item.wrap.menuType = getVal(item.wrap.menuType)
+          }
+
+          if (item.type === 'timeline') {
+            if (item.wrap.label) {
+              item.wrap.label = getVal(item.wrap.label)
+            }
+            if (item.wrap.node) {
+              item.wrap.node = getVal(item.wrap.node)
+            }
+          }
         }
 
         return item
@@ -434,6 +546,15 @@
       confirming: false,
       visible: false
     })
+
+    if (is(fromJS(this.props.config), fromJS(config))) {
+      notification.success({
+        top: 92,
+        message: '鏈煡璇㈠埌闇�瑕佹浛鎹㈢殑瀛楁銆�',
+        duration: 3
+      })
+      return
+    }
 
     notification.success({
       top: 92,
@@ -544,15 +665,6 @@
           item.cols = _update(item.cols)
         }
 
-        if (item.subtype === 'basetable') {
-          item.cols = item.cols.map(col => {
-            if (col.field && map[col.field.toLowerCase()]) {
-              col.label = map[col.field.toLowerCase()].FieldDec
-            }
-            return col
-          })
-        }
-
         return item
       })
     }
@@ -575,6 +687,15 @@
       visible: false
     })
 
+    if (is(fromJS(this.props.config), fromJS(config))) {
+      notification.success({
+        top: 92,
+        message: '鏈煡璇㈠埌闇�瑕佹浛鎹㈢殑瀛楁銆�',
+        duration: 3
+      })
+      return
+    }
+
     notification.success({
       top: 92,
       message: '鏇存柊宸插畬鎴愩��',

--
Gitblit v1.8.0