Browse Source

Merge branch 'master' of http://192.168.20.122:3000/root/qiyewechatApp.git

Lgx 4 years ago
parent
commit
400410c5c6

+ 22 - 19
UI/src/components/Form/BirdButton.js

@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import { permission, deepClone, request, config,util } from 'utils';
+import { permission, deepClone, config,util } from 'utils';
+import { arequest } from 'utils/request';
 import { Button } from 'antd';
 import axios from 'axios';
 import qs from 'qs';
@@ -46,26 +47,28 @@ class BirdButton extends React.Component {
     data['applicationKey'] = ApplicationKey;
     data['refresh_token'] = util.auth.getToken();
     let strData = qs.stringify(data);
-    request({
-      url: config.api.getOperationToken,
-      method: 'post',
-      data:strData,
-      dataHeader:{headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}}
-    }).then(data => {
+    
+    (async ()=>{
+      let data = await arequest({
+        url: config.api.getOperationToken,
+        method: 'post',
+        data:strData,
+        dataHeader:{headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}}
+      });
       // 改为sso token
-      if(data.success){
-        // this.setState({ token: data.result.access_token })
-        var user = util.auth.getUser();
-        if(user){
-          user.staffid = data.result.access_token;
-          util.auth.setUser(user);
+        if(data.success){
+          // this.setState({ token: data.result.access_token })
+          var user = util.auth.getUser();
+          if(user){
+            user.staffid = data.result.access_token;
+            util.auth.setUser(user);
+          }
+          util.auth.setToken(data.result.access_token);
+        }else{
+          util.auth.removeToken();
+          permission.clear();
+          window.location.href = "/";
         }
-        util.auth.setToken(data.result.access_token);
-      }else{
-        util.auth.removeToken();
-        permission.clear();
-        window.location.href = "/";
-      }
     })
   }
 

+ 60 - 21
UI/src/components/Form/BirdMulti.js

@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import { request, config, util } from 'utils';
+import { arequest } from 'utils/request';
 import { Checkbox } from 'antd';
 const CheckboxGroup = Checkbox.Group;
 
@@ -13,38 +14,27 @@ class BirdMulti extends React.Component {
     }
   }
 
