|
@@ -0,0 +1,235 @@
|
|
|
+/*
|
|
|
+ * @Author: your name
|
|
|
+ * @Date: 2021-07-26 10:13:13
|
|
|
+ * @LastEditTime: 2021-08-02 18:27:21
|
|
|
+ * @LastEditors: Please set LastEditors
|
|
|
+ * @Description: In User Settings Edit
|
|
|
+ * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
|
|
|
+ */
|
|
|
+
|
|
|
+import { PlusOutlined } from '@ant-design/icons';
|
|
|
+import { Button, Popconfirm, message, Input, Modal } from 'antd';
|
|
|
+import React, { useState, useRef, useEffect } from 'react';
|
|
|
+import { useIntl, FormattedMessage,useModel } from 'umi';
|
|
|
+import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
|
|
|
+import ProTable from '@ant-design/pro-table';
|
|
|
+import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form';
|
|
|
+import UpdateForm from './updateForm';
|
|
|
+
|
|
|
+import { getRoleList, addUser, editUser, delUser } from './service';
|
|
|
+
|
|
|
+const UserMana = () => {
|
|
|
+ const columns = [
|
|
|
+ {
|
|
|
+ title: '院区名称',
|
|
|
+ dataIndex: 'hospName',
|
|
|
+ key: 'hosp_name',
|
|
|
+ hideInSearch: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '角色名',
|
|
|
+ dataIndex: 'roleName',
|
|
|
+ key: 'role_name',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '变更人',
|
|
|
+ dataIndex: 'modifyUserName',
|
|
|
+ key: 'modifyUserName',
|
|
|
+ hideInSearch: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '变更日期',
|
|
|
+ dataIndex: 'modifyTime',
|
|
|
+ key: 'modifyTime',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:'操作',
|
|
|
+ dataIndex: 'option',
|
|
|
+ valueType: 'option',
|
|
|
+ render: (_, record) => [
|
|
|
+ <a
|
|
|
+ key="config"
|
|
|
+ onClick={() => {
|
|
|
+ handleUpdateModalVisible(true);
|
|
|
+ setCurrentRow(record);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 用户
|
|
|
+ </a>,
|
|
|
+ <a
|
|
|
+ key="config"
|
|
|
+ onClick={() => {
|
|
|
+ handleUpdateModalVisible(true);
|
|
|
+ setCurrentRow(record);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 权限
|
|
|
+ </a>,
|
|
|
+ <a
|
|
|
+ key="config"
|
|
|
+ onClick={() => {
|
|
|
+ handleUpdateModalVisible(true);
|
|
|
+ setCurrentRow(record);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </a>,
|
|
|
+ <Popconfirm
|
|
|
+ key="subscribeAlert"
|
|
|
+ title="是否确定删除?"
|
|
|
+ onConfirm={() => {
|
|
|
+ setCurrentRow(record);
|
|
|
+ delUserHandler(record);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <a>删除</a>
|
|
|
+ </Popconfirm>,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const [createModalVisible, handleModalVisible] = useState(false);
|
|
|
+ const [updateModalVisible, handleUpdateModalVisible] = useState(false);
|
|
|
+ const actionRef = useRef();
|
|
|
+ const [currentRow, setCurrentRow] = useState({});
|
|
|
+
|
|
|
+
|
|
|
+ // const [shareParamsSetting,setShareParamsSetting] = useState(false); //是否分摊参数设置
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Boolean} bool 弹窗展示状态
|
|
|
+ */
|
|
|
+ const updateModalVisibleChange = (bool) => {
|
|
|
+ handleUpdateModalVisible(bool);
|
|
|
+ if (!bool) setCurrentRow(undefined);
|
|
|
+ };
|
|
|
+
|
|
|
+ //获取列表
|
|
|
+ const getList = async (params = {}, sort, filter) => {
|
|
|
+ const res = await getRoleList(params);
|
|
|
+ return {
|
|
|
+ data: res.data.list,
|
|
|
+ total: res.data.totalCount,
|
|
|
+ success: res.success,
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} value 删除项数据
|
|
|
+ */
|
|
|
+ const delUserHandler = async (value) => {
|
|
|
+ const resp = await delUser(value);
|
|
|
+ if(resp.msg){
|
|
|
+ if (actionRef.current) {
|
|
|
+ actionRef.current.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <PageContainer>
|
|
|
+ <ProTable
|
|
|
+ columns={columns}
|
|
|
+ request={getList}
|
|
|
+ actionRef={actionRef}
|
|
|
+ rowKey="roleId"
|
|
|
+ toolBarRender={() => [
|
|
|
+ <Button
|
|
|
+ key="button"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="primary"
|
|
|
+ onClick={() => {
|
|
|
+ handleModalVisible(true);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </Button>,
|
|
|
+
|
|
|
+ ]}
|
|
|
+ pagination={{
|
|
|
+ pageSize: 10,
|
|
|
+ }}
|
|
|
+ search={{
|
|
|
+ defaultCollapsed: false,
|
|
|
+ labelWidth: 'auto',
|
|
|
+ }}
|
|
|
+ />
|
|
|
+
|
|
|
+ <ModalForm
|
|
|
+ title="新增角度"
|
|
|
+ width="800px"
|
|
|
+ labelCol={{ span: 5, offset: 3 }}
|
|
|
+ layout={'horizontal'}
|
|
|
+ visible={createModalVisible}
|
|
|
+ onVisibleChange={handleModalVisible}
|
|
|
+ onFinish={async (value) => {
|
|
|
+ const success = await addUser(value);
|
|
|
+ // console.log({ success });
|
|
|
+ if (success) {
|
|
|
+ handleModalVisible(false);
|
|
|
+
|
|
|
+ if (actionRef.current) {
|
|
|
+ actionRef.current.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <ProFormText
|
|
|
+ label="角色名"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:'角色名是必填项!',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ width="sm"
|
|
|
+ name="roleName"
|
|
|
+ />
|
|
|
+ <ProFormText
|
|
|
+ label="备注"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: false,
|
|
|
+ message:'',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ width="sm"
|
|
|
+ name="remark"
|
|
|
+ />
|
|
|
+
|
|
|
+ </ModalForm>
|
|
|
+
|
|
|
+ {/* 更新 */}
|
|
|
+ <UpdateForm
|
|
|
+ onSubmit={async (value) => {
|
|
|
+ // console.log({value});
|
|
|
+ const success = await editUser(value);
|
|
|
+
|
|
|
+ if (success) {
|
|
|
+ handleUpdateModalVisible(false);
|
|
|
+ setCurrentRow(undefined);
|
|
|
+
|
|
|
+ if (actionRef.current) {
|
|
|
+ actionRef.current.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onCancel={() => {
|
|
|
+ handleUpdateModalVisible(false);
|
|
|
+ setCurrentRow(undefined);
|
|
|
+ }}
|
|
|
+ updateModalVisible={updateModalVisible}
|
|
|
+ updateModalVisibleChange={updateModalVisibleChange}
|
|
|
+ values={currentRow || {}}
|
|
|
+ />
|
|
|
+
|
|
|
+
|
|
|
+ </PageContainer>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default UserMana;
|