浏览代码

Merge branch 'ch/ht_3.1' of eta_front/eta_chart_front into master

leichen 2 月之前
父节点
当前提交
b7f4062020

+ 16 - 1
src/request/api.ts

@@ -65,7 +65,22 @@ export const ChartApi = {
 	 */
 	chartCollect:params=>{
 		return post('/chart/dw/collect',params)
-	}
+	},
+
+	
+	// 海通
+	/**
+	 * 图表详情
+	 */
+	chartDetail:params=>{
+		return get('/chart/detail',params)
+	},
+	/**
+	 * 图表收藏/取消收藏
+	 */
+	chartMiniBookMark:params=>{
+		return post('/chart/mini/bookMark',params)
+	},
 }
 
 /* 表格模块 */

+ 5 - 0
src/router/index.ts

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

+ 44 - 0
src/views/chartShow/components/collectBtnHT.vue

@@ -0,0 +1,44 @@
+<script setup>
+import {ref} from 'vue'
+import {apiChartIsCollect} from '@/request/yb/api'
+import { useRoute } from 'vue-router'
+import { ElMessage } from 'element-plus';
+import { ChartApi } from '@/request/api';
+
+const route=useRoute()
+
+let isCollect=ref(false)
+async function getInitStatus(){
+    const params={
+        UniqueCode:route.query.code || '',
+        MiniSource:'ht',
+    }
+    const { Data } = await ChartApi.chartDetail(params);
+    isCollect.value=Data.IsCollect
+}
+getInitStatus()
+
+// 收藏状态修改
+async function handleCollectStatusChange(){
+    const params={
+        uniqueCode:route.query.code || '',
+        source:'ht',
+        // Token:route.query.token,
+        action: isCollect.value ? 'unBookMark' : 'bookMark'
+      }
+      const res=await ChartApi.chartMiniBookMark(params)
+      if(res.Ret===200){
+        ElMessage.success(isCollect.value?'取消收藏成功':'收藏成功')
+        isCollect.value=!isCollect.value
+      }
+}
+
+</script>
+
+<template>
+    <div @click="handleCollectStatusChange">{{isCollect?'取消收藏':'收藏'}}</div>
+</template>
+
+<style>
+
+</style>

+ 12 - 3
src/views/chartShow/index.vue

@@ -57,7 +57,7 @@
     <div class="bootom-source">
 
       <!-- 自定义来源 -->
-      <div>
+      <div class="source-box">
         <div class="chart-source text_oneLine" 
           v-if="chartInfo.SourcesFrom&&JSON.parse(chartInfo.SourcesFrom).isShow"
           :style="`
@@ -74,6 +74,7 @@
         <li v-if="$route.query.source==='ybxcx'"><collectBtn/></li>
         <!-- eta小程序报告详情中的有收藏 -->
         <li v-if="$route.query.source==='etamini'" @click="handleChangeChartCollect">{{IsCollect?'取消收藏':'收藏'}}</li>
+        <li v-if="$route.query.source==='ht_chart'"><collectBtnHT/></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>
@@ -90,13 +91,15 @@ import chart from '@/components/chart.vue';
 import { IState } from './typing';
 import { ChartApi } from '@/request/api';
 import collectBtn from './components/collectBtn.vue'
+import collectBtnHT from './components/collectBtnHT.vue'
 import { useChartRender } from '@/hooks/chart/useChartRender';
 
 
 export default defineComponent({
   components: {
     chart,
-    collectBtn
+    collectBtn,
+    collectBtnHT
   },
   setup() {
     const route = useRoute();
@@ -125,7 +128,7 @@ export default defineComponent({
     const language = ref(route.query.fromPage || route.query.lang || 'zh');
     const IsCollect=ref(false)//图表是否收藏
     const getChartInfo = async (type='') => {
-
+      localStorage.setItem('token', `Bearer ${route.query.token}`)
       if(!code.value) {
         haveData.value = false; 
         return
@@ -141,6 +144,9 @@ export default defineComponent({
           params.Source=1
           params.Token=route.query.token
         }
+        if(route.query.source==='ht_chart'){
+          params.MiniSource='ht'
+        }
         const { Data } = await ChartApi.getChart(params);
         loading.value = false;
         state.chartInfo = Data.ChartInfo;
@@ -240,4 +246,7 @@ export default defineComponent({
 </script>
 <style scoped lang="less">
 @import './index.less';
+.source-box {
+  max-width: 50%;
+}
 </style>

+ 65 - 0
src/views/chartShow/previewHT.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.chartDetail({
+      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>