Commit 3f0e0889 authored by 田翔's avatar 田翔

fix: 日期类控件增加计算规则

parent 47bdfc94
{
"name": "panda-xform",
"version": "5.7.5",
"description": "5.7.5 获取的数据修改2",
"version": "5.7.6",
"description": "5.7.6 日期类控件增加计算规则",
"keywords": [
"panda-xform"
],
......
......@@ -16,17 +16,6 @@ const groupStyle = {
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
const layoutWidgets = [
......@@ -261,19 +250,6 @@ const textWidgets = [
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
}, */
},
},
{
......@@ -382,17 +358,6 @@ const textWidgets = [
widget: 'RadioGroupW',
default: '100%',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -540,17 +505,6 @@ const textWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -621,17 +575,6 @@ const textWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -729,19 +672,6 @@ const textWidgets = [
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
}, */
},
},
{
......@@ -817,17 +747,6 @@ const textWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
]
......@@ -990,17 +909,6 @@ const selectWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
{
......@@ -1116,17 +1024,6 @@ const selectWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
{
......@@ -1242,17 +1139,6 @@ const selectWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
{
......@@ -1329,17 +1215,6 @@ const selectWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -1516,18 +1391,8 @@ const selectWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},}
},
}
]
const businessWidgets = [
......@@ -1639,17 +1504,6 @@ const businessWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
{
......@@ -1735,17 +1589,6 @@ const businessWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
{
......@@ -1909,6 +1752,11 @@ const dateWidgets = [
description: '所有形态默认显示',
widget: 'HiddenCondition'
},
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
required: {
title: '必填',
type: 'boolean',
......@@ -1953,17 +1801,6 @@ const dateWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -2010,6 +1847,11 @@ const dateWidgets = [
description: '所有形态默认显示',
widget: 'HiddenCondition'
},
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
presetValue: {
title: '默认值',
type: 'string',
......@@ -2049,17 +1891,6 @@ const dateWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
}
},
]
......@@ -2182,17 +2013,6 @@ const fileWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
]
......@@ -2284,17 +2104,6 @@ const mapWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -2378,17 +2187,6 @@ const mapWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -2465,17 +2263,6 @@ const mapWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -2552,17 +2339,6 @@ const mapWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
]
......@@ -2672,17 +2448,6 @@ const advancedWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
description: '默认值10',
default: 10,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
{
......@@ -2749,16 +2514,6 @@ const advancedWidgets = [
type: 'string',
widget: 'RadioGroupW',
},
/* labelWidth: {
title: '标签宽度',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
}, */
},
},
]
......
......@@ -49,7 +49,7 @@ const jsonToValues = (data, paths) => {
}
}
const getWidgetInfo = (json, widget) => {
const getWidgetInfo = (json, widgets) => {
let AutoCalculate = []
let parent = json?.properties
if (isObject(parent)) {
......@@ -57,7 +57,7 @@ const getWidgetInfo = (json, widget) => {
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
if (child[s].widget === widget) {
if (widgets.includes(child[s].widget)) {
AutoCalculate.push({
gorupName: v,
fieldName: s,
......@@ -137,7 +137,13 @@ const formAutomatic = async (params) => {
data.forEach(v => {
let path = getPath(params.schema, v.fieldName)
if (path) {
params.form.setValueByPath(path, v.fieldValue + '')
if (['DateTime', 'Time'].includes(params.widget)) {
if (v.fieldValue !== 0) {
params.form.setValueByPath(path, v.fieldValue + '')
}
} else {
params.form.setValueByPath(path, v.fieldValue + '')
}
}
})
}
......@@ -210,12 +216,12 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
let formValue = form?.getValues()
let { relationForm } = formValue
const configs = relationForm?.configs || []
const AutoCalculate = getWidgetInfo(schema, 'NumberInput')
const AutoCalculate = getWidgetInfo(schema, ['NumberInput', 'DateTime', 'Time'])
const HiddenWidget = getHiddenWidget(schema)
const RelevanceSelect = getWidgetInfo(schema, 'RelevanceSelect')
const RelevanceSelect = getWidgetInfo(schema, ['RelevanceSelect'])
if (Array.isArray(AutoCalculate)) {
AutoCalculate.forEach(item => {
const { gorupName, fieldName, rules, calculateRule } = item
const { gorupName, fieldName, rules, calculateRule, widget } = item
if (Array.isArray(rules)) {
rules.forEach(s => {
if (schema.tableName === s.tableName) {
......@@ -223,14 +229,14 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
s.fields.forEach(v => {
let path = getPath(schema, v)
if (path) {
paths.push({ gorupName, type: ['AutoCalculate'], path: path, fieldName, formula: calculateRule })
paths.push({ gorupName, type: ['AutoCalculate'], path: path, fieldName, formula: calculateRule, widget })
}
})
}
} else {
let path = getFieldName(configs, s.tableName)
if (path) {
paths.push({ gorupName, type: ['AutoCalculate'], path, fieldName, formula: calculateRule })
paths.push({ gorupName, type: ['AutoCalculate'], path, fieldName, formula: calculateRule, widget })
}
}
})
......
import React, { useState, useRef } from 'react'
import React, { useState, useRef, useMemo } from 'react'
import { Modal, Input, message, Dropdown, Menu, Tree } from 'antd'
import styles from './index.less'
import { getTableNumberList, getFormFieldAnalysisDtos } from '../../../../../apis/process'
......@@ -7,15 +7,15 @@ import Drag from '../../../../components/Drag'
const { TextArea } = Input
const fnList = [
{ 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()' },
]
// const fnList = [
// { 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()' },
// ]
const CalculateRule = (props) => {
......@@ -27,6 +27,25 @@ const CalculateRule = (props) => {
const [currentSelectId, setCurrentSelectId] = useState('')
const ruleText = useRef()
const fnList = useMemo(() => {
if (['DateTime', 'Time'].includes(widget)) {
return [
{ label: '时间差', value: '$sql.datediff()' },
{ label: '向下取整', value: '$sql.ceiling()' },
{ label: '向上取整', value: '$sql.floor()' },
]
}
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()' },
]
}, [widget])
const getFieldList = async () => {
let { code, data, msg } = await getTableNumberList(tableNameParent)
if (code === 0) {
......
......@@ -4,7 +4,6 @@ const TextHTML = (props) => {
const { value, onChange, schema } = props
const { contentHTML, styleHTML } = schema
console.log('props', props)
return (
<div style={{ width: '100%', ...styleHTML }}>
......
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