소스 검색

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

jinsy 7 년 전
부모
커밋
e377d21a3b
16개의 변경된 파일226개의 추가작업 그리고 111개의 파일을 삭제
  1. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java
  2. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java
  3. 3 2
      applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml
  4. 44 41
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/MoneyReportServiceImpl.java
  5. 5 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java
  6. 2 0
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/StocktakingServiceImpl.java
  7. 4 4
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/CompanyApi.java
  8. 13 0
      base-servers/auth/auth-dto/src/main/java/com/usoftchina/saas/auth/dto/AuthDTO.java
  9. 11 8
      base-servers/auth/auth-server/src/main/java/com/usoftchina/saas/auth/controller/AuthController.java
  10. 5 0
      frontend/saas-web/app/Application.scss
  11. 3 0
      frontend/saas-web/app/view/core/base/ImportWindow.js
  12. 9 9
      frontend/saas-web/app/view/core/form/FormPanel.js
  13. 46 16
      frontend/saas-web/app/view/core/form/FormPanelController.js
  14. 33 27
      frontend/saas-web/app/view/core/report/ReportPanel.js
  15. 1 1
      frontend/saas-web/app/view/core/report/ReportPanelController.js
  16. 45 1
      frontend/saas-web/app/view/viewport/ViewportController.js

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java

@@ -24,7 +24,7 @@ public interface BankinformationMapper extends CommonBaseMapper<Bankinformation>
     List<Bankinformation> selectBankinformationBycondition(@Param("con") String con, @Param("companyId") Long companyId);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
-    String selectBankcode(String bk_bankcode);
+    String selectBankcode(@Param("bk_bankcode") String bk_bankcode, @Param("companyId") Long companyId);
     Long selectBankId(String bk_bankcode);
 
     void check(Map<String, Object> map);

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java

@@ -52,7 +52,7 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
         bankinformation.setCreatorName(BaseContextHolder.getUserName());
         int bid = Math.toIntExact(bankinformation.getId());
 
-        String bktion = bankinformationMapper.selectBankcode(bankinformation.getBk_bankcode());
+        String bktion = bankinformationMapper.selectBankcode(bankinformation.getBk_bankcode() ,BaseContextHolder.getCompanyId());
         //先判断ID,再判断编号
         if (bankinformation.getId() == 0)
         {

+ 3 - 2
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -321,8 +321,9 @@
     </select>
 
 
-  <select id="selectBankcode" parameterType="java.lang.String" resultType="java.lang.String">
-        select bk_bankcode from bankinformation where bk_bankcode = #{bk_bankcode,jdbcType=VARCHAR}
+  <select id="selectBankcode" resultType="java.lang.String">
+        select bk_bankcode from bankinformation where
+        bk_bankcode = #{bk_bankcode,jdbcType=VARCHAR} and companyId = #{companyId}
     </select>
 
   <select id="selectBankId" parameterType="java.lang.String" resultType="java.lang.Long">

+ 44 - 41
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/MoneyReportServiceImpl.java

@@ -98,7 +98,6 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         }
 
         String res = null;
