|
@@ -8,7 +8,8 @@ import ProForm, {
|
|
|
ProFormSelect,
|
|
|
} from '@ant-design/pro-form';
|
|
|
import {
|
|
|
- addSupPermission
|
|
|
+ addSupPermission,
|
|
|
+ addPermission,
|
|
|
} from '../services/API';
|
|
|
import {
|
|
|
urlType
|
|
@@ -17,70 +18,65 @@ import {
|
|
|
class NewPermission extends Component{
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state={
|
|
|
- showDesc: false,
|
|
|
- };
|
|
|
- this.addClick = this.addClick.bind(this);
|
|
|
this.newPermission = this.newPermission.bind(this);
|
|
|
+ this.addNewPermission = this.addNewPermission.bind(this);
|
|
|
}
|
|
|
|
|
|
- addClick=()=>{
|
|
|
- this.setState({
|
|
|
- showDesc: true
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
+ // 添加导航权限
|
|
|
newPermission= async(values) => {
|
|
|
- if(this.props.userDetaile){
|
|
|
- if (!this.state.auto) {
|
|
|
- message.warning('请输入上级模块')
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
const msg = await addSupPermission(values);
|
|
|
if(msg.error.length === 0){
|
|
|
- message.success('新增成功')
|
|
|
+ message.success('新增成功');
|
|
|
+ this.props.tableRef.current.reload();// 刷新列表
|
|
|
return true;
|
|
|
- }else {
|
|
|
+ }else{
|
|
|
+ message.warning(msg.error[0].message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加导航下级权限
|
|
|
+ addNewPermission= async(values) => {
|
|
|
+ const msg = await addPermission({...values,superId:this.props.superData.name});
|
|
|
+ if(msg.error.length === 0){
|
|
|
+ message.success('新增成功');
|
|
|
+ this.props.tableRef.current.reload();// 刷新列表
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
message.warning(msg.error[0].message);
|
|
|
return false;
|
|
|
}
|
|
|
- // {
|
|
|
- // id: this.state.ids,
|
|
|
- // name: this.state.name, //接口名称
|
|
|
- // url: this.state.url, //接口路径
|
|
|
- // type: this.state.urlType || "0",
|
|
|
- // superId: this.state.auto, //接口上级模板功能
|
|
|
- // showOrder: this.state.showOrder,
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
<ModalForm
|
|
|
- title="新建权限"
|
|
|
- initialValues={{
|
|
|
- type: 0
|
|
|
+ title={this.props.superData ? "新建下级权限模板":"新建权限"}
|
|
|
+ initialValues={this.props.superData ? null : {
|
|
|
+ type: 0// 导航级别
|
|
|
}}
|
|
|
trigger={
|
|
|
<Button
|
|
|
type="primary"
|
|
|
key='addSupPermission'
|
|
|
- icon={<PlusOutlined />}
|
|
|
- onClick={this.addClick}>
|
|
|
- 新增权限
|
|
|
+ style={{...this.props.buttonStyle}}
|
|
|
+ icon={!this.props.superData && <PlusOutlined />}>
|
|
|
+ {this.props.superData ? '新增下级权限':'新增权限'}
|
|
|
</Button>
|
|
|
}
|
|
|
modalProps={{
|
|
|
- onCancel: () => this.setState({ showDesc: true }),
|
|
|
- }}
|
|
|
- onFinish={async (values) => {
|
|
|
- this.newPermission(values);
|
|
|
+ onCancel: () => {},
|
|
|
}}
|
|
|
+ onFinish={this.props.superData ? this.addNewPermission : this.newPermission}
|
|
|
>
|
|
|
<ProForm.Group>
|
|
|
<ProFormText
|
|
|
- required
|
|
|
+ rules={
|
|
|
+ [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入接口名称!',
|
|
|
+ }]
|
|
|
+ }
|
|
|
width="xl"
|
|
|
name="name"
|
|
|
label="接口名称:"
|
|
@@ -89,7 +85,12 @@ class NewPermission extends Component{
|
|
|
</ProForm.Group>
|
|
|
<ProForm.Group>
|
|
|
<ProFormText
|
|
|
- required
|
|
|
+ rules={
|
|
|
+ [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入接口路径'
|
|
|
+ }]
|
|
|
+ }
|
|
|
width="xl"
|
|
|
name="url"
|
|
|
label="接口路径:"
|
|
@@ -98,15 +99,24 @@ class NewPermission extends Component{
|
|
|
</ProForm.Group>
|
|
|
<ProForm.Group>
|
|
|
<ProFormSelect
|
|
|
- required
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required:true,
|
|
|
+ message:'请选择接口类型'
|
|
|
+ }
|
|
|
+ ]}
|
|
|
width="xl"
|
|
|
name="type"
|
|
|
label="接口类型:"
|
|
|
placeholder="请选择接口类型"
|
|
|
- disabled
|
|
|
+ disabled={!this.props.superData}
|
|
|
request={async () => urlType}
|
|
|
/>
|
|
|
</ProForm.Group>
|
|
|
+ {this.props.superData && <ProForm.Group>
|
|
|
+ <span>上级功能模块:</span>
|
|
|
+ <span>{this.props.superData.name}</span>
|
|
|
+ </ProForm.Group>}
|
|
|
</ModalForm>
|
|
|
);
|
|
|
}
|