Commit e4723722 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加 到期日 与 有效期之间的联动

parent 7469d7b1
/*
* @Author: XieZhiXiong
* @Date: 2021-06-15 13:38:56
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-15 14:10:11
* @Description: 联动逻辑
*/
import { FormEffectHooks, FormPath } from '@formily/antd';
const {
onFieldInputChange$,
} = FormEffectHooks;
export const useBusinessEffects = (context, actions, fieldName: string) => {
const {
setFieldState,
} = actions;
// 如果勾选了长期有效,则清空 到期日
onFieldInputChange$(`${fieldName}.*.permanent`).subscribe(fieldState => {
const { name, value } = fieldState;
if (value && value.length) {
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `${fieldName}.${$1}.expireDay`
}),
state => {
state.value = '';
}
);
}
});
// 如果选择了到期日,则清空 有效期
onFieldInputChange$(`${fieldName}.*.expireDay`).subscribe(fieldState => {
const { name, value } = fieldState;
if (value && value.length) {
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `${fieldName}.${$1}.permanent`
}),
state => {
state.value = [];
}
);
}
});
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-01 20:03:23 * @Date: 2021-06-01 20:03:23
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-04 20:47:18 * @LastEditTime: 2021-06-15 13:54:42
* @Description: 补充资质证明抽屉 * @Description: 补充资质证明抽屉
*/ */
import React from 'react'; import React from 'react';
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
import { DatePicker, Checkbox } from '@formily/antd-components' import { DatePicker, Checkbox } from '@formily/antd-components'
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { schema } from './schema'; import { schema } from './schema';
import { useBusinessEffects } from '../../../components/QualitiesUploadFormItem/effects';
import QualitiesUpload from '../../../components/QualitiesUpload'; import QualitiesUpload from '../../../components/QualitiesUpload';
import QualitiesUploadFormItem from '../../../components/QualitiesUploadFormItem'; import QualitiesUploadFormItem from '../../../components/QualitiesUploadFormItem';
...@@ -123,8 +124,8 @@ const UploadQualificationsDrawer: React.FC<IProps> = (props: IProps) => { ...@@ -123,8 +124,8 @@ const UploadQualificationsDrawer: React.FC<IProps> = (props: IProps) => {
QualitiesUpload, QualitiesUpload,
QualitiesUploadFormItem, QualitiesUploadFormItem,
}} }}
effects={() => { effects={(context, actions) => {
useBusinessEffects(context, actions, 'qualities');
}} }}
actions={formActions} actions={formActions}
schema={schema} schema={schema}
......
...@@ -22,6 +22,7 @@ import NiceForm from '@/components/NiceForm'; ...@@ -22,6 +22,7 @@ import NiceForm from '@/components/NiceForm';
import MellowCard from '@/components/MellowCard'; import MellowCard from '@/components/MellowCard';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import schema, { GroupItem } from './schema'; import schema, { GroupItem } from './schema';
import { useBusinessEffects } from '../../components/QualitiesUploadFormItem/effects';
import ComingAgreement from './components/ComingAgreement'; import ComingAgreement from './components/ComingAgreement';
import RegisterInfo from './components/RegisterInfo'; import RegisterInfo from './components/RegisterInfo';
import SubmitSuccess from './components/SubmitSuccess'; import SubmitSuccess from './components/SubmitSuccess';
...@@ -337,7 +338,7 @@ const MemberQueryApplyMember: React.FC = () => { ...@@ -337,7 +338,7 @@ const MemberQueryApplyMember: React.FC = () => {
RegisterInfo: <RegisterInfo upperMemberId={upperMemberId} upperRoleId={upperRoleId} />, RegisterInfo: <RegisterInfo upperMemberId={upperMemberId} upperRoleId={upperRoleId} />,
SubmitSuccess: <SubmitSuccess />, SubmitSuccess: <SubmitSuccess />,
}} }}
effects={($, { setFieldState }) => { effects={($, actions) => {
onStepNext$().subscribe(() => { onStepNext$().subscribe(() => {
stepRef.current += 1; stepRef.current += 1;
setCurrenStep(stepRef.current); setCurrenStep(stepRef.current);
...@@ -354,6 +355,8 @@ const MemberQueryApplyMember: React.FC = () => { ...@@ -354,6 +355,8 @@ const MemberQueryApplyMember: React.FC = () => {
setUnsaved(true); setUnsaved(true);
} }
}); });
useBusinessEffects($, actions, 'step4.qualities');
}} }}
schema={schema(depositInfo, validateId)} schema={schema(depositInfo, validateId)}
/> />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-05-26 17:00:39 * @Date: 2021-05-26 17:00:39
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-07 11:58:03 * @LastEditTime: 2021-06-15 14:05:18
* @Description: * @Description:
*/ */
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
......
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