From a9b02f6862522b54d0824152017bf2acfec2af7b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 三月 2024 10:29:50 +0800
Subject: [PATCH] 2024-03-21

---
 src/menu/components/card/cardcellcomponent/elementform/index.jsx |  132 +++++++++++++++++++++++++------------------
 1 files changed, 77 insertions(+), 55 deletions(-)

diff --git a/src/menu/components/card/cardcellcomponent/elementform/index.jsx b/src/menu/components/card/cardcellcomponent/elementform/index.jsx
index 647b4ee..dee9a31 100644
--- a/src/menu/components/card/cardcellcomponent/elementform/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/elementform/index.jsx
@@ -10,16 +10,17 @@
 
 const { TextArea } = Input
 const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
+const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror'))
 const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
 const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
 
 const cardTypeOptions = {
-  sequence: ['eleType', 'width'],
+  sequence: ['eleType', 'width', 'prefix', 'postfix'],
   text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'anchors', 'noValue', 'bgImage', 'fixStyle', 'copyable', 'alignItems', 'sortField'],
   number: ['eleType', 'datatype', 'width', 'height', 'prefix', 'postfix', 'noValue', 'fixStyle', 'alignItems'],
   picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'maxWidth', 'link', 'noValue'],
   video: ['eleType', 'datatype', 'width', 'aspectRatio', 'autoPlay', 'loop', 'startTime', 'noValue', 'posterType'],
-  icon: ['eleType', 'datatype', 'width', 'tooltip'],
+  icon: ['eleType', 'datatype', 'tipType', 'width', 'tooltip'],
   slider: ['eleType', 'datatype', 'width', 'color', 'maxValue', 'showInfo', 'showType', 'strokeWidth', 'strokeLinecap', 'trailColor'],
   splitline: ['eleType', 'color', 'width', 'borderWidth'],
   barcode: ['eleType', 'datatype', 'width', 'barHeight', 'displayValue', 'interval', 'noValue'],
@@ -164,7 +165,10 @@
       } else {
         _options.push('value')
       }
-      if (this.record.eleType === 'video' && this.record.posterType) {
+      
+      if (this.record.eleType === 'picture' && this.record.noValue === 'show') {
+        _options.push('lostTip')
+      } else if (this.record.eleType === 'video' && this.record.posterType) {
         if (this.record.posterType === 'dynamic') {
           _options.push('posterField')
         } else {
@@ -173,7 +177,19 @@
       }
 
       if (['text', 'picture'].includes(this.record.eleType) && this.record.link) {
-        _options.push('linkurl', 'joint', 'linkType')
+        _options.push('linkType')
+        if (this.record.linkType === 'linkmenu') {
+          _options.push('open', 'joint')
+          if (this.record.link === 'static') {
+            _options.push('linkmenu')
+          } else {
+            _options.push('linkurl')
+          }
+        } else if (this.record.linkType === 'other') {
+          _options.push('linkurl', 'joint', 'open')
+        } else {
+          _options.push('linkurl')
+        }
       } else if (this.record.eleType === 'picture' && !this.record.link) {
         _options.push('scale')
       } else if (this.record.eleType === 'slider') {
@@ -187,8 +203,13 @@
     } else if (this.record.eleType === 'icon') {
       if (this.record.datatype === 'dynamic') {
         _options.push('field', 'noValue')
+      } else if (this.record.tipType === 'text') {
+        _options.push('value')
       } else {
         _options.push('icon')
+      }
+      if (this.record.tipType === 'text') {
+        _options.push('height')
       }
     } else if (this.record.eleType === 'formula' && this.record.eval === 'true') {
       _options.push('decimal')
@@ -324,7 +345,7 @@
           return item
         })
       })
