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

fix: 计算规则优化

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