Commit ccc48107 authored by 前端-许佳敏's avatar 前端-许佳敏

Merge branch 'dev-srm' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform into dev-srm

parents 8e53be3c d264c174
......@@ -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;
......
......@@ -22,7 +22,6 @@ const addSchemaAction = createFormActions()
const SignUpForm = () => {
const { number } = history.location.query;
const { memberId, memberRoleId, name } = JSON.parse(localStorage.getItem('auth'));
const {
id,
......@@ -34,7 +33,7 @@ const SignUpForm = () => {
const [btnLoading, setBtnLoading] = useState(false);
const [refundDisabled, setRefundDisabled] = useState(false);
const [formValue, setFormValue] = useState<any>({ areas: [] });
const { token } = getAuth() || {}
const { token, name } = getAuth() || {}
const getCountryCodeId = async () => {
......@@ -150,4 +149,4 @@ const SignUpForm = () => {
</PageHeaderWrapper>
)
}
export default SignUpForm
export default SignUpForm
\ No newline at end of file
......@@ -6,6 +6,7 @@ import { Tabs, Card, Button, Badge } from 'antd';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
import { getAuth } from '@/utils/auth';
import Material from '../../purchaseInquiry/addInquiry/components/material';
import Demand from '../../purchaseInquiry/addInquiry/components/demand';
......@@ -34,7 +35,7 @@ const AddForm = () => {
number
},
pathname, } = history.location;
const { memberId, memberRoleId, name } = JSON.parse(localStorage.getItem('auth'));
const { memberId, memberRoleId, name } = getAuth();
const [path] = useState(pathname.split('/')[pathname.split('/').length - 1]);
console.log(path)
/** 基本信息 */
......@@ -266,4 +267,4 @@ const AddForm = () => {
</PageHeaderWrapper>
)
}
export default AddForm
export default AddForm
\ No newline at end of file
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