﻿---
title: 复制权限组件
sidemenu: true
---

## 复制权限组件

这个组件用来复制权限

> 注意： 需要在 <span style="color: red;">url</span> 上带上 <span style="color: red;">appId</span> 参数 

```tsx
/**
 * background: '#f0f2f5'
 */
import React, { useEffect } from 'react';
import { useDispatch } from 'umi';
import { Space, Button } from 'antd';
import { ProFormText } from '@ant-design/pro-form';
import { CopyPermission } from '@/components';

export default () => {
  const dispatch = useDispatch();
  useEffect(() => {
    dispatch({
      type: 'public/fetchRoleList',
      payload: 4294967530,
    });
    dispatch({
      type: 'public/fetchFeatureTreeDatas',
      payload: 4294967530,
    });
    dispatch({
      type: 'public/fetchFlagList',
      payload: 4294967530,
    });
    dispatch({
      type: 'public/fetchStrategyList',
      payload: 4294967530,
    });
  }, [dispatch]);
  const contentRender = ()=>(<>
        <ProFormText width="md" name="remark" label="备注" placeholder="请输入" />
  </>);
  return (
    <Space>
      <CopyPermission name="aaaa" type="role" id={4294970531} copyList={['feature', 'flag', 'policy']} title="角色" onFinish={()=>{}}>
        {contentRender()}
      </CopyPermission>
      <CopyPermission name="bbbb" isHaveDate type="user" id={4294970531} copyList={['feature', 'flag', 'policy', 'role']} title="用户" onFinish={()=>{}} >
        {contentRender()}
      </CopyPermission>
      <CopyPermission name="bbbb" isHaveDate type="user" copyList={['feature', 'flag', 'policy', 'role']}  title="用户" titleRender={()=>"新增用户"} linkRender={()=> <Button>新增</Button>} onFinish={()=>{}} >
        {contentRender()}
      </CopyPermission>
    </Space>
  );
};
```

<API src="./index.tsx"></API>
