|
|
@@ -4,26 +4,21 @@ import type { TenantDetail } from '@/pages/system/Tenant/typings';
|
|
|
import type { TenantItem } from '@/pages/system/Tenant/typings';
|
|
|
import BaseCrud from '@/components/BaseCrud';
|
|
|
import { useRef } from 'react';
|
|
|
-import { Avatar, Menu, message, Popconfirm, Tooltip } from 'antd';
|
|
|
+import { Avatar, Drawer, Tooltip } from 'antd';
|
|
|
import Service from '@/pages/system/Tenant/service';
|
|
|
-import { CurdModel } from '@/components/BaseCrud/model';
|
|
|
-import {
|
|
|
- CloseCircleOutlined,
|
|
|
- EditOutlined,
|
|
|
- KeyOutlined,
|
|
|
- PlayCircleOutlined,
|
|
|
-} from '@ant-design/icons';
|
|
|
+import { EyeOutlined, KeyOutlined } from '@ant-design/icons';
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
+import moment from 'moment';
|
|
|
+import { Link } from 'umi';
|
|
|
+import TenantModel from '@/pages/system/Tenant/model';
|
|
|
+import type { ISchema } from '@formily/json-schema';
|
|
|
+import autzModel from '@/components/Authorization/autz';
|
|
|
+import Authorization from '@/components/Authorization';
|
|
|
+import { observer } from '@formily/react';
|
|
|
|
|
|
-const menu = (
|
|
|
- <Menu>
|
|
|
- <Menu.Item key="1">1st item</Menu.Item>
|
|
|
- <Menu.Item key="2">2nd item</Menu.Item>
|
|
|
- <Menu.Item key="3">3rd item</Menu.Item>
|
|
|
- </Menu>
|
|
|
-);
|
|
|
-const service = new Service('tenant');
|
|
|
-const Tenant = () => {
|
|
|
+export const service = new Service('tenant');
|
|
|
+
|
|
|
+const Tenant = observer(() => {
|
|
|
const intl = useIntl();
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
const columns: ProColumns<TenantItem>[] = [
|
|
|
@@ -50,6 +45,9 @@ const Tenant = () => {
|
|
|
}),
|
|
|
align: 'center',
|
|
|
renderText: (text: TenantDetail) => text.name,
|
|
|
+ search: {
|
|
|
+ transform: (value) => ({ name$LIKE: value }),
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
dataIndex: 'members',
|
|
|
@@ -58,6 +56,7 @@ const Tenant = () => {
|
|
|
defaultMessage: '成员数',
|
|
|
}),
|
|
|
align: 'center',
|
|
|
+ search: false,
|
|
|
},
|
|
|
{
|
|
|
dataIndex: 'tenant',
|
|
|
@@ -70,6 +69,7 @@ const Tenant = () => {
|
|
|
valueType: 'select',
|
|
|
hideInForm: true,
|
|
|
onFilter: true,
|
|
|
+ search: false,
|
|
|
valueEnum: [
|
|
|
{
|
|
|
text: intl.formatMessage({
|
|
|
@@ -95,6 +95,16 @@ const Tenant = () => {
|
|
|
],
|
|
|
},
|
|
|
{
|
|
|
+ title: '创建时间',
|
|
|
+ dataIndex: 'tenant',
|
|
|
+ width: '200px',
|
|
|
+ align: 'center',
|
|
|
+ renderText: (record: TenantDetail) => moment(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ sorter: true,
|
|
|
+ search: false,
|
|
|
+ defaultSortOrder: 'descend',
|
|
|
+ },
|
|
|
+ {
|
|
|
title: intl.formatMessage({
|
|
|
id: 'pages.data.option',
|
|
|
defaultMessage: '操作',
|
|
|
@@ -103,17 +113,32 @@ const Tenant = () => {
|
|
|
align: 'center',
|
|
|
width: 200,
|
|
|
render: (text, record) => [
|
|
|
- <a key="editable" onClick={() => CurdModel.update(record)}>
|
|
|
+ <Link
|
|
|
+ onClick={() => {
|
|
|
+ TenantModel.current = record;
|
|
|
+ }}
|
|
|
+ to={`/system/tenant/detail/${record.tenant.id}`}
|
|
|
+ key="link"
|
|
|
+ >
|
|
|
<Tooltip
|
|
|
title={intl.formatMessage({
|
|
|
- id: 'pages.data.option.edit',
|
|
|
- defaultMessage: '编辑',
|
|
|
+ id: 'pages.data.option.detail',
|
|
|
+ defaultMessage: '查看',
|
|
|
})}
|
|
|
+ key={'detail'}
|
|
|
>
|
|
|
- <EditOutlined />
|
|
|
+ <EyeOutlined />
|
|
|
</Tooltip>
|
|
|
- </a>,
|
|
|
- <a onClick={() => console.log('授权')}>
|
|
|
+ </Link>,
|
|
|
+
|
|
|
+ <a
|
|
|
+ key="auth"
|
|
|
+ onClick={() => {
|
|
|
+ autzModel.autzTarget.id = record.tenant.id!;
|
|
|
+ autzModel.autzTarget.name = record.tenant.name!;
|
|
|
+ autzModel.visible = true;
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tooltip
|
|
|
title={intl.formatMessage({
|
|
|
id: 'pages.data.option.authorize',
|
|
|
@@ -123,57 +148,112 @@ const Tenant = () => {
|
|
|
<KeyOutlined />
|
|
|
</Tooltip>
|
|
|
</a>,
|
|
|
- <a href={record.tenant.id} target="_blank" rel="noopener noreferrer" key="view">
|
|
|
- <Popconfirm
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.data.option.disabled.tips',
|
|
|
- defaultMessage: '确认禁用?',
|
|
|
- })}
|
|
|
- onConfirm={async () => {
|
|
|
- await service.update({
|
|
|
- tenant: {
|
|
|
- id: record.tenant.id,
|
|
|
- state: record.tenant?.state.value ? 0 : 1,
|
|
|
- },
|
|
|
- });
|
|
|
- message.success(
|
|
|
- intl.formatMessage({
|
|
|
- id: 'pages.data.option.success',
|
|
|
- defaultMessage: '操作成功!',
|
|
|
- }),
|
|
|
- );
|
|
|
- actionRef.current?.reload();
|
|
|
- }}
|
|
|
- >
|
|
|
- <Tooltip
|
|
|
- title={intl.formatMessage({
|
|
|
- id: `pages.data.option.${record.tenant?.state.value ? 'disabled' : 'enabled'}`,
|
|
|
- defaultMessage: record.tenant?.state?.value ? '禁用' : '启用',
|
|
|
- })}
|
|
|
- >
|
|
|
- {record.tenant?.state.value ? <CloseCircleOutlined /> : <PlayCircleOutlined />}
|
|
|
- </Tooltip>
|
|
|
- </Popconfirm>
|
|
|
- </a>,
|
|
|
],
|
|
|
},
|
|
|
];
|
|
|
|
|
|
+ const schema: ISchema = {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ name: {
|
|
|
+ type: 'string',
|
|
|
+ title: '名称',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ },
|
|
|
+ username: {
|
|
|
+ type: 'string',
|
|
|
+ title: '用户名',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ },
|
|
|
+ password: {
|
|
|
+ type: 'string',
|
|
|
+ title: '密码',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Password',
|
|
|
+ 'x-component-props': {
|
|
|
+ checkStrength: true,
|
|
|
+ },
|
|
|
+ 'x-reactions': [
|
|
|
+ {
|
|
|
+ dependencies: ['.confirmPassword'],
|
|
|
+ fulfill: {
|
|
|
+ state: {
|
|
|
+ selfErrors:
|
|
|
+ '{{$deps[0] && $self.value && $self.value !== $deps[0] ? "确认密码不匹配" : ""}}',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ confirmPassword: {
|
|
|
+ type: 'string',
|
|
|
+ title: '确认密码',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Password',
|
|
|
+ 'x-component-props': {
|
|
|
+ checkStrength: true,
|
|
|
+ },
|
|
|
+ 'x-reactions': [
|
|
|
+ {
|
|
|
+ dependencies: ['.password'],
|
|
|
+ fulfill: {
|
|
|
+ state: {
|
|
|
+ selfErrors:
|
|
|
+ '{{$deps[0] && $self.value && $self.value !== $deps[0] ? "确认密码不匹配" : ""}}',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ description: {
|
|
|
+ type: 'string',
|
|
|
+ title: '备注',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input.TextArea',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<PageContainer>
|
|
|
<BaseCrud<TenantItem>
|
|
|
- request={(params = {}) => service.queryDetail(params)}
|
|
|
+ request={(params = {}) => service.queryList(params)}
|
|
|
columns={columns}
|
|
|
service={service}
|
|
|
title={intl.formatMessage({
|
|
|
id: 'pages.system.tenant.list',
|
|
|
defaultMessage: '租户列表',
|
|
|
})}
|
|
|
- schema={{}}
|
|
|
- menu={menu}
|
|
|
+ schema={schema}
|
|
|
actionRef={actionRef}
|
|
|
/>
|
|
|
+ <Drawer
|
|
|
+ title={intl.formatMessage({
|
|
|
+ id: 'pages.data.option.authorize',
|
|
|
+ defaultMessage: '授权',
|
|
|
+ })}
|
|
|
+ width="50vw"
|
|
|
+ visible={autzModel.visible}
|
|
|
+ onClose={() => {
|
|
|
+ autzModel.visible = false;
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Authorization
|
|
|
+ close={() => {
|
|
|
+ autzModel.visible = false;
|
|
|
+ }}
|
|
|
+ target={autzModel.autzTarget}
|
|
|
+ type={'tenant'}
|
|
|
+ />
|
|
|
+ </Drawer>
|
|
|
</PageContainer>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
export default Tenant;
|