Quellcode durchsuchen

ETA1.6.1 ICPI数据源对接

hbchen vor 10 Monaten
Ursprung
Commit
c92cec66c5

+ 1 - 9
src/api/modules/thirdBaseApi.js

@@ -793,15 +793,7 @@ const icpiInterface={
 	 */
 	dataList: params => {
 		return http.get('/data_source/icpi/index/data',params);
-	},
-	//单个指标数据
-	getTargetDataList:params=>{
-		return http.get('/datamanage/yongyi/single_data',params);
-	},
-	// 搜索
-	getTargetListByName:params=>{
-		return http.get('/datamanage/yongyi/search_list',params);
-	},
+	}
 }
 
 export { 

+ 6 - 42
src/components/lzTable.vue

@@ -69,22 +69,13 @@ export default {
 		headerArr(){
 			let arr=['QuotaName','LzCode','Frequency','UnitName','ModifyTime']
 
+			let sourceTypeOne = ['smm','coal','baiinfo','yyzx','icpi']
+
 			if(this.source==='gl'){
 				arr=['IndexName','IndexCode','FrequencyName','UnitName','UpdateTime']
-			}
-			if(this.source==='smm'){
+			}else if(sourceTypeOne.includes(this.source)){
 				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
 			}
-			if(this.source==='coal'){
-				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
-			}
-			if(this.source==='baiinfo'){
-				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
-			}
-			if(this.source==='yyzx'){
-				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
-			}
-
 			return arr
 		},
 		labelArr(){
@@ -95,6 +86,7 @@ export default {
 				['UnitName', '单位'],
 				['ModifyTime', '更新时间'],
 			])
+			let sourceTypeOne = ['smm','coal','baiinfo','yyzx','icpi']
 
 			if(this.source==='gl'){
 				temMap=new Map([
@@ -104,35 +96,7 @@ export default {
 					['UnitName', '单位'],
 					['UpdateTime', '更新时间'],
 				])
-			}
-			if(this.source==='smm'){
-				temMap=new Map([
-					['IndexName', '指标名称'],
-					['IndexCode', '指标ID'],
-					['Frequency', '频度'],
-					['Unit', '单位'],
-					['ModifyTime', '更新时间'],
-				])
-			}
-			if(this.source==='coal'){
-				temMap=new Map([
-					['IndexName', '指标名称'],
-					['IndexCode', '指标ID'],
-					['Frequency', '频度'],
-					['Unit', '单位'],
-					['ModifyTime', '更新时间'],
-				])
-			}
-			if(this.source==='baiinfo'){
-				temMap=new Map([
-					['IndexName', '指标名称'],
-					['IndexCode', '指标ID'],
-					['Frequency', '频度'],
-					['Unit', '单位'],
-					['ModifyTime', '更新时间'],
-				])
-			}
-			if(this.source==='yyzx'){
+			}else if(sourceTypeOne.includes(this.source)){
 				temMap=new Map([
 					['IndexName', '指标名称'],
 					['IndexCode', '指标ID'],
@@ -146,7 +110,7 @@ export default {
 		},
 		dynamic_key(){
 			let key='InputValue'
-			if(['smm','baiinfo','coal','yyzx'].includes(this.source)){
+			if(['smm','baiinfo','coal','yyzx','icpi'].includes(this.source)){
 				key='Value'
 			}
 

+ 84 - 81
src/views/dataEntry_manage/thirdBase/icpiConsumption.vue

@@ -27,6 +27,7 @@
           placeholder="指标名称/指标ID"
           @select="handleSelectLeftSearchval"
           popper-class="el-autocomplete-suggestion-data-entry"
+          @clear="clearSearchVal"
           clearable
         >
           <template slot-scope="scope">
@@ -34,20 +35,19 @@
               暂无数据
             </div>
             <div v-else>
-              {{ scope.item.QuotaName }}
-              {{ frequencyType.get(scope.item.Frequency) }}
+              {{ scope.item.IndexName }}
             </div>
           </template>
         </el-autocomplete>
       </div>
       <ul class="classify-list">
         <li
-          :class="['classify-item', { act: select_classify === item.BreedId }]"
+          :class="['classify-item', { act: select_classify === item.BaseFromIcpiClassifyId }]"
           v-for="item in classifyList"
-          :key="item.BreedId"
+          :key="item.BaseFromIcpiClassifyId"
           @click="changeClassify(item)"
         >
-          {{ item.BreedName }}
+          {{ item.ClassifyName }}
         </li>
       </ul>
     </div>
@@ -56,14 +56,14 @@
       v-loading="dataloading"
       element-loading-text="获取数据中..."
     >
-      <div class="right-box" v-if="rightShow">
+      <div class="right-box" v-if="rightShow" @scroll="scrollHandle">
         <template v-if="dateArr.length">
           <div class="data-header">
             <lz-table
               :tableOption="tableOption"
               tableType="header"
               ref="table"
-              source="lz"
+              source="icpi"
             />
           </div>
           <div class="data-cont">
@@ -71,7 +71,7 @@
               :tableOption="tableOption"
               tableType="data"
               :dateArr="dateArr"
-              source="lz"
+              source="icpi"
             />
           </div>
         </template>
@@ -94,51 +94,31 @@ export default {
       isLeftWrapShow:true,
       dataloading: false,
       rightShow: false,
-      exportBase: process.env.VUE_APP_API_ROOT + "/datamanage/export/lzList", //数据导出接口
+      exportBase: process.env.VUE_APP_API_ROOT + "/data_source/icpi/export/icpiDataList", //数据导出接口
       select_classify: "",
       classifyList: [],
-      frequencyType: new Map([
-        [1, "日度"],
-        [2, "周度"],
-        [3, "月度"],
-        [4, "季度"],
-        [5, "年度"],
-        [99, "无固定频率"],
-      ]),
       tableOption: [],
       dateArr: [], //最长的日期数组
       btnload: false,
 
       leftSearchVal: "", //左侧搜索值
-      leftSearchTradeCode: "", //如果是搜索选择的 则有此code
-      select_quota: "", // 选中的指标名称
-      select_Unit: "", // 选中的单位
-      select_ModifyTime: "", //选中的更新时间
-      select_breed: "", // 选中的分类名称
       pageParams:{
         PageSize:20,
-        CurrentIndex:1
-      }
+        CurrentIndex:1,
+        KeyWord:''
+      },
+      havemore:true
     };
   },
   computed: {
-    exportLzapi() {
+    exportIcpiApi() {
       // 数据导出接口
       let urlStr = this.exportBase;
       // token
       urlStr += `?${localStorage.getItem("auth") || ""}`;
-      // 指标名称参数
-      urlStr += `&QuotaName=${this.select_quota}`;
-      // 指标id
-      urlStr += `&LzCode=${this.leftSearchTradeCode}`;
-      // 分类名称
-      urlStr += `&BreedName=${this.select_breed}`;
-      // 频度
-      urlStr += `&Frequency=${this.select_frequency}`;
-      // 单位
-      urlStr += `&UnitName=${this.select_Unit}`;
-      // 修改时间
-      urlStr += `&ModifyTime=${this.select_ModifyTime}`;
+      // 分类Id参数
+      urlStr += `&BaseFromIcpiClassifyId=${this.select_classify}`;
+      urlStr += `&KeyWord=${this.pageParams.KeyWord}`;
       return this.escapeStr(urlStr);
     },
   },
@@ -148,14 +128,12 @@ export default {
   methods: {
     /* 获取分类 */
     getClassify() {
-      // icpiInterface
-      lzDataInterface.classifyList().then((res) => {
+      icpiInterface.classifyList().then((res) => {
         if (res.Ret !== 200) return;
-        console.log(res);
         this.classifyList = res.Data || [];
         this.select_classify =
-          this.select_classify || this.classifyList[0].BreedId;
-        this.select_breed = this.classifyList[0].BreedName;
+          this.select_classify || this.classifyList[0].BaseFromIcpiClassifyId;
+        
         this.getDataList()
       });
     },
@@ -163,14 +141,20 @@ export default {
     /* 获取数据 */
     getDataList() {
       this.dataloading = true;
-      // icpiInterface.dataList({
-      //   BaseFromIcpiClassifyId: Number(this.select_classify),
-      //   PageSize:this.pageParams.PageSize,
-      //   CurrentIndex:this.pageParams.CurrentIndex
-      // })
-      lzDataInterface.dataList({BaseFromIcpiClassifyId: Number(this.select_classify),Frequency:1}).then((res) => {
+      icpiInterface.dataList({
+        BaseFromIcpiClassifyId: Number(this.select_classify),
+        PageSize:this.pageParams.PageSize,
+        CurrentIndex:this.pageParams.CurrentIndex,
+        KeyWord:this.pageParams.KeyWord
+      }).then((res) => {
         this.rightShow = true;
         if (res.Ret !== 200) return;
+
+        // 找出最多的页码 判断是否还有数据
+        let page_arrs = res.Data.map((item) => item.Paging?item.Paging.Pages:0);
+        let totalPage = Math.max.apply(Math, page_arrs);
+        this.havemore = this.pageParams.CurrentIndex < totalPage ? true : false;
+        
         // 设置表格数据
         this.setDataList(res.Data);
         this.$nextTick(() => {
@@ -182,13 +166,9 @@ export default {
     },
     /* 改变品种 */
     changeClassify(item) {
-      this.select_classify = item.BreedId;
-      this.select_breed = item.BreedName;
+      this.select_classify = item.BaseFromIcpiClassifyId;
       this.leftSearchVal = ""
-      this.leftSearchTradeCode = ""
-      this.select_quota = ""
-      this.select_Unit = ""
-      this.select_ModifyTime = ""
+      this.pageParams.KeyWord=''
       this.getDataList()
     },
 
@@ -198,12 +178,15 @@ export default {
       $(".right-box")[0].scrollTop = 0;
       $(".right-box")[0].scrollLeft = 0;
     },
+    // 对[#,;]转义
+    escapeStr(str) {
+      return str.replace(/#/g, escape("#")).replace(/;/g, escape(";")); 
+    },
     /* 导出 */
     exportClick() {
       this.btnload = true;
-      // TODO: 导出接口对接
       const link = document.createElement("a");
-      link.href = this.exportLzapi;
+      link.href = this.exportIcpiApi;
       link.download = "";
       link.click();
       setTimeout(() => {
@@ -215,8 +198,8 @@ export default {
     async handleLeftSearch(query, cb) {
       cb([]);
       if (!query) return;
-      const res = await lzDataInterface.getTargetListByName({
-        Keyword: query,
+      const res = await icpiInterface.dataList({
+        KeyWord: query
       });
       if (res.Ret === 200) {
         let arr = res.Data || [];
@@ -229,25 +212,22 @@ export default {
     },
     // 选中左侧搜索值
     handleSelectLeftSearchval(e) {
-      if (!e.LzCode) return;
+      if (!e.BaseFromIcpiIndexId) return;
       this.rightShow = false;
-      this.leftSearchTradeCode = e.LzCode;
-      this.leftSearchVal = e.QuotaName;
-      this.select_quota = e.QuotaName;
-      this.select_Unit = e.UnitName;
-      this.select_ModifyTime = e.ModifyTime;
-      this.select_classify = this.classifyList.find(
-        (item) => item.BreedName === e.BreedName
-      ).BreedId;
-      this.select_breed = "";
-
-      this.setDataList([e]);
+      this.leftSearchVal = e.IndexName;
+      this.pageParams.KeyWord=e.IndexName
+      this.select_classify = e.BaseFromIcpiClassifyId;
+      this.pageParams.CurrentIndex=1
       this.getDataList()
       this.$nextTick(() => {
         this.rightShow = true;
         this.handleScrollLeftWrap();
       });
     },
+    clearSearchVal(){
+      this.pageParams.KeyWord=''
+      this.getDataList()
+    },
     // 左侧滚动
     handleScrollLeftWrap() {
       let top = $(".act")[0].offsetTop;
@@ -255,19 +235,41 @@ export default {
         scrollTop: top - 200,
       });
     },
+    /* 滚动加载 */
+    scrollHandle(e) {
+      const dom = e.target;
+      let total = dom.scrollTop + dom.clientHeight;
+      if (total >= dom.scrollHeight && this.havemore) {
+        this.pageParams.CurrentIndex++;
+        // console.log("load下一页");
+        this.getDataList();
+      }
+    },
     // 设置表格数据
-    setDataList(tableOption) {
-      this.tableOption = tableOption;
-      /* 不满7个追加7个空的显示一排 别问 问就是为了美观  */
-      if (tableOption.length < 7)
-        for (let i = 0; i < 7; i++) {
-          this.tableOption.push({
-            DataList: [],
-          });
-          if (this.tableOption.length >= 7) break;
+    setDataList(data) {
+      if(this.pageParams.CurrentIndex==1){
+        this.tableOption = data;
+        /* 不满7个追加7个空的显示一排 别问 问就是为了美观  */
+        if (this.tableOption.length < 7){
+          for (let i = 0; i < 7; i++) {
+            this.tableOption.push({
+              DataList: [],
+            });
+            if (this.tableOption.length >= 7) break;
+          }
         }
+      }else{
+        this.tableOption.forEach((item) => {
+          data.forEach((_item) => {
+            if (item.IndexCode === _item.IndexCode) {
+              item.DataList = item.DataList.concat(_item.DataList);
+            }
+          });
+        });
+      }
+
       // 合并所有日期
-      let arr = tableOption.map((item) => item.DataList);
+      let arr = this.tableOption.map((item) => item.DataList);
       let obj = [];
       arr.forEach((dataList) => {
         obj.push(...dataList.map((item) => item.DataTime));
@@ -275,11 +277,12 @@ export default {
       // 日期去重倒序排序
       this.dateArr = [...new Set(obj)].sort().reverse();
       //数据最大长度小于13个 追加数据满13个 别问 问就是为了美观
-      if (this.dateArr.length < 13)
+      if (this.dateArr.length < 13){
         for (let i = 0; i < 13; i++) {
           this.dateArr.push("");
           if (this.dateArr.length >= 13) break;
         }
+      }
     },
   },
 };