You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
import {
createForm,
onFieldValueChange,
onFormValuesChange,
} from "@formily/core";
import { createSchemaField, FormProvider } from "@formily/react";
import { Alert, Button, Drawer, Modal, Space } from "@m-ui/react";
import React, { memo, useEffect, useMemo } from "react";
import { useLegendReservedMoney } from "@/Store/LegendWithdrawReserveMoney";
import getSchema from "./schemal";
import { isEmpty } from "lodash";
import { OPERATE_REASONS_VALUES_LIST } from "../config";
const AddReserveAmount = () => {
const {
updateStore,
updateAddFormData,
modalVisible,
editFormData,
reserveAmountForm,
resetReserveAmountStore,
addReserveAmount,
fetchAccountList,
getSettlementChannel,
fetchLegendReservedMoney,
editReserveAmount,
} = useLegendReservedMoney();
};
export default memo(AddReserveAmount);
上述是一个Modal弹框
import { useLegendReservedMoney } from "@/Store/LegendWithdrawReserveMoney";
import {
FormItem,
Input,
Select,
FormGrid,
NumberPicker,
} from "@ks-lfe/formily-mui";
import { CHANNEL_OPTIONS, ROLE_TYPE_OPTIONS } from "../config";
import OperateReason from "./OperateReason";
type AccountListType = (value: number) => void;
const getSchema = (
AccountList: AccountListType,
handleSubjectIdChange: AccountListType,
handleRoleChange: AccountListType
) => {
const schemaFieldProps = {
components: {
FormItem,
Input,
Select,
FormGrid,
NumberPicker,
OperateReason,
},
};
const COMMON_ITEM_CONFIG = {
labelWidth: 137,
};
const schema = {
type: "object",
properties: {
grid: {
type: "void",
"x-component": "FormGrid",
"x-component-props": {
maxColumns: 1,
minColumns: 1,
},
properties: {
customerSource: {
type: "number",
title: "角色类型",
required: true,
"x-decorator": "FormItem",
"x-component": "Select",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component-props": {
style: { width: "360px" },
placeholder: "请选择角色类型",
options: ROLE_TYPE_OPTIONS,
onChange: (value: number) => {
handleRoleChange(value);
},
},
},
outerCustomerId: {
type: "string",
title: "客户id",
required: true,
description:
"商家为商家id;门店为门店poi id;达人为达人id;服务商为服务商id",
"x-decorator": "FormItem",
"x-component": "Input",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component-props": {
style: { width: "360px" },
placeholder: "请输入客户id",
onBlur: (e: any) => {
AccountList(e.target.value);
},
},
},
subjectId: {
type: "number",
title: "收款账户",
required: true,
description: "请先填写角色类型和客户id",
"x-decorator": "FormItem",
"x-component": "Select",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component-props": {
style: { width: "360px" },
placeholder: "请输入收款账户",
options: [],
disabled: true,
onChange: (value: number) => {
handleSubjectIdChange(value);
},
},
},
channel: {
type: "string",
title: "结算渠道",
required: true,
description: "请先填写角色类型和收款账户",
"x-decorator": "FormItem",
"x-component": "Select",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component-props": {
style: { width: "360px" },
placeholder: "请选择结算渠道",
options: CHANNEL_OPTIONS,
disabled: true,
},
},
reserveAmount: {
type: "number",
title: "预留金额",
required: true,
"x-decorator": "FormItem",
"x-component": "NumberPicker",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component-props": {
style: { width: "360px" },
placeholder: "请输入冻结金额",
addonAfter: "元",
min: 0,
},
},
freezeReason: {
type: "object",
title: "操作原因",
required: true,
"x-decorator": "FormItem",
"x-decorator-props": {
...COMMON_ITEM_CONFIG,
},
"x-component": "OperateReason",
"x-validator": (value: {
type: string;
extInfo: string;
}) => {
if (!value?.type && !value?.extInfo) {
return "该字段是必填字段";
}
return "";
},
},
},
},
},
};
return {
schema,
schemaFieldProps,
};
};
export default getSchema;
上面是schema
表单项的联动能不能优化下 因为这个formily我真的不怎么会
Beta Was this translation helpful? Give feedback.
All reactions