Commit 489c989c authored by 田翔's avatar 田翔

fix: 关联表单计算监听逻辑添加

parent ed3ea722
This diff is collapsed.
import React, { useState, useEffect, useRef } from 'react';
import { FormRender, FormDesigner } from '../../src/index';
import { options1, options2 } from './data';
import { schemaValues } from './data';
import { Button, Tabs } from 'antd';
window.globalConfig = {
......@@ -3509,7 +3509,11 @@ window.globalConfig = {
const Test = (props) => {
return (
<FormDesigner tableName='事件_测试02' />
// <FormDesigner tableName='工单_维修填报' />
// <FormDesigner tableName='事件_表单测试表' />
<FormRender
schemaValues={schemaValues}
/>
)
}
......
......@@ -28,7 +28,9 @@ app.use(['/admin', '/manager'], admin);
app.use(webpackHotMiddleware(compiler));
app.use(express.static(__dirname));
// app.use('/', createProxyMiddleware('/', { target: 'http://127.0.0.1:8880', changeOrigin: true }));
app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8088/', changeOrigin: true }));
app.use('/', createProxyMiddleware('/', { target: 'http://192.168.12.178:8085', changeOrigin: true }));
// app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8083', changeOrigin: true }));
// app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8088/', changeOrigin: true }));
// app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.178:8082', changeOrigin: true }));
// app.use('/', createProxyMiddleware('/', { target: 'http://192.168.10.167:8088/', changeOrigin: true }));
const port = process.env.PORT || 8888;
......
{
"name": "panda-xform",
"version": "2.2.9",
"description": "2.2.9: 各个形态组件不做数据类型校验统一使用字符串处理",
"version": "2.3.0",
"description": "2.3.0: 关联表单计算监听逻辑添加",
"keywords": [
"panda-xform"
],
......
......@@ -220,7 +220,10 @@ const FormDesigner = (props, ref) => {
</div>
}
>
<FormRender ref={formRenderRef} schemaValues={{ formJson: schema }} extraData={{ codes: { '事件编号': '123123' } }} />
<FormRender
ref={formRenderRef}
schemaValues={{ formJson: schema }}
/>
</Drag>
</div>
</div>
......
......@@ -97,6 +97,7 @@ const getFieldName = (configs, tableName) => {
}
const automaticComputation = async (params) => {
console.log('form.getValues()', params?.form?.getValues())
if ((new Date().getTime() - params.startTime) < 1000) return
let param = {
tableName: params.tableName,
......
......@@ -20,10 +20,6 @@ const BaseForm = (props, ref) => {
const form = useForm()
const [startTime, setStartTime] = useState(new Date().getTime())
const watch = useMemo(() => {
return getWatch(schemaForm, form, startTime)
}, [schemaForm, form, startTime])
//表单需要显示的字段
const field = useMemo(() => {
const { fieldGroup, editFieldGroup, addFieldGroup } = config
......@@ -67,11 +63,15 @@ const BaseForm = (props, ref) => {
return { ...group, properties: parentObj }
}, [schemaForm, field, formState])
const watch = useMemo(() => {
return getWatch(schema, form, startTime)
}, [schema, form, startTime])
const getValues = async () => {
let { data, errors } = await form.submit()
let formValue = []
Object.keys(data).map((k) => {
if (isObject(data[k]) && ['relationForm'].includes(k)) {
if (isObject(data[k]) && !['relationForm'].includes(k)) {
Object.keys(data[k]).map((key) => {
formValue.push({ fieldName: key, fieldValue: data[k][key] + '' })
})
......
......@@ -4,10 +4,11 @@ import date from '../../../date'
import select from '../../../select'
import business from '../../../business'
import file from '../../../file'
import Signature from '../../Signature'
import coord from '../../../coord'
import AutoCalculate from '../../AutoCalculate'
const coord = {
Signature
const advanced = {
AutoCalculate
}
const widgets = {
......@@ -18,6 +19,7 @@ const widgets = {
...business,
...file,
...coord,
...advanced,
}
export default widgets
\ No newline at end of file
......@@ -91,7 +91,6 @@ const RelationForm = (props) => {
const getFieldValue = (s, formDataObj, codes) => {
return codes ? (codes[s.fromField] || formDataObj[s.fromField]) : formDataObj[s.fromField]
}
console.log('field', field)
field.forEach(v => {
mappedField.forEach(s => {
if (s.toField === v) {
......@@ -231,7 +230,7 @@ const RelationForm = (props) => {
const { code, data, msg } = await GetTableJson(accountName)
if (code === 0) {
if (data && typeof data === 'string') {
setSchemaGroup(JSON.parse(data))
setSchemaGroup(JSON.parse(aa))
}
} else {
message.error(msg)
......@@ -259,7 +258,6 @@ const RelationForm = (props) => {
const getTableData = async (addFieldGroup) => {
if (!addons) return
let queryWheres = getQueryWheres(addFieldGroup)
console.log('queryWheres', queryWheres)
if (!queryWheres.length) {
message.info('映射字段配置错误!')
}
......@@ -355,7 +353,7 @@ const RelationForm = (props) => {
}, [])
return (
<div className={styles.relationForm} style={{ display: (!addons || show) ? 'block' : 'none' }}>
<div className={styles.relationForm} style={{ display: (addons && !show) ? 'none' : 'block' }}>
<div className={styles.header}>
<span className='account-header-title'>{titleShow}</span>
{disabled ? null : <Button className={styles.headerBtn} type='primary' size='middle' icon={<PlusOutlined />} onClick={addClick}>添加</Button>}
......
......@@ -9,20 +9,14 @@ const DateTime = (props) => {
const { value, onChange, schema, addons } = props
const { disabled, format, presetValue, placeholder, options, currentDate, defaultCurrent } = schema
const valueShow = useMemo(() => {
if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date()) : null
}
return value ? moment(value) : null
}, [defaultCurrent, value])
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('YYYY-MM-DD HH:ss:mm') : null)
addons.setValue(addons.dataPath, value)
} else {
onChange(presetValue)
}
}, [presetValue])
}, [presetValue, options])
const disabledDate = (current) => {
if (options === '不超过当前时间') {
......@@ -46,7 +40,7 @@ const DateTime = (props) => {
picker={format}
disabled={disabled}
placeholder={placeholder}
value={valueShow}
value={value ? moment(value) : null}
onChange={dateChange}
showNow
showTime={format === 'dateTime'}
......
......@@ -8,13 +8,6 @@ const Time = (props) => {
const { value, onChange, schema, addons } = props
const { presetValue, currentDate, defaultCurrent, options } = schema
const valueShow = useMemo(() => {
if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date(), 'HH:mm:ss') : null
}
return value ? moment(value, 'HH:mm:ss') : null
}, [value, defaultCurrent])
const disabledDate = (current) => {
if (options === '不超过当前时间') {
return current && current.format('HH:mm:ss') > moment().format('HH:mm:ss')
......@@ -29,16 +22,17 @@ const Time = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('HH:mm:ss') : null)
addons.setValue(addons.dataPath, value)
} else {
onChange(presetValue)
}
}, [presetValue])
}, [presetValue, options])
return (
<TimePicker
style={{ width: '100%' }}
value={valueShow}
value={value ? moment(value, 'HH:mm:ss') : null}
onChange={timeChange}
disabledDate={disabledDate}
locale={locale}
......
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