Commit d078dc93 by zhaochengxiang

bug fix

parent dfe76c92
......@@ -94,6 +94,7 @@ export const Basic = React.forwardRef(function ({ type, item }, ref) {
const [loadingCheckTypes, setLoadingCheckTypes] = React.useState(false)
const [checkTypes, setCheckTypes] = React.useState()
const [checkTypeValue, setCheckTypeValue] = React.useState()
const [preCatalog, setPreCatalog] = React.useState()
const [form] = Form.useForm()
......@@ -111,6 +112,7 @@ export const Basic = React.forwardRef(function ({ type, item }, ref) {
if (item) {
form?.setFieldsValue(item)
setCheckTypeValue(item.checkType)
setPreCatalog(item.preCheckProperty?.propertyCatalog)
}
}, [item])
......@@ -157,6 +159,8 @@ export const Basic = React.forwardRef(function ({ type, item }, ref) {
const onValuesChange = (changedValues, allValues) => {
if (changedValues.hasOwnProperty('checkType')) {
setCheckTypeValue(changedValues.checkType)
} else if (changedValues.hasOwnProperty('preCheckProperty')) {
setPreCatalog(changedValues?.preCheckProperty?.propertyCatalog)
}
}
......@@ -272,7 +276,7 @@ export const Basic = React.forwardRef(function ({ type, item }, ref) {
]}
>
{
type === 'detail' ? <span>{checkPropertyDescription}</span> : <CheckItem />
type === 'detail' ? <span>{checkPropertyDescription}</span> : <CheckItem preCatalog={preCatalog} />
}
</Form.Item>
</Form.Item>
......@@ -282,7 +286,7 @@ export const Basic = React.forwardRef(function ({ type, item }, ref) {
)
})
const CheckItem = ({ value, onChange }) => {
const CheckItem = ({ value, onChange, preCatalog }) => {
const [loadingCheckPropertyTypes, setLoadingCheckPrpertyTypes] = React.useState(false)
const [checkPropertyTypes, setCheckPropertyTypes] = React.useState()
const [loadingExpressionTypes, setLoadingExpressionTypes] = React.useState(false)
......@@ -337,6 +341,22 @@ const CheckItem = ({ value, onChange }) => {
return []
}, [expressionMapping, currentExpressionType])
const _checkPropertyTypes = React.useMemo(() => {
if (preCatalog) {
return (checkPropertyTypes??[]).filter(item => item.propertyCatalog === preCatalog)
}
return checkPropertyTypes
}, [checkPropertyTypes, preCatalog])
React.useEffect(() => {
if (preCatalog) {
if (currentCheckPropertyType?.propertyCatalog && currentCheckPropertyType?.propertyCatalog !== preCatalog) {
setCurrentCheckPropertyType()
}
}
}, [preCatalog, currentCheckPropertyType])
const getCheckPropertyTypes = () => {
setLoadingCheckPrpertyTypes(true)
dispatch({
......@@ -396,7 +416,7 @@ const CheckItem = ({ value, onChange }) => {
}}
placeholder='请选择检查对象'
>
{ (checkPropertyTypes??[]).map((item, index) => (
{ (_checkPropertyTypes??[]).map((item, index) => (
<Select.Option key={item.propertyEnName} value={item.propertyEnName}>{item.propertyCnName}</Select.Option>
)) }
</Select>
......
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