-        VendOrCustAdd vendOrCustAdd = new VendOrCustAdd();
         List<Map<String, Double>> list1 = new ArrayList<>();
         if ("Supplier".equals(type)) {
             list = vendorAcountViewMapper.selectByCondition(con, companyId);
@@ -107,26 +106,28 @@ public class MoneyReportServiceImpl implements MoneyReportService {
                 Integer vid = new Integer(0);
                 vid = vendorAcountViewMapper.getId(vendorAcountView.getPi_vendcode(), Long.valueOf(vendorAcountView.getCompanyId()));
                 Integer ym = Integer.valueOf(req.getYm());
-                vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, ym, Long.valueOf(vendorAcountView.getCompanyId()));
-                vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                        + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                        - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
-                //封装成list
-                Map<String, Double> map1 = new HashMap<>();
-                map1.put("beginamount", vendOrCustAdd.getBeginamount());
-                list1.add(map1);
-
-                Map<String, Double> map2 = new HashMap<>();
-                map2.put("nowamount", vendOrCustAdd.getNowamount());
-                list1.add(map2);
-
-                Map<String, Double> map3 = new HashMap<>();
-                map3.put("nowpay", vendOrCustAdd.getNowpay());
-                list1.add(map3);
-
-                Map<String, Double> map4 = new HashMap<>();
-                map4.put("nowbalance", vendOrCustAdd.getNowbalance());
-                list1.add(map4);
+                VendOrCustAdd vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, ym, Long.valueOf(vendorAcountView.getCompanyId()));
+                if (vendOrCustAdd != null) {
+                    vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
+                            + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
+                            - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
+                    //封装成list
+                    Map<String, Double> map1 = new HashMap<>();
+                    map1.put("beginamount", vendOrCustAdd.getBeginamount());
+                    list1.add(map1);
+
+                    Map<String, Double> map2 = new HashMap<>();
+                    map2.put("nowamount", vendOrCustAdd.getNowamount());
+                    list1.add(map2);
+
+                    Map<String, Double> map3 = new HashMap<>();
+                    map3.put("nowpay", vendOrCustAdd.getNowpay());
+                    list1.add(map3);
+
+                    Map<String, Double> map4 = new HashMap<>();
+                    map4.put("nowbalance", vendOrCustAdd.getNowbalance());
+                    list1.add(map4);
+                }
             }
         } else if("payDetail".equals(type)){
             list = paydetailViewMapper.selectByCondition(con, companyId);
@@ -154,26 +155,28 @@ public class MoneyReportServiceImpl implements MoneyReportService {
 
                 vid = customerCheckViewMapper.getId(customerCheckView.getPi_custcode(), Long.valueOf(customerCheckView.getCompanyId()));
                 Integer ym = Integer.valueOf(req.getYm());
-                vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, ym, Long.valueOf(customerCheckView.getCompanyId()));
-                vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                        + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                        - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
-                //封装成list
-                Map<String, Double> map1 = new HashMap<>();
-                map1.put("beginamount", vendOrCustAdd.getBeginamount());
-                list1.add(map1);
-
-                Map<String, Double> map2 = new HashMap<>();
-                map2.put("nowamount", vendOrCustAdd.getNowamount());
-                list1.add(map2);
-
-                Map<String, Double> map3 = new HashMap<>();
-                map3.put("nowpay", vendOrCustAdd.getNowpay());
-                list1.add(map3);
-
-                Map<String, Double> map4 = new HashMap<>();
-                map4.put("nowbalance", vendOrCustAdd.getNowbalance());
-                list1.add(map4);
+                VendOrCustAdd vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, ym, Long.valueOf(customerCheckView.getCompanyId()));
+                if (vendOrCustAdd != null) {
+                    vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
+                            + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
+                            - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
+                    //封装成list
+                    Map<String, Double> map1 = new HashMap<>();
+                    map1.put("beginamount", vendOrCustAdd.getBeginamount());
+                    list1.add(map1);
+
+                    Map<String, Double> map2 = new HashMap<>();
+                    map2.put("nowamount", vendOrCustAdd.getNowamount());
+                    list1.add(map2);
+
+                    Map<String, Double> map3 = new HashMap<>();
+                    map3.put("nowpay", vendOrCustAdd.getNowpay());
+                    list1.add(map3);
+
+                    Map<String, Double> map4 = new HashMap<>();
+                    map4.put("nowbalance", vendOrCustAdd.getNowbalance());
+                    list1.add(map4);
+                }
             }
         }else if ("accountdetails".equals(type)){
             list = accountDetailsViewMapper.selectByCondition(con, companyId);

+ 5 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java

@@ -552,6 +552,11 @@ public class SaleServiceImpl implements SaleService{
     @Override
     public DocBaseDTO saleTurnPurchase(Long id) {
         Sale sale = saleMapper.selectByPrimaryKey(id);
+
+        //检查销售订单是否关闭
+        if(sale.getSa_sendstatuscode().equals("CLOSE")){
+            throw new BizException(BizExceptionCode.SALE_CLOSE.getCode(),BizExceptionCode.SALE_CLOSE.getMessage());
+        }
         List<SaleList> dateilList = saleListMapper.selectSaleListByCondition("sa_id="+id,BaseContextHolder.getCompanyId());
 
         //判断是否已转采购单

+ 2 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/StocktakingServiceImpl.java

@@ -128,6 +128,7 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
                 prodInDetail.setCompanyId(companyId);
                 prodInDetail.setCreateTime(new Date());
                 prodInDetail.setCreatorId(userId);
+                prodInDetail.setPd_remark("盘盈单");
                 prodIODetailMapper.insertSelective(prodInDetail);
             }
             DocBaseDTO baseDTOIN = new DocBaseDTO(inid,piInno,"其它入库单");
@@ -167,6 +168,7 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
                 prodOutDetail.setCompanyId(companyId);
                 prodOutDetail.setCreateTime(new Date());
                 prodOutDetail.setCreatorId(userId);
+                prodOutDetail.setPd_remark("盘亏单");
                 prodIODetailMapper.insertSelective(prodOutDetail);
             }
             DocBaseDTO baseDTOOUT = new DocBaseDTO(outid,piOutno,"其它出库单");

+ 4 - 4
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/CompanyApi.java

@@ -39,7 +39,7 @@ public interface CompanyApi {
      * @return
      */
     @GetMapping(path = "/company/read", params = "name")
-    Result<CompanyDTO> getCompanyByName(@RequestParam String name);
+    Result<CompanyDTO> getCompanyByName(@RequestParam("name") String name);
 
     /**
      * 按商业登记证号查找
@@ -48,7 +48,7 @@ public interface CompanyApi {
      * @return
      */
     @GetMapping(path = "/company/read", params = "businessCode")
-    Result<CompanyDTO> getCompanyByBusinessCode(@RequestParam String businessCode);
+    Result<CompanyDTO> getCompanyByBusinessCode(@RequestParam("businessCode") String businessCode);
 
     /**
      * 按企业uu查找
@@ -57,7 +57,7 @@ public interface CompanyApi {
      * @return
      */
     @GetMapping(path = "/company/read", params = "uu")
-    Result<CompanyDTO> getCompanyByUu(@RequestParam Long uu);
+    Result<CompanyDTO> getCompanyByUu(@RequestParam("uu") Long uu);
 
     /**
      * 按ID查找
@@ -66,5 +66,5 @@ public interface CompanyApi {
      * @return
      */
     @GetMapping(path = "/company/read/{id}")
-    Result<CompanyDTO> getCompanyById(@PathVariable Long id);
+    Result<CompanyDTO> getCompanyById(@PathVariable("id") Long id);
 }

+ 13 - 0
base-servers/auth/auth-dto/src/main/java/com/usoftchina/saas/auth/dto/AuthDTO.java

@@ -11,6 +11,19 @@ import java.io.Serializable;
 public class AuthDTO implements Serializable{
     private TokenDTO token;
     private AccountDTO account;
+    /**
+     * 用户登录优软云后,直接地址栏上进入saas系统.
+     * 通过cookie中的企业UU判断saas是否已开通,开通则返回companyId给前端直接登录该企业
+     */
+    private Long companyId;
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
 
     public AuthDTO() {
     }

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

@@ -2,14 +2,11 @@ package com.usoftchina.saas.auth.controller;
 
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.account.api.AccountApi;
+import com.usoftchina.saas.account.api.CompanyApi;
 import com.usoftchina.saas.account.constant.AccountType;
-import com.usoftchina.saas.account.dto.AccountCopyDTO;
-import com.usoftchina.saas.account.dto.AccountDTO;
-import com.usoftchina.saas.account.dto.AccountUpdateDTO;
-import com.usoftchina.saas.account.dto.CompanyBaseDTO;
+import com.usoftchina.saas.account.dto.*;
 import com.usoftchina.saas.auth.common.cookie.CookieHelper;
 import com.usoftchina.saas.auth.common.cookie.CookieInfo;
-import com.usoftchina.saas.auth.common.cookie.CookieUtils;
 import com.usoftchina.saas.auth.common.jwt.JwtHelper;
 import com.usoftchina.saas.auth.common.jwt.JwtInfo;
 import com.usoftchina.saas.auth.common.jwt.JwtToken;
@@ -34,8 +31,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.http.server.reactive.ServerHttpResponse;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -57,6 +52,9 @@ public class AuthController {
     @Autowired
     private AccountApi accountApi;
 
+    @Autowired
+    private CompanyApi companyApi;
+
     @Value("${auth.public-key}")
     private String publicKeyPath;
 
@@ -203,7 +201,12 @@ public class AuthController {
             JwtInfo jwtInfo = new JwtInfo(appId, companyId, accountDTO.getId(), accountDTO.getUsername(), accountDTO.getRealname());
             JwtToken jwtToken = JwtHelper.generateToken(jwtInfo, privateKeyPath, expire);
             TokenDTO tokenDTO = BeanMapper.map(jwtToken, TokenDTO.class);
-            return Result.success(new AuthDTO(tokenDTO, accountDTO));
+            AuthDTO authDTO = new AuthDTO(tokenDTO, accountDTO);
+            CompanyDTO companyDTO = companyApi.getCompanyByUu(info.getSpaceUU()).getData();
+            if (null != companyDTO){
+                authDTO.setCompanyId(companyDTO.getId());
+            }
+            return Result.success(authDTO);
         }
         return Result.error(ExceptionCode.COOKIE_ILLEGAL_ARGUMENT);
     }

+ 5 - 0
frontend/saas-web/app/Application.scss

@@ -465,4 +465,9 @@ div::-webkit-scrollbar-track {
       background-size: 16px 16px;
       background-position: center;
   }
+}
+
+/** tab **/
+.x-tab-default.x-tab-active .x-tab-close-btn {
+  color: #34BAF6;
 }

+ 3 - 0
frontend/saas-web/app/view/core/base/ImportWindow.js

@@ -131,6 +131,9 @@ Ext.define('saas.view.core.base.ImportWindow', {
                     buttonConfig:{
                         xtype:'button',
                         handler:function(b){
+                            var caller = b.ownerCt.ownerCt.ownerCt.ownerCt.caller;
+                            //获取模版
+                            window.location.href = 'http://192.168.253.58:8560/api/commons/excel/import/templet?caller='+caller;
                         }
                     }
                 },{

+ 9 - 9
frontend/saas-web/app/view/core/form/FormPanel.js

@@ -52,15 +52,6 @@ Ext.define('saas.view.core.form.FormPanel', {
         me.initFormItems();
 
         me.defaultBtns = me.defaultBtns || [{
-            cls: 'x-formpanel-btn-blue',
-            xtype: 'button',
-            text: '刷新',
-            hidden: true,
-            bind: {
-                hidden: '{!id}'
-            },
-            handler: 'refresh'
-        }, {
             cls: 'x-formpanel-btn-blue',
             xtype: 'button',
             text: '新增',
@@ -104,6 +95,15 @@ Ext.define('saas.view.core.form.FormPanel', {
                 hidden:'{!showAuditBtn}'
             },
             handler: "auditBtnClick",
+        }, {
+            cls: 'x-formpanel-btn-white',
+            xtype: 'button',
+            text: '刷新',
+            hidden: true,
+            bind: {
+                hidden: '{!id}'
+            },
+            handler: 'refresh'
         }, {
             cls:'x-formpanel-btn-white',
             text:'打印',

+ 46 - 16
frontend/saas-web/app/view/core/form/FormPanelController.js

@@ -410,10 +410,47 @@ Ext.define('saas.view.core.form.FormPanelController', {
         caller = form.caller,
         id = viewModel.get(form._idField);
 
-        saas.util.BaseUtil.request({
-            url: '/api/commons/jasperReport/printByDefault',
-            // url: 'http://192.168.253.58:8920/jasperReport/printByDefault',
-            method: 'POST',
+        me.beforePrint(caller).then(function(flag) {
+            if(!flag) {
+                return false;
+            }
+            saas.util.BaseUtil.request({
+                url: '/api/commons/jasperReport/printByDefault',
+                // url: 'http://192.168.253.58:8920/jasperReport/printByDefault',
+                method: 'POST',
+                headers: {
+                    "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
+                },
+                params: {
+                    caller: caller,
+                    id: id
+                }
+            }).then(function(res) {
+                var data = res.data,
+                printurl = data.printurl,
+                printtype = data.printtype,
+                reportName = data.reportName,
+                title = data.title,
+                whereCondition = data.whereCondition,
+                companyId = saas.util.BaseUtil.getCurrentUser().companyId;
+    
+                var url = printurl + '?' + 'reportName=' + reportName + '&' + 'companyId=' + companyId + '&whereCondition=' + whereCondition
+    
+                window.open(url);
+            }).catch(function(res) {
+                console.error(res.message);
+                saas.util.BaseUtil.showErrorToast('获取打印报表错误:' + res.message);
+            });
+        });
+    },
+
+    /**
+     * 判断权限
+     */
+    beforePrint: function(caller) {
+        return saas.util.BaseUtil.request({
+            url: '/api/commons/' + caller + '/print',
+            method: 'GET',
             headers: {
                 "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
             },
@@ -422,17 +459,10 @@ Ext.define('saas.view.core.form.FormPanelController', {
                 id: id
             }
         }).then(function(res) {
-            var data = res.data,
-            printurl = data.printurl,
-            printtype = data.printtype,
-            reportName = data.reportName,
-            title = data.title,
-            whereCondition = data.whereCondition,
-            companyId = saas.util.BaseUtil.getCurrentUser().companyId;
-
-            var url = printurl + '?' + 'reportName=' + reportName + '&' + 'companyId=' + companyId + '&whereCondition=' + whereCondition
-
-            window.open(url);
+            return res.success;
+        }).catch(function(res) {
+            console.error(res.message);
+            saas.util.BaseUtil.showErrorToast('未通过权限验证:' + res.message);
         });
-    },
+    }
 });

+ 33 - 27
frontend/saas-web/app/view/core/report/ReportPanel.js

@@ -84,42 +84,48 @@ Ext.define('saas.view.core.report.ReportPanel', {
                                     includeSummary: true
                                 }
                             }, {
-                                text: 'Excel xml',
-                                cfg: {
-                                    type: 'excel03',
-                                    ext: 'xml'
-                                }
-                            }, {
-                                text: 'Excel xml (包含分组合计)',
-                                cfg: {
-                                    type: 'excel03',
-                                    ext: 'xml',
-                                    includeGroups: true,
-                                    includeSummary: true
-                                }
-                            }, {
+                            //     text: 'Excel xml',
+                            //     cfg: {
+                            //         type: 'excel03',
+                            //         ext: 'xml'
+                            //     }
+                            // }, {
+                            //     text: 'Excel xml (包含分组合计)',
+                            //     cfg: {
+                            //         type: 'excel03',
+                            //         ext: 'xml',
+                            //         includeGroups: true,
+                            //         includeSummary: true
+                            //     }
+                            // }, {
                                 text: 'CSV',
                                 cfg: {
                                     type: 'csv'
                                 }
                             }, {
-                                text: 'TSV',
-                                cfg: {
-                                    type: 'tsv',
-                                    ext: 'csv'
-                                }
-                            }, {
-                                text: 'HTML',
-                                cfg: {
-                                    type: 'html'
-                                }
-                            }, {
-                                text: 'HTML (包含分组合计)',
+                                text: 'CSV (包含分组合计)',
                                 cfg: {
-                                    type: 'html',
+                                    type: 'csv',
                                     includeGroups: true,
                                     includeSummary: true
                                 }
+                            //     text: 'TSV',
+                            //     cfg: {
+                            //         type: 'tsv',
+                            //         ext: 'csv'
+                            //     }
+                            // }, {
+                            //     text: 'HTML',
+                            //     cfg: {
+                            //         type: 'html'
+                            //     }
+                            // }, {
+                            //     text: 'HTML (包含分组合计)',
+                            //     cfg: {
+                            //         type: 'html',
+                            //         includeGroups: true,
+                            //         includeSummary: true
+                            //     }
                             }]
                         }
                     }]

+ 1 - 1
frontend/saas-web/app/view/core/report/ReportPanelController.js

@@ -30,7 +30,7 @@ Ext.define('saas.view.core.report.ReportPanelController', {
                 }
                 //font:
             },
-            fileName: title + Ext.Date.format(new Date(),'Y-m-d_H-i-s') +'.' + (btn.cfg.ext || btn.cfg.type)
+            fileName: title + Ext.Date.format(new Date(),'Y-m-d H-i-s') +'.' + (btn.cfg.ext || btn.cfg.type)
         }, btn.cfg);
         grid.store.exportPageSize = 5000;
         grid.store.exportNumber = 1;

+ 45 - 1
frontend/saas-web/app/view/viewport/ViewportController.js

@@ -73,7 +73,13 @@ Ext.define('saas.view.viewport.ViewportController', {
             // There is no authenticated user, let's redirect to the login page but keep track
             // of the original route to restore the requested route after user authentication.
             me.originalRoute = route;
-            me.redirectTo('login', {replace: true});
+            //没有session时  判断cookie中的uid
+            var hasValidCookie = Ext.util.Cookies.get('uid')?me.getAccountCookie():false;
+            if(!hasValidCookie){
+                me.redirectTo('login', {replace: true});
+            }else{
+                me.redirectTo('main', {replace: true});
+            }
             return;
         }
 
@@ -85,6 +91,44 @@ Ext.define('saas.view.viewport.ViewportController', {
         }
     },
 
+    getAccountCookie:function(){
+        var hasValidCookie = false;
+        Ext.Ajax.request({
+            url: '/api/auth/info',
+            withCredentials: true,
+            async:false,
+            dataType: 'json',
+            headers:{
+                'Authorization':'',
+                'Access-Control-Allow-Origin': '<origin> | *'
+            },
+            method: 'GET',
+            success: function(response, opts) {
+                var res = Ext.decode(response.responseText);
+                var data = res.data;
+                var token = data.token;
+                data.expire = token.expire;
+                data.timestamp = token.timestamp;
+                data.token = token.token;
+                delete data['token'];
+                if(data.conpanyId){
+                    session = data? saas.model.Session.loadData(data) : null;
+                    if (session && session.isValid()) {
+                        me.setRequestToken(session.get('token'));
+                        me.saveSession(session);
+                    }
+                    hasValidCookie = true
+                }else{
+                    window.location.href = Ext.manifest.server.accountCenter
+                }
+            },
+            failure: function(response, opts) {
+                showErrorToast('解析cookie失败:'+response.message)
+            }
+        });
+        return hasValidCookie;
+    },
+
     setRequestToken: function(token) {
         var headers = Ext.Ajax.getDefaultHeaders() || {};
         if (token) {