Browse Source

区间分析

jwyu 7 months ago
parent
commit
9f632289ff

+ 5 - 1
src/api/modules/intervalAnalysis.js

@@ -67,9 +67,13 @@ export default{
     return http.get('/range_analysis/chart_info/detail',params)
   },
 
-  // 指标保存
+  // 指标保存/更新
   edbSave:params=>{
     return http.post('/range_analysis/edb/save',params)
+  },
+  // 获取上次保存过的指标集合
+  getSavedEdbList:params=>{
+    return http.get('/range_analysis/edb/list',params)
   }
   
 }

+ 2 - 0
src/components/selectUnit.vue

@@ -54,6 +54,8 @@ export default {
             handler(){
                 if(this.value){
                     this.unit = this.getUnitTrans(this.value)
+                }else{
+                    this.unit=''
                 }
             },
             immediate:true

+ 0 - 2
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -2690,8 +2690,6 @@ export const chartSetMixin = {
     initIntervalAnalysisChartData(data){
       // 
       console.log('初始化区间分析数据');
-      this.tableData=data.EdbInfoList
-      this.chartInfo=data.ChartInfo
       this.intervalAnalysisChartData=data.DataResp
       this.setLimitData(this.tableData)
       this.setIntervalAnalysisChart()

+ 149 - 17
src/views/intervalAnalysis/addChart.vue

@@ -44,6 +44,7 @@
         <edbComputedWrap
           :computedType="computedType"
           @showBatchSelectEdb="handleShowBatchSelectEdb"
+          @closeChart="handleCloseChart"
           ref="edbComputedWrap"
         />
       </div>
@@ -74,21 +75,39 @@
             </template>
           </div>
           <div class="top-left">
+            <!-- 保存指标 -->
             <el-button
+              v-if="!hasSaveEdbFlag"
               type="primary"
               size="medium"
               class="year-btn"
               @click="handleShowSaveEdb"
               >{{$t('StatisticAnalysis.ChartRelevance.save_edb')}}</el-button
             >
+            <!-- 更新指标 -->
+            <el-dropdown 
+              v-else
+              split-button 
+              size="medium"
+              type="primary" 
+              class="year-btn"
+              @click="updateEdbHandle" 
+              @command="edbSaveOtherHandle"
+            >
+              {{$t('StatisticAnalysis.ChartRelevance.update_edb')}}
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item :command="{scence:'saveOther'}">{{$t('StatisticAnalysis.ChartRelevance.save_other')}}</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+
             <el-dropdown
               v-if="$route.query.id"
               split-button
               size="medium"
               type="primary"
               class="year-btn"
-              @click="updateEdbHandle"
-              @command="edbCommandHandle"
+              @click="updateChartHandle"
+              @command="showChartSaveOther"
             >
               {{ $t("StatisticAnalysis.ChartRelevance.update_edb") }}
               <el-dropdown-menu slot="dropdown">
@@ -259,8 +278,10 @@
       :isShow="showSingleEdbSave"
       :singleEdbData="singleEdbData"
       :tableData="tableData"
-      @close="showSingleEdbSave = false"
-      @save="handleSaveEdb"
+      :MultipleGraphConfigId="MultipleGraphConfigId"
+      :IsEdbSaveAs="IsEdbSaveAs"
+      @close="showSingleEdbSave = false;IsEdbSaveAs=false"
+      @success="handleSaveEdbSuccess"
     />
 
     <!-- 多指标计算保存指标 -->
@@ -268,8 +289,11 @@
       :isShow="showMultipleEdbSave"
       :singleEdbData="singleEdbData"
       :tableData="tableData"
-      @close="showMultipleEdbSave = false"
-      @save="handleSaveEdb"
+      :MultipleGraphConfigId="MultipleGraphConfigId"
+      :IsEdbSaveAs="IsEdbSaveAs"
+      :updateBeforeEdbList="updateBeforeEdbList"
+      @close="showMultipleEdbSave = false;IsEdbSaveAs=false"
+      @success="handleSaveEdbSuccess"
     />
 
     <!-- 图表设置 -->
@@ -389,7 +413,12 @@ export default {
 
       isShowSaveOther: false,//另存为
 
-      showExplain:false
+      showExplain:false,
+
+      MultipleGraphConfigId:0,//配置id
+      hasSaveEdbFlag:false,//是否保存过指标了
+      IsEdbSaveAs:false,//是否为指标另存为
+      updateBeforeEdbList:[],//上次保存过的指标
     }
   },
   methods: {
@@ -402,23 +431,85 @@ export default {
         this.showMultipleEdbSave = true
       }
     },
-    // 保存指标
-    handleSaveEdb(arr){
+    // 保存指标成功回调
+    handleSaveEdbSuccess(){
+      this.hasSaveEdbFlag=true
+    },
+    // 更新指标
+    async updateEdbHandle(){
+      const res=await apiIntervalAnalysis.getSavedEdbList({
+        MultipleGraphConfigId:this.MultipleGraphConfigId
+      })
+      if(res.Ret!==200) return
+      const list=res.Data.EdbInfoList
+      this.updateBeforeEdbList=list
+      // 更新单指标的指标
+      if(this.computedType===0){
+        this.handleUpdateSingleEdb(list)
+      }else{
+        this.handleUpdateMultipleEdb(list)
+      }
+    },
+    // 更新单指标的指标
+    handleUpdateSingleEdb(list){
+
+      //修改了指标类型(如从指标库切换到了预测指标库)则弹出弹窗
+      if(list[0].EdbTypeInfo!==this.tableData[0].EdbInfoCategoryType){
+        this.handleShowSaveEdb()
+        return
+      }
+
       const edbParams = this.$refs.edbComputedWrap.getParams()
+      const edbList=[{
+        ...list[0],
+        FromEdbInfoId:this.tableData[0].EdbInfoId
+      }]
       const params={
-        EdbInfoList:arr,
-        MultipleGraphConfigId:this.intervalAnalysisChartData.MultipleGraphConfigId,
+        EdbInfoList:edbList,
+        MultipleGraphConfigId:this.MultipleGraphConfigId,
         IsSaveAs:false,
         EdbInfoType:this.tableData[0].EdbInfoCategoryType,
         ExtraConfig:JSON.stringify(edbParams.ExtraConfig)
       }
       apiIntervalAnalysis.edbSave(params).then(res=>{
         if(res.Ret===200){
-          this.$message.success(this.$t('MsgPrompt.saved_msg'))
-          this.showMultipleEdbSave=false
+          this.$message.success(this.$t('StatisticAnalysis.ChartRelevance.update_success'));
         }
       })
     },
+    // 更新多指标的指标
+    async handleUpdateMultipleEdb(list){
+      // 判断是否修改了指标
+      let flag=false
+      this.tableData.forEach(item => {
+        if(!list.some(_i=>_i.FromEdbInfoId===item.EdbInfoId)){
+          flag=true
+        }
+      });
+      if(flag){
+        this.handleShowSaveEdb()
+        return
+      }
+      const edbParams = this.$refs.edbComputedWrap.getParams()
+      const params={
+        EdbInfoList:list,
+        MultipleGraphConfigId:this.MultipleGraphConfigId,
+        IsSaveAs:false,
+        EdbInfoType:this.tableData[0].EdbInfoCategoryType,
+        ExtraConfig:JSON.stringify(edbParams.ExtraConfig)
+      }
+      apiIntervalAnalysis.edbSave(params).then(res=>{
+        if(res.Ret===200){
+          this.$message.success(this.$t('StatisticAnalysis.ChartRelevance.update_success'));
+        }
+      })
+    },
+
+    // 指标另存为
+    edbSaveOtherHandle(){
+      this.IsEdbSaveAs=true
+      this.handleShowSaveEdb()
+    },
 
     // 多指标选择回调
     handleBatchSelectEdbSuccess(e) {
@@ -434,6 +525,10 @@ export default {
         this.$message.warning('编辑状态不允许切换计算类型')
         return
       }
+      this.chartInfo=null
+      this.tableData=[]
+      this.MultipleGraphConfigId=0
+      this.hasSaveEdbFlag=false
       this.computedType = type
       if (type === 1 && this.$refs.edbComputedWrap.edbList.length === 0) {
         this.showBatchSelectEdb = true
@@ -466,11 +561,12 @@ export default {
     },
 
     //更新图
-    updateEdbHandle() {
+    updateChartHandle() {
       const edbParams = this.$refs.edbComputedWrap.getParams()
       const {
         min, max, rightMin, rightMax, rightTwoMin, rightTwoMax
       } = this.chartLimit
+      console.log(this.chartInfo);
       const params = {
         ChartInfoId: Number(this.$route.query.id),
         ChartEdbInfoList: edbParams.ChartEdbInfoList,
@@ -503,10 +599,16 @@ export default {
     },
 
     //另存为
-    edbCommandHandle(e) {
+    showChartSaveOther(e) {
       this.isShowSaveOther = true
     },
 
+    // 删除了指标则关闭右侧图
+    handleCloseChart(){
+      this.chartInfo=null
+      this.tableData=[]
+    },
+
     // 新增图
     handleSaveChart(e) {
       const edbParams = this.$refs.edbComputedWrap.getParams()
@@ -539,7 +641,11 @@ export default {
     async handleComputed() {
       const edbParams = this.$refs.edbComputedWrap.getParams()
       const params = {
-        ...edbParams,
+        ChartEdbInfoList:edbParams.ChartEdbInfoList,
+        ExtraConfig:{
+          ...edbParams.ExtraConfig,
+          MultipleGraphConfigId:this.MultipleGraphConfigId
+        },
         DateType: this.year_select,
         StartDate: [5, 6].includes(this.year_select)
           ? this.select_date[0]
@@ -547,7 +653,6 @@ export default {
         EndDate: this.year_select === 5 ? this.select_date[1] : '',
         StartYear: this.count_year || 0,
       }
-      console.log(params);
       if (!params.ChartEdbInfoList.length || !params.ChartEdbInfoList[0].EdbInfoId) {
         this.$message.warning('请选择指标')
         return
@@ -556,6 +661,12 @@ export default {
       const res = await apiIntervalAnalysis.chartPreview(params)
       if (res.Ret === 200) {
         this.initChartName(res.Data)
+        const data=res.data
+        this.MultipleGraphConfigId=res.Data.DataResp.MultipleGraphConfigId
+        this.tableData=res.Data.EdbInfoList
+        if(!this.chartInfo){
+          this.chartInfo=res.Data.ChartInfo
+        }
         this.initIntervalAnalysisChartData(res.Data)
       }
     },
@@ -634,6 +745,23 @@ export default {
       this.handleComputed();
     },
 
+    /* 设置默认时间选中项 */
+    setDefaultDateSelect() {
+      this.year_select = this.chartInfo.DateType;
+      this.select_date = [this.chartInfo.StartDate, this.chartInfo.EndDate];
+      this.count_year = this.chartInfo.StartYear;
+
+      this.dateTip =
+        this.chartInfo.DateType === 5
+          ? `${this.chartInfo.StartDate}~${this.chartInfo.EndDate}`
+          : this.chartInfo.DateType === 6
+          ? /* `${this.chartInfo.StartDate}~至今` */ this.$t('Chart.data_tip_since',{date:this.chartInfo.StartDate})
+          : this.chartInfo.DateType === 20
+          ?/* `最近${this.chartInfo.StartYear}年` */ this.$t('Chart.date_tip_count',{year:this.chartInfo.StartYear})
+          :/* '请选择时间段' */this.$t('Chart.choose_time');
+
+    },
+
     // 获取图表详情
     getChartInfo() {
       apiIntervalAnalysis.chartInfo({
@@ -641,6 +769,10 @@ export default {
       }).then(res => {
         if (res.Ret === 200) {
           this.initEditData(res.Data)
+          this.tableData=res.Data.EdbInfoList
+          this.chartInfo=res.Data.ChartInfo
+          this.setDefaultDateSelect()
+          
           this.initIntervalAnalysisChartData(res.Data)
         }
       })

+ 7 - 1
src/views/intervalAnalysis/components/batchSelectEdb.vue

@@ -387,9 +387,15 @@ export default {
         this.$message.warning(this.$t('Chart.Vailds.serie_name_msg'))
         return
       }
+      const arr=this.selectList.map(item=>{
+        return {
+          ...item,
+          EdbInfoCategoryType:item.EdbInfoType
+        }
+      })
       this.$emit('success', {
         seriesName: this.seriesName,
-        edbList: this.selectList
+        edbList: arr
       })
       this.$emit('close')
     },

+ 2 - 0
src/views/intervalAnalysis/components/edbComputedWrap.vue

@@ -549,9 +549,11 @@ export default {
         seriesName: this.seriesName
       })
     },
+    // 多指标删除指标
     handleDelBatchSelectEbd() {
       this.edbList = []
       this.seriesName = ''
+      this.$emit('closeChart')
     },
 
     // 获取参数

+ 270 - 140
src/views/intervalAnalysis/components/saveMultipleEdb.vue

@@ -1,46 +1,102 @@
 <template>
-	<el-dialog :modal-append-to-body="false" title="保存指标" :visible.sync="isShow" :close-on-click-modal="false" @close="cancelHandle" center v-dialogDrag>
-		<div class="save-multiple-edb-wrap">
-			<el-table :data="list" border height="500px">
-				<el-table-column :label="$t('EtaBasePage.full_metric_name')" align="center" :prop="$parent.currentLang === 'en' ? 'EdbNameEn' : 'EdbName'" />
-				<el-table-column :label="$t('EtaBasePage.gen_metric_name_label')" align="center">
-					<template slot-scope="scope">
-						<el-input v-model="scope.row.name" :placeholder="$t('EtaBasePage.metric_name_input')" style="width:100%" />
-					</template>
-				</el-table-column>
-				<el-table-column label="单位" align="center" width="200px">
-					<template slot-scope="scope">
-						<selectUnit v-model="scope.row.unit" />
-					</template>
-				</el-table-column>
-				<el-table-column :label="$t('Edb.Detail.e_fre')" align="center" width="200px">
-					<template slot-scope="scope">
-						<el-select v-model="scope.row.frequency" :placeholder="$t('EtaBasePage.select_frequency')" @change="handleFrequencyChange(scope)">
-							<el-option v-for="item in frequencyArr" :key="item" :label="item" :value="item">
-							</el-option>
-						</el-select>
-					</template>
-				</el-table-column>
-				<el-table-column align="center" width="300px">
-					<template slot="header" slot-scope="scope">
-						<span style="margin-right:40px;display:inline-block"> <!-- 目录 -->{{ $t('EtaBasePage.catalogue_directory') }}</span>
-						<el-radio-group v-model="classifyType" @change="handleClassifyTypeChange">
-							<el-radio :label="0"><!-- 分目录 -->{{ $t('EtaBasePage.subdirectory_radio') }}</el-radio>
-							<el-radio :label="1"><!-- 同目录 -->{{ $t('EtaBasePage.directory_radio') }}</el-radio>
-						</el-radio-group>
-					</template>
-					<template slot-scope="{row,$index}">
-						<el-cascader v-model="row.classify" :options="classifyOpt" :props="classifyProps" :placeholder="$t('Edb.InputHolderAll.input_menu')" @change="handleClassifyChange(row, $index)" />
-					</template>
-				</el-table-column>
-			</el-table>
-
-			<div class="dia-bot">
-				<el-button type="primary" style="margin-right: 20px" @click="saveHandle"><!-- 保存 -->{{ $t("Dialog.confirm_save_btn") }}</el-button>
-				<el-button type="primary" plain @click="cancelHandle"><!-- 取消 -->{{ $t("Dialog.cancel_btn") }}</el-button>
-			</div>
-		</div>
-	</el-dialog>
+  <el-dialog
+    :modal-append-to-body="false"
+    title="保存指标"
+    :visible.sync="isShow"
+    :close-on-click-modal="false"
+    @close="cancelHandle"
+    center
+    v-dialogDrag
+  >
+    <div class="save-multiple-edb-wrap">
+      <el-table :data="list" border height="500px">
+        <el-table-column
+          :label="$t('EtaBasePage.full_metric_name')"
+          align="center"
+          :prop="$parent.currentLang === 'en' ? 'EdbNameEn' : 'EdbName'"
+        />
+        <el-table-column
+          :label="$t('EtaBasePage.gen_metric_name_label')"
+          align="center"
+        >
+          <template slot-scope="scope">
+            <el-input
+              v-model="scope.row.name"
+              :placeholder="$t('EtaBasePage.metric_name_input')"
+              style="width: 100%"
+            />
+          </template>
+        </el-table-column>
+        <el-table-column label="单位" align="center" width="200px">
+          <template slot-scope="scope">
+            <selectUnit v-model="scope.row.unit" />
+          </template>
+        </el-table-column>
+        <el-table-column
+          :label="$t('Edb.Detail.e_fre')"
+          align="center"
+          width="200px"
+        >
+          <template slot-scope="scope">
+            <el-select
+              v-model="scope.row.frequency"
+              :placeholder="$t('EtaBasePage.select_frequency')"
+              @change="handleFrequencyChange(scope)"
+            >
+              <el-option
+                v-for="item in frequencyArr"
+                :key="item"
+                :label="item"
+                :value="item"
+              >
+              </el-option>
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" width="300px">
+          <template slot="header" slot-scope="scope">
+            <span style="margin-right: 40px; display: inline-block">
+              <!-- 目录 -->{{ $t("EtaBasePage.catalogue_directory") }}</span
+            >
+            <el-radio-group
+              v-model="classifyType"
+              @change="handleClassifyTypeChange"
+            >
+              <el-radio :label="0"
+                ><!-- 分目录 -->{{
+                  $t("EtaBasePage.subdirectory_radio")
+                }}</el-radio
+              >
+              <el-radio :label="1"
+                ><!-- 同目录 -->{{
+                  $t("EtaBasePage.directory_radio")
+                }}</el-radio
+              >
+            </el-radio-group>
+          </template>
+          <template slot-scope="{ row, $index }">
+            <el-cascader
+              :disabled="classifyType === 1 && $index > 0"
+              v-model="row.classify"
+              :options="classifyOpts"
+							:props="classifyProps"
+							:placeholder="$t('Chart.InputHolderAll.input_classify')"
+              @change="handleClassifyChange(row, $index)"
+            />
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <div class="dia-bot">
+        <el-button type="primary" style="margin-right: 20px" @click="saveHandle"
+          ><!-- 保存 -->{{ $t("Dialog.confirm_save_btn") }}</el-button
+        >
+        <el-button type="primary" plain @click="cancelHandle"
+          ><!-- 取消 -->{{ $t("Dialog.cancel_btn") }}</el-button
+        >
+      </div>
+    </div>
+  </el-dialog>
 </template>
 
 <script>
@@ -49,117 +105,191 @@ import apiIntervalAnalysis from "@/api/modules/intervalAnalysis";
 import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
 import { frequencyArr } from "@/views/dataEntry_manage/databaseComponents/util";
 export default {
-	props: {
-		isShow: {
-			type: Boolean,
-			default: false,
-		},
-		tableData: [],
-		singleEdbData: {},
-	},
-	watch: {
-		isShow(n) {
-			if (n) {
-				const edbData = this.tableData || [];
-				if (edbData) {
-					const calculateTypeMap = {
-						0: "Average()",
-						1: "Sum()",
-						2: "Growth Rate()",
-						3: "Annualized Growth Rate()",
-						4: "Max()",
-						5: "Min()",
-					};
-					this.list=edbData.map(item=>{
-						return {
-							EdbName:item.EdbName,
-							EdbNameEn:item.EdbNameEn,
-							name:`${this.$i18nt.locale === "zh" ? item.EdbName : item.EdbNameEn}${calculateTypeMap[this.singleEdbData.ExtraConfig.CalculateType]}`,
-							unit:item.Unit,
-							frequency:item.Frequency,
-							classify:''
-						}
+  props: {
+    isShow: {
+      type: Boolean,
+      default: false,
+    },
+    tableData: [],
+    singleEdbData: {},
+		MultipleGraphConfigId: 0,
+    IsEdbSaveAs: false,
+		updateBeforeEdbList:[]
+  },
+  watch: {
+    isShow(n) {
+      if (n) {
+        const edbData = this.tableData || [];
+        if (edbData) {
+          const calculateTypeMap = {
+            0: "Average()",
+            1: "Sum()",
+            2: "Growth Rate()",
+            3: "Annualized Growth Rate()",
+            4: "Max()",
+            5: "Min()",
+          };
+          const list = edbData.map(item => {
+            return {
+							EdbInfoId:item.EdbInfoId,
+              EdbName: item.EdbName,
+              EdbNameEn: item.EdbNameEn,
+
+							originEdbInfoId:0,//原指标id 如果是上次保存过则可能有
+              name: `${this.$i18nt.locale === "zh" ? item.EdbName : item.EdbNameEn}${calculateTypeMap[this.singleEdbData.ExtraConfig.CalculateType]}`,
+              unit: item.Unit,
+              frequency: item.Frequency,
+              classify: ''
+            }
+          })
+					// 更新列表信息如果是更新指标则有可能有指标是上次保存过的则此时用上次保存的信息
+					list.forEach(item=>{
+						this.updateBeforeEdbList.forEach(_item=>{
+							if(_item.FromEdbInfoId===item.EdbInfoId){
+								item.originEdbInfoId=_item.EdbInfoId
+								item.name=this.$i18nt.locale === "zh" ?_item.EdbName:_item.EdbNameEn
+								item.unit=this.$i18nt.locale === "zh" ?_item.Unit:_item.UnitEn
+								item.frequency=_item.Frequency
+								item.classify=item.EdbInfoCategoryType===_item.EdbTypeInfo?_item.ClassifyId:''
+							}
+						})
 					})
 
+					this.list=list
+
+          this.getClassifyOpts();
+        }
+      }
+    },
+  },
+  data() {
+    return {
+      list: [],
+      classifyType: 1,
 
-					this.getClassifyOpts();
+      classifyOpts: [],
+      classifyProps: {
+        label: "ClassifyName",
+        value: "ClassifyId",
+        children: "Children",
+        checkStrictly: true,
+        emitPath: false,
+      },
+      frequencyArr,
+    };
+  },
+  methods: {
+    async saveHandle() {
+			const edbList=this.list.map(item=>{
+				return {
+					EdbName: item.name,
+					Frequency: item.frequency,
+					Unit: item.unit || '无',
+					ClassifyId: item.classify,
+					FromEdbInfoId: item.EdbInfoId,
+					EdbInfoId: item.originEdbInfoId,
 				}
-			}
-		},
-	},
-	data() {
-		return {
-			list: [],
-			classifyType:1,
-
-			classifyOpts: [],
-			classifyProps: {
-				label: "ClassifyName",
-				value: "ClassifyId",
-				children: "Children",
-				checkStrictly: true,
-				emitPath: false,
-			},
-			frequencyArr,
-		};
-	},
-	methods: {
-		async saveHandle() {
-			await this.$refs.diaForm.validate();
-		},
-
-		cancelHandle() {
-			this.$emit("close");
-		},
-
-		// 递归改变第三级目录结构
-		filterNodes(arr) {
-			arr.length &&
-				arr.forEach((item) => {
-					item.Children.length && this.filterNodes(item.Children);
-					if (!item.Children.length) {
-						delete item.Children;
-					}
-				});
-		},
-
-		async getClassifyOpts() {
-			const res=await dataBaseInterface.menuListV3();
-			// const res = this.tableData[0].EdbInfoType === 1 ? await preDictEdbInterface.classifyListV2() : await dataBaseInterface.menuListV3();
-			if (res.Ret === 200) {
-				this.filterNodes(res.Data.AllNodes || []);
-				this.classifyOpts = res.Data.AllNodes || [];
-			}
-		},
-	},
+			})
+
+      const params = {
+        EdbInfoList: edbList,
+        MultipleGraphConfigId: this.MultipleGraphConfigId,
+        IsSaveAs: this.IsEdbSaveAs ? true : false,
+        EdbInfoType: this.tableData[0].EdbInfoCategoryType,
+        ExtraConfig: JSON.stringify(this.singleEdbData.ExtraConfig)
+      }
+			let isEnough = params.EdbInfoList.every(item => item.EdbName&&item.ClassifyId&&item.Frequency)
+      if(!isEnough) return this.$message.warning(/*'请填写完整信息'*/ this.$t('EtaBasePage.complete_information_msg'));
+
+      apiIntervalAnalysis.edbSave(params).then(res => {
+        if (res.Ret === 200) {
+          const { Fail,Success } = res.Data;
+
+          if(Fail.length) {
+            let message = '';
+            Fail.forEach(item => {
+              message+=`${item.CalculateId}:${item.Msg}</br>`
+            })
+
+            this.$message({
+              dangerouslyUseHTMLString: true,
+              message,
+              type: 'error'
+            })
+            return
+          }
+          this.$message.success(this.$t('MsgPrompt.saved_msg'))
+          this.$emit('success')
+          this.cancelHandle()
+        }
+      })
+    },
+
+    cancelHandle() {
+      this.$emit("close");
+    },
+
+    // 同目录修改
+    handleClassifyChange(e, index) {
+      if (this.classifyType === 1) {
+        // 修改所有的指标的目录为第一个
+        this.list.forEach(item => {
+          item.classify = e.classify
+        })
+      }
+    },
+
+    handleClassifyTypeChange() {
+      this.handleClassifyChange(this.list[0])
+    },
+
+    // 递归改变第三级目录结构
+    filterNodes(arr) {
+      arr.length &&
+        arr.forEach((item) => {
+          item.Children.length && this.filterNodes(item.Children);
+          if (!item.Children.length) {
+            delete item.Children;
+          }
+        });
+    },
+
+    async getClassifyOpts() {
+      const res = this.tableData[0].EdbInfoCategoryType === 1 ? await preDictEdbInterface.classifyListV2() : await dataBaseInterface.menuListV3()
+      if (res.Ret === 200) {
+        this.filterNodes(res.Data.AllNodes || []);
+        this.classifyOpts = res.Data.AllNodes || [];
+      }
+    },
+  },
 };
 </script>
 
 <style lang="scss">
-.el-dialog{
-	max-width: 1200px;
+.el-dialog {
+  max-width: 1200px;
   width: 90vw;
 }
 .save-multiple-edb-wrap {
-	.el-input {
-		width: 100%;
-	}
-	.el-input{
-        input{
-            border: none;
-            text-align: center;
-        }
+  .el-input {
+    width: 100%;
+  }
+  .el-input {
+    input {
+      border: none;
+      text-align: center;
     }
-    .el-table tr{
-        background-color: #fff !important;
-        &:hover>td{
-            background-color: transparent !important; /* 或者其他想要的颜色值 */
-        }
+  }
+  .el-table tr {
+    background-color: #fff !important;
+    &:hover > td {
+      background-color: transparent !important; /* 或者其他想要的颜色值 */
     }
+  }
 
-	.dia-bot {
-		margin: 30px 0;
-		text-align: center;
-	}
+  .dia-bot {
+    margin: 30px 0;
+    text-align: center;
+  }
 }
 </style>

+ 69 - 42
src/views/intervalAnalysis/components/saveSingleEdb.vue

@@ -10,12 +10,17 @@
     width="550px"
   >
     <div class="save-chart-wrap">
-      <el-form ref="diaForm" :model="formData" :rules="rules" label-width="100px">
+      <el-form
+        ref="diaForm"
+        :model="formData"
+        :rules="rules"
+        label-width="100px"
+      >
         <el-form-item :label="$t('Edb.Detail.e_name')" prop="name">
           <el-input
             :placeholder="$t('Chart.Detail.chart_name')"
             v-model="formData.name"
-            style="width:80%"
+            style="width: 80%"
           ></el-input>
         </el-form-item>
         <el-form-item :label="$t('Edb.Detail.e_menu')" prop="classify">
@@ -25,7 +30,7 @@
             :props="classifyProps"
             clearable
             :placeholder="$t('Chart.InputHolderAll.input_classify')"
-            style="width:80%"
+            style="width: 80%"
           />
         </el-form-item>
         <el-form-item :label="$t('Edb.Detail.e_fre')" prop="frequency">
@@ -33,7 +38,7 @@
             v-model="formData.frequency"
             :placeholder="$t('Edb.InputHolderAll.input_fre')"
             clearable
-            style="width:80%"
+            style="width: 80%"
           >
             <el-option
               v-for="item in frequencyArr"
@@ -45,7 +50,7 @@
           </el-select>
         </el-form-item>
         <el-form-item :label="$t('Edb.Detail.e_unit')" prop="unit">
-          <selectUnit v-model="formData.unit" style="width:80%"/>
+          <selectUnit v-model="formData.unit" style="width: 80%" />
         </el-form-item>
       </el-form>
 
@@ -74,29 +79,31 @@ export default {
     },
     singleEdbData: {},
     tableData: [],
+    MultipleGraphConfigId: 0,
+    IsEdbSaveAs: false
   },
   watch: {
     isShow(n) {
       if (n) {
-        const edbData=this.tableData[0]||null
-        if(edbData){
-          const calculateTypeMap={
-            0:'Average()',
-            1:'Sum()',
-            2:'Growth Rate()',
-            3:'Annualized Growth Rate()',
-            4:'Max()',
-            5:'Min()'
+        const edbData = this.tableData[0] || null
+        if (edbData) {
+          const calculateTypeMap = {
+            0: 'Average()',
+            1: 'Sum()',
+            2: 'Growth Rate()',
+            3: 'Annualized Growth Rate()',
+            4: 'Max()',
+            5: 'Min()'
           }
-          this.formData.name=`${this.$i18nt.locale==='zh'?edbData.EdbName:edbData.EdbNameEn}${calculateTypeMap[this.singleEdbData.ExtraConfig.CalculateType]}`
-          this.formData.classify=edbData.ClassifyId
-          this.formData.frequency=edbData.Frequency
-          this.formData.unit=edbData.Unit
+          this.formData.name = `${this.$i18nt.locale === 'zh' ? edbData.EdbName : edbData.EdbNameEn}${calculateTypeMap[this.singleEdbData.ExtraConfig.CalculateType]}${this.IsEdbSaveAs ? '(1)' : ''}`
+          this.formData.classify = edbData.ClassifyId
+          this.formData.frequency = edbData.Frequency
+          this.formData.unit = edbData.Unit
 
           this.getClassifyOpts()
 
         }
-        
+
       }
     }
   },
@@ -122,9 +129,9 @@ export default {
       classifyOpts: [],
       classifyProps: {
         label: 'ClassifyName',
-				value: 'ClassifyId',
-				children: 'Children',
-				checkStrictly: true,
+        value: 'ClassifyId',
+        children: 'Children',
+        checkStrictly: true,
         emitPath: false
       },
       frequencyArr
@@ -134,14 +141,34 @@ export default {
   methods: {
     async saveHandle() {
       await this.$refs.diaForm.validate();
-      const edbList=[{
-        EdbName:this.formData.name,
-        Frequency:this.formData.frequency,
-        Unit:this.formData.unit,
-        ClassifyId:this.formData.classify,
-        FromEdbInfoId:this.tableData[0].EdbInfoId
+      const edbList = [{
+        EdbName: this.formData.name,
+        Frequency: this.formData.frequency,
+        Unit: this.formData.unit || '无',
+        ClassifyId: this.formData.classify,
+        FromEdbInfoId: this.tableData[0].EdbInfoId,
+        EdbInfoId: 0,
       }]
-      this.$emit('save',edbList)
+
+      const params = {
+        EdbInfoList: edbList,
+        MultipleGraphConfigId: this.MultipleGraphConfigId,
+        IsSaveAs: this.IsEdbSaveAs ? true : false,
+        EdbInfoType: this.tableData[0].EdbInfoCategoryType,
+        ExtraConfig: JSON.stringify(this.singleEdbData.ExtraConfig)
+      }
+      apiIntervalAnalysis.edbSave(params).then(res => {
+        if (res.Ret === 200) {
+          if(res.Data.Fail.length>0){
+            this.$message.error(res.Data.Fail[0].Msg)
+            return
+          }
+          this.$message.success(this.$t('MsgPrompt.saved_msg'))
+          this.$emit('success')
+          this.cancelHandle()
+        }
+      })
+
     },
 
     cancelHandle() {
@@ -149,21 +176,21 @@ export default {
     },
 
     // 递归改变第三级目录结构
-		filterNodes(arr) {
-			arr.length && arr.forEach(item => {
-				item.Children.length && this.filterNodes(item.Children)
-				if(!item.Children.length) {
-					delete item.Children
-				}
-			})
-		},
+    filterNodes(arr) {
+      arr.length && arr.forEach(item => {
+        item.Children.length && this.filterNodes(item.Children)
+        if (!item.Children.length) {
+          delete item.Children
+        }
+      })
+    },
 
     async getClassifyOpts() {
-      const res=this.tableData[0].EdbInfoCategoryType===1?await preDictEdbInterface.classifyListV2():await dataBaseInterface.menuListV3()
-			if(res.Ret === 200) {
-				this.filterNodes(res.Data.AllNodes||[]);
-				this.classifyOpts = res.Data.AllNodes || [];
-			}
+      const res = this.tableData[0].EdbInfoCategoryType === 1 ? await preDictEdbInterface.classifyListV2() : await dataBaseInterface.menuListV3()
+      if (res.Ret === 200) {
+        this.filterNodes(res.Data.AllNodes || []);
+        this.classifyOpts = res.Data.AllNodes || [];
+      }
     }
 
 

+ 38 - 23
src/views/intervalAnalysis/list.vue

@@ -471,16 +471,6 @@ export default {
     };
   },
   methods: {
-    //控制页面按钮权限
-		isEdbBtnShow(type){
-			const {statisticPermission,checkPermissionBtn}=this.permissionBtn
-      const BtnMap={
-        'moveCatalog':statisticPermission.rangeAnalysis_classifyOpt_move,
-        'editCatalog':statisticPermission.rangeAnalysis_classifyOpt_edit,
-        'deleteCatalog':statisticPermission.rangeAnalysis_classifyOpt_delete
-      }
-      return checkPermissionBtn(BtnMap[type])
-    },
 
     /* 添加图表 */
     goAddChart() {
@@ -621,27 +611,52 @@ export default {
         this.dateTip = /* `${data.start_date}~至今` */ this.$t('Chart.data_tip_since', { date: data.start_date });
       }
 
-      // this.handleComputed();
+      this.getChartInfo()
     },
 
-    getChartInfo() {
-      this.getDetailHandle();
+    /* 设置默认时间选中项 */
+    setDefaultDateSelect() {
+      this.year_select = this.chartInfo.DateType;
+      this.select_date = [this.chartInfo.StartDate, this.chartInfo.EndDate];
+      this.count_year = this.chartInfo.StartYear;
+
+      this.dateTip =
+        this.chartInfo.DateType === 5
+          ? `${this.chartInfo.StartDate}~${this.chartInfo.EndDate}`
+          : this.chartInfo.DateType === 6
+          ? /* `${this.chartInfo.StartDate}~至今` */ this.$t('Chart.data_tip_since',{date:this.chartInfo.StartDate})
+          : this.chartInfo.DateType === 20
+          ?/* `最近${this.chartInfo.StartYear}年` */ this.$t('Chart.date_tip_count',{year:this.chartInfo.StartYear})
+          :/* '请选择时间段' */this.$t('Chart.choose_time');
+
     },
 
     /* 获取图表详情 */
-    getDetailHandle() {
-      apiIntervalAnalysis.chartInfo({
+    getChartInfo(type) {
+      let params={
         ChartInfoId: this.select_id,
-        DateType: this.year_select,
-        StartDate: [5 , 6].includes(this.year_select)
-          ? this.select_date[0]
-          : '',
-        EndDate: this.year_select === 5 ? this.select_date[1] : '',
-        StartYear:this.count_year || 0,
-
-      }).then(res => {
+      }
+      if(type!=='init'){
+        params={
+          ...params,
+          DateType: this.year_select,
+          StartDate: [5 , 6].includes(this.year_select)
+            ? this.select_date[0]
+            : '',
+          EndDate: this.year_select === 5 ? this.select_date[1] : '',
+          StartYear:this.count_year || 0,
+        }
+      }
+      apiIntervalAnalysis.chartInfo(params).then(res => {
         if (res.Ret !== 200) return
 
+        this.tableData=res.Data.EdbInfoList
+        this.chartInfo=res.Data.ChartInfo
+        if(type==='init'){
+          this.setDefaultDateSelect()
+        }
+        
+
         this.initIntervalAnalysisChartData(res.Data)
         // 展开左侧目录树
         this.defaultShowNodes = res.Data.ClassifyLevels || []

+ 9 - 28
src/views/intervalAnalysis/mixin/leftMixin.js

@@ -33,7 +33,7 @@ export default {
     select_id(newval) {
       if (newval) {
         // this.currentLang = "ch";
-        this.getDetailHandle();
+        this.getChartInfo('init');
       } else {
         this.chartInfo = {};
       }
@@ -104,33 +104,14 @@ export default {
   methods: {
     //控制页面按钮权限
 		isEdbBtnShow(type){
-			const {edbDataPermission,checkPermissionBtn}=this.permissionBtn
-			const BtnMap = {
-				'update':edbDataPermission.edbData_update,//指标更新
-				'edit':edbDataPermission.edbData_edit,//指标编辑
-				/* 'toImg':edbDataPermission.edbData_toImgs, */
-				'copyData':edbDataPermission.edbData_copyData,//复制数据
-				'toSource':edbDataPermission.edbData_edbSource,//指标溯源
-				'setEn':edbDataPermission.edbData_enNameSetting,//设置英文名称
-				'newValue':edbDataPermission.edbData_newestValue,//添加/编辑最新值
-				'refreshAll':edbDataPermission.edbData_refreshAll,//全部刷新
-				'saveEdb':edbDataPermission.edbData_saveEdb,//保存指标
-				'deleteEdb':edbDataPermission.edbData_deleteEdb,//删除指标
-				'showChartBasis':edbDataPermission.edbData_showChartBasis,//展示/隐藏同比图
-				'switchSeason':edbDataPermission.edbData_switchSeason,//切换季节性图
-				'editLimit':edbDataPermission.edbData_editLimit,//编辑上下限
-				'calculateAgain':edbDataPermission.edbData_calculateAgain,//重新计算
-
-				'editCatalog':edbDataPermission.edbData_classifyOpt_add,//添加编辑目录
-				'deleteCatalog':edbDataPermission.edbData_classifyOpt_delete,//删除目录
-				'moveCatalog':edbDataPermission.edbData_classifyOpt_move,//删除目录
-				'checkRelatedChart':edbDataPermission.edbData_checkRelatedChart,//查看关联图表
-				'checkRelatedEdb':edbDataPermission.edbData_checkRelatedEdb,//查看关联指标
-				'checkCalcChart':edbDataPermission.edbData_checkCalcChart,//查看计算指标
-				'enableOrDisable':edbDataPermission.edbData_enableOrDisable,//启用/停用
-			}
-			return checkPermissionBtn(BtnMap[type])
-		},
+			const {statisticPermission,checkPermissionBtn}=this.permissionBtn
+      const BtnMap={
+        'moveCatalog':statisticPermission.rangeAnalysis_classifyOpt_move,
+        'editCatalog':statisticPermission.rangeAnalysis_classifyOpt_edit,
+        'deleteCatalog':statisticPermission.rangeAnalysis_classifyOpt_delete
+      }
+      return checkPermissionBtn(BtnMap[type])
+    },
 
 
     /* 根据unicode展开树结构并选中当前图表 重置图表配置 日期区间 */