| | |
| | | </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') { |
| | |
| | | type: 'form', |
| | | label: '关联主表', |
| | | subType: 'linkMain', |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '公式', |
| | | subType: 'formula', |
| | | } |
| | | ] |
| | | |
| | |
| | | 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 { |
| | |
| | | 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] |
| | |
| | | </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 = '' |
New file |
| | |
| | | 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 |
| | |
| | | </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') { |
| | |
| | | type: 'form', |
| | | label: '关联主表', |
| | | subType: 'linkMain', |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '公式', |
| | | subType: 'formula', |
| | | } |
| | | ] |
| | | |
| | |
| | | }, { |
| | | value: 'linkMain', |
| | | text: '关联主表' |
| | | }, { |
| | | value: 'formula', |
| | | text: '公式' |
| | | }] |
| | | |
| | | let _fieldlength = 50 |
| | |
| | | }, { |
| | | value: 'linkMain', |
| | | text: '关联主表' |
| | | }, { |
| | | value: 'formula', |
| | | text: '公式' |
| | | }] |
| | | } |
| | | |
| | |
| | | }] |
| | | }, |
| | | { |
| | | 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: '分割线', |
| | |
| | | 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 '居左' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | |
| | | 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'] |
| | |
| | | |
| | | reRequired.field = true |
| | | |
| | | if (type === 'hint' || type === 'split') { |
| | | if (['hint', 'split', 'formula'].includes(type)) { |
| | | reRequired.field = false |
| | | shows = fromJS(modalTypeOptions[type]).toJS() |
| | | } |
| | |
| | | reTooltip.initval = '使用$first表示默认选择第一项。' |
| | | } |
| | | |
| | | if (this.record.supField) { |
| | | if (this.record.supField && !['hint', 'split', 'formula'].includes(type)) { |
| | | shows.push('supvalue') |
| | | } |
| | | |