Commit 77d09c60 authored by 田翔's avatar 田翔

自动计算属性增加控制规则函数

parent 56de3529
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "2.0.1", "version": "2.0.2",
"description": "2.0.1: 增加业务表单与自动计算的控制规则", "description": "2.0.2: 自动计算属性增加控制规则函数",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -6,6 +6,17 @@ import { isObject } from '../../../../../utils' ...@@ -6,6 +6,17 @@ import { isObject } from '../../../../../utils'
const { TextArea } = Input const { TextArea } = Input
const fnList = [
{ label: '最大值', value: '$math.max()' },
{ label: '最小值', value: '$math.min()' },
{ label: '求和', value: '$math.sum()' },
{ label: '平均值', value: '$math.avg()' },
{ label: '时间差(小时)', value: '$math.datediffhour()' },
{ label: '时间差(天)', value: '$math.datediffday()' },
{ label: '向下取整', value: '$math.ceiling()' },
{ label: '向上取整', value: '$math.floor()' },
]
const ControlRules = (props) => { const ControlRules = (props) => {
const { value, onChange, addons } = props const { value, onChange, addons } = props
...@@ -82,6 +93,20 @@ const ControlRules = (props) => { ...@@ -82,6 +93,20 @@ const ControlRules = (props) => {
ruleText.current.focus() ruleText.current.focus()
} }
const insertFn = value => {
insert(value)
}
const fnListRender = (
<Menu>
{fnList.map(item => (
<Menu.Item key={item.value} onClick={() => insertFn(item.value)}>
{item.label}
</Menu.Item>
))}
</Menu>
)
return ( return (
<div> <div>
<Input <Input
...@@ -111,6 +136,9 @@ const ControlRules = (props) => { ...@@ -111,6 +136,9 @@ const ControlRules = (props) => {
</div> </div>
<div className={styles.rightContent}> <div className={styles.rightContent}>
<div className={styles.textAreaBox}> <div className={styles.textAreaBox}>
<Dropdown overlay={fnListRender} placement="bottom" arrow>
<div className={styles.insertFn}>插入函数</div>
</Dropdown>
<TextArea <TextArea
id="calculateRule" id="calculateRule"
autoSize={{ minRows: 19, maxRows: 19 }} autoSize={{ minRows: 19, maxRows: 19 }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment