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

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

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