From 871597aaf2c838946723ee44fc7fa12487b56d34 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 一月 2025 15:14:25 +0800
Subject: [PATCH] 2025-01-22

---
 src/components/normalform/modalform/index.jsx                |    3 +
 src/menu/components/editor/braft-editor/options.jsx          |   22 +++++++
 src/menu/components/form/step-form/index.jsx                 |    1 
 src/tabviews/custom/components/editor/braft-editor/index.jsx |   42 +++++++++++--
 src/menu/components/form/tab-form/index.jsx                  |    1 
 src/tabviews/custom/components/share/braftContent/index.scss |    2 
 src/mob/components/formdragelement/index.jsx                 |    1 
 src/menu/components/code/sandbox/codecontent/index.scss      |    2 
 src/menu/components/form/simple-form/index.jsx               |    1 
 src/tabviews/custom/components/share/braftContent/index.jsx  |   57 ++++++++++--------
 src/templates/sharecomponent/fieldscomponent/index.jsx       |    3 
 src/menu/components/editor/braft-editor/index.jsx            |    7 -
 src/templates/modalconfig/dragelement/index.jsx              |    1 
 src/tabviews/zshare/actionList/normalbutton/index.jsx        |    9 +-
 14 files changed, 108 insertions(+), 44 deletions(-)

diff --git a/src/components/normalform/modalform/index.jsx b/src/components/normalform/modalform/index.jsx
index 6c7d9f3..5b1cb47 100644
--- a/src/components/normalform/modalform/index.jsx
+++ b/src/components/normalform/modalform/index.jsx
@@ -22,6 +22,7 @@
 // const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor'))
 const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
 const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
+const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror'))
 
 class ModalForm extends Component {
   static propTpyes = {
@@ -362,6 +363,8 @@
         return
       } else if (item.type === 'printTemps') {
         content = <MkPrintTemps onChange={(val) => this.recordChange({[item.field]: val})}/>
+      } else if (item.type === 'codemirror') {
+        content = <CodeMirror mode="text/javascript" theme="cobalt" onChange={(val) => this.recordChange({[item.field]: val})}/>
       }
 
       if (!content) return
diff --git a/src/menu/components/code/sandbox/codecontent/index.scss b/src/menu/components/code/sandbox/codecontent/index.scss
index f2f0d33..1bf75e2 100644
--- a/src/menu/components/code/sandbox/codecontent/index.scss
+++ b/src/menu/components/code/sandbox/codecontent/index.scss
@@ -18,7 +18,7 @@
       background-color: #f0f0f0;
     }
     td, th {
-      padding: 5px 14px;
+      padding: 5px 10px;
       font-size: 16px;
       border: 1px solid #ddd;
     }
diff --git a/src/menu/components/editor/braft-editor/index.jsx b/src/menu/components/editor/braft-editor/index.jsx
index 0878d3e..67fcb70 100644
--- a/src/menu/components/editor/braft-editor/index.jsx
+++ b/src/menu/components/editor/braft-editor/index.jsx
@@ -200,7 +200,7 @@
         <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <NormalForm title="瀵屾枃鏈缃�" width={850} update={this.updateWrap} getForms={this.getWrapForms}>
+            <NormalForm title="瀵屾枃鏈缃�" width={900} update={this.updateWrap} getForms={this.getWrapForms}>
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
             <CopyComponent type="editor" card={card}/>
@@ -212,10 +212,7 @@
         } trigger="hover">
           <ToolOutlined />
         </Popover>
-        <BraftContent
-          value={card.wrap.datatype !== 'static' ? '<p class="empty-content">瀵屾枃鏈�</p>' : card.html}
-          encryption="false"
-        />
+        <BraftContent value={card.wrap.datatype !== 'static' ? '<p class="empty-content">瀵屾枃鏈�</p>' : card.html}/>
         <div className="component-name">
           <div className="center">
             <div className="title">{card.name}</div>
diff --git a/src/menu/components/editor/braft-editor/options.jsx b/src/menu/components/editor/braft-editor/options.jsx
index 72d9018..bd9e84c 100644
--- a/src/menu/components/editor/braft-editor/options.jsx
+++ b/src/menu/components/editor/braft-editor/options.jsx
@@ -167,6 +167,28 @@
     },
     {
       type: 'radio',
+      field: 'loaded',
+      label: '甯冨眬璋冩暣',
+      initval: wrap.loaded || 'false',
+      required: false,
+      options: [
+        {value: 'false', label: '鍏抽棴'},
+        {value: 'true', label: '寮�鍚�'},
+      ],
+      controlFields: [
+        {field: 'loadedfunc', values: ['true']},
+      ]
+    },
+    {
+      type: 'codemirror',
+      field: 'loadedfunc',
+      label: '澶勭悊鑴氭湰',
+      initval: wrap.loadedfunc || '',
+      required: true,
+      span: 24
+    },
+    {
+      type: 'radio',
       field: 'permission',
       label: '鏉冮檺楠岃瘉',
       initval: wrap.permission || 'false',
diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx
index 3e67e97..fd8d4f7 100644
--- a/src/menu/components/form/simple-form/index.jsx
+++ b/src/menu/components/form/simple-form/index.jsx
@@ -325,6 +325,7 @@
       orderType: 'asc',
       readonly: 'false',
       required: 'true',
+      readin: 'top',
       focus: true
     }
 
diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx
index eb48849..81a2984 100644
--- a/src/menu/components/form/step-form/index.jsx
+++ b/src/menu/components/form/step-form/index.jsx
@@ -425,6 +425,7 @@
       orderType: 'asc',
       readonly: 'false',
       required: 'true',
+      readin: 'top',
       focus: true
     }
 
diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx
index c7591d4..ba0f02b 100644
--- a/src/menu/components/form/tab-form/index.jsx
+++ b/src/menu/components/form/tab-form/index.jsx
@@ -431,6 +431,7 @@
       orderType: 'asc',
       readonly: 'false',
       required: 'true',
+      readin: 'top',
       focus: true
     }
 
diff --git a/src/mob/components/formdragelement/index.jsx b/src/mob/components/formdragelement/index.jsx
index 794fa72..d25eeab 100644
--- a/src/mob/components/formdragelement/index.jsx
+++ b/src/mob/components/formdragelement/index.jsx
@@ -94,6 +94,7 @@
       newcard.options = []
       newcard.readonly = 'false'
       newcard.required = 'true'
+      newcard.readin = 'top'
       newcard.span = 24
       newcard.focus = true
 
diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx
index 2c5ddd6..067b69f 100644
--- a/src/tabviews/custom/components/editor/braft-editor/index.jsx
+++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx
@@ -73,7 +73,7 @@
     }
 
     this.setState({
-      data: _data,
+      data: this.decodeHtml(_data, _config.wrap),
       BID: BID || '',
       config: _config,
     })
@@ -130,7 +130,7 @@
 
     let _data = window.GLOB.SyncData.get(config.dataName) || []
 
-    this.setState({data: _data})
+    this.setState({data: this.decodeHtml(_data, config.wrap)})
 
     window.GLOB.SyncData.delete(config.dataName)
 
@@ -158,7 +158,7 @@
         _data = [_data]
       }
 
-      this.setState({data: _data})
+      this.setState({data: this.decodeHtml(_data, config.wrap)})
     }
   }
 
@@ -224,7 +224,7 @@
     let result = await Api.genericInterface(param)
     if (result.status) {
       this.setState({
-        data: result.data || [],
+        data: this.decodeHtml(result.data, config.wrap),
         loading: false
       })
       
@@ -236,6 +236,35 @@
       
       UtilsDM.queryFail(result)
     }
+  }
+
+  decodeHtml = (data, wrap) => {
+    if (!data || data.length === 0) return []
+
+    data.forEach(item => {
+      item.$html = item[wrap.field] || ''
+      if (item.$html) {
+        if (wrap.encryption === 'true') {
+          try {
+            item.$html = window.decodeURIComponent(window.atob(item.$html))
+          } catch (e) {
+            item.$html = item[wrap.field] || ''
+          }
+        }
+
+        delete item[wrap.field]
+
+        if (/\$[\s\S]+\$/.test(item.$html)) {
+          Object.keys(item).forEach(key => {
+            if (/^\$/.test(key)) return
+            let reg = new RegExp('\\$' + key + '\\$', 'ig')
+            item.$html = item.$html.replace(reg, item[key])
+          })
+        }
+      }
+    })
+
+    return data
   }
 
   render() {
@@ -254,11 +283,10 @@
         <NormalHeader config={config}/>
         {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}
+          value={item.$html}
+          script={config.wrap.loaded === 'true' ? config.wrap.loadedfunc : ''}
         />)}
       </div>
     )
diff --git a/src/tabviews/custom/components/share/braftContent/index.jsx b/src/tabviews/custom/components/share/braftContent/index.jsx
index 527e61f..553249f 100644
--- a/src/tabviews/custom/components/share/braftContent/index.jsx
+++ b/src/tabviews/custom/components/share/braftContent/index.jsx
@@ -1,13 +1,12 @@
-import React, {Component} from 'react'
+import React, { Component } from 'react'
 import PropTypes from 'prop-types'
