Commit 4ba792f0 authored by 田翔's avatar 田翔

fix: 计算规则优化

parent 3f0e0889
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.7.6", "version": "5.7.7",
"description": "5.7.6 日期类控件增加计算规则", "description": "5.7.7 计算规则优化",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -28,21 +28,15 @@ const CalculateRule = (props) => { ...@@ -28,21 +28,15 @@ const CalculateRule = (props) => {
const ruleText = useRef() const ruleText = useRef()
const fnList = useMemo(() => { const fnList = useMemo(() => {
if (['DateTime', 'Time'].includes(widget)) { let disabled = ['DateTime', 'Time'].includes(widget)
return [
{ label: '时间差', value: '$sql.datediff()' },
{ label: '向下取整', value: '$sql.ceiling()' },
{ label: '向上取整', value: '$sql.floor()' },
]
}
return [ return [
{ label: '最大值', value: '$sql.max()' }, { label: '最大值', value: '$sql.max()', disabled },
{ label: '最小值', value: '$sql.min()' }, { label: '最小值', value: '$sql.min()', disabled },
{ label: '求和', value: '$sql.sum()' }, { label: '求和', value: '$sql.sum()', disabled },
{ label: '平均值', value: '$sql.avg()' }, { label: '平均值', value: '$sql.avg()', disabled },
{ label: '时间差', value: '$sql.datediff()' }, { label: '时间差', value: '$sql.datediff()', disabled: false },
{ label: '向下取整', value: '$sql.ceiling()' }, { label: '向下取整', value: '$sql.ceiling()', disabled: false },
{ label: '向上取整', value: '$sql.floor()' }, { label: '向上取整', value: '$sql.floor()', disabled: false },
] ]
}, [widget]) }, [widget])
...@@ -91,7 +85,7 @@ const CalculateRule = (props) => { ...@@ -91,7 +85,7 @@ const CalculateRule = (props) => {
const onOk = async () => { const onOk = async () => {
if (rule) { if (rule) {
const { code, data, msg } = await getFormFieldAnalysisDtos({ formula: rule }) const { code, data, msg } = await getFormFieldAnalysisDtos({ formula: rule, widget })
if (code === 0) { if (code === 0) {
addons.setValue('rules', data) addons.setValue('rules', data)
setVisible(false) setVisible(false)
...@@ -128,7 +122,7 @@ const CalculateRule = (props) => { ...@@ -128,7 +122,7 @@ const CalculateRule = (props) => {
const fnListRender = ( const fnListRender = (
<Menu> <Menu>
{fnList.map(item => ( {fnList.map(item => (
<Menu.Item key={item.value} onClick={() => insertFn(item.value)}> <Menu.Item key={item.value} disabled={item.disabled} onClick={() => insertFn(item.value)}>
{item.label} {item.label}
</Menu.Item> </Menu.Item>
))} ))}
......
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