Commit 78607ee9 authored by 田翔's avatar 田翔

fix: 节点不显示的字段不参与隐藏计算

parent 6e98aa64
{
"name": "panda-xform",
"version": "4.9.0",
"description": "4.9.0 编码形态优化",
"version": "4.9.1",
"description": "4.9.1 节点不显示的字段不参与隐藏计算",
"keywords": [
"panda-xform"
],
......
import React, { useRef, useState, useContext, forwardRef, useImperativeHandle, useMemo, useLayoutEffect } from 'react'
import { ConfigProvider, message, Modal, Button } from 'antd'
import React, { useRef, useState, forwardRef, useImperativeHandle, useMemo, useLayoutEffect } from 'react'
import { message, Modal, Button } from 'antd'
import { ExclamationCircleOutlined } from '@ant-design/icons'
import Generator, { defaultSettings, defaultCommonSettings, defaultGlobalSettings } from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config'
......
......@@ -28,12 +28,14 @@ const XRender = (props, ref) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const pandaXform = getPrefixCls()
const [startTime, setStartTime] = useState(new Date().getTime())
const [initField, setInitField] = useState([])
const form = useForm()
const schemaForm = useMemo(() => {
let schemaForm = formJson ? (isObject(formJson) ? formJson : JSON.parse(formJson)) : {}
let parent = schemaForm?.properties
let parentObj = {}
let array = []
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
......@@ -60,6 +62,9 @@ const XRender = (props, ref) => {
if (disabledField) {
required = false
}
if (!child[s].hidden) {
array.push(s)
}
childObj[s] = {
...child[s],
presetValue: value || child[s].presetValue,
......@@ -79,12 +84,13 @@ const XRender = (props, ref) => {
displayType: schemaForm.displayType === 'column' ? 'column' : 'row',//未知原因出现存储'左右'/'上下'
properties: parentObj
}
setInitField(array)
return json
}, [formJson, values, disabledFields, disabled])
const watch = useMemo(() => {
return getWatch(schemaForm, form, startTime)
}, [schemaForm, form, startTime])
return getWatch({schemaForm, form, startTime, initField})
}, [schemaForm, form, startTime, initField])
const getValues = async () => {
let { data, errors } = await form.submit()
......
......@@ -171,11 +171,13 @@ const formFieldHide = async (params) => {
if (code === 0) {
if (Array.isArray(data)) {
data.forEach(v => {
let path = getPath(params.schema, v.fieldName)
if (path) {
params?.form?.setSchemaByPath(path, { ...params?.form?.getSchemaByPath(path), hidden: v.isHide, presetValue: v.fieldValue })
let hidden = getGroupHidden(params?.form, params.schema, params.gorupName)
params?.form?.setSchemaByPath(params.gorupName, { ...params?.form?.getSchemaByPath(params.gorupName), hidden: hidden })
if (params?.initField.includes(v.fieldName)) {
let path = getPath(params.schema, v.fieldName)
if (path) {
params?.form?.setSchemaByPath(path, { ...params?.form?.getSchemaByPath(path), hidden: v.isHide, presetValue: v.fieldValue })
let hidden = getGroupHidden(params?.form, params.schema, params.gorupName)
params?.form?.setSchemaByPath(params.gorupName, { ...params?.form?.getSchemaByPath(params.gorupName), hidden: hidden })
}
}
})
}
......@@ -201,7 +203,7 @@ const getFieldValue = (formValue, fieldName) => {
}
//自动计算监听/隐藏条件监听
const getAutoWatch = (schema, form, startTime) => {
const getAutoWatch = ({ schema, form, startTime, initField }) => {
let watch = {}
let paths = []
let formValue = form?.getValues()
......@@ -268,7 +270,8 @@ const getAutoWatch = (schema, form, startTime) => {
paths: paths,
relationForm,
schema: schema,
startTime
startTime,
initField,
}
if (v.type.includes('AutoCalculate')) {
Automatic(params)
......@@ -295,7 +298,7 @@ const getSelectItemList = async (params) => {
}
//关联选择监听
const getSelectWatch = (schema, form, startTime) => {
const getSelectWatch = ({ schema, form, startTime, initField }) => {
let watch = {}
const RelevanceSelect = getWidgetInfo(schema, 'RelevanceSelect')
if (Array.isArray(RelevanceSelect)) {
......@@ -321,9 +324,9 @@ const getSelectWatch = (schema, form, startTime) => {
return watch
}
export const getWatch = (schema, form, startTime) => {
export const getWatch = ({ schema, form, startTime, initField }) => {
return {
...getAutoWatch(schema, form, startTime),
...getSelectWatch(schema, form, startTime)
...getAutoWatch({ schema, form, startTime, initField }),
...getSelectWatch({ schema, form, startTime, initField })
}
}
\ No newline at end of file
......@@ -8,10 +8,9 @@ import {
GetTableDataInfo,
SaveTableDataInfo,
EditTableDataInfo,
DeleteTableDataInfo
DeleteTableDataInfo,
} from '../../../../apis/process'
import { PlusOutlined } from '@ant-design/icons'
import { GetTableJson } from '../../../../apis/process'
import BaseForm from './BaseForm'
import TablePack from '../../../Account/components/TablePack'
import { isObject, isJson } from '../../../../utils'
......@@ -37,12 +36,11 @@ const RelationForm = (props) => {
const codes = window?.pandaXform?.codes || {}
const { value, onChange, schema, addons } = props
const { disabled, '台账名称': accountName, '默认显示': defaultShow, '控制规则': controlShow, titleShow, '映射字段': mappedField } = schema
const [config, setConfig] = useState({ accountFieids: [], webShowFieldGroup: '', fieldGroup: '' })
const [config, setConfig] = useState({ accountFieids: [], webShowFieldGroup: '', fieldGroup: '', formJson: {} })
const [dataSource, setDataSource] = useState([])
const [visible, setVisible] = useState(false)
const [formState, setFormState] = useState('详情')
const [row, setRow] = useState({})
const [schemaGroup, setSchemaGroup] = useState({})
const [schemaValues, setSchemaValues] = useState([])
const [loading, setLoading] = useState(false)
const baseFormRef = useRef(null)
......@@ -163,19 +161,6 @@ const RelationForm = (props) => {
}
}
const getGroupMeta = async () => {
setLoading(true)
const { code, data, msg } = await GetTableJson(accountName)
if (code === 0) {
if (data && typeof data === 'string') {
setSchemaGroup(JSON.parse(data))
}
} else {
message.error(msg)
}
setLoading(false)
}
const getQueryWheres = (addFieldGroup) => {
let queryWheres = []
let formDataObj = getFormDataObj(addons?.formData)
......@@ -228,7 +213,6 @@ const RelationForm = (props) => {
const getData = () => {
getConfig()
getGroupMeta()
}
const onOk = async () => {
......@@ -274,9 +258,6 @@ const RelationForm = (props) => {
return message.info('台账添加字段未配置!')
}
if (addons) {
if (JSON.stringify(schemaGroup) === '{}') {
return message.info(`台账[${accountName}]未配置形态!`)
}
setRow({ ID: `前端ID${new Date().getTime()}` })
setFormState('添加')
setSchemaValues(localForm)
......@@ -299,7 +280,6 @@ const RelationForm = (props) => {
//初始化关联表单配置信息,初始显示隐藏
if (addons) {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
console.log('relationForm', relationForm)
addons.setValue('relationForm', { ...relationForm, configs: [...relationForm.configs, schema] })
}
}, [])
......@@ -328,7 +308,7 @@ const RelationForm = (props) => {
>
<BaseForm
schemaForm={{
group: schemaGroup,
group: config.formJson,
values: schemaValues,
}}
formState={formState}
......
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