Commit 7b623fe6 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 处理新增招标切换锚点品类置空问题

parent 6404ab29
import React, { ReactNode, useCallback, useContext, useEffect, useRef, useState } from 'react'
import { Modal, Drawer, Button, Tabs, Row, Col, Anchor } from 'antd'
import React, { ReactNode, useEffect, useState } from 'react'
import { Drawer, Row, Col, Anchor } from 'antd'
import style from './index.less'
import NiceForm from '../NiceForm'
import { IAntdSchemaFormProps, registerVirtualBox } from '@formily/antd'
......@@ -27,6 +27,8 @@ export interface AnchorProps extends IAntdSchemaFormProps {
isForm?: boolean,
/** Drawer其他配置 */
restDrawer?: any,
/** 重载的字段 */
reloadFields?: string[],
}
const AnchorDrawer: React.FC<AnchorProps> = ({
......@@ -40,20 +42,13 @@ const AnchorDrawer: React.FC<AnchorProps> = ({
isForm = false,
actions,
restDrawer,
reloadFields,
...restProps
}) => {
const [current, setCurrent] = useState<number>(0)
const [offsetTopList, setOffsetTopList] = useState<number[]>([])
// useEffect(() => {
// if (currentRef) {
// currentRef.current = {
// formActions,
// }
// }
// }, [])
useEffect(() => {
let tempArr: any = []
let floors: any = []
......@@ -96,8 +91,17 @@ const AnchorDrawer: React.FC<AnchorProps> = ({
behavior: "smooth",
})
if(offsetTopList[i] + dom.clientHeight >= dom.scrollHeight) {
// @tofix 此状态的变更会影响表单某些字段的显示
setCurrent(i)
}
// @tofixed 重置字段值
if(reloadFields.length) {
for(let i = 0; i < reloadFields.length; i++) {
actions.getFieldValue(reloadFields[i]).then(value => {
actions.setFieldValue(reloadFields[i], value)
})
}
}
}
registerVirtualBox("CustomTitle", ({ children, schema }) => {
......
......@@ -210,6 +210,7 @@ export const RelevanceGoodDrawer:React.FC<RelevanceGoodDrawerProps> = ({
effects={($, ctx) => {
ctx.reset()
$('onFormMount').subscribe(async () => {
console.log(1)
const commonData = await getCommonData()
ctx.setFieldState('categoryId', state => {
state.props['x-component-props'].options = commonData['categoryData']
......@@ -247,6 +248,7 @@ export const RelevanceGoodDrawer:React.FC<RelevanceGoodDrawerProps> = ({
className: style.parentDrawerWrapper,
destroyOnClose: true,
}}
reloadFields={['categoryId']}
>
<DrawerTable
drawerTitle='选择货品'
......
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