Commit 6f6425b1 authored by Bill's avatar Bill

fix: 修改整改

parent f9200484
......@@ -42,26 +42,40 @@ type SubmitData = {
const formActions = createFormActions()
const format = 'YYYY-MM-DD';
const InspectionAdd = (props) => {
const { location } = props;
const { id, memberId, memberName, roleId } = usePageStatus();
const { visible, toggle } = useModal()
const { memberColumns, memberSchema, handleFetchData } = useGetCommonSubMember(PublicApi.getMemberInspectMembers)
const [memberModalValue, setMemberModalValue] = useState([])
const [memberModalValue, setMemberModalValue] = useState<{ subMemberId: number, subRoleId: number, name: string }[]>([])
const [submitLoading, setSubmitLoading] = useState<boolean>(false)
const isPreview = location.pathname.includes('/memberCenter/memberAbility/memberRectification/rectificationAdd/view');
const { id } = usePageStatus();
const isEdit = useMemo(() => id && typeof id === 'string', [id]);
const params = useMemo(() => { return id ? { id: id.toString() } : null }, [id]);
const { loading, initialValue }= useInitialValue<GetMemberRectifyWaitAddGetResponse, { id: string }>(PublicApi.getMemberRectifyWaitAddGet, params)
const [unsaved, setUnsaved] = useState(false);
/** 从会员信息列表设置默认会员 */
const shouldSetInitiialMember = useMemo(() => {
if (memberId && roleId) {
return {
subMemberId: memberId,
name: memberName,
subRoleId: roleId
}
}
return null
}, [memberId, memberName, roleId])
console.log(memberId, memberName, roleId, shouldSetInitiialMember)
/**
/**
* 格式化初始化值
*/
const formatedInitialValue = useMemo(() => {
if(!isEdit && shouldSetInitiialMember !== null) {
return shouldSetInitiialMember;
}
if (!isEdit || !initialValue) {
return {}
}
......@@ -71,9 +85,16 @@ const InspectionAdd = (props) => {
rectifyDayEnd: moment(rectifyDayEnd, 'YYYY-MM-DD'),
...rest,
}
}, [initialValue])
}, [initialValue, isEdit, shouldSetInitiialMember])
useEffect(() => {
if(!isEdit && shouldSetInitiialMember !== null) {
setMemberModalValue([{
subMemberId: shouldSetInitiialMember.subMemberId,
subRoleId: shouldSetInitiialMember.subRoleId,
name: shouldSetInitiialMember.name
}])
}
if (initialValue) {
setMemberModalValue([{
subMemberId: initialValue.subMemberId,
......@@ -81,7 +102,7 @@ const InspectionAdd = (props) => {
name: initialValue.name
}])
}
}, [initialValue])
}, [initialValue,isEdit, shouldSetInitiialMember])
const handleSubmit = useCallback(async (value: SubmitData) => {
const { name, rectifyDayStart, rectifyDayEnd, attachments, ...rest } = value;
......
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