浏览代码

加临时访问token

shanbinzhang 2 月之前
父节点
当前提交
1b7e4defb4
共有 4 个文件被更改,包括 117 次插入62 次删除
  1. 二进制
      src/assets/img/no_auth.png
  2. 37 0
      src/components/noAuth.vue
  3. 54 44
      src/views/chartShow/index.vue
  4. 26 18
      src/views/sheetShow/index.vue

二进制
src/assets/img/no_auth.png


+ 37 - 0
src/components/noAuth.vue

@@ -0,0 +1,37 @@
+
+<script setup lang="ts">
+import { ref } from 'vue'
+
+const props = defineProps({
+  text: {
+    type: String,
+    default: '暂无权限'
+  }
+})
+
+</script>
+<template>
+  <div class="no-auth-wapper">
+    <div>
+      <img
+        src="@/assets/img/no_auth.png"
+        alt=""
+      />
+      <span>{{text}}</span>
+    </div>
+  </div>
+</template>
+<style scoped lang="less">
+.no-auth-wapper {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  text-align: center;
+  color: #666;
+  img {
+    display: block;
+  }
+}
+</style>

+ 54 - 44
src/views/chartShow/index.vue

@@ -20,6 +20,7 @@
     </header>
     <template v-if="haveData">
       <div
+        v-if="haveAuth"
         class="chart-wrapper"
         id="chart-wrapper"
         v-loading="loading"
@@ -32,52 +33,56 @@
 
         <div class="mark"></div>
       </div>
+
+      <NoAuth v-else/>
     </template>
     <div class="chart-wrapper notfound" v-else>
       <i class="el-icon-warning"></i>哎吆,你的图飞了,赶快去找管理员救命吧~
     </div>
 
-    <!-- 图表来源说明 -->
-    <div 
-      class="chart-bottom-info bootom-source"
-      v-if="chartInfo.Instructions&&JSON.parse(chartInfo.Instructions).isShow
-    ">
-
-      <!-- 图表说明 -->
+    <template v-if="haveAuth">
+      <!-- 图表来源说明 -->
       <div 
-        class="chart-instruction text_oneLine" 
-        v-text="JSON.parse(chartInfo.Instructions).text"
-        :style="`
-          color: ${JSON.parse(chartInfo.Instructions).color};
-          font-size: ${ JSON.parse(chartInfo.Instructions).fontSize }px
-        `"
-      ></div>
-    </div>
-
-    <div class="bootom-source">
-
-      <!-- 自定义来源 -->
-      <div>
-        <div class="chart-source text_oneLine" 
-          v-if="chartInfo.SourcesFrom&&JSON.parse(chartInfo.SourcesFrom).isShow"
+        class="chart-bottom-info bootom-source"
+        v-if="chartInfo.Instructions&&JSON.parse(chartInfo.Instructions).isShow
+      ">
+
+        <!-- 图表说明 -->
+        <div 
+          class="chart-instruction text_oneLine" 
+          v-text="JSON.parse(chartInfo.Instructions).text"
           :style="`
