Commit bd2fe042 authored by 田翔's avatar 田翔

fix: 关联表单bug

parent 3774d66d
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.8.5", "version": "5.8.8",
"description": "5.8.5 支持mov文件预览", "description": "5.8.8 关联表单bug",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -309,7 +309,7 @@ const FormDesigner = (props, ref) => { ...@@ -309,7 +309,7 @@ const FormDesigner = (props, ref) => {
const testSubmit = async () => { const testSubmit = async () => {
const { formValue, relationForm, errors } = await formRenderRef?.current?.getValues() const { formValue, relationForm, errors } = await formRenderRef?.current?.getValues()
console.log(formValue, relationForm) // console.log(formValue, relationForm)
if (errors.length) { if (errors.length) {
setTextShow(false) setTextShow(false)
return message.error('表单校验未通过!') return message.error('表单校验未通过!')
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @params schemaValues:表单结构与数据, disabledFields:需要只读的字段, disabled:所有字段只读 * @params schemaValues:表单结构与数据, disabledFields:需要只读的字段, disabled:所有字段只读
* 2023年2月23日 增加参数 * 2023年2月23日 增加参数
*/ */
import React, { useMemo, useContext, forwardRef, useImperativeHandle, createContext, useState } from 'react' import React, { useMemo, useContext, forwardRef, useImperativeHandle, useState, useEffect } from 'react'
import FormRender, { useForm } from 'form-render' import FormRender, { useForm } from 'form-render'
import { ConfigProvider, Spin } from 'antd' import { ConfigProvider, Spin } from 'antd'
import widgets from '../widgets' import widgets from '../widgets'
...@@ -127,6 +127,11 @@ const XRender = (props, ref) => { ...@@ -127,6 +127,11 @@ const XRender = (props, ref) => {
//初始化时存储外部传的额外数据 //初始化时存储外部传的额外数据
const onMount = () => { } const onMount = () => { }
useEffect(() => {
window.configsLocal = []
window.tableLocal = []
}, [])
return ( return (
<div className={styles.formRender}> <div className={styles.formRender}>
<FormRender <FormRender
......
...@@ -23,6 +23,7 @@ const getFormDataObj = (formData) => { ...@@ -23,6 +23,7 @@ const getFormDataObj = (formData) => {
return formDataObj return formDataObj
} }
const RelationForm = (props) => { const RelationForm = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
...@@ -143,12 +144,6 @@ const RelationForm = (props) => { ...@@ -143,12 +144,6 @@ const RelationForm = (props) => {
queryWheres.push({ field: v.toField, type: '等于', value: codes[v.fromField] || formDataObj[v.fromField] }) queryWheres.push({ field: v.toField, type: '等于', value: codes[v.fromField] || formDataObj[v.fromField] })
}) })
} }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [], table: [] }
addons.setValueByPath('relationForm',
{
...relationForm,
configs: [...relationForm.configs, { ...schema, id: schema.$id, queryWheres: queryWheres.map(v => ({ fieldName: v.field, fieldValue: v.value })) }]
})
return queryWheres return queryWheres
} }
...@@ -171,7 +166,13 @@ const RelationForm = (props) => { ...@@ -171,7 +166,13 @@ const RelationForm = (props) => {
setDataSource(tableData) setDataSource(tableData)
onChange(`${tableData.length}`) onChange(`${tableData.length}`)
let relationForm = addons.getValue('relationForm') || { configs: [], data: [], table: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [], table: [] }
addons.setValue('relationForm', { ...relationForm, table: [...relationForm.table, { config, dataSource: tableData, schema }] }) window.configsLocal.push({ ...schema, id: schema.$id, queryWheres: queryWheres.map(v => ({ fieldName: v.field, fieldValue: v.value })) })
window.tableLocal.push({ config, dataSource: tableData, schema })
addons.setValue('relationForm', {
...relationForm,
configs: window.configsLocal,
table: window.tableLocal,
})
} else { } else {
setDataSource([]) setDataSource([])
onChange(`${0}`) onChange(`${0}`)
......
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