-  componentDidMount() {
+  async componentDidMount() {
     let self = this;
     if (self.props.options.length > 0) return;
 
-    if (self.props.url) {
-      request({
-        url: self.props.url,
-        method: "get"
-      }).then(function (result) {
-        self.setState({
-          options: result
-        })
-      });
-    } else if (self.props.dicKey) {
-      request({
-        url: config.api.getDic + self.props.dicKey,
-        method: "get"
-      }).then(function (result) {
-        self.setState({
-          options: result.options
-        });
-        result.defaultCode && self.onPropsChange(result.defaultCode);
-      });
+    
+    if(!this.state.inline &&(!self.props.paramsData||!self.props.paramsData.length) && this.state.options.length == 0){
+      await this.initOptionData(self.props);
     }
+
   }
 
-  UNSAFE_componentWillReceiveProps(nextProps) {
+  async UNSAFE_componentWillReceiveProps(nextProps) {
     if (!util.object.equal(nextProps.options, this.props.options)) {
       this.setState({
         options: nextProps.options
       })
     }
+    
+    if(!this.state.inline && (!nextProps.paramsData||!nextProps.paramsData.length) && this.state.options.length == 0){
+      await this.initOptionData(nextProps);
+    }
   }
 
   checkAll = () => {
@@ -63,6 +53,55 @@ class BirdMulti extends React.Component {
   onPropsChange = (value) => {
     this.props.onChange && this.props.onChange(value);
   }
+  
+  async initOptionData(nextProps){
+    let self = this;
+
+    
+    // if (self.props.url) {
+    //   request({
+    //     url: self.props.url,
+    //     method: "get"
+    //   }).then(function (result) {
+    //     self.setState({
+    //       options: result
+    //     })
+    //   });
+    // } 
+    if (self.props.url) {
+      let urlstr = self.props.url+"";
+      if(self.props.params&&nextProps.params.length>0){
+          urlstr += "?";
+          for(var param in nextProps.params){
+            urlstr += nextProps.params[param].key+"=";
+            for(var paramData in nextProps.paramsData){
+              if(nextProps.paramsData[paramData].key == nextProps.params[param].key){
+                urlstr += nextProps.paramsData[paramData].value+
+                "&";
+              }
+            }
+          }
+      }
+         
+          var result = await arequest({
+            url: urlstr,
+            method: "get"
+          });
+          
+          self.setState({options: result.result})
+          return result; 
+    }else if (self.props.dicKey) {
+      request({
+        url: config.api.getDic + self.props.dicKey,
+        method: "get"
+      }).then(function (result) {
+        self.setState({
+          options: result.result.options
+        });
+        result.result.defaultCode && self.onPropsChange(result.result.defaultCode);
+      });
+    }
+  }
 
   render() {
     let innerProps = this.props.innerProps || {};

+ 21 - 60
UI/src/components/Form/BirdSelector.js

@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import { request, config, util } from 'utils';
+import {  config, util } from 'utils';
+import { arequest } from 'utils/request';
 import { Select } from 'antd';
 
 const defaultInnerProps = {
@@ -40,7 +41,7 @@ class BirdSelector extends React.Component {
     });
   }
 
- componentDidMount() {
+  async componentDidMount() {
     let self = this;
     if (self.props.data.length > 0) return;
 
@@ -49,44 +50,8 @@ class BirdSelector extends React.Component {
     }
     
     if(!this.state.inline &&(!self.props.paramsData||!self.props.paramsData.length) && this.state.options.length == 0){
-      var result =  this.initOptionData(self.props);
-      ;
-      //this.setStateAsync({options: result})
+      await this.initOptionData(self.props);
     }
-    /*if (self.props.url) {
-      let urlstr = self.props.url+"";
-      if(self.props.params&&self.props.params.length>0){
-          urlstr += "?";
-          for(var param in self.props.params){
-            urlstr += self.props.params[param].key+"=";
-            for(var paramData in self.props.paramsData){
-              if(self.props.paramsData[paramData].key == self.props.params[param].key){
-                urlstr += self.props.paramsData[paramData].value+
-                "&";
-              }
-            }
-          }
-      }
-      request({
-        url: urlstr,
-        method: "get"
-      }).then(function (result) {
-        self.setState({
-          options: result
-        })
-      });
-    } else if (self.props.dicKey) {
-      request({
-        url: config.api.getDic + self.props.dicKey,
-        method: "get"
-      }).then(function (result) {
-        self.setState({
-          placeholder: result.placeholder,
-          options: result.options
-        });
-        result.defaultCode && self.onPropsChange(result.defaultCode);
-      });
-    }*/
   }
 
   async UNSAFE_componentWillReceiveProps(nextProps) {
@@ -101,29 +66,15 @@ class BirdSelector extends React.Component {
       })
     }
     if(!this.state.inline && (!nextProps.paramsData||!nextProps.paramsData.length) && this.state.options.length == 0){
-      var result =  this.initOptionData(nextProps);
-      
-      //this.setStateAsync({options: result});
+      await this.initOptionData(nextProps);
     }
-    /*
-    let self = this;
-    if(typeof(this.props.data)=="object" ){
-      this.props.data.then(result=>{
-        console.log("-->"+result);
-        self.setState({
-          options: result
-        }, () => {
-          console.log("==>"+this.state.options); // 12
-      })
-      });
-    }*/
   }
 
   onPropsChange(value) {
     this.props.onChange && this.props.onChange(value);
   }
 
-  initOptionData(nextProps){
+  async initOptionData(nextProps){
     let self = this;
     if (self.props.url) {
       let urlstr = self.props.url+"";
@@ -139,14 +90,24 @@ class BirdSelector extends React.Component {
             }
           }
       }
-      var dom = request({
-        url: urlstr,
+         
+          var result = await arequest({
+            url: urlstr,
+            method: "get"
+          });
+          
+          self.setState({options: result.result})
+          return result; 
+    }else if (self.props.dicKey) {
+      request({
+        url: config.api.getDic + self.props.dicKey,
         method: "get"
       }).then(function (result) {
-        self.setState({options: result})
-        return result;
+        self.setState({
+          options: result.result.options
+        });
+        result.result.defaultCode && self.onPropsChange(result.result.defaultCode);
       });
-      return dom;
     }
   }
 

+ 11 - 11
UI/src/pages/auth/bird-permission.js

@@ -19,7 +19,7 @@ class BirdGridPermissionPage extends React.Component {
         formOption:{modal:"",title:""},
     }
   }
-  
+
   /* 弹出框取消事件 */
   cancelClick() {
     this.setState({
@@ -88,19 +88,19 @@ class BirdGridPermissionPage extends React.Component {
       ],
       actions: [{ name: '按钮新增', onClick: function () {
           const fields=[
-            { title: "权限id", data: "Id", type: "number" },
-            { title: "权限名", data: "PermissionName", type: "text", editor: {}, query: true, isRequired: true },
-            { title: "权限url", data: "PermissionUrl", type: "text", editor: {}, query: true, isRequired: true },
-            { title: "类型", data: "AuthType", type: "dropdown", editor: {}, source: {data:[{value:'A',label:'按钮'}]}, query: true },
-            { title: "按钮类型", data: "ActionType", type: "dropdown", editor: {}, 
+            { title: "权限id", data: "id", type: "number" },
+            { title: "权限名", data: "name", type: "text", editor: {}, query: true, isRequired: true },
+            { title: "权限url", data: "url", type: "text", editor: {}, query: true, isRequired: true },
+            { title: "类型", data: "types", type: "dropdown", editor: {}, source: {data:[{value:'A',label:'按钮'}]}, query: true },
+            { title: "按钮类型", data: "actionType", type: "dropdown", editor: {}, 
               source: {
                 data:[{value:'1',label:'外部按钮'},{value:'2',label:'内部按钮'}]
               }, query: true },
-            { title: "权限图标", data: "Icon", type: "text", editor: {}, query: true },
-            { title: "父权限", data: "ParentId", type: "dropdown", editor: {},source: {url: '/web/auth/parents'} ,query: true },
-            { title: "是否禁用", data: "IsDelete", type: "switch", editor: {}, query: true },
-            { title: "角色", data: "Roleids", type: "multi", editor: {}, source: { url: '/web/user/role' }, query: true },
-            { title: "创建时间", data: "CreationDate", type: "datetime", query: true }
+            { title: "权限图标", data: "icon", type: "text", editor: {}, query: true },
+            { title: "父权限", data: "parentId", type: "dropdown", editor: {},source: {url: '/ums/resource/parents'} ,query: true },
+            { title: "是否禁用", data: "status", type: "switch", editor: {}, query: true },
+            { title: "角色", data: "roleIds", type: "multi", editor: {}, source: { url: '/ums/resource/roles' }, query: true },
+            { title: "创建时间", data: "createTime", type: "datetime", query: true }
           ];
           let formOption = {
             model: "add",

+ 30 - 30
UI/src/utils/request.js

@@ -72,37 +72,37 @@ const fetch = (options) => {
   );
 
   //拦截器
-  axios.interceptors.response.use(
-  response => {
-    if(response && response.data && response.data.messageCode){
-      switch (response.data.messageCode) {
+  // axios.interceptors.response.use(
+  // response => {
+  //   if(response && response.data && response.data.messageCode){
+  //     switch (response.data.messageCode) {
         
-        case 105:
-          util.auth.removeToken();
-          permission.clear();
-          //confirm('过期')
-          console.log('过期');
-          router.push('/login');
-          break;
-      }
-    }
-    return response
-  },
-  error => {
-    if (error.response) {
-      switch (error.response.status) {
-        case 401:
-          // 返回 401 清除token信息并跳转到登录页面
-          util.auth.removeToken();
-          permission.clear();
-          //confirm('过期')
-          console.log('过期');
-          router.push('/login');
-          break;
-      }
-    }
-    // return Promise.reject(error.response)   // 返回接口返回的错误信息
-  });
+  //       case 105:
+  //         util.auth.removeToken();
+  //         permission.clear();
+  //         //confirm('过期')
+  //         console.log('过期');
+  //         router.push('/login');
+  //         break;
+  //     }
+  //   }
+  //   return response
+  // },
+  // error => {
+  //   if (error.response) {
+  //     switch (error.response.status) {
+  //       case 401:
+  //         // 返回 401 清除token信息并跳转到登录页面
+  //         util.auth.removeToken();
+  //         permission.clear();
+  //         //confirm('过期')
+  //         console.log('过期');
+  //         router.push('/login');
+  //         break;
+  //     }
+  //   }
+  //   // return Promise.reject(error.response)   // 返回接口返回的错误信息
+  // });
 
   switch (method.toLowerCase()) {
     case 'get':