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

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

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