-import { is, fromJS } from 'immutable'
 
 import './index.scss'
 
 class BraftContent extends Component {
   static propTpyes = {
     value: PropTypes.any,       // 鍐呭
-    encryption: PropTypes.any,  // 鏄惁瑙g爜
+    script: PropTypes.any       // 鑷畾涔夎剼鏈�
   }
 
   state = {
@@ -15,34 +14,42 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { encryption, value } = this.props
-    let html = value
-
-    if (encryption === 'true' && html) {
-      try {
-        html = window.decodeURIComponent(window.atob(html))
-      } catch (e) {
-        html = value
-      }
-    }
+    const { value } = this.props
     
-    this.setState({html})
+    this.setState({html: value})
+  }
+
+  componentDidMount() {
+    this.loadScript()
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
-    if (!is(fromJS(this.props), fromJS(nextProps))) {
-      const { encryption, value } = nextProps
-      let html = value
+    if (this.props.value !== nextProps.value) {
+      this.setState({html: nextProps.value}, () => {
+        this.loadScript()
+      })
+    }
+  }
 
-      if (encryption === 'true' && html) {
-        try {
-          html = window.decodeURIComponent(window.atob(html))
-        } catch (e) {
-          html = value
-        }
+  loadScript = () => {
+    const { script } = this.props
+    const { html } = this.state
+
+    if (script && html) {
+      const that = this
+      let _html = ''
+      try {
+        // eslint-disable-next-line
+        let func = new Function('that', 'html', script)
+        _html = func(that, html)
+      } catch (e) {
+        _html = ''
+        console.warn(e)
       }
-      
-      this.setState({html})
+
+      if (_html) {
+        this.setState({html: _html})
+      }
     }
   }
 
diff --git a/src/tabviews/custom/components/share/braftContent/index.scss b/src/tabviews/custom/components/share/braftContent/index.scss
index bf6b2f9..5064a93 100644
--- a/src/tabviews/custom/components/share/braftContent/index.scss
+++ b/src/tabviews/custom/components/share/braftContent/index.scss
@@ -36,7 +36,7 @@
       background-color: #f0f0f0;
     }
     td, th {
-      padding: 5px 14px;
+      padding: 5px 10px;
       font-size: 16px;
       border: 1px solid #ddd;
     }
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 117d4f3..517c21c 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -4121,13 +4121,14 @@
    */
   getModels = () => {
     const { BID, btn, BData } = this.props
-    const { btnconfig, visible, dict, confirmLoading, submitType } = this.state
+    const { btnconfig, visible, dict, confirmLoading, submitType, loadingNumber, loadingTotal } = this.state
 
     if (!btnconfig || !btnconfig.setting) return null
 
     let title = btn.label
     let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw'
     let clickouter = btnconfig.setting.clickouter === 'close'
+    let num = loadingNumber && !loadingTotal ? `(${loadingNumber}) ` : ''
 
     if (btnconfig.setting.display === 'drawer') {
       let height = '100vh'
@@ -4196,9 +4197,9 @@
           onCancel={this.handleCancel}
           footer={[
             <Button key="cancel" onClick={this.handleCancel}>{dict['cancel'] || '鍙栨秷'}</Button>,
-            btn.extBtn === 'true' ? <Button key="extend" className={'extend-btn ' + (btn.extStyle || '')} disabled={confirmLoading && submitType !== btn.extValue} loading={confirmLoading && submitType === btn.extValue} onClick={() => this.handleOk(btn.extValue)}>{btn.extLabel}</Button> : null,
-            btn.extBtn === 'true' ? <Button key="confirm" className={'confirm-btn ' + (btn.confStyle || '')} disabled={confirmLoading && submitType !== ''} loading={confirmLoading && submitType === ''} onClick={() => this.handleOk()}>{btn.confLabel || dict['ok'] || '纭畾'}</Button> : null,
-            btn.extBtn !== 'true' ? <Button key="confirm" type="primary" loading={confirmLoading} onClick={() => this.handleOk()}>{dict['ok'] || '纭畾'}</Button> : null
+            btn.extBtn === 'true' ? <Button key="extend" className={'extend-btn ' + (btn.extStyle || '')} disabled={confirmLoading && submitType !== btn.extValue} loading={confirmLoading && submitType === btn.extValue} onClick={() => this.handleOk(btn.extValue)}>{submitType === btn.extValue ? num : ''}{btn.extLabel}</Button> : null,
+            btn.extBtn === 'true' ? <Button key="confirm" className={'confirm-btn ' + (btn.confStyle || '')} disabled={confirmLoading && submitType !== ''} loading={confirmLoading && submitType === ''} onClick={() => this.handleOk()}>{submitType === '' ? num : ''}{btn.confLabel || dict['ok'] || '纭畾'}</Button> : null,
+            btn.extBtn !== 'true' ? <Button key="confirm" type="primary" loading={confirmLoading} onClick={() => this.handleOk()}>{num}{dict['ok'] || '纭畾'}</Button> : null
           ]}
           destroyOnClose
         >
diff --git a/src/templates/modalconfig/dragelement/index.jsx b/src/templates/modalconfig/dragelement/index.jsx
index a9ac1a0..a7fbb53 100644
--- a/src/templates/modalconfig/dragelement/index.jsx
+++ b/src/templates/modalconfig/dragelement/index.jsx
@@ -94,6 +94,7 @@
       newcard.options = []
       newcard.readonly = 'false'
       newcard.required = 'true'
+      newcard.readin = 'top'
       newcard.focus = true
 
       if (item.subType === 'linkMain') {
diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx
index 9db6d1e..4bbf651 100644
--- a/src/templates/sharecomponent/fieldscomponent/index.jsx
+++ b/src/templates/sharecomponent/fieldscomponent/index.jsx
@@ -305,7 +305,8 @@
           decimal: item.decimal,
           orderType: 'asc',
           readonly: 'false',
-          required: 'true'
+          required: 'true',
+          readin: 'top'
         }
 
         if (/^icon|images?$/ig.test(item.field)) {

--
Gitblit v1.8.0