Commit bfbfffee authored by 田翔's avatar 田翔

fix: 隐藏条件修复

parent 551246e4
{
"name": "panda-xform",
"version": "4.9.8",
"description": "4.9.8 bug修复",
"version": "4.9.9",
"description": "4.9.9 隐藏条件修复",
"keywords": [
"panda-xform"
],
......
......@@ -1019,7 +1019,7 @@ const selectWidgets = [
name: '选项',
type: 'array',
hidden: '{{formData.sourceType !== "手动输入"}}',
default: [{ value: '选项一' }],
default: [{ key: '选项一', value: '选项一' }],
widget: 'SimpleList',
dependencies: ['sourceType', 'color']
},
......
......@@ -89,7 +89,7 @@ const XRender = (props, ref) => {
}, [formJson, values, disabledFields, disabled])
const watch = useMemo(() => {
return getWatch({schemaForm, form, startTime, initField})
return getWatch({ schema: schemaForm, form, startTime, initField })
}, [schemaForm, form, startTime, initField])
const getValues = async () => {
......
......@@ -171,7 +171,7 @@ const formFieldHide = async (params) => {
if (code === 0) {
if (Array.isArray(data)) {
data.forEach(v => {
if (params?.initField.includes(v.fieldName)) {
if (params?.initField?.length === 0 || (params?.initField?.length !== 0 && 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 })
......@@ -207,6 +207,7 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
let watch = {}
let paths = []
let formValue = form?.getValues()
console.log('form?.getValues()', form?.getValues(), form)
let { relationForm } = formValue
const configs = relationForm?.configs || []
const AutoCalculate = getWidgetInfo(schema, 'NumberInput')
......@@ -259,6 +260,7 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
}
})
}
console.log('paths', paths)
if (Array.isArray(paths)) {
paths.forEach(v => {
watch[v.path] = () => {
......@@ -282,6 +284,7 @@ const getAutoWatch = ({ schema, form, startTime, initField }) => {
}
})
}
console.log('watch', watch)
return watch
}
......
......@@ -68,7 +68,7 @@ const BaseForm = (props, ref) => {
}, [schemaForm, field, disabled])
const watch = useMemo(() => {
return getWatch(schema, form, startTime)
return getWatch({ schema, form, startTime, initField: [] })
}, [schema, form, startTime])
const getValues = async () => {
......
......@@ -99,7 +99,7 @@ const RadioButton = (props) => {
children.push(<Radio key={isStoreID ? v.stationID : v.stationName} value={isStoreID ? v.stationID : v.stationName}>{v.stationName}</Radio>)
} else if (sourceType === '手动输入') {
children.push(
<Radio key={v.value} value={v.value}>
<Radio key={v.key || v.value} value={v.value}>
{
color ? <TagPack color={v.color} text={v.value} /> : v.value
}
......
......@@ -5,6 +5,7 @@ import Drag from './../../../../components/Drag'
import DragTable from '../../../../components/DragTable'
import { CheckOutlined, DeleteOutlined, MenuOutlined } from '@ant-design/icons'
import { colors } from '../../../../../constant'
import { getNanoid } from '../../../../../utils'
const SimpleList = (props) => {
......@@ -31,7 +32,7 @@ const SimpleList = (props) => {
const onPressEnter = (i) => {
let length = [...value].length
let array = [...value]
array.splice(i + 1, 0, { key: `${length + 1}`, index: length + 1, color: colors[length % 10], value: '' })
array.splice(i + 1, 0, { key: getNanoid(), index: length + 1, color: colors[length % 10], value: '' })
onChange(array)
}
......@@ -171,7 +172,7 @@ const SimpleList = (props) => {
const add = () => {
let length = [...value].length
let array = [...value]
array.push({ key: `${length + 1}`, index: length + 1, color: colors[length % 10], value: '' })
array.push({ key: getNanoid(), index: length + 1, color: colors[length % 10], value: '' })
onChange(array)
}
......
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