Browse Source

Merge remote-tracking branch 'origin/dev' into dev

heqinwei 7 years ago
parent
commit
42113f7845

+ 4 - 1
applications/document/document-server/src/main/resources/application.yml

@@ -73,4 +73,7 @@ mybatis:
   type-aliases-package: com.usoftchina.saas.document.entities
   mapper-locations: classpath:mapper/*.xml
 auth:
-  public-key: auth/pub.key
+  public-key: auth/pub.key
+ribbon:
+  ReadTimeout: 6000
+  ConnectTimeout: 6000

+ 2 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/PurchaseApplication.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.purchase;
 
 import com.usoftchina.saas.auth.client.EnableAuthClient;
+import com.usoftchina.saas.server.jdbc.EnableDynamicDataSource;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableFeignClients("com.usoftchina.saas")
 @EnableAuthClient
 @MapperScan("com.usoftchina.saas.purchase.mapper")
+@EnableDynamicDataSource
 public class PurchaseApplication {
     public static void main(String[] args) {
         SpringApplication.run(PurchaseApplication.class, args);

+ 7 - 10
base-servers/auth/auth-server/src/main/java/com/usoftchina/saas/auth/controller/AuthController.java

@@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -219,8 +218,8 @@ public class AuthController {
      * @param info
      * @return
      */
