Browse Source

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

Lgx 4 years ago
parent
commit
adea58b2f3

+ 8 - 5
UI/src/components/Form/BirdButton.js

@@ -54,10 +54,12 @@ class BirdButton extends React.Component {
     }).then(data => {
       // 改为sso token
       if(data.success){
-        this.setState({ token: data.result.access_token })
+        // this.setState({ token: data.result.access_token })
         var user = util.auth.getUser();
-        user.staffid = data.result.access_token;
-        util.auth.setUser(user);
+        if(user){
+          user.staffid = data.result.access_token;
+          util.auth.setUser(user);
+        }
         util.auth.setToken(data.result.access_token);
       }else{
         util.auth.removeToken();
@@ -83,8 +85,9 @@ class BirdButton extends React.Component {
       props.onClick = () => {
         var reqInterceptor = axios.interceptors.request.use(config => {
           this.setState({ loading: true });
-          if (this.state.token) {
-            config.headers['bird-idempotency'] = this.state.token;
+          // if (this.state.token) {
+          if (util.auth.getToken()) {
+            config.headers['bird-idempotency'] = util.auth.getToken();
           }
           return config;
         });

+ 13 - 13
UI/src/layouts/components/user/UserAvatar.js

@@ -42,9 +42,9 @@ class UserAvatar extends React.Component {
       message.error("两次输入密码不一致");
       return;
     }
-
+    pass['staffid'] = this.state.curUser.staffid;
     request({
-      url: '/web/user/modifypwd?staffid='+this.state.curUser.staffid,
+      url: '/web/user/modifypwd',
       method: 'POST',
       data: pass
     }).then((rep) => {console.log(rep)
@@ -65,19 +65,19 @@ class UserAvatar extends React.Component {
       permission.clear();
         
       if(this.state.curUser){
-        request({
-          url: '/web/login/logout?staffId='+this.state.curUser.staffid,
-          method: 'POST',
-          data: {}
-        }).then((rep) => {
-          if(rep.success){
+        // request({
+        //   url: '/web/login/logout?staffId='+this.state.curUser.staffid,
+        //   method: 'POST',
+        //   data: {}
+        // }).then((rep) => {
+        //   if(rep.success){
             message.success("退出成功");
             window.location.href = "/login";
-          }
-          else{
-            message.error(rep.msg);
-          }
-        })
+          // }
+          // else{
+          //   message.error(rep.msg);
+          // }
+        // })
       }else{
         window.location.href = "/login";
       }

+ 43 - 24
UI/src/layouts/layoutTwo/layoutTwo.js

@@ -15,7 +15,7 @@ import Breadcrumb from '../components/Bread/Breadcrumb';
 import MessageBar from '../components/message/messagebar';
 import TopTabs from './toptaps/toptaps';
 // const { TabPane } = Tabs;
-import * as menuService from 'services/menus';
+import * as menuService from 'services/menus'
 
 const { Header, Content } = Layout;
 const { openPages, iconFontJS, iconFontCSS, logo } = config;
@@ -62,30 +62,49 @@ const LayoutTwo = ({ children, dispatch, app, loading, location }) => {
     let parentId = clickedKeys[0];
     if(clickedKeys[0] === "264"){
       parentId = "";
-    }
-    request({
-      url: config.api.menus,  
-      method: 'get',
-      data: {type:"U",ParentId:parentId}
-    }).then(menus => {
-      let menuHash = {}, openKeys = [];
-      menus = util.json.generateNode(menus);
+    } 
+      
+      var token = util.auth.getToken();
+      request({
+        url: config.api.menus,  
+        method: 'get',
+        data: {types:"1",ParentId:parentId},
+        dataHeader:{headers: {'Sso-Token': token}}
+      }).then(menus => {
+        
+        // let menus = yield call(query, {});
 
-      menus.forEach(item => { menuHash[item.id] = item });
-      if (menus.length > 0) {
-        openKeys = [`sMenu_${menus[0].id}`];
-      }
-      let menuTree = arrayToTree(menus, 'id', 'parentId');
-      dispatch({
-        type: 'app/updateState', payload: {
-          menus: menuTree,
-          cfMenu: menuTree.length > 0 ? menuTree[0] : {},
-          menuHash,
-          openKeys,
-          topOpenKeys: clickedKeys
+        let menuHash = {}, openKeys = [];
+        menus = util.json.generateNode(menus);
+
+        menus.forEach(item => { menuHash[item.id] = item });
+        if (menus.length > 0) {
+          openKeys = [`sMenu_${menus[0].id}`];
+        }
+        let menuTree = arrayToTree(menus, 'id', 'parentId');
+        dispatch({
+          type: 'app/updateState', payload: {
+            menus: menuTree,
+            cfMenu: menuTree.length > 0 ? menuTree[0] : {},
+            menuHash,
+            openKeys,
+            topOpenKeys: clickedKeys
+          }
+        });
+      }).catch((error) => {
+        const { response } = error
+        let msg
+        let statusCode
+        if (response && response instanceof Object) {
+          const { data, statusText } = response
+          statusCode = response.status
+          msg = data.message || statusText
+        } else {
+          statusCode = 600
+          msg = error.message || 'Network Error'
         }
+        message.error(msg);
       });
-    });
   }
 
   const remove = function(menuPath,lastIndex){
@@ -121,7 +140,7 @@ const LayoutTwo = ({ children, dispatch, app, loading, location }) => {
   
   const targetPanes = globalPanes.filter(pane => pane.key == (menuData == undefined?"252":menuData.id)); //当前页面panel
   if(targetPanes&&targetPanes.length>0){
-    activeKey = targetPanes[0].key;
+    activeKey = ''+targetPanes[0].key;
     // globalPanes.map((v,index)=>{
     //   if(v.key === activeKey)
     //   v.content = children;
@@ -135,7 +154,7 @@ const LayoutTwo = ({ children, dispatch, app, loading, location }) => {
       globalPanes.push({ title: typeof(menuData) === 'undefined'?"仪表盘":menuData.name, content:children, 
       key: typeof(menuData) === 'undefined'?"252":menuData.id,
       menuPath:menuPath,closable:true });
-      activeKey = menuData == undefined?"252":menuData.id;
+      activeKey = ''+menuData == undefined?"252":menuData.id;
       // globalPanes = panes;
     }
   }

+ 40 - 14
UI/src/models/app.js

@@ -57,21 +57,47 @@ export default {
 
       let user = util.auth.getUser();
       if (user) {
-        let menus = yield call(menuService.query,{type:"U",parentId:""});
+        let menusData = yield call(menuService.query,{types:"1",parentId:""});
+        let menus = [];
+        if(menusData.success){
+          menus = menusData.result;
+        }else{
+          util.auth.removeToken();
+          permission.clear();
+         //  window.location.href = "/";
+          yield put(routerRedux.push({
+           pathname: '/',
+           search: queryString.stringify({
+             from: ''
+           })
+         }))
+        }
         let menuHash = {}, openKeys = [];
 
-        let topMenus = yield call(menuService.query,{type:"M"});
         let topOpenKeys = [];
         if(menus && menus.length > 0){
-            //顶部菜单初始化
-            let topMenusNode = util.json.generateNode(topMenus);
+            let topMenusData = yield call(menuService.query,{types:"3"});
+            let topMenus = [];
 
-            topMenusNode.forEach(item => { menuHash[item.id] = item });
-            if (topMenusNode.length > 0) {
-              topOpenKeys = [`${topMenusNode[0].id}`];
+            if(topMenusData.success){ 
+              topMenus = topMenusData.result;
+            }else{
+              //什么都不做 
             }
-            let topMenuTree = arrayToTree(topMenusNode, 'id', 'parentId');
-          
+
+            let topMenusNode = [];
+            let topMenuTree = [];
+            if(topMenus && topMenus.length>0){
+              //顶部菜单初始化
+              topMenusNode = util.json.generateNode(topMenus);
+
+              topMenusNode.forEach(item => { menuHash[item.id] = item });
+              if (topMenusNode.length > 0) {
+                topOpenKeys = [`${topMenusNode[0].id}`];
+              }
+              topMenuTree = arrayToTree(topMenusNode, 'id', 'parentId');
+            }
+
             //侧边菜单初始化
             let menusNode = util.json.generateNode(menus);
 
@@ -82,11 +108,11 @@ export default {
             let menuTree = arrayToTree(menusNode, 'id', 'parentId');
           
   
-          let permissions = permission.getPermissions();
-          if (!permissions) {
-            permissions = yield call(permissionsService.query);
-            permission.setPermissions(permissions)
-          }
+          // let permissions = permission.getPermissions();//接口权限
+          // if (!permissions) {
+          //   permissions = yield call(permissionsService.query,{});
+          //   permission.setPermissions(permissions)
+          // }
   
           //获取当前location的menupath 用于刷新时面包屑的menupath丢失
           var menuPath1 = [{id:"252",name:"仪表盘",url:"/dashboard"}];

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

@@ -61,25 +61,25 @@ class BirdGridPermissionPage extends React.Component {
     let gridOption = {
       title: "权限资源",
       url: {
-        read: "/web/auth/index",
-        add: "/web/auth/add",
-        edit: "/web/auth/edit",
-        delete: "/web/auth/delete"
+        read: "/ums/resource/searchByCondition",
+        add: "/ums/resource//add",
+        edit: "/ums/resource/edit",
+        delete: "/ums/resource/delete"
       },
       checkable: true,
       sortField:"Sort",
       sortDirection:0,
       columns: [
-        { 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: "AuthType", type: "dropdown", editor: {}, source: { url: '/web/auth/authType' }, 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: "Status", type: "switch", editor: {}, query: true },
+        { 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: "AuthType", type: "dropdown", editor: {}, source: { url: '/web/auth/authType' }, 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: "status", type: "switch", editor: {}, query: true },
         // { title: "排序", data: "Sort", type: "number" },
         // { title: "角色", data: "Roleids", type: "multi", editor: {}, source: { url: '/web/user/role' }, query: true },
-        { title: "创建时间", data: "CreateTime", type: "datetime", query: true },
+        { title: "创建时间", data: "createTime", type: "datetime", query: true },
         {
           title: "操作选项", type: "command", actions: []
         }
@@ -115,18 +115,18 @@ class BirdGridPermissionPage extends React.Component {
       }]
     };
     
-    let treeOption = {
-      url: "/web/auth/menusTree?type=U','O','M",
-      canSelectFolder: false,
-      expandAll: true,
-      paramName:"ParentId",
-      onSelect: (value,selectKeys,type) => {
-        if(type === "folder"){
-          self.refs.tg.getTree().setState({selectedKeys: selectKeys});
-        }
-      },
-      title:"树实例"
-    };
+    // let treeOption = {
+    //   url: "/web/auth/menusTree?type=U','O','M",
+    //   canSelectFolder: false,
+    //   expandAll: true,
+    //   paramName:"ParentId",
+    //   onSelect: (value,selectKeys,type) => {
+    //     if(type === "folder"){
+    //       self.refs.tg.getTree().setState({selectedKeys: selectKeys});
+    //     }
+    //   },
+    //   title:"树实例"
+    // };
 
     return <div>
       {/* <BirdTreeGrid gridOption={gridOption}

+ 34 - 34
UI/src/pages/login/model.js

@@ -17,45 +17,45 @@ export default {
       
       // let data = {};
       try{
-      const data = yield call(login, payload)
-      const { locationQuery } = yield select(_ => _.app)
-      if (data.success) {
-        console.log(data);
-        const user = decode(data.result.access_token);
-        user.staffid = data.result.access_token;
-        util.auth.setUser(user);
-        util.auth.setToken(data.result.access_token);
-        const { from } = locationQuery
-        yield put({ type: 'app/query' })
-        if (from !=undefined&& from && from !== '/login') {
-          yield put(routerRedux.push(from))
-        } else {
-          if(data.user){
-            if(data.user.roleid==2){
-              yield put(routerRedux.push('/'))
-            }else if(data.user.roleid==3){
-              yield put(routerRedux.push('/purchasedemand/purchasedemand'))
-            }else if(data.user.roleid==1){
-              yield put(routerRedux.push('/dashboard'))
+        const data = yield call(login, payload)
+        const { locationQuery } = yield select(_ => _.app)
+        if (data.success) {
+          console.log(data);
+          const user = decode(data.result.access_token);
+          user.staffid = data.result.access_token;
+          util.auth.setUser(user);
+          util.auth.setToken(data.result.access_token);
+          const { from } = locationQuery
+          yield put({ type: 'app/query' })
+          if (from !=undefined&& from && from !== '/login') {
+            yield put(routerRedux.push(from))
+          } else {
+            if(data.user){
+              if(data.user.roleid==2){
+                yield put(routerRedux.push('/'))
+              }else if(data.user.roleid==3){
+                yield put(routerRedux.push('/purchasedemand/purchasedemand'))
+              }else if(data.user.roleid==1){
+                yield put(routerRedux.push('/dashboard'))
+              }else{
+                yield put(routerRedux.push('/dashboard'))
+              }
             }else{
-              yield put(routerRedux.push('/dashboard'))
+              yield put(routerRedux.push('/auth/bird-permission'))
             }
-          }else{
-            yield put(routerRedux.push('/auth/bird-permission'))
           }
+        } else {
+          if(data.msg)
+          message.error(data.msg);
+          //throw data
         }
-      } else {
-        if(data.msg)
-        message.error(data.msg);
-        //throw data
+        
+      }catch (e) {
+        console.error(e.message);
+        // onError(e)
+        
+        // e.preventDefault();
       }
-      
-    }catch (e) {
-      console.error(e.message);
-      // onError(e)
-      
-      // e.preventDefault();
-    }
     }
   }
 }

+ 23 - 7
UI/src/services/menus.js

@@ -1,10 +1,26 @@
 import { request, config } from 'utils'
 
-export async function query(params) {
-  let menus = request({
-    url: config.api.menus,  
-    method: 'get',
-    data: params
-  });
+
+const { api,ClientId,ClientSecret,ApplicationKey } = config
+export async function query(data) {
+  data['client_id'] = ClientId;
+  data['client_secret'] = ClientSecret;
+  data['applicationKey'] = ApplicationKey;
+  
+  let types = data['types'];
+  let menus = [];
+  try{
+    menus= request({
+      url: config.api.menus+'?types='+types,
+      method: 'post',
+      data: data
+    });
+    
+  }catch (e) {
+    console.error(e.message);
+    // onError(e)
+    
+    // e.preventDefault();
+  }
   return menus;
-}
+}

+ 9 - 3
UI/src/services/permissions.js

@@ -1,9 +1,15 @@
 import { request, config } from 'utils'
+  
+const { api,ClientId,ClientSecret,ApplicationKey } = config
 
-export async function query(params) {
+export async function query(data) {
+
+  data['client_id'] = ClientId;
+  data['client_secret'] = ClientSecret;
+  data['applicationKey'] = ApplicationKey; 
   return request({
     url: config.api.permissions,
-    method: 'get',
-    data: params
+    method: 'post',
+    data: data
   })
 }

+ 3 - 3
UI/src/utils/config.js

@@ -5,7 +5,7 @@ const APIV3Auth = 'http://localhost:8030'
 const JAPIV = 'http://localhost:8005'
 const APIV4 = 'http://localhost:8005'
 module.exports =  {
-  name: '亮健会员中心',
+  name: '亮健会员系统管理',
   prefix: 'bird',
   footerText: 'bird admin  © 2018 360lj.com',
   logo: '/logo.svg',
@@ -46,7 +46,7 @@ module.exports =  {
     userLogout: `${APIV3Auth}/web/login/logout`,
     //menus: `${APIV1}/menus`,
     // menus: `${APIV3}/web/auth/menus`,
-    menus: `${APIV3Auth}/ums/oauth2/list/permission?types=1`,
+    menus: `${APIV3Auth}/ums/oauth2/list/permission`,//?types=1 两种菜单类型 顶部菜单和左侧菜单
     getDic:`${APIV1}/getdic?key=`,
 
     upload:`${APIV3}/web/upload/uploadprofile`,
@@ -54,8 +54,8 @@ module.exports =  {
     getFileName:`${APIV3}/`,
     // getOperationToken:`${APIV3}/web/login/getOperationToken`,
     getOperationToken: `${APIV3Auth}/ums/oauth2/accessToken?grant_type=refresh_token`,
-    permissions:`${APIV3}/ums/oauth2/list/permission?types=2`,
     // permissions:`${APIV3}/web/auth/permissions`
+    permissions:`${APIV3Auth}/ums/oauth2/list/permission?types=2`,
   },
   JAPIV, 
 }