瀏覽代碼

权限管理

HW 4 年之前
父節點
當前提交
daf57851b6

+ 1 - 1
config/routes.ts

@@ -9,7 +9,7 @@
     path: '/jurisdiction',
     component: './admin/user/jurisdiction',
     access: 'jurisdiction',
-  }
+  },
   {
     path: '/welcome',
     name: 'welcome',

+ 39 - 10
src/pages/admin/user/jurisdiction/components/newPermission.jsx

@@ -7,6 +7,12 @@ import ProForm, {
   ProFormDateRangePicker,
   ProFormSelect,
 } from '@ant-design/pro-form';
+import {
+  addSupPermission
+} from '../services/API';
+import {
+  urlType
+} from '@/utils/dataDic';
 
 class NewPermission extends Component{
   constructor(props) {
@@ -24,14 +30,38 @@ class NewPermission extends Component{
     });
   }
 
-  newPermission=()=>{
-
+  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('新增成功')
+      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
+          }}
           trigger={
             <Button
               type="primary"
@@ -45,10 +75,7 @@ class NewPermission extends Component{
             onCancel: () => this.setState({ showDesc: true }),
           }}
           onFinish={async (values) => {
-            await waitTime(2000);
-            console.log(values);
-            message.success('提交成功');
-            return true;
+            this.newPermission(values);
           }}
         >
           <ProForm.Group>
@@ -64,20 +91,22 @@ class NewPermission extends Component{
             <ProFormText
               required
               width="xl"
-              name="name"
+              name="url"
               label="接口路径:"
               placeholder="请输入接口路径"
             />
           </ProForm.Group>
           <ProForm.Group>
-            <ProFormText
+            <ProFormSelect
+              required
               width="xl"
-              name="name"
+              name="type"
               label="接口类型:"
               placeholder="请选择接口类型"
               disabled
+              request={async () => urlType}
             />
-            </ProForm.Group>
+          </ProForm.Group>
         </ModalForm>
     );
   }

+ 9 - 0
src/pages/admin/user/jurisdiction/services/API.ts

@@ -0,0 +1,9 @@
+import { request } from 'umi';
+
+// 添加权限
+export async function addSupPermission(data: object) {
+  return request('/api/admin/addSupPermission',{
+    method:'post',
+    data,
+  });
+}

+ 6 - 6
src/utils/dataDic.js

@@ -2170,16 +2170,16 @@ module.exports = {
   // 接口类型
   urlType: [
     {
-      value: "0",
-      key: "导航",
+      value: 0,
+      label: "导航",
     },
     {
-      value: "1",
-      key: "一级菜单",
+      value: 1,
+      label: "一级菜单",
     },
     {
-      value: "2",
-      key: "二级菜单",
+      value: 2,
+      label: "二级菜单",
     },
   ],
   // 客户端