提交 2441ad01 authored 作者: 钟是志's avatar 钟是志

31396 勤工助学学生申请岗位和填报岗位工时需要做手机端

上级 f7af5abe
...@@ -2,12 +2,12 @@ import React, { useState, useEffect, useMemo, useCallback, memo, useRef } from ' ...@@ -2,12 +2,12 @@ import React, { useState, useEffect, useMemo, useCallback, memo, useRef } from '
import { Steps } from 'antd'; import { Steps } from 'antd';
import ZdyTable from '@/webPublic/one_stop_public/Table'; import ZdyTable from '@/webPublic/one_stop_public/Table';
import styles from '../style.less'; import styles from '../style.less';
const { Step } = Steps; const { Step } = Steps;
const Child = memo((props) => { const Child = memo(props => {
const { value, json, partFormProps } = props; const { value, json, partFormProps } = props;
const diyProps = useMemo( const diyProps = useMemo(() => {
() => {
let b = {}; let b = {};
if (value && typeof value === 'object') { if (value && typeof value === 'object') {
b = { b = {
...@@ -30,16 +30,13 @@ const Child = memo((props) => { ...@@ -30,16 +30,13 @@ const Child = memo((props) => {
} else { } else {
return b; return b;
} }
}, }, [json.otherProps, value]);
[json.otherProps, value],
);
// console.log(diyProps); // console.log(diyProps);
const [current, setCurrent] = useState(diyProps?.StepsProps?.current || 0); const [current, setCurrent] = useState(diyProps?.StepsProps?.current || 0);
const partFormKey = useMemo( const partFormKey = useMemo(() => {
() => {
if (typeof current !== 'undefined') { if (typeof current !== 'undefined') {
let item = diyProps.Step.find((g, index) => { let item = diyProps.Step.find((g, index) => {
return index === current; return index === current;
...@@ -49,32 +46,31 @@ const Child = memo((props) => { ...@@ -49,32 +46,31 @@ const Child = memo((props) => {
} }
} }
return undefined; return undefined;
}, }, [current]);
[current],
);
useEffect( useEffect(() => {
() => {
if (diyProps?.StepsProps?.current !== current) { if (diyProps?.StepsProps?.current !== current) {
setCurrent(diyProps?.StepsProps?.current); setCurrent(diyProps?.StepsProps?.current);
} }
}, }, [diyProps?.StepsProps?.current]);
[diyProps?.StepsProps?.current],
);
return ( return (
<div style={diyProps.outSideDivStyle} className={styles.stepsInfo}> <div style={diyProps.outSideDivStyle} className={styles.stepsInfo}>
<Steps {...diyProps.StepsProps} current={current}> <Steps {...diyProps.StepsProps} current={current}>
{Array.isArray(diyProps.Step) && {Array.isArray(diyProps.Step) &&
diyProps.Step.map((g) => { diyProps.Step.map(g => {
return <Step {...g} key={g.title} />; return <Step {...g} key={g.title} />;
})} })}
</Steps> </Steps>
{Array.isArray(diyProps.Step) && {Array.isArray(diyProps.Step) &&
diyProps.Step.filter((g) => !!g.formKey).map((g, index) => { diyProps.Step.filter(g => !!g.formKey && g.formKey === partFormKey).map((g, index) => {
// 解决禅道 31396 勤工助学学生申请岗位和填报岗位工时需要做手机端
// 钟是志 切换step时 重新渲染formkey
return ( return (
<div key={g.formKey} style={{ display: partFormKey === g.formKey ? 'block' : 'none' }}> <div key={g.formKey}
style={{ display: partFormKey === g.formKey ? 'block' : 'none' }}
>
<ZdyTable <ZdyTable
{...partFormProps} {...partFormProps}
currentFormTitle={'Steps组件的子表单' + g.formKey} currentFormTitle={'Steps组件的子表单' + g.formKey}
...@@ -90,7 +86,7 @@ const Child = memo((props) => { ...@@ -90,7 +86,7 @@ const Child = memo((props) => {
); );
}); });
export default function StepDiy(props){ export default function StepDiy(props) {
const { value, json, partFormProps, form } = props; const { value, json, partFormProps, form } = props;
const js = useMemo(() => { const js = useMemo(() => {
return json; return json;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论