import React from 'react'; import KCModal from '@/components/KCModal'; import KCProSelect from '@/components/KCProSelect'; import { roleManageModelState, Dispatch } from 'umi'; import { ProFormText, ProFormTextArea } from '@ant-design/pro-form'; import { getHospList, getShareHospList } from '@/service/hospList'; import { AddUsersDataType, getYoushuUsers } from '@/service/user'; import { TableActType } from '..'; import { Form } from 'antd'; import MenuEditer from '@/pages/platform/components/menuEditer/menu'; import UserEditer from '@/pages/platform/components/usersEditer'; interface ActModalProps extends roleManageModelState { dispatch: Dispatch | undefined; } const ActModal: React.FC = ({ dispatch, isShowModal, tableAct, currentEdit, hospId }) => { const setInitialValues = () => { if (tableAct === TableActType.EDIT) { return { ...currentEdit }; } if (tableAct === TableActType.ADD) { return { hospId: hospId }; } if (tableAct === TableActType.EDITMENU || tableAct === TableActType.EDITRELAUSER) { return { ...currentEdit }; } }; const initialValues = setInitialValues(); // 在表单渲染之前设置初始值 const onVisibleChangeHandle = (bool: boolean) => { if (!bool) { dispatch && dispatch({ type: 'roleManageModel/cancelTableAct', }); } }; const onFinishHandle = (data: any & AddUsersDataType) => { console.log({initialValues}); if (tableAct === TableActType.ADD) { dispatch && dispatch({ type: 'roleManageModel/postAddData', payload: data, // 使用合并后的数据 }); } if (tableAct === TableActType.EDIT || tableAct === TableActType.EDITMENU || tableAct === TableActType.EDITRELAUSER) { dispatch && dispatch({ type: 'roleManageModel/postEditData', payload: data, // 使用合并后的数据 }); } return true; }; const setModalTitle = () => { if (tableAct === TableActType.EDIT) { return '编辑角色'; } if (tableAct === TableActType.ADD) { return '新增角色'; } if (tableAct === TableActType.EDITMENU) { return `绑定菜单(${currentEdit?.roleName})`; } if (tableAct === TableActType.EDITRELAUSER) { return `绑定人员(${currentEdit?.roleName})`; } }; return ( onFinishHandle({...data})} > {tableAct === TableActType.EDITMENU && ( )} {tableAct === TableActType.EDITRELAUSER && ( )} {(tableAct === TableActType.ADD || tableAct === TableActType.EDIT) && ( <> { const hospList = await getShareHospList(); if (hospList) { return hospList.map((t) => ({ label: t.name, value: t.id, })); } return []; }} /> { const resp = await getYoushuUsers(); if (resp) { return resp.map((t) => ({ label: t.name, value: t.id, })); } return []; }} /> )} ); }; export default ActModal;