-    @GetMapping(value = "/sso/callback/{clientId}", produces = {"application/javascript"})
-    public String ssoCallback(HttpServletRequest request, HttpServletResponse response,
+    @GetMapping("/sso/callback/{clientId}")
+    public void ssoCallback(HttpServletRequest request, HttpServletResponse response,
                             @PathVariable(required = false) String clientId, CookieInfo info, String callback) throws IOException{
         if (null != info && null != info.getMobile()) {
             AccountDTO accountDTO = null;
@@ -231,8 +230,8 @@ public class AuthController {
                     accountDTO = createAccountByCookieInfo(info);
                 } else {
                     logger.error(result.getMessage());
-                    //ServletUtils.writeJsonPMessage(response, callback, false);
-                    return "successCallback({success:'0'})";
+                    ServletUtils.writeJsonPMessage(response, callback, false);
+                    return;
                 }
             } else {
                 accountDTO = result.getData();
@@ -242,8 +241,8 @@ public class AuthController {
                     Result updateResult = accountApi.update(BeanMapper.map(accountDTO, AccountUpdateDTO.class));
                     if (!updateResult.isSuccess()) {
                         logger.error(updateResult.getMessage());
-                        //ServletUtils.writeJsonPMessage(response, callback, false);
-                        return "successCallback({success:'0'})";
+                        ServletUtils.writeJsonPMessage(response, callback, false);
+                        return;
                     }
                 }
             }
@@ -265,10 +264,8 @@ public class AuthController {
                 socketMessageApi.sendToClient(clientId, "/sso/callback",
                         JsonUtils.toJsonString(new AuthDTO(tokenDTO, accountDTO)));
             }
-            //ServletUtils.writeJsonPMessage(response, callback, true);
-            return "successCallback({success:'1'})";
+            ServletUtils.writeJsonPMessage(response, callback, true);
         }
-        return "successCallback({success:'0'})";
     }
 
     /**

+ 15 - 0
frontend/saas-portal-web/static/set-token.html

@@ -0,0 +1,15 @@
+<script>
+    // iframe接收消息
+	window.addEventListener('message', function(e) {
+		if (e.source != window.parent) {
+            return;
+        }
+        var storeKey = 'app-state-session';
+        if (e.data) {
+            localStorage.setItem(storeKey, e.data);
+        } else {
+            localStorage.removeItem(storeKey);
+        }
+        window.parent.postMessage("success", "*");
+    });
+</script>

+ 15 - 1
frontend/saas-portal-web/yarn.lock

@@ -2901,7 +2901,7 @@ glob@7.0.5:
     once "^1.3.0"
     path-is-absolute "^1.0.0"
 
-glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
+glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3:
   version "7.1.3"
   resolved "http://registry.npm.taobao.org/glob/download/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
   dependencies:
@@ -6941,6 +6941,12 @@ uuid@^3.0.1, uuid@^3.3.2:
   version "3.3.2"
   resolved "http://registry.npm.taobao.org/uuid/download/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
 
+v-distpicker@^1.0.20:
+  version "1.0.21"
+  resolved "http://registry.npm.taobao.org/v-distpicker/download/v-distpicker-1.0.21.tgz#50356c68220586ada9131fe1160fabf0cf805294"
+  dependencies:
+    vue "^2.5.17"
+
 validate-npm-package-license@^3.0.1:
   version "3.0.4"
   resolved "http://registry.npm.taobao.org/validate-npm-package-license/download/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
@@ -7029,10 +7035,18 @@ vue-template-es2015-compiler@^1.5.3, vue-template-es2015-compiler@^1.6.0:
   version "1.6.0"
   resolved "http://registry.npm.taobao.org/vue-template-es2015-compiler/download/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
 
+vue@^2.5.17:
+  version "2.5.21"
+  resolved "http://registry.npm.taobao.org/vue/download/vue-2.5.21.tgz#3d33dcd03bb813912ce894a8303ab553699c4a85"
+
 vue@^2.5.2:
   version "2.5.17"
   resolved "http://registry.npm.taobao.org/vue/download/vue-2.5.17.tgz#0f8789ad718be68ca1872629832ed533589c6ada"
 
+vuex@^3.0.1:
+  version "3.0.1"
+  resolved "http://registry.npm.taobao.org/vuex/download/vuex-3.0.1.tgz#e761352ebe0af537d4bb755a9b9dc4be3df7efd2"
+
 w3c-hr-time@^1.0.1:
   version "1.0.1"
   resolved "http://registry.npm.taobao.org/w3c-hr-time/download/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"

+ 1 - 0
frontend/saas-web/app/view/core/base/BasePanel.scss

@@ -39,6 +39,7 @@
     }
 }
 .x-basepanel-pagingtoolbar{
+    padding: 6px 0 5px 8px;
     border:1px solid #abdaff !important;
     border-top-width: 0 !important;
 }

+ 3 - 5
frontend/saas-web/app/view/core/base/GridPanel.js

@@ -111,7 +111,7 @@ Ext.define('saas.view.core.base.GridPanel', {
                         text: '禁用',
                         handler: function(){
                             var form = this.ownerCt.ownerCt.ownerCt;
-                            me.onVastDeal(form._batchCloseUrl,'CLOSE');
+                            me.onVastDeal(form._batchCloseUrl,'BANNED');
                         },
                         menu: {
                             cls:'x-query-menu',
@@ -253,10 +253,8 @@ Ext.define('saas.view.core.base.GridPanel', {
         boxready: function(grid, width, height, eOpts) {
             var store = grid.getStore(),
             gridBodyBox = grid.body.dom.getBoundingClientRect(),
-            gridBodyBoxHeight = gridBodyBox.height;
-
-            var pageSize = Math.floor(gridBodyBoxHeight / 32);
-
+            gridBodyBoxHeight = gridBodyBox.height;//可能有滚动条
+            var pageSize = Math.floor(gridBodyBoxHeight / 33);
             store.setPageSize(pageSize);
         },
         itemClick: function(view,record,a,index,c) {

+ 1 - 1
frontend/saas-web/app/view/document/kind/ChildForm.js

@@ -216,7 +216,7 @@ Ext.define('saas.view.document.kind.ChildForm', {
                         grid.store.load();
                     }
                 }
-                if(relativeField&&relativeValue&&form.ownerCt._parent){
+                if(relativeField&&relativeValue&&form.ownerCt._parent&&form.ownerCt._parent.xtype!='document-kind'){
                     var grid = form.ownerCt._parent.down('grid');
                     var rec = grid.getSelectionModel().getLastSelected();
                     rec.set(relativeField,relativeValue);

+ 25 - 9
frontend/saas-web/app/view/viewport/ViewportController.js

@@ -23,8 +23,11 @@ Ext.define('saas.view.viewport.ViewportController', {
     },
 
     mainviewboxready: function() {
-        //初始化accountPage地址
-        document.getElementsByName('accountPage')[0].setAttribute('src',getTokenPage());
+        //初始化setSessionPage地址
+        Ext.DomHelper.insertHtml('beforeEnd', document.body, 
+            '<iframe name="setSessionPage" hidden src="' + 
+            Ext.manifest.server.accountCenter + '/static/set-token.html"></iframe>');
+
         if(!Ext.isChrome && !Ext.isFirefox) {
             saas.util.BaseUtil.showConfirm('温馨提示', '为了更好地呈现页面效果,推荐使用Chrome浏览器或火狐浏览器');
         }
@@ -77,7 +80,7 @@ Ext.define('saas.view.viewport.ViewportController', {
             var hasValidCookie = Ext.util.Cookies.get('uid')?me.getAccountCookie():false;
             if(!hasValidCookie){
                 if(window.location.host.indexOf('.usoftchina.com')>-1){
-                    window.location.href = Ext.manifest.server.accountCenter
+                    me.redirectPortal();
                 }else{
                     me.redirectTo('login', {replace: true});
                 }
@@ -122,8 +125,8 @@ Ext.define('saas.view.viewport.ViewportController', {
                         me.saveSession(session);
                     }
                     hasValidCookie = true
-                }else{
-                    window.location.href = Ext.manifest.server.accountCenter
+                } else{
+                    me.redirectPortal();
                 }
             },
             failure: function(response, opts) {
@@ -202,10 +205,8 @@ Ext.define('saas.view.viewport.ViewportController', {
             me.originalRoute = Ext.History.getToken();
             me.terminateSession();
             view.unmask();
-            //跳转到账户中心
-            const frame = window.frames[window.frames.length - 1];
-            frame.postMessage('removeToken','*');
-            window.location.href = getAccountPage();
+            me.syncSessionToPortal();
+            me.redirectPortal();
             //me.redirectTo('login', {replace: true});
         });
     },
@@ -221,6 +222,7 @@ Ext.define('saas.view.viewport.ViewportController', {
                 .then(function(newSession) {
                     newSession.get('account').companyId = companyId;
                     me.initiateSession(newSession);
+                    me.syncSessionToPortal(newSession);
                 })
                 .catch(function(error) {
                     saas.util.BaseUtil.showErrorToast(error.message);
@@ -230,6 +232,20 @@ Ext.define('saas.view.viewport.ViewportController', {
                     window.location.reload();
                 }); 
         }        
+    },
+    /**
+     * 同步session到门户
+     * @param {} session 
+     */
+    syncSessionToPortal: function(session) {
+        const frame = window.frames[window.frames.length - 1];
+        frame.postMessage(session ? JSON.stringify(session) : '', '*');
+    },
+    /**
+     * 跳转门户
+     */
+    redirectPortal: function() {
+        window.location.href = Ext.manifest.server.accountCenter;
     }
 });
 

