develop #1
@ -26,35 +26,32 @@ export default function Update(props: MyBetaModalFormProps) {
|
||||
width="1000px"
|
||||
key={new Date().getTime()}
|
||||
form={form}
|
||||
request={async () => {
|
||||
const res = await Apis.Activity.Activities.Show({
|
||||
id: props.item?.id ?? 0,
|
||||
});
|
||||
return {
|
||||
project_ids: res.data.activity_projects[0]?.asset_projects_id,
|
||||
};
|
||||
}}
|
||||
// request={async () => {
|
||||
// const res = await Apis.Activity.Activities.Show({
|
||||
// id: props.item?.id ?? 0,
|
||||
// });
|
||||
// return {
|
||||
// project_ids: res.data.activity_projects[0]?.asset_projects_id,
|
||||
// };
|
||||
// }}
|
||||
onOpenChange={(open: any) => {
|
||||
if (open && props.item) {
|
||||
form.setFieldsValue(props.item);
|
||||
// form.setFieldValue(
|
||||
// 'project_ids',
|
||||
// props.item?.activity_projects[0]?.asset_projects_id,
|
||||
// );
|
||||
form.setFieldValue('activity_time', [
|
||||
props.item?.start_time,
|
||||
props.item?.end_time,
|
||||
]);
|
||||
form.setFieldValue('content', props.item?.content);
|
||||
form.setFieldsValue({
|
||||
...props.item,
|
||||
activity_time: [
|
||||
props.item?.start_time || '',
|
||||
props.item?.end_time || '',
|
||||
],
|
||||
project_ids: props?.item?.activity_projects?.map(
|
||||
(res: any) => res?.asset_projects_id,
|
||||
),
|
||||
});
|
||||
}
|
||||
}}
|
||||
onFinish={async (values) =>
|
||||
Apis.Activity.Activities.Update({
|
||||
...values,
|
||||
id: props.item?.id ?? 0,
|
||||
project_ids: values?.project_ids
|
||||
? [values?.project_ids]
|
||||
: [props.item?.id],
|
||||
})
|
||||
.then(() => {
|
||||
props.reload?.();
|
||||
@ -67,14 +64,26 @@ export default function Update(props: MyBetaModalFormProps) {
|
||||
Selects?.AssetProjects({
|
||||
key: 'project_ids',
|
||||
title: '关联项目',
|
||||
formItemProps: { ...rulesHelper.array },
|
||||
colProps: { span: 24 },
|
||||
required: true,
|
||||
fieldProps: {
|
||||
showSearch: true,
|
||||
mode: 'multiple',
|
||||
fieldNames: {
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
},
|
||||
labelRender: (res: any) => {
|
||||
if (res?.label) {
|
||||
return res?.label;
|
||||
} else {
|
||||
return props?.item?.activity_projects?.map((i: any) => {
|
||||
if (res?.value === i?.asset_projects_id) {
|
||||
return i?.asset_project?.name;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user