king
2022-06-21 870b6e10f9428e769530b94df3034e567a516429
2022-06-21
8个文件已修改
2个文件已添加
137 ■■■■■ 已修改文件
src/mob/components/formdragelement/card.jsx 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/mob/modalconfig/source.jsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/index.jsx 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/mkFormula/index.jsx 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/mkFormula/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/modalconfig/dragelement/card.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/modalconfig/source.jsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/formconfig.jsx 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/modalform/fieldtable/index.jsx 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/modalform/index.jsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/mob/components/formdragelement/card.jsx
@@ -192,6 +192,15 @@
        </div>
      </div>
    </div>
  } else if (card.type === 'formula') {
    formItem = <div className="am-list-item hint">
      <div className="am-list-line">
        <div className="am-input-label">{card.label}</div>
        <div className="am-input-control">
          {card.formula}{card.postfix || ''}
        </div>
      </div>
    </div>
  } else if (card.type === 'split') {
    formItem = <div className="split-line">{card.label}</div>
  } else if (card.type === 'checkcard') {
src/mob/modalconfig/source.jsx
@@ -110,6 +110,11 @@
    type: 'form',
    label: '关联主表',
    subType: 'linkMain',
  },
  {
    type: 'form',
    label: '公式',
    subType: 'formula',
  }
]
src/tabviews/zshare/mutilform/index.jsx
@@ -25,6 +25,7 @@
const MKTextArea = asyncComponent(() => import('./mkTextArea'))
const MKFileUpload = asyncComponent(() => import('../fileupload'))
const MKColor = asyncComponent(() => import('./mkColor'))
const MkFormula = asyncComponent(() => import('./mkFormula'))
const MKEditor = asyncComponent(() => import('@/components/editor'))
class MainSearch extends Component {
@@ -84,7 +85,7 @@
        delete item.style.marginRight
      }
      if (item.type === 'split') return true
      if (item.type === 'split' || item.type === 'formula') return true
      if (item.type === 'hint') {
        if (item.field && data && data[item.field]) {
          item.message = data[item.field]
@@ -807,6 +808,14 @@
            </Form.Item>
          </Col>
        )
      } else if (item.type === 'formula') {
        fields.push(
          <Col span={item.span || 24} key={index}>
            <Form.Item className="hint" colon={false} label={<span className="mk-form-label" style={item.style}>{item.label}</span>} labelCol={item.labelCol} wrapperCol={item.wrapperCol}>
              <MkFormula config={item} data={this.record}></MkFormula>
            </Form.Item>
          </Col>
        )
      } else {
        let content = null
        let className = ''
src/tabviews/zshare/mutilform/mkFormula/index.jsx
New file
@@ -0,0 +1,44 @@
import React, { Component } from 'react'
// import { is, fromJS } from 'immutable'
// import './index.scss'
/**
 * @description 公式
 */
class MkFormula extends Component {
  constructor(props) {
    super(props)
    this.state = {}
  }
  render() {
    const { config, data } = this.props
    if (!data) return null
    let _val = config.formula
    Object.keys(data).forEach(key => {
      let reg = new RegExp('@' + key + '@', 'ig')
      _val = _val.replace(reg, data[key])
    })
    if (config.eval !== 'false') {
      try {
        // eslint-disable-next-line
        _val = eval(_val)
      } catch (e) {
        _val = ''
      }
    }
    if (config.postfix && _val !== '') {
      _val = _val + config.postfix
    }
    return <div className="message" style={config.style}>{_val}</div>
  }
}
export default MkFormula
src/tabviews/zshare/mutilform/mkFormula/index.scss
src/templates/modalconfig/dragelement/card.jsx
@@ -131,6 +131,8 @@
    </Checkbox.Group>)
  } else if (card.type === 'hint') {
    formItem = <div style={{marginTop: '10px', color: 'rgba(0, 0, 0, 0.85)', lineHeight: '1.5', ...card.style}}>{card.message}</div>
  } else if (card.type === 'formula') {
    formItem = <div style={{marginTop: '8px', color: 'rgba(0, 0, 0, 0.85)', lineHeight: '1.5', ...card.style}}>{card.formula}{card.postfix || ''}</div>
  } else if (card.type === 'split') {
    formItem = <div className="split-line" style={card.style}>{card.label}</div>
  } else if (card.type === 'checkcard') {
src/templates/modalconfig/source.jsx
@@ -178,6 +178,11 @@
    type: 'form',
    label: '关联主表',
    subType: 'linkMain',
  },
  {
    type: 'form',
    label: '公式',
    subType: 'formula',
  }
]
src/templates/zshare/formconfig.jsx
@@ -2387,6 +2387,9 @@
  }, {
    value: 'linkMain',
    text: '关联主表'
  }, {
    value: 'formula',
    text: '公式'
  }]
  let _fieldlength = 50
@@ -2446,6 +2449,9 @@
    }, {
      value: 'linkMain',
      text: '关联主表'
    }, {
      value: 'formula',
      text: '公式'
    }]
  }
@@ -3206,6 +3212,37 @@
      }]
    },
    {
      type: 'textarea',
      key: 'formula',
      label: '公式',
      initVal: card.formula || '',
      tooltip: '动态替换相应的字段,展示获得的结果。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等',
      rows: 2,
      required: true
    },
    {
      type: 'radio',
      key: 'eval',
      label: '解析',
      initVal: card.eval || 'true',
      tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。',
      required: false,
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'text',
      key: 'postfix',
      label: '后缀',
      initVal: card.postfix || '',
      required: false
    },
    {
      type: 'radio',
      key: 'splitline',
      label: '分割线',
src/templates/zshare/modalform/fieldtable/index.jsx
@@ -63,11 +63,20 @@
        editable: true,
        width: '20%',
        options: [
          {value: 'left', text: 'left'},
          {value: 'center', text: 'center'},
          {value: 'right', text: 'right'},
          {value: 'justify', text: 'justify'}
        ]
          {value: 'left', text: '居左'},
          {value: 'center', text: '居中'},
          {value: 'right', text: '居右'},
          // {value: 'justify', text: 'justify'}
        ],
        render: (text, record) => {
          if (text === 'center') {
            return '居中'
          } else if (text === 'right') {
            return '居右'
          } else {
            return '居左'
          }
        }
      }
    ]
  }
src/templates/zshare/modalform/index.jsx
@@ -37,6 +37,7 @@
  rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'rateCount', 'character', 'place'],
  hint: ['label', 'field', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
  split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline'],
  formula: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'span', 'labelwidth', 'formula', 'eval', 'postfix'],
  brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'],
  funcvar: ['span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
  linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom']
@@ -119,7 +120,7 @@
    reRequired.field = true
    if (type === 'hint' || type === 'split') {
    if (['hint', 'split', 'formula'].includes(type)) {
      reRequired.field = false
      shows = fromJS(modalTypeOptions[type]).toJS()
    }
@@ -215,7 +216,7 @@
      reTooltip.initval = '使用$first表示默认选择第一项。'
    }
    if (this.record.supField) {
    if (this.record.supField && !['hint', 'split', 'formula'].includes(type)) {
      shows.push('supvalue')
    }