瀏覽代碼

处理登录时,获取租户ID

ZaiZai 2 年之前
父節點
當前提交
b5c435fdaa
共有 4 個文件被更改,包括 106 次插入81 次删除
  1. 9 0
      src/api/modules/user.js
  2. 4 16
      src/utils/tools.js
  3. 62 63
      src/views/custody/testing.vue
  4. 31 2
      src/views/login/index.vue

+ 9 - 0
src/api/modules/user.js

@@ -86,3 +86,12 @@ export const loginByToken = (form, msg = true) => httpApi({
     method: 'post',
     params: form
 }, msg);
+
+//获取租户ID
+export const getTenantID = (domain, msg = true) => httpApi({
+    url: '/api/blade-system/tenant/info',
+    method: 'get',
+    params: {
+        domain
+    }
+}, msg);

+ 4 - 16
src/utils/tools.js

@@ -88,20 +88,8 @@ export const dateFormat = (date, format) => {
     }
     return '';
 }
-//是否为jsson
-export const isJSON = (str) =>{
-    if (typeof str == 'string') {
-        try {
-            var obj=JSON.parse(str);
-            if(typeof obj == 'object' && obj ){
-                return true;
-            }else{
-                return false;
-            }
-        } catch(e) {
-            console.log('error:'+str+'!!!'+e);
-            return false;
-        }
-    }
-    console.log('It is not a string!')
+
+//获取当前域名
+export const getTopUrl = () => {
+    return window.location.href.split('/#/')[0];
 }

+ 62 - 63
src/views/custody/testing.vue

@@ -1,6 +1,6 @@
 <template>
      <div class="hc-page-box" style="backgroundcolor:white">
-            
+
               <HcCard1 scrollbar >
 
                   <div class="bannerbox" :style="`background-image: url(${testBgbig});`"  v-if="isStatus">
@@ -20,7 +20,7 @@
                                             <div class="history_box" v-for="item in historyRportlist">
                                                 <el-link type="primary" @click="viewHpdf(item)">{{ item.reportName }}</el-link>
                                                 <span class="m15">{{ item.examiningTime }}</span>
-                                                
+
                                             </div>
                                           </div>
                                           <div v-else>暂无数据</div>
@@ -39,7 +39,7 @@
                                     [2]电子档案"四性"检测要求及其实现方法[j].浙江档案
                                 </div>
                             </el-col>
-                           
+
                          </el-row>
                         <el-row>
                             <el-col :span="24">
@@ -47,17 +47,17 @@
                                    制定系统电子文件归档真实性、完整性、可用性、安全性检测服务
                                 </div>
                             </el-col>
-                           
+
                          </el-row>
                       </div>
                            <div class="circlebox" @click="detection" >
                                <span v-loading="detectionLoad"> 一键检测</span>
-                            </div>  
+                            </div>
                   </div>
-                  
+
                   <div class="bannerbox " :style="`background-image: url(${testBgsamll});  aspect-ratio: 1993/468;`" v-if="!isStatus">
                       <div class="infobox">
-                          <el-row > 
+                          <el-row >
                             <el-col :span="20">
                                 <div >
                                     [1]文书档案检测一般要求:DA/T 70-2018
@@ -71,7 +71,7 @@
                                                         <div class="history_box" v-for="item in historyRportlist">
                                                             <el-link type="primary" @click="viewHpdf(item)">{{ item.reportName }}</el-link>
                                                             <span class="m15">{{ item.examiningTime }}</span>
-                                                            
+
                                                         </div>
                                                     </div>
                                                     <div v-else>暂无数据</div>
@@ -83,7 +83,7 @@
                                     </el-tooltip>
                                 </div>
                           </el-col>
-                     
+
                          </el-row>
                         <el-row>
                             <el-col :span="24">
@@ -91,7 +91,7 @@
                                     [2]电子档案"四性"检测要求及其实现方法[j].浙江档案
                                 </div>
                             </el-col>
-                           
+
                          </el-row>
                         <el-row>
                             <el-col :span="24">
@@ -99,10 +99,10 @@
                                    制定系统电子文件归档真实性、完整性、可用性、安全性检测服务
                                 </div>
                             </el-col>
-                           
+
                          </el-row>
                       </div>
-                           
+
                              <el-tooltip
                                 class="box-item"
                                 effect="light"
@@ -112,26 +112,26 @@
                             >
                                 <div class="circlebox circlebox2" v-if="activeIndex===4">
                                     <span>100%</span>
-                                </div>  
+                                </div>
                                <div class="circlebox circlebox1" v-else>
                                     <span>26%</span>
                                 </div>
-                                 
-                            </el-tooltip> 
+
+                            </el-tooltip>
                   </div>
-                  
+
                   <div class="statusbox"   v-if="isStatus">
                       <div class="statusboxitem" :style="`background-image: url(${bgColor});`">
                           <div class="statusboxitem_top">
                              <div  class="statusboxitem_top_first">
-                                  
+
                                 <div style=" font-size: 5.25rem;color :white;">
                                    <i class="ri-checkbox-multiple-line"></i>
                                 </div>
                                   <div class="title">
                                       真实性检测
                                   </div>
-                             </div> 
+                             </div>
                              <div  class="statusboxitem_top_second">
                                  <span>检测范围</span>
                                   <el-link  type="success"  :underline="false" @click="viewDialogTrue(1)">查看</el-link>
@@ -141,7 +141,7 @@
                                   <span>开启检测</span>
                                     <el-switch
                                         v-model="openTruevalue"
-                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66" 
+                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66"
                                         active-value="100"
                                         inactive-value="0"
                                         />
@@ -150,14 +150,14 @@
                         <div class="statusboxitem" :style="`background-image: url(${bgColor});`">
                           <div class="statusboxitem_top">
                              <div  class="statusboxitem_top_first">
-                                  
+
                                 <div style=" font-size: 5.25rem;color :white;">
                                    <i class="ri-radio-button-line"></i>
                                 </div>
                                   <div class="title">
                                       完整性检测
                                   </div>
-                             </div> 
+                             </div>
                              <div  class="statusboxitem_top_second">
                                  <span>检测范围</span>
                                   <el-link  type="success"  :underline="false" @click="viewDialogTrue(2)">查看</el-link>
@@ -167,7 +167,7 @@
                                   <span>开启检测</span>
                                     <el-switch
                                         v-model="openFullvalue"
-                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66" 
+                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66"
                                         active-value="100"
                                         inactive-value="0"
                                         />
@@ -176,14 +176,14 @@
                                      <div class="statusboxitem" :style="`background-image: url(${bgColor});`">
                           <div class="statusboxitem_top">
                              <div  class="statusboxitem_top_first">
-                                  
+
                                 <div style=" font-size: 5.25rem;color :white;">
                                     <i class="ri-chat-upload-fill"></i>
                                 </div>
                                   <div class="title">
                                       可用性检测
                                   </div>
-                             </div> 
+                             </div>
                              <div  class="statusboxitem_top_second">
                                  <span>检测范围</span>
                                   <el-link  type="success"  :underline="false" @click="viewDialogTrue(3)">查看</el-link>
@@ -193,7 +193,7 @@
                                   <span>检测范围</span>
                                     <el-switch
                                         v-model="openUsevalue"
-                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66" 
+                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66"
                                         active-value="100"
                                         inactive-value="0"
                                         />
@@ -202,14 +202,14 @@
                       <div class="statusboxitem" :style="`background-image: url(${bgColor});`">
                           <div class="statusboxitem_top">
                              <div  class="statusboxitem_top_first">
-                                  
+
                                 <div style=" font-size: 5.25rem;color :white;">
                                  <i class="ri-shield-cross-line"></i>
                                 </div>
                                   <div class="title">
                                       安全性检测
                                   </div>
-                             </div> 
+                             </div>
                              <div  class="statusboxitem_top_second">
                                  <span>检测范围</span>
                                   <el-link  type="success"  :underline="false" @click="viewDialogTrue(4)">查看</el-link>
@@ -219,7 +219,7 @@
                                   <span>开启检测</span>
                                     <el-switch
                                         v-model="openSafevalue"
-                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66" 
+                                        style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66"
                                         active-value="100"
                                         inactive-value="0"
                                         />
@@ -238,9 +238,9 @@
                                 </el-steps>
                                 <el-button type="success" v-if="activeIndex===4">查看报告</el-button>
                             </div>
-                             
+
                       </div>
-                       
+
                       <div class="tablebox">
                             <HcTable1 ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading">
                                <template #key3="{row}">
@@ -250,7 +250,7 @@
                             </HcTable1>
                        </div>
                   </div>
-                  
+
              </HcCard1>
 
              <!-- 查看弹窗 -->
@@ -272,8 +272,7 @@ import testBgsamll  from '~src/assets/view/testBgsamll.png';
 import HcCard1 from './components/hc-card1.vue'
 import HcTable1 from './components/hc-table1.vue'
 import reportApi from "~api/custody/testing.js";
-import {getArrValue, getObjValue, isArrIndex} from "js-fast-way"
-import {isJSON} from '~uti/tools'
+import {getArrValue, toParse, getObjValue, isArrIndex} from "js-fast-way"
 import truePng from '~src/assets/testphoto/true.png';
 import fullPng from '~src/assets/testphoto/full.png';
 import usePng from '~src/assets/testphoto/use.png';
@@ -297,7 +296,7 @@ const tableColumn = ref([
     {key:'key1', name: '检测项目'},
     {key:'key2', name: '不合格统计',width:150,align:'center'},
     {key:'key3', name: '检测结果',width:150,align:'center'},
-   
+
 ])
 const tableData = ref([
     {
@@ -305,35 +304,35 @@ const tableData = ref([
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: true,
-        
+
     },
       {
         id: 1,
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
          key3: true,
-        
+
     },
       {
         id: 1,
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
        key3: true,
-        
+
     },
       {
         id: 1,
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: true,
-        
+
     },
       {
         id: 1,
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: false,
-        
+
     },
     ,
       {
@@ -341,7 +340,7 @@ const tableData = ref([
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: false,
-        
+
     },
     ,
       {
@@ -349,7 +348,7 @@ const tableData = ref([
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: false,
-        
+
     },
     ,
       {
@@ -357,7 +356,7 @@ const tableData = ref([
         key1: '初步设计外业验收有关文件、工程初步设计图纸、初步设计批复、初步设计审查咨询报告',
         key2:3,
         key3: false,
-        
+
     },
 
 ])
@@ -369,7 +368,7 @@ const reportId=ref(0)
 const detectionLoad=ref(false)
 const detection=async()=>{
     console.log('一键检测');
-   
+
     detectionLoad.value=true
     const { error, code, data } = await reportApi.getExamining({
         projectId: projectId.value,
@@ -403,8 +402,8 @@ const getReportStatusdata=async()=>{
             isStatus.value=false
             // reportId.value=data
         }
-    } 
-    
+    }
+
 }
 
 //消息数量
@@ -422,9 +421,9 @@ const menumsgCount = ref(props.msgCount)
 watch(() => [
         props.msgCount,
     ], ([val]) => {
-        if(isJSON(val)){
-        let retrunStatus=JSON.parse(val).status
-         activeIndex.value=retrunStatus
+        const res = toParse(val)
+        if(res) {
+            activeIndex.value = res.status
         }
         menumsgCount.value = val
     }
@@ -454,12 +453,12 @@ const getReportData = async () => {
     if (!error && code === 200) {
         historyRportlist.value = getArrValue(data)
         console.log(data,'data');
-      
+
     } else {
         historyRportlist.value = []
-     
+
     }
-   
+
 }
 //查看历史报告
 const viewHpdf=(item)=>{
@@ -468,7 +467,7 @@ const viewHpdf=(item)=>{
     }else{
         window.$message.warning('暂无pdf')
     }
-   
+
 }
 
 
@@ -514,8 +513,8 @@ const imageDialogClose=()=>{
     margin: 0 auto;
     .statusboxitem{
         width: 15%;
-        
-    
+
+
         background-size: 100% 100%;
         border-radius: 5px;
         font-size: 14px;
@@ -529,13 +528,13 @@ const imageDialogClose=()=>{
                 flex-direction: column;
                 align-items: center;
                 justify-content: center;
-               
+
               .title{
                   font-weight: bold;
                    color:white;
                    font-size: 1rem;
               }
-              
+
             }
              .statusboxitem_top_second{
                 display: flex;
@@ -566,7 +565,7 @@ const imageDialogClose=()=>{
     position: relative;
     margin-bottom: 30px;
    .infobox{
-     
+
        width: 100%;
     //   line-height: 30px;
        color: white;
@@ -584,19 +583,19 @@ const imageDialogClose=()=>{
         z-index: 67;
         border: 2px solid white;
         border-radius: 50%;
-        box-shadow: 0 0 10px 15px rgba(255, 255, 255, 0.9); 
+        box-shadow: 0 0 10px 15px rgba(255, 255, 255, 0.9);
         margin: 0 auto;
         display: flex;
         justify-content: center;
         align-items: center;
         color: white;
         font-weight: bolder;
-       
+
         font-size: 30px;
         cursor: pointer;
         box-sizing: border-box;
    }
-  
+
    .circlebox1{
          top: 38%;
          left:45.5%;
@@ -629,12 +628,12 @@ const imageDialogClose=()=>{
        width: 100%;
        display: flex;
    }
-   
+
      .tablebox{
         padding: 20px;
         margin-top: 30px;
         height: 90%;
-    
+
     }
 }
     .hc-steps-view .el-steps {
@@ -668,7 +667,7 @@ const imageDialogClose=()=>{
     border-bottom: 1px solid gray;
     height: 30px;
     line-height: 30px;
-   
+
 }
 .m15{
     margin-left: 15px;

+ 31 - 2
src/views/login/index.vue

@@ -21,6 +21,9 @@
                 </div>
                 <div class="form-box mt-4" v-if="account">
                     <el-form ref="formRef" :model="formValue" :rules="formRules" label-width="0px" label-position="left" size="large">
+                        <el-form-item prop="tenantId" v-if="tenantMode">
+                            <el-input v-model="formValue.tenantId" clearable placeholder="租户ID"/>
+                        </el-form-item>
                         <el-form-item prop="username">
                             <el-input v-model="formValue.username" placeholder="账号" clearable/>
                         </el-form-item>
@@ -60,29 +63,42 @@
 </template>
 
 <script setup>
-import {ref} from "vue";
+import {ref, onMounted} from "vue";
 import website from '~src/config/index'
 import router from '~src/router/index';
 import {useAppStore} from "~src/store";
 import {useAppLogin} from "~sto/user";
-import {formValidate} from "js-fast-way"
+import {formValidate, getToObjVal} from "js-fast-way"
 import HcPicVue from './components/pic.vue'
 import HcHomeBg from './components/home-bg.vue'
+import {getTenantID} from "~api/user";
+import {getTopUrl} from "~uti/tools";
 
 const userStore = useAppStore()
 userStore.clearStoreData() //先清理下缓存
 
 //切换登录类型
 const account = ref(true)
+const tenantMode = ref(true)
+
 const accountClick = () => {
     account.value = !account.value;
 }
 
+onMounted(() => {
+    getTenantIdApi()
+})
+
 //表单
 const formRef = ref(null);
 const checkbox = ref(false)
 const formValue = ref({tenantId: "000000", username: '', password: '', type: "account"})
 const formRules = {
+    tenantId: {
+        required: true,
+        message: "请输入租户ID",
+        trigger: "blur"
+    },
     username: {
         required: true,
         message: "请输入账号",
@@ -100,6 +116,19 @@ const passwordKeyUp = (e) => {
     }
 }
 
+//获取租户id
+const getTenantIdApi = async () => {
+    const {error, code, data} = await getTenantID(getTopUrl())
+    const res = getToObjVal(data)
+    if (!error && code === 200 && res) {
+        tenantMode.value = false
+        formValue.value.tenantId = res.tenantId
+    } else {
+        tenantMode.value = true
+        formValue.value.tenantId = "000000"
+    }
+}
+
 //登录
 const loading = ref(false)
 const formValidateClick = async () => {