|
@@ -1,5 +1,5 @@
|
|
|
<script setup>
|
|
|
-import {ref,nextTick, reactive} from 'vue'
|
|
|
+import {ref,nextTick, reactive,computed} from 'vue'
|
|
|
import apiETAChart from '@/api/chart'
|
|
|
import apiFutureChart from '@/api/futureChart'
|
|
|
import apiCorrelationChart from '@/api/correlationChart'
|
|
@@ -21,7 +21,19 @@ import SetChartEnName from '@/components/SetChartEnName.vue'
|
|
|
import {useCachedViewsStore} from '@/store/modules/cachedViews'
|
|
|
import AddChartToMyETA from '@/views/chartETA/components/AddChartToMyETA.vue'
|
|
|
import { setExtremumDate } from '@/hooks/chart/commonFun.js'
|
|
|
-
|
|
|
+import {myETABtn,useAuthBtn} from '@/hooks/useAuthBtn'
|
|
|
+const {checkAuthBtn} = useAuthBtn()
|
|
|
+
|
|
|
+const isMoreActionShow = computed(()=>{
|
|
|
+ return checkAuthBtn(myETABtn.myChart_refresh)
|
|
|
+ || checkAuthBtn(myETABtn.myChart_share)
|
|
|
+ || checkAuthBtn(myETABtn.myChart_move)
|
|
|
+ || checkAuthBtn(myETABtn.myChart_copyTo)
|
|
|
+ || checkAuthBtn(myETABtn.myChart_otherSave)
|
|
|
+ || (checkAuthBtn(myETABtn.myChart_copyWechat)&&checkAuthBtn(myETABtn.myChart_copyOffice))
|
|
|
+ || checkAuthBtn(myETABtn.myChart_enNameSetting)
|
|
|
+ || checkAuthBtn(myETABtn.myChart_del)
|
|
|
+})
|
|
|
const { width, height } = useWindowSize()
|
|
|
const cachedViewsStore=useCachedViewsStore()
|
|
|
const {options,axisLimitState,chartRender}=useChartRender()
|
|
@@ -524,6 +536,120 @@ function handleChartShare(){
|
|
|
const url=import.meta.env.VITE_CHART_LINK+`?code=${chartInfo.value.UniqueCode}&fromType=share&lang=ch`
|
|
|
setClipboardData(url)
|
|
|
}
|
|
|
+//保存图表:目前myETA里能保存的只有ETA图库的图和商品价格曲线图
|
|
|
+function handleChartSave(){
|
|
|
+ const sourceMap = {
|
|
|
+ 1: saveChartHandle,
|
|
|
+ 2: saveCommodityChart,//商品价格曲线
|
|
|
+ 5: saveCommodityChart,//利润曲线
|
|
|
+ }
|
|
|
+ sourceMap[chartInfo.value.Source]&&sourceMap[chartInfo.value.Source]();
|
|
|
+}
|
|
|
+function saveChartHandle(){
|
|
|
+ //获取每条线的指标配置
|
|
|
+ let arr = edbList.value.map((item)=>{
|
|
|
+ return {
|
|
|
+ ChartColor: item.ChartColor,
|
|
|
+ PredictChartColor: item.PredictChartColor,
|
|
|
+ ChartStyle: item.ChartStyle,
|
|
|
+ ChartWidth: Number(item.ChartWidth),
|
|
|
+ EdbInfoId: item.EdbInfoId,
|
|
|
+ EdbInfoType: item.EdbInfoType,
|
|
|
+ IsAxis: item.IsAxis,
|
|
|
+ IsOrder: item.IsOrder,
|
|
|
+ LeadUnit: item.EdbInfoType ? '' : item.LeadUnit,
|
|
|
+ LeadValue: item.EdbInfoType ? 0 : Number(item.LeadValue),
|
|
|
+ MaxData: Number(item.MaxData),
|
|
|
+ MinData: Number(item.MinData),
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //所有图表的公共参数
|
|
|
+ let public_param = {
|
|
|
+ ChartClassifyId: chartInfo.value.ChartClassifyId,
|
|
|
+ ChartInfoId: chartInfo.value.ChartInfoId,
|
|
|
+ ChartEdbInfoList: arr,
|
|
|
+ }
|
|
|
+ //根据ChartType决定剩余参数
|
|
|
+ let type_param = {}
|
|
|
+ switch(chartInfo.value.ChartType){
|
|
|
+ case 2:
|
|
|
+ type_param = {
|
|
|
+ DateType: chartState.yearVal,
|
|
|
+ StartYear:chartState.startYear || 0,
|
|
|
+ Calendar: chartState.calendarType,
|
|
|
+ StartDate: chartState.startTime||'',
|
|
|
+ EndDate: chartState.endTime||'',
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 7:
|
|
|
+ type_param = {
|
|
|
+ DateType: 6,
|
|
|
+ LeftMin: String(axisLimitState.leftMin),
|
|
|
+ LeftMax: String(axisLimitState.leftMax),
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 10:
|
|
|
+ type_param = {
|
|
|
+ DateType: 6,
|
|
|
+ Calendar: "公历",
|
|
|
+ ExtraConfig: JSON.stringify({
|
|
|
+ ...JSON.parse(chartInfo.value.ExtraConfig),
|
|
|
+ XMinValue: String(axisLimitState.xMin),
|
|
|
+ XMaxValue: String(axisLimitState.xMax),
|
|
|
+ YMinValue: String(axisLimitState.leftMin),
|
|
|
+ YMaxValue: String(axisLimitState.leftMax),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if(sameOptionType.includes(chartInfo.value.ChartType)){
|
|
|
+ type_param = {
|
|
|
+ DateType: chartState.yearVal,
|
|
|
+ StartYear:chartState.startYear || 0,
|
|
|
+ StartDate:chartState.yearVal === 5 || chartState.yearVal === 6
|
|
|
+ ? chartState.startTime
|
|
|
+ : '',
|
|
|
+ EndDate: chartState.yearVal === 5 ? chartState.endTime : '',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let params = {...public_param,...type_param}
|
|
|
+ //保存
|
|
|
+ apiChart.chartSave(params).then(async res=>{
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ showToast("保存成功")
|
|
|
+ setChartImage()
|
|
|
+ })
|
|
|
+}
|
|
|
+function saveCommodityChart(){
|
|
|
+ apiMyETAChart.myETASaveChart({
|
|
|
+ ChartInfoId:chartInfo.value.ChartInfoId,
|
|
|
+ LeftMin:String(axisLimitState.leftMin),
|
|
|
+ LeftMax:String(axisLimitState.leftMax),
|
|
|
+ }).then(res=>{
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ showToast("保存成功")
|
|
|
+ setChartImage()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//更新缩略图
|
|
|
+async function setChartImage(){
|
|
|
+ //打开保存图片弹窗
|
|
|
+ const svgData = CHARTINS.getSVG({
|
|
|
+ chart: {
|
|
|
+ width: 340,
|
|
|
+ height: 230,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let form = new FormData();
|
|
|
+ form.append('Img', svgData);
|
|
|
+ let {Data,Ret} = await apiETAChart.uploadChartImg(form)
|
|
|
+ if(Ret!==200||!Data) return
|
|
|
+ await apiETAChart.setChartImg({
|
|
|
+ ChartInfoId:Number(chartInfo.value.ChartInfoId),
|
|
|
+ ImageUrl:Data.ResourceUrl
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
//保存图片
|
|
|
let savePicDialogShow = ref(false)
|
|
@@ -597,11 +723,11 @@ const isShowAddToMyETADialog=ref(false)
|
|
|
>{{chartState.startTime?chartState.startTime+'~'+(chartState.endTime?chartState.endTime:'至今'):'请选择时间段'}}</span>
|
|
|
</div>
|
|
|
<div class="right-action-box">
|
|
|
- <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)">
|
|
|
+ <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
|
|
|
<img src="@/assets/imgs/myETA/icon_limit2.png" alt="">
|
|
|
<span>上下限设置</span>
|
|
|
</div>
|
|
|
- <div class="item" @click="showMoreAction=true">
|
|
|
+ <div class="item" @click="showMoreAction=true" v-if="isMoreActionShow||$route.query.from==='edbRelationChart'">
|
|
|
<img src="@/assets/imgs/chartETA/more-icon.png" alt="">
|
|
|
<span>更多设置</span>
|
|
|
</div>
|
|
@@ -659,11 +785,11 @@ const isShowAddToMyETADialog=ref(false)
|
|
|
<img class="icon" style="transform: rotate(180deg);" src="@/assets/imgs/icon_arrow.png" alt="">
|
|
|
<div>下一张</div>
|
|
|
</div>
|
|
|
- <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)">
|
|
|
+ <div class="item" @click="handleShowAxisLimitOpt" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_editLimit)">
|
|
|
<img class="icon" src="@/assets/imgs/myETA/icon_limit.png" alt="">
|
|
|
<div>上下限</div>
|
|
|
</div>
|
|
|
- <div class="item" @click="showMoreAction=true">
|
|
|
+ <div class="item" @click="showMoreAction=true" v-if="isMoreActionShow||$route.query.from==='edbRelationChart'">
|
|
|
<img class="icon" src="@/assets/imgs/myETA/icon_menu.png" alt="">
|
|
|
<div>更多</div>
|
|
|
</div>
|
|
@@ -815,31 +941,34 @@ const isShowAddToMyETADialog=ref(false)
|
|
|
>
|
|
|
<div class="more-action-wrap">
|
|
|
<div class="van-ellipsis title-box">{{chartInfo.ChartName}}</div>
|
|
|
- <div class="item" @click.stop="handleChartRefresh">
|
|
|
+ <div class="item" @click.stop="handleChartRefresh" v-permission="myETABtn.myChart_refresh">
|
|
|
刷新
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleChartShare" v-if="!chartInfo.Disabled">
|
|
|
+ <div class="item" @click.stop="handleChartShare" v-if="!chartInfo.Disabled&&checkAuthBtn(myETABtn.myChart_share)">
|
|
|
分享
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleRemoveChart" v-if="$route.query.iscommon!='true'">
|
|
|
+ <div class="item" @click.stop="handleChartSave" v-if="![3,4,6,7,8,9].includes(chartInfo.Source)&&checkAuthBtn(myETABtn.myChart_save)">
|
|
|
+ 保存
|
|
|
+ </div>
|
|
|
+ <div class="item" @click.stop="handleRemoveChart" v-if="$route.query.iscommon!='true'&&checkAuthBtn(myETABtn.myChart_move)">
|
|
|
移出
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleShowCopyTo" v-if="$route.query.iscommon!='true'">
|
|
|
+ <div class="item" @click.stop="handleShowCopyTo" v-if="$route.query.iscommon!='true'&&checkAuthBtn(myETABtn.myChart_copyTo)">
|
|
|
复制到
|
|
|
</div>
|
|
|
<div class="item" @click.stop="isShowAddToMyETADialog=true" v-if="$route.query.from==='edbRelationChart'">
|
|
|
加入我的图库
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="showSaveChartOther=true" v-if="chartInfo.Button.IsCopy">
|
|
|
+ <div class="item" @click.stop="showSaveChartOther=true" v-if="chartInfo.Button.IsCopy&&checkAuthBtn(myETABtn.myChart_otherSave)">
|
|
|
另存为
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleChartSavePicture" v-if="!chartInfo.Disabled">
|
|
|
+ <div class="item" @click.stop="handleChartSavePicture" v-if="!chartInfo.Disabled&&checkAuthBtn(myETABtn.myChart_copyWechat)&&checkAuthBtn(myETABtn.myChart_copyOffice)">
|
|
|
保存图片
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleShowEditEnName">
|
|
|
+ <div class="item" @click.stop="handleShowEditEnName" v-permission="myETABtn.myChart_enNameSetting">
|
|
|
设置英文名称
|
|
|
</div>
|
|
|
- <div class="item" @click.stop="handleDeleteChart" v-if="chartInfo.IsEdit">
|
|
|
+ <div class="item" @click.stop="handleDeleteChart" v-if="chartInfo.IsEdit&&checkAuthBtn(myETABtn.myChart_del)">
|
|
|
删除
|
|
|
</div>
|
|
|
</div>
|