Commit d078dc93 by zhaochengxiang

bug fix

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