123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /*
- * @Author: your name
- * @Date: 2022-01-12 17:11:11
- * @LastEditTime: 2023-09-18 18:07:16
- * @LastEditors: code4eat awesomedema@gmail.com
- * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/userManage/modal.tsx
- */
- 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<ActModalProps> = ({ dispatch, isShowModal, tableAct, currentEdit, hospId }) => {
- const onVisibleChangeHandle = (bool: boolean) => {
- // console.log({bool});
- if (!bool) {
- dispatch &&
- dispatch({
- type: 'roleManageModel/cancelTableAct',
- });
- }
- };
- const onFinishHandle = (data: any & AddUsersDataType) => {
- 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 '绑定菜单';
- }
- if (tableAct == TableActType.EDITRELAUSER) {
- return '绑定人员';
- }
- };
- const setInitialValues = () => {
- if (tableAct == TableActType.EDIT) {
- return { ...currentEdit };
- }
- if (tableAct == TableActType.ADD) {
- console.log({hospId});
- return { hospId: hospId };
- }
- if (tableAct == TableActType.EDITMENU || tableAct == TableActType.EDITRELAUSER) {
- return { ...currentEdit };
- }
- };
- return (
- <KCModal
- visible={isShowModal}
- onVisibleChange={onVisibleChangeHandle}
- layout="horizontal"
- width={500}
- initialValues={setInitialValues()}
- title={setModalTitle()}
- labelCol={{
- span: 5,
- }}
- onFinish={async (data) => onFinishHandle(data)}
- >
- {tableAct == TableActType.EDITMENU && (
- <Form.Item name="bindMenuIds">
- <MenuEditer noAction={true} hospId={currentEdit?.hospId} />
- </Form.Item>
- )}
- {tableAct == TableActType.EDITRELAUSER && (
- <Form.Item name="bindUserIds">
- <UserEditer total={currentEdit?currentEdit.allUsers:[]} noAction={true} />
- </Form.Item>
- )}
- {(tableAct == TableActType.ADD || tableAct == TableActType.EDIT) && (
- <>
- <KCProSelect
- label="选择院区"
- width="md"
- name="hospId"
- disabled
- request={async () => {
- const hospList = await getShareHospList();
- if (hospList) {
- return hospList.map((t) => ({
- label: t.name,
- value: t.id,
- }));
- }
- return [];
- }}
- />
- <ProFormText
- width="md"
- name="roleName"
- label="角色名称"
- placeholder="请输入"
- rules={[
- {
- required: true,
- message: '请输入医院名称!',
- },
- ]}
- />
- <KCProSelect
- label="关联有数账号"
- width="md"
- name="youshuUserId"
- request={async () => {
- const resp = await getYoushuUsers();
- if (resp) {
- return resp.map((t) => ({
- label: t.name,
- value: t.id,
- }));
- }
- return [];
- }}
- />
- <ProFormTextArea name="remark" label="备注" placeholder="请输入名称" width="md" fieldProps={{}} />
- </>
- )}
- </KCModal>
- );
- };
- export default ActModal;
|