-              color: ${ JSON.parse(chartInfo.SourcesFrom).color };
-              font-size: ${ JSON.parse(chartInfo.SourcesFrom).fontSize }px;
+            color: ${JSON.parse(chartInfo.Instructions).color};
+            font-size: ${ JSON.parse(chartInfo.Instructions).fontSize }px
           `"
-        >
-            source:<em>{{ JSON.parse(chartInfo.SourcesFrom).text}}</em>
-        </div>
+        ></div>
       </div>
 
+      <div class="bootom-source">
+
+        <!-- 自定义来源 -->
+        <div>
+          <div class="chart-source text_oneLine" 
+            v-if="chartInfo.SourcesFrom&&JSON.parse(chartInfo.SourcesFrom).isShow"
+            :style="`
+                color: ${ JSON.parse(chartInfo.SourcesFrom).color };
+                font-size: ${ JSON.parse(chartInfo.SourcesFrom).fontSize }px;
+            `"
+          >
+              source:<em>{{ JSON.parse(chartInfo.SourcesFrom).text}}</em>
+          </div>
+        </div>
 
-      <ul class="right-action" @click.stop>
-        <li v-if="$route.query.source==='ybxcx'"><collectBtn/></li>
-        <!-- eta小程序报告详情中的有收藏 -->
-        <li v-if="$route.query.source==='etamini'" @click="handleChangeChartCollect">{{IsCollect?'取消收藏':'收藏'}}</li>
-        <li @click="copyUrl" class="copy" v-if="isShare"><i class="el-icon-share"/>分享</li>
-        <li @click="refreshChart" v-if="chartInfo.UniqueCode&&$route.query.source!=='smartReportGetImg'"><i class="el-icon-refresh"/>刷新</li>
-      </ul>
-    </div>
+
+        <ul class="right-action" @click.stop>
+          <li v-if="$route.query.source==='ybxcx'"><collectBtn/></li>
+          <!-- eta小程序报告详情中的有收藏 -->
+          <li v-if="$route.query.source==='etamini'" @click="handleChangeChartCollect">{{IsCollect?'取消收藏':'收藏'}}</li>
+          <li @click="copyUrl" class="copy" v-if="isShare"><i class="el-icon-share"/>分享</li>
+          <li @click="refreshChart" v-if="chartInfo.UniqueCode&&$route.query.source!=='smartReportGetImg'"><i class="el-icon-refresh"/>刷新</li>
+        </ul>
+      </div>
+    </template>
   </div>
 </template>
 
@@ -91,12 +96,14 @@ import { IState } from './typing';
 import { ChartApi } from '@/request/api';
 import collectBtn from './components/collectBtn.vue'
 import { useChartRender } from '@/hooks/chart/useChartRender';
+import NoAuth from '@/components/noAuth.vue';
 
 
 export default defineComponent({
   components: {
     chart,
-    collectBtn
+    collectBtn,
+    NoAuth
   },
   setup() {
     const route = useRoute();
@@ -124,6 +131,7 @@ export default defineComponent({
     // 语言 中英文 ch en  默认中文
     const language = ref(route.query.fromPage || route.query.lang || 'zh');
     const IsCollect=ref(false)//图表是否收藏
+    const haveAuth = ref(true)
     const getChartInfo = async (type='') => {
 
       if(!code.value) {
@@ -135,7 +143,7 @@ export default defineComponent({
       try {
         let params={
           UniqueCode: code.value || '',
-          AuthToken: route.query.authToken
+          AuthToken: route.query?.authToken || ''
         }
         // 如果是来自etamini 也就是eta小程序的报告详情
         if(route.query.source==='etamini'){
@@ -145,26 +153,27 @@ export default defineComponent({
         const { Data } = await ChartApi.getChart(params);
         loading.value = false;
         state.chartInfo = Data.ChartInfo;
-        IsCollect.value=Data.IsCollect
+        IsCollect.value=Data.IsCollect;
         state.dataList = Data.ChartInfo.Source === 1 ? Data.EdbInfoList : [Data.EdbInfoList[0]];
+        haveData.value = true;
+        haveAuth.value = Data.IsAuth;
 
-        //处理英文研报英文设置不全就展示中文
-        // setLangFromEnReport();
         document.title = language.value==='zh'?Data.ChartInfo.ChartName:Data.ChartInfo.ChartNameEn;
 
+        if(!Data.IsAuth) return
+
         state.options = useChartRender(Data,language.value)
         
-        haveData.value = true;
         type === 'refresh' && ElMessage.success('刷新成功');
 
         //水印配置
         nextTick(()=>{
-          const markDom = document.querySelector('.mark')
+          const markDom = document.querySelector('.mark') as HTMLElement
           Data.WaterMark&&(markDom.style.backgroundImage = `url(${Data.WaterMark})`)
         })
       }catch (e) {
         loading.value = false;
-        haveData.value = false; 
+        haveData.value = false;
       }
 
     };
@@ -234,7 +243,8 @@ export default defineComponent({
       refreshChart,
       copyText,
       handleChangeChartCollect,
-      IsCollect
+      IsCollect,
+      haveAuth
     };
   },
 });

+ 26 - 18
src/views/sheetShow/index.vue

@@ -4,7 +4,8 @@ import { useRoute } from 'vue-router';
 import { SheetApi } from '@/request/api';
 import sheet from '@/components/sheet.vue'
 import { IUnknowObject } from '@/types';
-import { ElMessage } from 'element-plus';
+import { ElMessage, valueEquals } from 'element-plus';
+import NoAuth from '@/components/noAuth.vue';
 
 const route = useRoute();
 const code = ref(route.query.code || '')
@@ -31,22 +32,26 @@ const setDefaultSource=(sourceText:string)=>{
   })
 }
 
+const haveAuth = ref(true)
 const getInfo = async(type='') => {
   loading.value = true;
   const { Data,Ret } = await SheetApi.getInfo({  
     UniqueCode: code.value, 
     FromScene: Number(route.query.fromScene||''),
-    AuthToken: route.query?.authToken
+    AuthToken: route.query?.authToken as string || ''
   });
   
   loading.value = false;
   if(Ret !== 200) return
 
   info.value = Data;
+  haveAuth.value = Data.IsAuth;
+  showData.value = true; 
+
+  if(!Data.IsAuth) return
   if(!info.value.SourcesFrom){
     info.value.SourcesFrom = Data.ExcelSource?setDefaultSource(Data.ExcelSource):''
   }
-  showData.value = true; 
   type==='refresh'&&ElMessage.success('刷新成功')
   nextTick(() => {
     let ele = document.getElementsByClassName('sheet-show-wrapper')[0] as HTMLElement;
@@ -83,22 +88,25 @@ const refreshSheet = async()=>{
     element-loading-text="加载中..."
   >
     <!-- <h3 class="title">{{info.ExcelName}}</h3> -->
-    
-    <sheet :data="info.TableInfo.TableDataList" :config="info.Config"/>
-    <div class="tool sheet-bottom">
-      <div class="sheet-source" 
-        v-if="info.SourcesFrom&&JSON.parse(info.SourcesFrom).isShow"
-        :style="`
-            color: ${ JSON.parse(info.SourcesFrom).color };
-            font-size: ${ JSON.parse(info.SourcesFrom).fontSize }px;
-        `"
-      >
-          source:<em>{{ JSON.parse(info.SourcesFrom).text}}</em>
+    <template v-if="haveAuth">
+      <sheet :data="info.TableInfo.TableDataList" :config="info.Config"/>
+      <div class="tool sheet-bottom">
+        <div class="sheet-source" 
+          v-if="info.SourcesFrom&&JSON.parse(info.SourcesFrom).isShow"
+          :style="`
+              color: ${ JSON.parse(info.SourcesFrom).color };
+              font-size: ${ JSON.parse(info.SourcesFrom).fontSize }px;
+          `"
+        >
+            source:<em>{{ JSON.parse(info.SourcesFrom).text}}</em>
+        </div>
+        <!-- 占位 -->
+        <div v-else></div>
+        <span @click="refreshSheet" style="color: #666;">刷新</span>
       </div>
-      <!-- 占位 -->
-      <div v-else></div>
-      <span @click="refreshSheet" style="color: #666;">刷新</span>
-    </div>
+    </template>
+
+    <NoAuth v-else/>
   </div>
 </template>