Commit b780e063 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents f60aa0e1 7fb3a840
......@@ -63,7 +63,7 @@
"@linkseeks/design-core": "^1.0.0",
"@linkseeks/design-react": "^1.0.0",
"@linkseeks/design-react-web": "^1.0.0",
"@linkseeks/design-ui": "^1.0.5",
"@linkseeks/design-ui": "^1.0.9",
"@linkseeks/design-utils": "^1.0.0",
"@linkseeks/god": "^1.0.0",
"@types/crypto-js": "^4.0.1",
......
......@@ -8,26 +8,30 @@ const { onFormInit$ } = FormEffectHooks
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
*/
export const useAsyncInitSelect = (name: string[], service: () => Promise<any>) => {
const { dispatch, setFieldState } = createFormActions()
const linkage = useLinkageUtils()
const { dispatch, setFieldState } = createFormActions();
const linkage = useLinkageUtils();
onFormInit$().subscribe(() => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-props.hasFeedback', true)
})
name.forEach(v => linkage.loaded(v))
const nameStr: string = name.toString();
const formPath: string = `*(${nameStr})`;
setFieldState(formPath, state => {
FormPath.setIn(state, 'props.x-props.hasFeedback', true);
});
linkage.loading(formPath);
service().then(res => {
name.forEach(v => {
linkage.loaded(v)
linkage.enum(v, res[v])
})
//请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch && dispatch('requestAsyncSelect', {
linkage.enum(v, res[v] || []);
});
// 请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch?.('requestAsyncSelect', {
name,
payload: res
})
}).catch(err => {
// linkage.loaded(name)
// linkage.enum(name, [])
})
payload: res,
});
}).finally(() => {
linkage.loaded(formPath);
});
})
}
\ No newline at end of file
......@@ -298,17 +298,16 @@ const DeliverCoupon: React.FC<IProps> = (props) => {
});
if (res.code === 1000) {
const { data = {} }: any = res;
const {
memberTypes = [],
levels = [],
suitableMemberTypes = [],
} = data;
} = res.data;
return {
memberType: memberTypes.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })),
memberTypeEnum: memberTypes.map(item => ({ label: item.name, value: item.value })),
level: levels.map(item => ({ label: item.levelTag, value: item.level })),
suitableMemberType: suitableMemberTypes.map(item => ({ label: item.name, value: item.value })),
suitableMemberType: suitableMemberTypes?.map(item => ({ label: item.name, value: item.value })),
};
}
return {};
......@@ -400,7 +399,7 @@ const DeliverCoupon: React.FC<IProps> = (props) => {
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['memberType', 'level', 'suitableMemberType'],
['memberTypeEnum', 'level', 'suitableMemberType'],
fetchSelectOptions,
);
},
......
......@@ -69,6 +69,7 @@ export const drawerSchema: ISchema = {
'x-component': 'NumberPicker',
'x-component-props': {
placeholder: '会员ID',
min: 0,
},
},
memberTypeEnum: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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