|
|
@@ -1,7 +1,7 @@ |
|
|
|
import { PlusOutlined } from '@ant-design/icons'; |
|
|
|
import { Button, message, Drawer, Popconfirm } from 'antd'; |
|
|
|
import React, { useState, useRef, useEffect } from 'react'; |
|
|
|
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; |
|
|
|
import { PageContainer } from '@ant-design/pro-layout'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
|
import ProDescriptions from '@ant-design/pro-descriptions'; |
|
|
|
import CreateForm from './components/CreateForm'; |
|
|
@@ -13,7 +13,6 @@ import api from './service'; |
|
|
|
* |
|
|
|
* @param fields |
|
|
|
*/ |
|
|
|
|
|
|
|
const handleAdd = async (fields) => { |
|
|
|
try { |
|
|
|
await api.addCompany(fields).then((r) => { |
|
|
@@ -38,10 +37,8 @@ const handleAdd = async (fields) => { |
|
|
|
* |
|
|
|
* @param fields |
|
|
|
*/ |
|
|
|
|
|
|
|
const handleUpdate = async (fields) => { |
|
|
|
try { |
|
|
|
|
|
|
|
await api.updateCompany(fields).then((r) => { |
|
|
|
if (!r.succeeded) { |
|
|
|
message.error(r.errors); |
|
|
@@ -59,30 +56,6 @@ const handleUpdate = async (fields) => { |
|
|
|
return false; |
|
|
|
} |
|
|
|
}; |
|
|
|
/** |
|
|
|
* 删除节点 |
|
|
|
* |
|
|
|
* @param selectedRows |
|
|
|
*/ |
|
|
|
|
|
|
|
const handleRemove = async (selectedRows) => { |
|
|
|
if (!selectedRows) return true; |
|
|
|
try { |
|
|
|
await api.removeCompany(selectedRows.map((row) => row.id)).then((r) => { |
|
|
|
if (r) { |
|
|
|
message.success('删除成功'); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
message.error('删除失败,请重试'); |
|
|
|
} |
|
|
|
}); |
|
|
|
return true; |
|
|
|
} catch (error) { |
|
|
|
message.error('删除失败,请重试'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const handleMenu = async (fields) => { |
|
|
|
try { |
|
|
@@ -111,24 +84,20 @@ const companyManage = () => { |
|
|
|
/*绑定数据 */ |
|
|
|
const actionRef = useRef(); |
|
|
|
const [currentRow, setCurrentRow] = useState(); |
|
|
|
/*选中*/ |
|
|
|
const [selectedRowsState, setSelectedRows] = useState(); |
|
|
|
|
|
|
|
//获取功能菜单数据 |
|
|
|
const [treeData, setTreeData] = useState(); |
|
|
|
|
|
|
|
const [row, setRow] = useState(); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
var parm={getType:'ALL',type:0} |
|
|
|
var parm = { getType: 'ALL', type: 0 } |
|
|
|
api.GetMenu(parm).then((r) => { |
|
|
|
if(r.data){ |
|
|
|
if (r.data) { |
|
|
|
setTreeData(r.data); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const handleResetPwd=(record)=>{ |
|
|
|
const handleResetPwd = (record) => { |
|
|
|
api.ResetPwd(record.userId).then(r => { |
|
|
|
r.data ? message.success("重置成功") : message.error("重置失败"); |
|
|
|
}) |
|
|
@@ -190,15 +159,16 @@ const companyManage = () => { |
|
|
|
width: 400, |
|
|
|
render: (_, record) => { |
|
|
|
var template = [ |
|
|
|
<a |
|
|
|
<Button |
|
|
|
type='link' |
|
|
|
style={{ padding: 0 }} |
|
|
|
onClick={() => { |
|
|
|
handleModalVisible(true); |
|
|
|
setStepFormValues(record); |
|
|
|
}} |
|
|
|
> |
|
|
|
{' '} |
|
|
|
更新 |
|
|
|
</a>, |
|
|
|
</Button>, |
|
|
|
<Popconfirm |
|
|
|
title="确认重置密码吗?" |
|
|
|
onConfirm={() => { handleResetPwd(record) }} |
|
|
@@ -206,11 +176,17 @@ const companyManage = () => { |
|
|
|
okText="确定" |
|
|
|
cancelText="取消" |
|
|
|
> |
|
|
|
<a> |
|
|
|
<Button |
|
|
|
type='link' |
|
|
|
style={{ padding: 0 }} |
|
|
|
> |
|
|
|
重置密码 |
|
|
|
</a> |
|
|
|
</Button> |
|
|
|
</Popconfirm>, |
|
|
|
<a |
|
|
|
<Button |
|
|
|
type='link' |
|
|
|
style={{ padding: 0 }} |
|
|
|
disabled={record.adminName === 'admin'} |
|
|
|
onClick={() => { |
|
|
|
api.GetRoleMenu(record.sysRoleId).then((r) => { |
|
|
|
setRow(r.data); |
|
|
@@ -219,10 +195,10 @@ const companyManage = () => { |
|
|
|
setStepFormValues(record); |
|
|
|
}} |
|
|
|
> |
|
|
|
{' '} |
|
|
|
企业菜单授权 |
|
|
|
</a>, |
|
|
|
</Button>, |
|
|
|
<Popconfirm |
|
|
|
disabled={record.adminName === 'admin'} |
|
|
|
type="primary" |
|
|
|
key="primary" |
|
|
|
title="删除加盟商将会删除下面的用户以及菜单权限,确认删除吗?" |
|
|
@@ -230,27 +206,19 @@ const companyManage = () => { |
|
|
|
cancelText="否" |
|
|
|
onConfirm={() => { |
|
|
|
api.removeCompany([record.id]).then((r) => { |
|
|
|
|
|
|
|
message.success('删除成功'); |
|
|
|
actionRef.current.reload(); |
|
|
|
}); |
|
|
|
}} |
|
|
|
onCancel={() => { }} |
|
|
|
> |
|
|
|
<a href="#">删除</a> |
|
|
|
<Button |
|
|
|
type='link' |
|
|
|
style={{ padding: 0 }} |
|
|
|
disabled={record.adminName === 'admin'} |
|
|
|
> |
|
|
|
删除 |
|
|
|
</Button> |
|
|
|
</Popconfirm>, |
|
|
|
// <a |
|
|
|
// // onClick={() => { |
|
|
|
// // api.GetRoleMenu(record.sysRoleId).then((r) => { |
|
|
|
// // setRow(r.data); |
|
|
|
// // handleUpdateMenuModalVisible(true); |
|
|
|
// // }); |
|
|
|
// // setStepFormValues(record); |
|
|
|
// // }} |
|
|
|
// > |
|
|
|
// {' '} |
|
|
|
// LOGO设置 |
|
|
|
// </a>, |
|
|
|
]; |
|
|
|
return template; |
|
|
|
}, |
|
|
@@ -294,55 +262,7 @@ const companyManage = () => { |
|
|
|
}; |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
rowSelection={{ |
|
|
|
onChange: (_, selectedRows) => { |
|
|
|
setSelectedRows(selectedRows); |
|
|
|
}, |
|
|
|
}} |
|
|
|
/> |
|
|
|
{selectedRowsState?.length > 0 && ( |
|
|
|
<FooterToolbar |
|
|
|
extra={ |
|
|
|
<div> |
|
|
|
已选择{' '} |
|
|
|
<a |
|
|
|
style={{ |
|
|
|
fontWeight: 600, |
|
|
|
}} |
|
|
|
> |
|
|
|
{selectedRowsState.length} |
|
|
|
</a>{' '} |
|
|
|
项 |
|
|
|
</div> |
|
|
|
} |
|
|
|
> |
|
|
|
{/* <Button |
|
|
|
type="primary" |
|
|
|
onClick={async () => { |
|
|
|
await handleRemove(selectedRowsState); |
|
|
|
setSelectedRows([]); |
|
|
|
actionRef.current?.reloadAndRest?.(); |
|
|
|
}} |
|
|
|
> |
|
|
|
批量删除 |
|
|
|
</Button> */} |
|
|
|
<Popconfirm |
|
|
|
type="primary" |
|
|
|
key="primary" |
|
|
|
title="确认删除吗?" |
|
|
|
okText="是" |
|
|
|
cancelText="否" |
|
|
|
onConfirm={() => { |
|
|
|
handleRemove(selectedRowsState); |
|
|
|
setSelectedRows([]); |
|
|
|
actionRef.current?.reloadAndRest?.(); |
|
|
|
}} |
|
|
|
onCancel={() => { }} |
|
|
|
> |
|
|
|
<a href="#">批量删除</a> |
|
|
|
</Popconfirm> |
|
|
|
</FooterToolbar> |
|
|
|
)} |
|
|
|
<CreateForm |
|
|
|
onFinish={async (value) => { |
|
|
|
var success = false; |
|
|
@@ -354,12 +274,8 @@ const companyManage = () => { |
|
|
|
if (success) { |
|
|
|
handleModalVisible(false); |
|
|
|
setCurrentRow(undefined); |
|
|
|
|
|
|
|
if (actionRef.current) { |
|
|
|
actionRef.current.reload(); |
|
|
|
} |
|
|
|
actionRef.current.reload(); |
|
|
|
} |
|
|
|
actionRef.current?.reload(); |
|
|
|
}} |
|
|
|
onCancel={() => { |
|
|
|
handleModalVisible(false); |
|
|
|