浏览代码

Merge branch 'eta2.4.5' into debug

shanbinzhang 2 月之前
父节点
当前提交
35c531fa94

+ 5 - 0
src/api/etaConfig.js

@@ -8,4 +8,9 @@ import { get,post } from "./index";
  */
 export const getBaseConfig = params =>{
     return get('/business_conf/fetch',params)
+}
+
+  /* 图表分享的临时有效期token */
+export const getChartShareToken = params => {
+    return get('/datamanage/chart_info/common/general_token',params)
 }

+ 6 - 2
src/hooks/useReportApprove.js

@@ -6,14 +6,17 @@ export function useReportApprove(){
     let isApprove = ref(false)
     let isOtherApprove = ref(false)
     let hasApproveFlow = ref(false)
+    const isLinkChartExpired = ref(false)//报告插入的图表是否开启有效期
+
     const configSettingStore = useConfigSettingStore()
     const { etaConfigInfo } = storeToRefs(configSettingStore)
     //获取基本配置,判断是否走审批流
     const getEtaConfig = async()=>{
         await configSettingStore.getBaseConfigSetting()
-        const {IsReportApprove='',ReportApproveType=''} = etaConfigInfo.value
+        const {IsReportApprove='',ReportApproveType='',IsOpenChartExpired} = etaConfigInfo.value
         isApprove.value = IsReportApprove==='true'?true:false
         isOtherApprove.value = isApprove.value&&ReportApproveType==='other' 
+        isLinkChartExpired.value = IsOpenChartExpired==='true'?true:false;
     }
     //检查分类是否存在审批流
     const checkClassifyNameArr = (type=1,classify=[])=>{
@@ -33,6 +36,7 @@ export function useReportApprove(){
         isOtherApprove,
         hasApproveFlow,
         getEtaConfig,
-        checkClassifyNameArr
+        checkClassifyNameArr,
+        isLinkChartExpired
     }
 }

+ 7 - 1
src/views/chartETA/ChartDetail.vue

@@ -6,6 +6,7 @@ import { useRoute, useRouter } from 'vue-router'
 import { useWindowSize } from '@vueuse/core'
 import {yearSelectOpt,sameOptionType} from '@/hooks/chart/config'
 import {useChartRender} from '@/hooks/chart/render'
+import { getChartShareExpireToken } from './hooks/useChartSharedToken'
 import moment from 'moment'
 import EdbInfo from './components/EdbInfo.vue'
 import SourceDetail from './components/SourceDetail.vue'
@@ -394,7 +395,12 @@ async function getShareLink(){
     }
     if(!confirmFlag.value) return 
     // const linkUrl = `${import.meta.env.VITE_CHART_LINK}?code=${chartInfo.value.UniqueCode}&fromType=share&lang=${currentLang}`
-    const linkUrl = `${publicSettingStore.publicSetting.ChartViewUrl}/chartshow?code=${chartInfo.value.UniqueCode}&fromType=share&lang=${currentLang}`
+
+    //临时权限token
+    const res = await getChartShareExpireToken(chartInfo.value.UniqueCode);
+    if(res.Ret !== 200) return
+
+    const linkUrl = `${publicSettingStore.publicSetting.ChartViewUrl}/chartshow?code=${chartInfo.value.UniqueCode}&fromType=share&lang=${currentLang}&authToken=${res.Data}`
     //console.log('url',linkUrl)
     if(navigator.clipboard&&window.isSecureContext){
          try{

+ 15 - 0
src/views/chartETA/hooks/useChartSharedToken.js

@@ -0,0 +1,15 @@
+
+import { getBaseConfig,getChartShareToken } from '@/api/etaConfig.js';
+
+/* 分享图表link时 加有效期超时无权限 Source chart/table*/
+export async function getChartShareExpireToken(UniqueCode='',Source="chart") {
+    const res = await getBaseConfig();
+    if(res.Ret!==200) return
+    
+    const { IsOpenChartExpired } = res.Data;
+    let needCheckAuth = IsOpenChartExpired==='true'?true:false;
+    
+    if(!needCheckAuth) return { Data:'',Ret:200 }
+    return await getChartShareToken({ UniqueCode,Source })
+
+}

+ 7 - 2
src/views/myETA/ChartDetail.vue

@@ -22,6 +22,7 @@ import ChartSaveOther from './components/ChartSaveOther.vue'
 import _ from 'lodash';
 import { useWindowSize } from '@vueuse/core'
 import {setClipboardData} from '@/hooks/common'
+import { getChartShareExpireToken } from '@/views/chartETA/hooks/useChartSharedToken'
 import SetChartEnName from '@/components/SetChartEnName.vue'
 import {useCachedViewsStore} from '@/store/modules/cachedViews'
 import AddChartToMyETA from '@/views/chartETA/components/AddChartToMyETA.vue'
@@ -587,9 +588,13 @@ async function handleChartRefresh(){
 }
 
 //分享
-function handleChartShare(){
+async function handleChartShare(){
     // const url=import.meta.env.VITE_CHART_LINK+`?code=${chartInfo.value.UniqueCode}&fromType=share&lang=ch`
-    const url=publicSettingStore.publicSetting.ChartViewUrl+`/chartshow?code=${chartInfo.value.UniqueCode}&fromType=share&lang=ch`
+    //临时权限token
+    const res = await getChartShareExpireToken(chartInfo.value.UniqueCode);
+    if(res.Ret !== 200) return
+
+    const url=publicSettingStore.publicSetting.ChartViewUrl+`/chartshow?code=${chartInfo.value.UniqueCode}&fromType=share&lang=ch&authToken=${res.Data}`
     setClipboardData(url)
 }
 //保存图表:目前myETA里能保存的只有ETA图库的图和商品价格曲线图

+ 27 - 7
src/views/report/EditReport.vue

@@ -7,6 +7,7 @@ import ReportPublishTimeSet from './components/ReportPublishTimeSet.vue'
 import apiReport from '@/api/report'
 // import {getSystemInfo} from '@/api/common'
 import moment from 'moment'
+import { getChartShareToken } from '@/api/etaConfig.js';
 import { showToast,showDialog } from 'vant'
 import { useRoute, useRouter } from 'vue-router'
 import {useCachedViewsStore} from '@/store/modules/cachedViews'
@@ -18,7 +19,7 @@ import { useReportHandles,useChapterRepoprtHandles } from './hooks/useReport'
 
 const cachedViewsStore=useCachedViewsStore()
 const publicSettingStore = usePublicSettingStore()
-const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr} = useReportApprove()
+const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr,isLinkChartExpired} = useReportApprove()
 const router=useRouter()
 const route=useRoute()
 const {checkAuthBtn} = useAuthBtn()
@@ -157,6 +158,18 @@ async function handleReportBaseInfoChange(e){
     showReportBaseInfo.value=false
 }
 
+
+async function getLinkAuthToken(UniqueCode,Source='chart') {
+    let authToken = ''
+    if(isLinkChartExpired.value) { //开启了图表有效期
+        const res = await getChartShareToken({ UniqueCode,Source })
+        if(res.Ret !== 200) return
+        authToken = res.Data;
+    }
+
+    return authToken;
+}
+
 // 报告插入数据弹窗
 const showReportInsertPop=ref(false)
 /**
@@ -164,7 +177,7 @@ const showReportInsertPop=ref(false)
  * type:iframe/img 插入的为iframe或者图片
  * chartType: chart-图表,sheet-表格
  */
-function handleInsert({list,type,chartType}){
+async function handleInsert({list,type,chartType}){
     reportContentEditorIns.events.focus()
     if(lastFocusPosition.value){
         reportContentEditorIns.selection.get().removeAllRanges()
@@ -172,21 +185,28 @@ function handleInsert({list,type,chartType}){
     }
     if(type==='iframe'){
         let link=publicSettingStore.publicSetting.ChartViewUrl;
+
         if(chartType==='chart'){
             // link=import.meta.env.MODE==='production'?'https://chartlib.hzinsights.com/chartshow':'https://charttest.hzinsights.com/chartshow'
             link=link+'/chartshow'
-            list.forEach(item => {
-                const isETAForumChart=item.startsWith('isETAForumChart_')?true:false
+            list.forEach(async(item) => {
+                const isETAForumChart=item.startsWith('isETAForumChart_')?true:false;
+                //临时权限token
+                let authToken = await getLinkAuthToken(item);
+
                 reportContentEditorIns.html.insert(`<p style='text-align:left; margin-top:10px;'>
-						<iframe src='${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&fromPage=&isETAForumChart=${isETAForumChart}' width='100%' height='350' style='border-width:0px; min-height:350px;'></iframe>
+						<iframe src='${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&fromPage=&isETAForumChart=${isETAForumChart}&authToken=${authToken}' width='100%' height='350' style='border-width:0px; min-height:350px;'></iframe>
 					</p>`,false)
             });
         }else if(chartType==='sheet'){
             // link=import.meta.env.MODE==='production'?'https://chartlib.hzinsights.com/sheetshow':'https://charttest.hzinsights.com/sheetshow'
             link=link+'/sheetshow'
-            list.forEach(item => {
+            list.forEach(async(item) => {
+                //临时权限token
+                let authToken = await getLinkAuthToken(item,'table');
+
                 reportContentEditorIns.html.insert(`<p style='text-align:left; margin-top:10px;'>
-						<iframe src='${link}?code=${item}' class='iframe${item}'  width='100%' style='border-width:0px;'></iframe>
+						<iframe src='${link}?code=${item}&authToken=${authToken}' class='iframe${item}'  width='100%' style='border-width:0px;'></iframe>
 					</p>`,false)
             });
         }

+ 1 - 1
src/views/report/PreviewDetail.vue

@@ -150,7 +150,7 @@ const getSystemInfoFun=()=>{
 </script>
 
 <template>
-    <div class="report-detail-page" v-if="reportInfo" :style="{backgroundColor:bgColor}">
+    <div class="report-detail-page select-text-disabled" v-if="reportInfo" :style="{backgroundColor:bgColor}">
         <!-- <div class="top-stage-box" v-if="$route.query.id!=-1">
             <span class="stage">第{{reportInfo.Stage}}期 / {{reportInfo.Frequency}}</span>
         </div> -->

+ 1 - 1
src/views/report/chapter/Preview.vue

@@ -25,7 +25,7 @@ async function getChapterDetail(){
 getChapterDetail()
 </script>
 <template>
-    <div class="report-detail-page" v-if="reportInfo">
+    <div class="report-detail-page select-text-disabled" v-if="reportInfo">
         <h1 class="report-title">{{reportInfo.Title}}</h1>
         <div class="auth-box">
             <span>{{reportInfo.Author}}</span>

+ 36 - 17
src/views/report/smartReport/EditReport.vue

@@ -4,6 +4,7 @@ import { V3ColorPicker } from "v3-color-picker-teleport"
 import ReportInsertContent from '../components/reportInsert/Index.vue'
 import ReportPublishTimeSet from '../components/ReportPublishTimeSet.vue'
 import apiReport from '@/api/report'
+import { getChartShareToken } from '@/api/etaConfig.js';
 import _ from 'lodash'
 import moment from 'moment'
 import { showToast,showDialog } from 'vant'
@@ -26,7 +27,7 @@ import ReportLayoutImg from './components/ReportLayoutImg.vue'
 
 const cachedViewsStore=useCachedViewsStore()
 const publicSettingStore = usePublicSettingStore()
-const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr} = useReportApprove()
+const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr,isLinkChartExpired} = useReportApprove()
 const router=useRouter()
 const route=useRoute()
 const {checkAuthBtn} = useAuthBtn()
@@ -159,6 +160,18 @@ watch(
 )
 
 
+async function getLinkAuthToken(UniqueCode,Source='chart') {
+    let authToken = ''
+    if(isLinkChartExpired.value) { //开启了图表有效期
+        const res = await getChartShareToken({ UniqueCode,Source })
+        if(res.Ret !== 200) return
+        authToken = res.Data;
+    }
+
+    return authToken;
+}
+
+
 /* map类型对应组件 */
 function getComponentName(item){
   const temMap=new Map([
@@ -499,7 +512,7 @@ function handleOpenComPop(e) {
   showReportInsertPop.value = true
 }
 /* 插入图表表格 */
-function handleChartInsert({list,type,chartType}){
+async function handleChartInsert({list,type,chartType}){
 		console.log(list,type,chartType)
     let tempCompDataArr=[]
     
@@ -509,30 +522,36 @@ function handleChartInsert({list,type,chartType}){
 
           link=link+'/chartshow'
 
-          tempCompDataArr = list.map(item =>{
+					for(let item of list) {
 						const isETAForumChart=item.startsWith('isETAForumChart_')?true:false
-						console.log(item,isETAForumChart);
-						return {
+						//临时权限token
+						const authToken = await getLinkAuthToken(item);
+						tempCompDataArr.push({
 							compId:3,
 							compType:'chart',
 							id:getCompId(3),
-							content:`${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&isETAForumChart=${isETAForumChart}`,
+							content:`${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&isETAForumChart=${isETAForumChart}&authToken=${authToken}`,
 							titleText: '',
 							style:'height:350px',
 							child:[]
-						}
-					})
+						})
+					}
         }else if(chartType==='sheet'){
             link=link+'/sheetshow'
-            tempCompDataArr = list.map(item =>({
-                compId:4,
-                compType:'sheet',
-                id:getCompId(4),
-                content:`${link}?code=${item}&fromScene=1`,
-                titleText: '',
-                style:'',
-                child:[]
-            }))
+
+						for(let item of list) {
+							//临时权限token
+							const authToken = await getLinkAuthToken(item,'table');
+							tempCompDataArr.push({
+								compId:4,
+								compType:'sheet',
+								id:getCompId(4),
+								content:`${link}?code=${item}&fromScene=1&authToken=${authToken}`,
+								titleText: '',
+								style:'',
+								child:[]
+							})
+						}
         }
     }else if(type==='img'){
 

+ 25 - 6
src/views/reportEn/AddReport.vue

@@ -5,6 +5,7 @@ import ReportInsertContent from '../report/components/reportInsert/Index.vue'
 import ReportPublishTimeSet from '@/views/report/components/ReportPublishTimeSet.vue'
 import apiReportEn from '@/api/reportEn'
 import apiChart from '@/api/chart'
+import { getChartShareToken } from '@/api/etaConfig.js';
 import {getSystemInfo} from '@/api/common'
 import moment from 'moment'
 import { showToast,showDialog } from 'vant'
@@ -20,7 +21,7 @@ const cachedViewsStore=useCachedViewsStore()
 const router=useRouter()
 const route=useRoute()
 const publicSettingStore = usePublicSettingStore()
-const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr} = useReportApprove()
+const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr,isLinkChartExpired} = useReportApprove()
 
 const {lastFocusPosition,frolaEditorContentChange,imgUploadFlag,initFroalaEditor}=useInitFroalaEditor()
 
@@ -160,6 +161,18 @@ function handleSaveOverview(){
 }
 
 
+async function getLinkAuthToken(UniqueCode,Source='chart') {
+    let authToken = ''
+    if(isLinkChartExpired.value) { //开启了图表有效期
+        const res = await getChartShareToken({ UniqueCode,Source })
+        if(res.Ret !== 200) return
+        authToken = res.Data;
+    }
+
+    return authToken;
+}
+
+
 // 报告插入数据弹窗
 const showReportInsertPop=ref(false)
 /**
@@ -178,18 +191,24 @@ function handleInsert({list,type,chartType}){
         if(chartType==='chart'){
             // link=import.meta.env.MODE==='production'?'https://chartlib.hzinsights.com/chartshow':'https://charttest.hzinsights.com/chartshow'
             link=link+'/chartshow'
-            list.forEach(item => {
-                const isETAForumChart=item.startsWith('isETAForumChart_')?true:false
+            list.forEach(async(item) => {
+                const isETAForumChart=item.startsWith('isETAForumChart_')?true:false;
+                //临时权限token
+                let authToken = await getLinkAuthToken(item);
+
                 reportContentIns.html.insert(`<p style='text-align:left; margin-top:10px;'>
-						<iframe src='${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&fromPage=en&isETAForumChart=${isETAForumChart}' width='100%' height='350' style='border-width:0px; min-height:350px;'></iframe>
+						<iframe src='${link}?code=${isETAForumChart?item.replace(/^isETAForumChart_/, ''):item}&fromPage=en&isETAForumChart=${isETAForumChart}&authToken=${authToken}' width='100%' height='350' style='border-width:0px; min-height:350px;'></iframe>
 					</p>`)
             });
         }else if(chartType==='sheet'){
             // link=import.meta.env.MODE==='production'?'https://chartlib.hzinsights.com/sheetshow':'https://charttest.hzinsights.com/sheetshow'
             link=link+'/sheetshow'
-            list.forEach(item => {
+            list.forEach(async(item) => {
+                //临时权限token
+                let authToken = await getLinkAuthToken(item,'table');
+
                 reportContentIns.html.insert(`<p style='text-align:left; margin-top:10px;'>
-						<iframe src='${link}?code=${item}' class='iframe${item}'  width='100%' style='border-width:0px;'></iframe>
+						<iframe src='${link}?code=${item}&authToken=${authToken}' class='iframe${item}'  width='100%' style='border-width:0px;'></iframe>
 					</p>`)
             });
         }