Browse Source

myETA权限设置,myETA保存功能

cxmo 1 year ago
parent
commit
365a2b7c60

+ 7 - 0
src/api/myETA.js

@@ -235,5 +235,12 @@ export default{
      */
     myETAClassifySort(params){
         return post('/my_chart/classify/move',params)
+    },
+    /**
+     * myETA中保存商品价格曲线图
+     * @param {*} params ChartInfoId LeftMin LeftMax
+     */
+    myETASaveChart(params){
+        return post('/future_good/chart_info/save',params)
     }
 }

+ 23 - 1
src/hooks/useAuthBtn.js

@@ -81,7 +81,29 @@ export const chartLibBtn={
 /*
 ------------------------MyETA--------------------
 */
-export const myETABtn={}
+export const myETABtn={
+    /*-----------图表详情弹窗按钮--------- */
+    myChart_del:'myChart:del',
+    myChart_enNameSetting:'myChart:enNameSetting',
+    myChart_copyWechat:'myChart:copyWechat',
+    myChart_copyOffice:'myChart:copyOffice',
+    myChart_otherSave:'myChart:otherSave',
+    myChart_save:'myChart:save',
+    myChart_refresh:'myChart:refresh',
+    myChart_copyTo:'myChart:copyTo',
+    myChart_share:'myChart:share',
+    myChart_move:'myChart:move',//移出,同时也控制列表项的移出
+    myChart_copyData:'myChart:copyData',//复制数据
+    myChart_checkData:'myChart:checkData',//查看数据
+    myChart_editLimit:'myChart:editLimit',//编辑上下限
+    /*-----------页面按钮--------- */
+    myChart_selectChart:'myChart:selectChart',//选择图表
+    myChart_classifyOpt_copy:'myChart:classifyOpt:copy',//复制
+    myChart_classifyOpt_show:'myChart:classifyOpt:show',//可见权限
+    myChart_classifyOpt_edit:'myChart:classifyOpt:edit',//添加我的分类
+    myChart_classifyOpt_rename:'myChart:classifyOpt:rename',//重命名
+    myChart_classifyOpt_delete:'myChart:classifyOpt:delete',//删除
+}
 
 
 export function useAuthBtn(){

+ 6 - 0
src/store/modules/authBtn.js

@@ -37,6 +37,12 @@ export const useAuthBtnStore = defineStore('authBtn',{
                     //chart
                     {ButtonCode:'chartLib:copyWechat'},
                     {ButtonCode:'chartLib:copyOffice'},
+                    {ButtonCode:'chartLib:editLimit'},
+
+                    {ButtonCode:'myChart:selectChart'},
+                    {ButtonCode:'myChart:move'},
+                    {ButtonCode:'myChart:save'},
+                    {ButtonCode:'myChart:editLimit'},
 
                 ]
                 resolve('权限获取成功')

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

@@ -494,7 +494,6 @@ function saveChart(){
     
 }
 async function setChartImage(){
-    //打开保存图片弹窗
     const svgData = highChart.value.getSVG({
         chart: {
             width: 340,

+ 142 - 14
src/views/myETA/ChartDetail.vue

@@ -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,119 @@ 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} = await apiETAChart.uploadChartImg(form)
+    await apiETAChart.setChartImg({
+        ChartInfoId:Number(chartInfo.value.ChartInfoId),
+        ImageUrl:Data.ResourceUrl
+    })
+}
 
 //保存图片
 let savePicDialogShow = ref(false)
@@ -597,11 +722,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 +784,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 +940,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>

+ 22 - 8
src/views/myETA/Index.vue

@@ -7,6 +7,8 @@ import { showConfirmDialog, showToast } from 'vant';
 import { useWindowSize } from '@vueuse/core'
 import draggable from 'vuedraggable'
 import {useCachedViewsStore} from '@/store/modules/cachedViews'
+import {myETABtn,useAuthBtn} from '@/hooks/useAuthBtn'
+const {checkAuthBtn} = useAuthBtn()
 
 const cachedViewsStore=useCachedViewsStore()
 const { width, height } = useWindowSize()
@@ -32,6 +34,18 @@ const {
 const curChartClassifyList=computed(()=>{
     return classifyState.classifyTypeAct==1?classifyState.myClassifyList:classifyState.pubClassifyList
 })
+//我的图库/公共图库opt:重命名、可见、复制、删除
+const isOptShow = computed(()=>{
+    if(classifyState.classifyTypeAct===1){
+        return checkAuthBtn(myETABtn.myChart_classifyOpt_rename)
+            || checkAuthBtn(myETABtn.myChart_classifyOpt_show)
+            || checkAuthBtn(myETABtn.myChart_classifyOpt_copy)
+            || checkAuthBtn(myETABtn.myChart_classifyOpt_delete)
+    }
+    if(classifyState.classifyTypeAct===2){
+        return checkAuthBtn(myETABtn.myChart_classifyOpt_copy)
+    }
+})
 // 拖动排序结束
 function onClassifySortEnd(e){
     console.log(e);
@@ -172,7 +186,7 @@ async function goSearch(){
                     placeholder="请输入图表名称"
                     @click="goSearch"
                 />
-                <img @click="goChooseChart" class="icon" src="@/assets/imgs/myETA/icon_select.png" alt="icon">
+                <img @click="goChooseChart" class="icon" src="@/assets/imgs/myETA/icon_select.png" alt="icon" v-permission="myETABtn.myChart_selectChart">
                 <img @click="showClassifyPop=true" class="icon" src="@/assets/imgs/myETA/icon_menu2.png" alt="icon">
             </div>
             <p style="margin-top:10px;font-weight:bold">{{listState.ctype}}{{listState.cname?'/'+listState.cname:''}}</p>
@@ -197,7 +211,7 @@ async function goSearch(){
                     <img class="img" :src="item.ChartImage" alt="">   
                     <div class="time">
                         <span>{{item.CreateTime.slice(0,10)}}</span>
-                        <img v-if="listState.ctype==='我的图库'" class="remove-box" @click.stop="handleRemoveChart(item,index)" src="@/assets/imgs/myETA/icon_remove2.png" alt="">
+                        <img v-if="listState.ctype==='我的图库'&&checkAuthBtn(myETABtn.myChart_move)" class="remove-box" @click.stop="handleRemoveChart(item,index)" src="@/assets/imgs/myETA/icon_remove2.png" alt="">
                     </div>
                 </li>
             </ul>
@@ -240,7 +254,7 @@ async function goSearch(){
                                 <path d="M40.4087 23.8334L33.7785 18.3083V22.7283H24.9384V13.8882H29.3585L23.8334 7.25806L18.3083 13.8882H22.7283V22.7283H13.8882V18.3083L7.25806 23.8334L13.8882 29.3585V24.9384H22.7283V33.7785H18.3083L23.8334 40.4087L29.3585 33.7785H24.9384V24.9384H33.7785V29.3585L40.4087 23.8334Z" fill="#666666"/>
                             </svg>
                         </div>
-                        <div class="icon-menu-box" @click.stop="handleShowOpt(element)">
+                        <div class="icon-menu-box" @click.stop="handleShowOpt(element)" v-if="isOptShow">
                             <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">
                                 <path d="M24 33C25.65 33 27 34.35 27 36C27 37.65 25.65 39 24 39C22.35 39 21 37.65 21 36C21 34.35 22.35 33 24 33ZM21 24C21 25.65 22.35 27 24 27C25.65 27 27 25.65 27 24C27 22.35 25.65 21 24 21C22.35 21 21 22.35 21 24ZM21 12C21 13.65 22.35 15 24 15C25.65 15 27 13.65 27 12C27 10.35 25.65 9 24 9C22.35 9 21 10.35 21 12Z" fill="#666666"/>
                             </svg>
@@ -248,7 +262,7 @@ async function goSearch(){
                     </li>
                 </template>
             </draggable>
-            <div class="bot-btns">
+            <div class="bot-btns" v-permission="myETABtn.myChart_classifyOpt_edit">
                 <van-button type="primary" block @click="handleAddClassify('')">添加我的分类</van-button>
             </div>
         </div>
@@ -281,11 +295,11 @@ async function goSearch(){
             </div> -->
             <!-- 我的图库分类操作 -->
             <template v-if="classifyState.classifyTypeAct==1">
-            <div class="item border" @click="handleAddClassify(classifyState.activeClassifyVal)">
+            <div class="item border" @click="handleAddClassify(classifyState.activeClassifyVal)" v-permission="myETABtn.myChart_classifyOpt_edit">
                 <!-- <img src="@/assets/imgs/ppt/ppt_icon_write.png" alt=""> -->
                 <span>重命名</span>
             </div>
-            <div class="item border">
+            <div class="item border" v-permission="myETABtn.myChart_classifyOpt_show">
                 <!-- <img src="@/assets/imgs/icon_user.png" alt=""> -->
                 <span style="display:inline-block;margin-right:10px">所有人可见</span>
                 <van-switch
@@ -295,14 +309,14 @@ async function goSearch(){
                     @update:model-value="handleClassifyShare"
                 />
             </div>
-            <div class="item border red" @click="handleClassifyDel(classifyState.activeClassifyVal)">
+            <div class="item border red" @click="handleClassifyDel(classifyState.activeClassifyVal)" v-permission="myETABtn.myChart_classifyOpt_delete">
                 <!-- <img src="@/assets/imgs/icon_del.png" alt=""> -->
                 <span>删除</span>
             </div>
             </template>
             <!-- 公共图库分类操作 -->
             <template v-if="classifyState.classifyTypeAct==2">
-            <div class="item border" @click="handleCopyClassify(classifyState.activeClassifyVal)">
+            <div class="item border" @click="handleCopyClassify(classifyState.activeClassifyVal)" v-permission="myETABtn.myChart_classifyOpt_copy">
                 <!-- <img src="@/assets/imgs/ppt/ppt_icon_copy.png" alt=""> -->
                 <span>复制</span>
             </div>

+ 5 - 4
src/views/myETA/components/EDBInfo.vue

@@ -6,7 +6,8 @@ import _ from 'lodash'
 // import apiChart from '@/api/chart'
 import SourceDetail from '@/views/chartETA/components/SourceDetail.vue'
 import {useCopyEdbData} from '@/hooks/edb/useCopyEdbData'
-
+import {myETABtn,useAuthBtn} from '@/hooks/useAuthBtn'
+const {checkAuthBtn} = useAuthBtn()
 const {copyData} =useCopyEdbData()
 
 const leadUnitOpt=[{text:'年'}, {text:'季'}, {text:'月'}, {text:'周'}, {text:'天'}]//领先指标频度配置
@@ -238,9 +239,9 @@ function handleCopyEDBData(){
                         </div>
                     </div>
                     </template>
-                    <div class="item-box">
-                        <van-button color="#F2F3FF" size="small" style="color:#0052D9;margin-right:10px" @click="handleCopyEDBData">复制数据</van-button>
-                        <van-button color="#0052D9" size="small">查看数据</van-button>
+                    <div class="item-box" v-if="checkAuthBtn(myETABtn.myChart_checkData)||checkAuthBtn(myETABtn.myChart_copyData)">
+                        <van-button color="#F2F3FF" size="small" style="color:#0052D9;margin-right:10px" @click="handleCopyEDBData" v-permission="myETABtn.myChart_copyData">复制数据</van-button>
+                        <van-button color="#0052D9" size="small" v-permission="myETABtn.myChart_checkData">查看数据</van-button>
                     </div>
                 </div>
             </div>