+ 1 - 1
frontend/saas-web/electron/login.html

@@ -47,7 +47,7 @@
                 var session = data.token, account = data.account;
                 account.companies = account.companies || [];
                 session.account = account;
-                ipc.send('session.change', session);
+                ipc.send('session.change', JSON.stringify(session));
             });
             var frame = document.createElement("iframe");
             frame.setAttribute("src", "https://sso.ubtob.com/sassLogin?appId=sp&baseUrl=" + 

+ 6 - 2
frontend/saas-web/electron/main.js

@@ -10,7 +10,7 @@ let mainWindow;
 ipcMain.on('session.change', (event, arg) => {
     if (arg) {
         loginWindow && loginWindow.close();
-        createMainWindow();
+        createMainWindow(arg);
     } else {
         mainWindow && mainWindow.close();
         createLoginWindow();
@@ -34,7 +34,7 @@ function createLoginWindow() {
     });
 }
 
-function createMainWindow () {
+function createMainWindow (session) {
     mainWindow = new BrowserWindow({ width: 1280, height: 720, show: false });
     mainWindow.once('ready-to-show', function(){
         mainWindow.maximize();
@@ -50,6 +50,10 @@ function createMainWindow () {
         mainWindow.webContents.openDevTools();
     }
 
+    mainWindow.webContents.on("did-finish-load", function() {
+        mainWindow.webContents.executeJavaScript('\
+            localStorage.setItem("app-state-session", decodeURIComponent("' + encodeURIComponent(session) + '"))');
+    });
     mainWindow.on('closed', function () {
         mainWindow = null;
     });

+ 2 - 11
frontend/saas-web/index.html

@@ -6,21 +6,12 @@
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
 
     <title>云进销存 - U企云服</title>
-    <link rel="icon" href="/resources/images/favicon.png" type="image/x-icon">
+    <link rel="icon" href="./resources/images/favicon.png" type="image/x-icon">
     <!-- 图片动画效果样式导入 -->
-    <link type="text/css" rel="stylesheet" href="/resources/othcss/imagehover.css" />
+    <link type="text/css" rel="stylesheet" href="./resources/othcss/imagehover.css" />
 
     <!-- The line below must be kept intact for Sencha Cmd to build your application -->
     <script id="microloader" data-app="a20e1670-7932-41f6-8e9c-55b77cba3f26" type="text/javascript" src="bootstrap.js"></script>
-    <script>
-        function getTokenPage(){
-            return Ext.manifest.server.accountCenter + "/remove-token.html"
-        }
-        function getAccountPage(){
-            return Ext.manifest.server.accountCenter
-        }
-    </script>
 </head>
-<iframe name="accountPage" hidden></iframe>
 <body class="launching"></body>
 </html>