Переглянути джерело

Merge branch 'master' into need_pool139

Karsa 6 місяців тому
батько
коміт
5c9bf437ae

+ 2 - 2
src/components/sheet.vue

@@ -96,7 +96,7 @@ const dynamicSty = computed(()=>{
 table {
   width: 100%;
   font-size: 14px;
-  color: #666;
+  color: #333;
   td,
   th {
     // min-width: 120px;
@@ -115,7 +115,7 @@ table {
   }
 
   .data-cell{
-    color: #666;
+    color: #333;
     &.one-bg {
       background-color: #EFEEF1;
     }

Різницю між файлами не показано, бо вона завелика
+ 443 - 103
src/hooks/chart/useChartRender.ts


+ 19 - 0
src/request/api.ts

@@ -53,6 +53,19 @@ export const ChartApi = {
 	refreshCrossVarietyChart: (params:IRefreshParams) => {
 		return get('/cross_variety/chart_info/refresh',params)
 	},
+
+	/**
+	 * 图表取消收藏
+	 */
+	chartCollectCancel:params=>{
+		return post('/chart/dw/collectCancel',params)
+	},
+	/**
+	 * 图表收藏
+	 */
+	chartCollect:params=>{
+		return post('/chart/dw/collect',params)
+	}
 }
 
 /* 表格模块 */
@@ -60,6 +73,9 @@ interface IExcelParams {
 	UniqueCode: string | any
 	FromScene: number
 }
+interface IFreshParams {
+	UniqueCode: string | any
+}
 export const SheetApi = {
 	/**
 	 * 获取表格详情
@@ -68,5 +84,8 @@ export const SheetApi = {
 	 */
 	getInfo: (params: IExcelParams) => {
 		return get('/excel_info/detail',params);
+	},
+	refreshInfo:(params:IFreshParams) => {
+		return get('excel_info/refresh',params)
 	}
 }

+ 5 - 0
src/router/index.ts

@@ -18,6 +18,11 @@ export const routes: AppRouteRecordRaw[] = [
     component: () => import('@/views/chartShow/index.vue'),
     name: '图表详情',
   },
+  {
+    path: '/chart/preview',
+    component: () => import('@/views/chartShow/preview.vue'),
+    name: '图表预览',
+  },
   {
     path: '/sheetshow',
     component: () => import('@/views/sheetShow/index.vue'),

+ 8 - 4
src/views/chartShow/index.less

@@ -151,8 +151,10 @@
 	}
 	@media (min-width: 980px) {
 		.mark {
-			width: 580px;
-			height: 60px;
+			// width: 580px;
+			// height: 60px;
+			width: 80%;
+			height: 80%;
 		}
 		.chart-show .notfound {
 			font-size: 24px;
@@ -160,8 +162,10 @@
 	}
 	@media (max-width: 979px) {
 		.mark {
-			width: 242px;
-			height: 25px;
+			// width: 242px;
+			// height: 25px;
+			width: 80%;
+			height: 80%;
 		}
 		.chart-show .notfound {
 			font-size: 14px;

+ 35 - 19
src/views/chartShow/index.vue

@@ -10,7 +10,7 @@
           color:${JSON.parse(chartInfo.ChartThemeStyle).titleOptions.style.color}
         `:''"
       >
-        {{ language === 'ch'?chartInfo.ChartName: chartInfo.ChartNameEn}}
+        {{ language === 'en'?(chartInfo.ChartNameEn||chartInfo.ChartName): chartInfo.ChartName}}
       </span>
 
       <div class="copy-icon" @click.stop="copyText">
@@ -72,6 +72,8 @@
 
       <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>
@@ -120,7 +122,8 @@ export default defineComponent({
     const code = ref(route.query.code);
     const isShare = ref(route.query.fromType === 'share');
     // 语言 中英文 ch en  默认中文
-    const language = ref(route.query.lang || 'ch');
+    const language = ref(route.query.fromPage || route.query.lang || 'zh');
+    const IsCollect=ref(false)//图表是否收藏
     const getChartInfo = async (type='') => {
 
       if(!code.value) {
@@ -130,16 +133,23 @@ export default defineComponent({
 
       loading.value = true;
       try {
-        const { Data } = await ChartApi.getChart({
+        let params={
           UniqueCode: code.value || '',
-        });
+        }
+        // 如果是来自etamini 也就是eta小程序的报告详情
+        if(route.query.source==='etamini'){
+          params.Source=1
+          params.Token=route.query.token
+        }
+        const { Data } = await ChartApi.getChart(params);
         loading.value = false;
         state.chartInfo = Data.ChartInfo;
+        IsCollect.value=Data.IsCollect
         state.dataList = Data.ChartInfo.Source === 1 ? Data.EdbInfoList : [Data.EdbInfoList[0]];
 
         //处理英文研报英文设置不全就展示中文
-        setLangFromEnReport();
-        document.title = language.value==='ch'?Data.ChartInfo.ChartName:Data.ChartInfo.ChartNameEn;
+        // setLangFromEnReport();
+        document.title = language.value==='zh'?Data.ChartInfo.ChartName:Data.ChartInfo.ChartNameEn;
 
         state.options = useChartRender(Data,language.value)
         
@@ -158,17 +168,6 @@ export default defineComponent({
 
     };
 
-
-    //处理英文研报的图表英文设置不全的情况
-    const setLangFromEnReport = () => {
-      //来源于英文研报
-      if(route.query.fromPage !== 'en') return
-      let is_name_en = state.chartInfo.ChartNameEn ? true : false;//名称是否有英文
-      let is_target_en = [2,9,10].includes(state.chartInfo.ChartType) ? true : state.dataList.every(_ => _.EdbNameEn);//指标是否有英文
-      console.log(is_name_en,is_target_en)
-      language.value = (is_name_en && is_target_en) ? 'en' : 'ch';
-    }
-
     /* 复制标题 */
     const copyText = () => {
       const { chartInfo } = state;
@@ -195,7 +194,7 @@ export default defineComponent({
     const refreshChart = _.debounce(async () => {
       loading.value = true;
       let res: any=null
-      if([1,6,7,8,9,10].includes(state.chartInfo.Source)){
+      if([1,6,7,8,9,10,11].includes(state.chartInfo.Source)){
         res=await ChartApi.refreshChart({UniqueCode: state.chartInfo.UniqueCode})
       }else if([2,5].includes(state.chartInfo.Source)){
         res=await ChartApi.refreshCommordityChart({UniqueCode: state.chartInfo.UniqueCode});
@@ -207,6 +206,21 @@ export default defineComponent({
       res.Ret === 200 && getChartInfo('refresh');
     },400)
 
+
+    // 点击收藏\取消收藏
+    const handleChangeChartCollect=async ()=>{
+      const params={
+        UniqueCode:code.value || '',
+        Token:route.query.token,
+      }
+      const res=IsCollect.value?await ChartApi.chartCollectCancel(params):await ChartApi.chartCollect(params)
+      if(res.Ret===200){
+        ElMessage.success(IsCollect.value?'取消收藏成功':'收藏成功')
+        IsCollect.value=!IsCollect.value
+      }
+      
+    }
+
     return {
       ...toRefs(state),
       loading,
@@ -217,7 +231,9 @@ export default defineComponent({
       isShare,
       language,
       refreshChart,
-      copyText
+      copyText,
+      handleChangeChartCollect,
+      IsCollect
     };
   },
 });

+ 65 - 0
src/views/chartShow/preview.vue

@@ -0,0 +1,65 @@
+<script setup>
+import { reactive, onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
+import chart from '@/components/chart.vue';
+import { ChartApi } from '@/request/api';
+import { useChartRender } from '@/hooks/chart/useChartRender';
+
+const route=useRoute()
+
+const state = reactive({
+  options: {},
+  chartInfo: {},
+  dataList: [],
+  sourceName: ''
+});
+
+/* 获取图表数据信息 */
+const loading = ref(false);
+const haveData = ref(false);
+const code = ref(route.query.code);
+
+// 语言 中英文 ch en  默认中文
+const language = ref('zh');
+const getChartInfo = async (type = '') => {
+
+  if (!code.value) {
+    haveData.value = false;
+    return
+  }
+
+  loading.value = true;
+  try {
+    const { Data } = await ChartApi.getChart({
+      UniqueCode: code.value || '',
+    });
+    loading.value = false;
+    state.chartInfo = Data.ChartInfo;
+    state.dataList = Data.ChartInfo.Source === 1 ? Data.EdbInfoList : [Data.EdbInfoList[0]];
+
+    state.options = useChartRender(Data, language.value)
+
+    haveData.value = true;
+
+
+  } catch (e) {
+    loading.value = false;
+    haveData.value = false;
+  }
+
+};
+
+onMounted(() => {
+  getChartInfo();
+});
+</script>
+
+<template>
+  <div class="chart-detail-preivew-page">
+    <chart
+      :options="state.options"
+      :chartId="state.chartInfo.ChartInfoId || 0"
+      :chartInfo="state.chartInfo"
+    />
+  </div>
+</template>

+ 61 - 4
src/views/sheetShow/index.vue

@@ -4,6 +4,7 @@ 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';
 
 const route = useRoute();
 const code = ref(route.query.code || '')
@@ -19,7 +20,18 @@ interface InfoType extends IUnknowObject {
 const showData = ref(false);
 const info = ref<InfoType|any>({});
 const loading = ref(false);
-const getInfo = async() => {
+
+
+const setDefaultSource=(sourceText:string)=>{
+  return JSON.stringify({
+    isShow: true,
+    text: sourceText,
+    color: "#606266",
+    fontSize: 9
+  })
+}
+
+const getInfo = async(type='') => {
   loading.value = true;
   const { Data,Ret } = await SheetApi.getInfo({  UniqueCode: code.value, FromScene: Number(route.query.fromScene||'') });
   
@@ -27,8 +39,11 @@ const getInfo = async() => {
   if(Ret !== 200) return
 
   info.value = Data;
-  showData.value = true;
-
+  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;
 
@@ -44,6 +59,14 @@ const getInfo = async() => {
 }
 getInfo()
 
+const refreshSheet = async()=>{
+    loading.value = true;
+    let res: any=null;
+    res = await SheetApi.refreshInfo({UniqueCode: code.value})
+    if(res.Ret!==200) return 
+    loading.value = false;
+    getInfo('refresh')
+}
 
 </script>
 
@@ -55,9 +78,23 @@ getInfo()
     element-loading-spinner="el-icon-loading"
     element-loading-text="加载中..."
   >
-    <h3 class="title">{{info.ExcelName}}</h3>
+    <!-- <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>
+      </div>
+      <!-- 占位 -->
+      <div v-else></div>
+      <span @click="refreshSheet" style="color: #666;">刷新</span>
+    </div>
   </div>
 </template>
 
@@ -75,5 +112,25 @@ getInfo()
     // text-align: center;
     margin-bottom: 8px;
   }
+  .tool{
+    // text-align: right;
+    margin-top: 5px;
+    span{
+        cursor: pointer;
+    }
+  }
+  .sheet-bottom{
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    white-space: nowrap;
+    padding: 0 10px;
+    .sheet-source{
+      width: 30%;
+      min-width: 150px;
+      overflow: hidden;
+      text-overflow: ellipsis;
+    }
+  }
 }
 </style>

Деякі файли не було показано, через те що забагато файлів було змінено