-    } else if (['datatype', 'showInfo', 'showType', 'fixStyle', 'posterType', 'eval'].includes(key)) {
+    } else if (['datatype', 'showInfo', 'showType', 'fixStyle', 'posterType', 'eval', 'linkType', 'tipType', 'noValue'].includes(key)) {
       let _options = this.getOptions()
 
       this.setState({
@@ -379,52 +400,26 @@
           </Col>
         )
       } else if (item.type === 'textarea') {
-        if (item.key === 'formula') {
-          fields.push(
-            <Col span={24} className="textarea" key={index}>
-              <Form.Item label={item.tooltip ?
-                <Tooltip placement="topLeft" title={item.tooltip}>
-                  <QuestionCircleOutlined className="mk-form-tip" />
-                  {item.label}
-                </Tooltip> : item.label
-              }>
-                {getFieldDecorator(item.key, {
-                  initialValue: item.initVal || '',
-                  rules: [
-                    {
-                      required: item.readonly ? false : !!item.required,
-                      message: '璇疯緭鍏�' + item.label + '!'
-                    }
-                  ]
-                })(<TextArea autoSize={{minRows: 2}} disabled={item.readonly} placeholder={item.placeholder || ''} />)}
-              </Form.Item>
-              <Popover overlayClassName="formula-fields" placement="topLeft" title="" content={<div>{item.fields}</div>} trigger="click">
-                <span className="formula-icon">瀛楁闆�</span>
-              </Popover>
-            </Col>
-          )
-        } else {
-          fields.push(
-            <Col span={24} className="textarea" key={index}>
-              <Form.Item label={item.tooltip ?
-                <Tooltip placement="topLeft" title={item.tooltip}>
-                  <QuestionCircleOutlined className="mk-form-tip" />
-                  {item.label}
-                </Tooltip> : item.label
-              }>
-                {getFieldDecorator(item.key, {
-                  initialValue: item.initVal || '',
-                  rules: [
-                    {
-                      required: item.readonly ? false : !!item.required,
-                      message: '璇疯緭鍏�' + item.label + '!'
-                    }
-                  ]
-                })(<TextArea autoSize={{minRows: 2}} disabled={item.readonly} placeholder={item.placeholder || ''} />)}
-              </Form.Item>
-            </Col>
-          )
-        }
+        fields.push(
+          <Col span={24} className="textarea" key={index}>
+            <Form.Item label={item.tooltip ?
+              <Tooltip placement="topLeft" title={item.tooltip}>
+                <QuestionCircleOutlined className="mk-form-tip" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal || '',
+                rules: [
+                  {
+                    required: item.readonly ? false : !!item.required,
+                    message: '璇疯緭鍏�' + item.label + '!'
+                  }
+                ]
+              })(<TextArea autoSize={{minRows: 2}} disabled={item.readonly} placeholder={item.placeholder || ''} />)}
+            </Form.Item>
+          </Col>
+        )
       } else if (item.type === 'number') {
         fields.push(
           <Col span={12} key={index}>
@@ -468,8 +463,8 @@
                   getPopupContainer={() => document.getElementById('card-winter')}
                 >
                   {item.options.map((option, index) =>
-                    <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value}>
-                      {option.text}
+                    <Select.Option id={`${index}`} title={option.text || option.label} key={`${index}`} value={option.value}>
+                      {option.text || option.label}
                     </Select.Option>
                   )}
                 </Select>
@@ -544,10 +539,11 @@
           </Col>
         )
       } else if (item.type === 'file') {
-        let type = this.state.eleType
+        let type = this.record.eleType
         if (item.key === 'posterUrl') {
           type = 'picture'
         }
+
         fields.push(
           <Col span={12} key={index}>
             <Form.Item label={item.tooltip ?
@@ -593,6 +589,32 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'codemirror') {
+        fields.push(
+          <Col span={24} key={index} className="textarea">
+            <Form.Item label={
+              <Tooltip placement="topLeft" overlayStyle={{width: 500, maxWidth: 500}} title={item.tooltip}>
+                <QuestionCircleOutlined className="mk-form-tip" />
+                {item.label}
+              </Tooltip>
+            }>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal || '',
+                rules: [
+                  {
+                    required: !!item.required,
+                    message: '璇疯緭鍏�' + item.label + '!'
+                  }
+                ]
+              })(
+                <CodeMirror mode="text/javascript"/>
+              )}
+            </Form.Item>
+            <Popover overlayClassName="formula-fields" placement="topLeft" title="" content={<div>{item.fields}</div>} trigger="click">
+              <span className="formula-icon">瀛楁闆�</span>
+            </Popover>
+          </Col>
+        )
       }
     })
     return fields
@@ -609,7 +631,7 @@
           values.marks = this.props.card.marks || null
 
           // eslint-disable-next-line
-          if (values.eleType === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) {
+          if (values.eleType === 'formula' && values.eval === 'true' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) {
             let cols = []
             config.subColumns && config.subColumns.forEach(col => {
               if (/^(Int|Decimal)/ig.test(col.datatype)) {

--
Gitblit v1.8.0