关注项目弹窗 - 可编辑项目列表
import { queryDict } from '@/services/common'; import ProForm, { ModalForm, ProFormInstance } from '@ant-design/pro-form'; import { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; import React, { useEffect, useRef, useState } from 'react'; import { getOnlyKey } from '@/utils/utils'; import { Button, Space } from 'antd'; import { PlusCircleOutlined } from '@ant-design/icons'; import { getProjectList } from '@/services/project/new/built'; import { useModel } from 'umi'; import { isArray } from 'lodash'; import { option } from 'yargs';
interface Props { children: React.ReactElement; }
interface ListItem { projectName: string; projectChip: string; projectType: string; publicTime: string; id: string; releaseTime: string; };
interface ProjectInfoDetail { projectChip: string; id: string; }
const ModalFocus: React.FC<React.PropsWithChildren
/*** 获取项目列表*/ const getProjectOptions = async () => { try { const { data } = await getProjectList({ projectStatuses: ['PROGRESSING', 'INIT', 'PAUSED', 'FINISH'], createBy: currentUser?.userName || '', userId: currentUser?.userId || '', }); if (!isArray(data)) throw new Error('暂无已建项目列表!'); setSelectOptions(data); return data; } catch (error) { setSelectOptions([]); return []; } };
useEffect(() => { getProjectOptions(); }, []);
const columns: ProColumns/project/operation/home?projectId=${record.id});
// }}
// >
// {record.projectName}
//
// ),
fieldProps: {
options: selectOptions,
fieldNames: {
label: 'projectName',
value: 'id',
},
onChange:(val:string,option:any)=>{
console.log(val,95,option);
option.find((item:projectTypeItem[])=>{item.id==val});
const optionData={
projectChip:option.projectChip,
}
}
},
},
{
title: '项目类型',
dataIndex: 'projectType',
readonly: true,
align: 'center',
width: 100,
// request: async () => {
// const { data } = await queryDict({ types: ['projectType'] });
// return data[0].enumTypeVOS;
// },
},
{
title: '操作',
dataIndex: 'opeation',
width: 100,
},
];
return (
<>
{React.cloneElement(children, {
onClick: () => {
setVisible(true);
},
// type: 'primary',
})}
<ModalForm
title="我关注的项目"
visible={visible}
submitter={{
searchConfig: {
submitText: '保存',
resetText: '取消',
},
}}
modalProps={{
destroyOnClose: true,
onCancel: () => {
setVisible(false);
},
}}
layout="horizontal"
>
// fetchList();
// },
onChange: setEditableRowKeys,
actionRender: (row, config, defaultDoms) => {
return [];
},
}}
/>
{/* </ProForm.Item> */}
<Space>
<Button
style={{ border: '1px' }}
onClick={() => {
// actionRef.current?.addEditRecord?.({
// key: getOnlyKey(),
// });
const data = focusData;
data.push({ id: getOnlyKey() });
setEditableRowKeys(data.map((item: any) => item.id));
setFocusData([...data]);
}}
>
<PlusCircleOutlined />
</Button>
</Space>
</ModalForm>
</>
); }; export default React.memo(ModalFocus);
原文地址: https://www.cveoy.top/t/topic/ogOU 著作权归作者所有。请勿转载和采集!