|
@@ -1,23 +1,21 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-01-12 17:11:11
|
|
|
- * @LastEditTime: 2022-01-21 09:31:14
|
|
|
+ * @LastEditTime: 2022-03-04 09:06:04
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
* @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 React, { useEffect, useRef, useState } from 'react';
|
|
|
import KCModal from '@/components/KCModal';
|
|
|
import KCProSelect from '@/components/KCProSelect';
|
|
|
import { hospManageModelState, Dispatch } from 'umi';
|
|
|
|
|
|
-import {
|
|
|
- ProFormText,
|
|
|
- ProFormRadio,
|
|
|
- ProFormDependency,
|
|
|
-} from '@ant-design/pro-form';
|
|
|
-import { getHospList } from '@/service/hospList';
|
|
|
+import { ProFormText, ProFormRadio, ProFormDependency, ProFormDigit } from '@ant-design/pro-form';
|
|
|
+import type { ProColumns } from '@ant-design/pro-table';
|
|
|
+import { EditableProTable } from '@ant-design/pro-table';
|
|
|
+import { getHospList, getHospYoushuAccounts, YoushuAccountsType } from '@/service/hospList';
|
|
|
import type { AddUsersDataType } from '@/service/user';
|
|
|
import { randomString } from '@/utils';
|
|
|
import { TableActType } from '..';
|
|
@@ -28,14 +26,63 @@ interface ActModalProps extends hospManageModelState {
|
|
|
dispatch: Dispatch | undefined;
|
|
|
}
|
|
|
|
|
|
-const ActModal: React.FC<ActModalProps> = ({
|
|
|
- dispatch,
|
|
|
- isShowModal,
|
|
|
- tableAct,
|
|
|
- currentEdit,
|
|
|
-}) => {
|
|
|
+type DataSourceType = YoushuAccountsType & { key: number };
|
|
|
+
|
|
|
+const ActModal: React.FC<ActModalProps> = ({ dispatch, isShowModal, tableAct, currentEdit }) => {
|
|
|
+ const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
|
|
|
+ const [dataSource, setDataSource] = useState<DataSourceType[]>([]);
|
|
|
+
|
|
|
+ const columns: ProColumns<DataSourceType>[] = [
|
|
|
+ {
|
|
|
+ title: 'id',
|
|
|
+ dataIndex: 'id',
|
|
|
+ key: 'id',
|
|
|
+ hideInTable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '账号',
|
|
|
+ dataIndex: 'account',
|
|
|
+ key: 'account',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '密码',
|
|
|
+ key: 'password',
|
|
|
+ dataIndex: 'password',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '是否默认',
|
|
|
+ dataIndex: 'isDefault',
|
|
|
+ valueType: 'select',
|
|
|
+ request: async () => [
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: '是',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 0,
|
|
|
+ label: '否',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ valueType: 'option',
|
|
|
+ key: 'option',
|
|
|
+ width: 120,
|
|
|
+ render: (text, record, _, action) => [
|
|
|
+ <a
|
|
|
+ key="delete"
|
|
|
+ onClick={() => {
|
|
|
+ setDataSource(dataSource.filter((item) => item.key !== record.key));
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </a>,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
const onVisibleChangeHandle = (bool: boolean) => {
|
|
|
- // console.log({bool});
|
|
|
if (!bool) {
|
|
|
dispatch &&
|
|
|
dispatch({
|
|
@@ -45,6 +92,7 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
};
|
|
|
|
|
|
const onFinishHandle = (data: any & AddUsersDataType) => {
|
|
|
+ console.log({ data });
|
|
|
if (tableAct == TableActType.ADD) {
|
|
|
dispatch &&
|
|
|
dispatch({
|
|
@@ -53,14 +101,17 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- if (tableAct == TableActType.EDIT || tableAct == TableActType.EDITMENU) {
|
|
|
+ if (
|
|
|
+ tableAct == TableActType.EDIT ||
|
|
|
+ tableAct == TableActType.EDITMENU ||
|
|
|
+ tableAct == TableActType.BINDACCOUNT
|
|
|
+ ) {
|
|
|
dispatch &&
|
|
|
dispatch({
|
|
|
type: 'hospManageModel/postEditData',
|
|
|
payload: data,
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
return true;
|
|
|
};
|
|
|
|
|
@@ -74,6 +125,9 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
if (tableAct == TableActType.EDITMENU) {
|
|
|
return '绑定菜单';
|
|
|
}
|
|
|
+ if (tableAct == TableActType.BINDACCOUNT) {
|
|
|
+ return '院区报告设置';
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const setInitialValues = () => {
|
|
@@ -89,8 +143,25 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
if (tableAct == TableActType.EDITMENU) {
|
|
|
return { ...currentEdit };
|
|
|
}
|
|
|
+
|
|
|
+ if (tableAct == TableActType.BINDACCOUNT) {
|
|
|
+ if (currentEdit?.reportId) {
|
|
|
+ return { ...currentEdit, reportId: parseInt(currentEdit.reportId) };
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ //加装key字段
|
|
|
+ const fixedDataSource = currentEdit?.youshuUsers
|
|
|
+ ? currentEdit.youshuUsers.map((t) => ({
|
|
|
+ ...t,
|
|
|
+ key: Number((Math.random() * 1000000).toFixed(0)),
|
|
|
+ }))
|
|
|
+ : [];
|
|
|
+ setDataSource(fixedDataSource);
|
|
|
+ }, [currentEdit]);
|
|
|
+
|
|
|
return (
|
|
|
<KCModal
|
|
|
visible={isShowModal}
|
|
@@ -100,15 +171,20 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
initialValues={setInitialValues()}
|
|
|
title={setModalTitle()}
|
|
|
labelCol={{
|
|
|
- span: 4,
|
|
|
+ span: 6,
|
|
|
}}
|
|
|
- onFinish={async (data) => onFinishHandle(data)}
|
|
|
+ wrapperCol={{ span: 12 }}
|
|
|
+ onFinish={async (data) =>
|
|
|
+ onFinishHandle(tableAct == TableActType.BINDACCOUNT ? { ...data, dataSource } : data)
|
|
|
+ }
|
|
|
>
|
|
|
- {tableAct == TableActType.EDITMENU ? (
|
|
|
+ {tableAct == TableActType.EDITMENU && (
|
|
|
<Form.Item name="bindMenuIds">
|
|
|
<MenuEditer />
|
|
|
</Form.Item>
|
|
|
- ) : (
|
|
|
+ )}
|
|
|
+
|
|
|
+ {tableAct != TableActType.EDITMENU && tableAct != TableActType.BINDACCOUNT && (
|
|
|
<>
|
|
|
<ProFormText
|
|
|
width="md"
|
|
@@ -173,18 +249,8 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
}}
|
|
|
</ProFormDependency>
|
|
|
<ProFormText width="md" name="hospSign" label="医院标识" disabled />
|
|
|
- <ProFormText
|
|
|
- width="md"
|
|
|
- name="hospAbbreviation"
|
|
|
- label="简称"
|
|
|
- placeholder="请输入"
|
|
|
- />
|
|
|
- <ProFormText
|
|
|
- width="md"
|
|
|
- name="systemName"
|
|
|
- label="系统名称"
|
|
|
- placeholder="请输入"
|
|
|
- />
|
|
|
+ <ProFormText width="md" name="hospAbbreviation" label="简称" placeholder="请输入" />
|
|
|
+ <ProFormText width="md" name="systemName" label="系统名称" placeholder="请输入" />
|
|
|
<ProFormRadio.Group
|
|
|
name="isDataShare"
|
|
|
label="是否数据分享"
|
|
@@ -201,6 +267,57 @@ const ActModal: React.FC<ActModalProps> = ({
|
|
|
/>
|
|
|
</>
|
|
|
)}
|
|
|
+ {tableAct == TableActType.BINDACCOUNT && (
|
|
|
+ <>
|
|
|
+ <ProFormText
|
|
|
+ width="md"
|
|
|
+ name="reportUrl"
|
|
|
+ label="报告请求地址"
|
|
|
+ placeholder="请输入"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入!',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <ProFormDigit
|
|
|
+ label="报告项目Id"
|
|
|
+ name="reportId"
|
|
|
+ min={0}
|
|
|
+ fieldProps={{ precision: 0 }}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入!',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <EditableProTable<DataSourceType>
|
|
|
+ rowKey="key"
|
|
|
+ headerTitle="院区[有数]账号绑定"
|
|
|
+ columns={columns}
|
|
|
+ value={dataSource}
|
|
|
+ recordCreatorProps={{
|
|
|
+ record: {
|
|
|
+ key: Number((Math.random() * 1000000).toFixed(0)),
|
|
|
+ id: -1,
|
|
|
+ userName: '',
|
|
|
+ account: '',
|
|
|
+ password: '',
|
|
|
+ isDefault: 0,
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ onChange={setDataSource}
|
|
|
+ editable={{
|
|
|
+ // type: 'multiple',
|
|
|
+ deletePopconfirmMessage: '确定删除此行?',
|
|
|
+ editableKeys,
|
|
|
+ onChange: setEditableRowKeys,
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
</KCModal>
|
|
|
);
|
|
|
};
|