/*
* @Author: your name
* @Date: 2021-07-26 10:13:13
* @LastEditTime: 2021-09-18 11:40:14
* @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 } from 'antd';
import React, { useState, useRef } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { ModalForm, ProFormText, ProFormSelect, ProFormDigit } from '@ant-design/pro-form';
import UpdateForm from './updateForm';
import { addList, editList, delList } from './service';
import { getMenuList } from '@/pages/platformMana/menuManage/service';
const UserMana = () => {
const columns = [
{
title: '菜单名称',
dataIndex: 'name',
key: 'name',
// ellipsis: true,
},
{
title: '菜单Id',
dataIndex: 'menuId',
key: 'menuId',
hideInSearch: true,
ellipsis: true,
},
{
title: 'URL',
dataIndex: 'url',
key: 'url',
ellipsis: true,
hideInSearch: true,
},
{
title: 'Path',
dataIndex: 'path',
key: 'path',
ellipsis: true,
hideInSearch: true,
},
{
title: '变更人',
dataIndex: 'modifyUserName',
key: 'modifyUserName',
hideInSearch: true,
ellipsis: true,
},
{
title: '变更日期',
dataIndex: 'modifyTime',
key: 'modifyTime',
valueType: 'date',
ellipsis: true,
hideInSearch: true,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
render: (_, record) => {
const { type } = record;
const btnGroups = [
{
handleUpdateModalVisible(true);
setCurrentRow(record);
}}
>
编辑
,
{
delUserHandler(record);
}}
>
删除
,
];
return type != 0
? [...btnGroups]
: [
{
setIfAddZeroLevelMenu(false);
handleModalVisible(true);
setCurrentRow(record);
}}
>
添加
,
...btnGroups,
];
},
},
];
const [createModalVisible, handleModalVisible] = useState(false);
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
const actionRef = useRef();
const [currentRow, setCurrentRow] = useState(undefined);
const [ifAddZeroLevelMenu, setIfAddZeroLevelMenu] = useState(true);
// const [shareParamsSetting,setShareParamsSetting] = useState(false); //是否分摊参数设置
/**
*
* @param {Boolean} bool 弹窗展示状态
*/
const updateModalVisibleChange = (bool) => {
handleUpdateModalVisible(bool);
if (!bool) setCurrentRow(undefined);
};
//获取Drawer菜单列表
const getMenus = async (params = {}, sort, filter) => {
const res = await getMenuList(params);
return {
data: res.data.list,
total: res.data.totalCount,
success: res.success,
};
};
/**
*
* @param {Object} value 删除项数据
*/
const delUserHandler = async (value) => {
const ids = [value.menuId];
const resp = await delList({ ids });
if (resp.status == 200) {
if (actionRef.current) {
actionRef.current.reload();
}
}
};
return (
[
}
type="primary"
onClick={() => {
setIfAddZeroLevelMenu(true);
handleModalVisible(true);
}}
>
新增
,
]}
pagination={{
pageSize: 10,
}}
search={false}
/>
{
let id = 0;
currentRow && (id = currentRow.menuId);
// console.log({id});
const resp = await addList({ ...value, parentId: id });
const { status } = resp;
if (status == 200) {
if (actionRef.current) {
actionRef.current.reload();
}
return true;
}
setCurrentRow(undefined);
}}
>
{/* */}
{/* 更新 */}
{
const { menuId, parentId = 0 } = currentRow;
// console.log({currentRow});
// console.log({'编辑':value});
const { name, path, url, perms, type, icon = 'ww', orderNum } = value;
const resp = await editList({
parentId,
name,
path,
url,
perms,
type,
icon,
orderNum,
id: menuId,
});
const { status } = resp;
if (status == 200) {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
}}
updateModalVisible={updateModalVisible}
updateModalVisibleChange={updateModalVisibleChange}
values={currentRow || {}}
/>
);
};
export default UserMana;