瀏覽代碼

ETA1.6.4-煤炭江湖数据对接 done

hbchen 10 月之前
父節點
當前提交
3910c81fa7
共有 5 個文件被更改,包括 207 次插入110 次删除
  1. 4 2
      src/api/api.js
  2. 38 1
      src/api/modules/thirdBaseApi.js
  3. 14 1
      src/components/lzTable.vue
  4. 1 1
      src/utils/buttonConfig.js
  5. 150 105
      src/views/dataEntry_manage/thirdBase/coalWord.vue

+ 4 - 2
src/api/api.js

@@ -11,7 +11,8 @@ import {
   baiinfoInterface,
   nationalInterface,
   databankInterface,
-  yongyiInterface
+  yongyiInterface,
+  coalWordInterface
 } from './modules/thirdBaseApi';
 
 //手工指标 手工数据 手工数据权限
@@ -114,7 +115,8 @@ export {
   homeInterface,
   businessTripInterence,
   reportVarietyENInterence,
-  yongyiInterface
+  yongyiInterface,
+  coalWordInterface
 };
 
 //老接口 研报 ppt等

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

@@ -777,6 +777,42 @@ const yongyiInterface={
 	},
 }
 
+/* 煤炭江湖 */
+const coalWordInterface={
+	/**
+	 * 分类列表
+	 * @param {} params 
+	 * @returns 
+	 */
+	classifyList: params => {
+		return http.get('/entry/data/mtjh/classify',params);
+	},
+	/**
+	 * 获取指标列表详情 Area PageSize CurrentIndex
+	 */
+	dataList: params => {
+		return http.get('/entry/data/mtjh/data',params);
+	},
+	/**
+	 * 单个指标数据 IndexCode PageSize CurrentIndex
+	*/
+	getTargetDataList:params=>{
+		return http.get('/entry/data/mtjh/single_data',params);
+	},
+	/**
+	 * 搜索 Keyword
+	*/
+	targetListSearch:params=>{
+		return http.get('/entry/data/mtjh/search',params);
+	},
+	/**
+	 * 获取频度列表 Area
+	*/
+	getFrequencyList:params=>{
+		return http.get('/entry/data/mtjh/frequency',params)
+	},
+}
+
 export { 
 	lzDataInterface,
 	glDataInterface,
@@ -788,5 +824,6 @@ export {
   baiinfoInterface,
   nationalInterface,
   databankInterface,
-  yongyiInterface
+  yongyiInterface,
+	coalWordInterface
 }

+ 14 - 1
src/components/lzTable.vue

@@ -85,6 +85,9 @@ export default {
 				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
 			}
 
+			if(this.source==='coalWord'){
+				arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
+			}
 			return arr
 		},
 		labelArr(){
@@ -141,13 +144,23 @@ export default {
 					['ModifyTime', '更新时间'],
 				])
 			}
-
+			if(this.source==='coalWord'){
+				temMap=new Map([
+					['IndexName', '指标名称'],
+					['IndexCode', '指标ID'],
+					['Frequency', '频度'],
+					['Unit', '单位'],
+					['ModifyTime', '更新时间'],
+				])
+			}
 			return temMap
 		},
 		dynamic_key(){
 			let key='InputValue'
 			if(['smm','baiinfo','coal','yyzx'].includes(this.source)){
 				key='Value'
+			}else if(this.source=='coalWord'){
+				key='DealValue'
 			}
 
 			return key

+ 1 - 1
src/utils/buttonConfig.js

@@ -242,7 +242,7 @@ export const dataSourcePermission = {
     yyzxData_export:'yyzx:exportData',
     /*--------煤炭江湖---- */
     coalWordData_view:'coalWord:view', // 查看
-    coalWordData_export:'coalWord:export', // 查看
+    coalWordData_export:'coalWord:export', // 导出
 }
 
 /*

+ 150 - 105
src/views/dataEntry_manage/thirdBase/coalWord.vue

@@ -9,7 +9,6 @@
     </span>
     <div class="left-cont minHeight" v-show="isLeftWrapShow">
       <div class="left-top">
-        <!-- v-permission="permissionBtn.dataSourcePermission.coalWordData_export" -->
         <el-button
           style="width: 100%;margin-bottom: 10px;"
           type="primary"
@@ -17,6 +16,7 @@
           size="medium"
           @click="exportClick"
           :loading="btnload"
+          v-permission="permissionBtn.dataSourcePermission.coalWordData_export" 
           >导出Excel</el-button
         >
         <el-autocomplete
@@ -27,6 +27,8 @@
           :trigger-on-focus="false"
           placeholder="指标名称/指标ID"
           @select="handleSelectLeftSearchval"
+          @blur="searchvalBlur"
+          @clear="searchvalClear"
           popper-class="el-autocomplete-suggestion-data-entry"
           clearable
         >
@@ -35,20 +37,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.Area }]"
           v-for="item in classifyList"
-          :key="item.BreedId"
+          :key="item.Area"
           @click="changeClassify(item)"
         >
-          {{ item.BreedName }}
+          {{ item.Area }}
         </li>
       </ul>
     </div>
@@ -57,14 +58,17 @@
       v-loading="dataloading"
       element-loading-text="获取数据中..."
     >
-      <div class="right-box" v-if="rightShow">
+      <div class="right-box" v-if="rightShow"
+        v-infinite-scroll="loadNext"
+        :infinite-scroll-disabled="!haveMore"
+        :infinite-scroll-immediate="false">
         <template v-if="dateArr.length">
           <div class="data-header">
             <lz-table
               :tableOption="tableOption"
               tableType="header"
               ref="table"
-              source="lz"
+              source="coalWord"
             />
           </div>
           <div class="data-cont" >
@@ -72,7 +76,7 @@
               :tableOption="tableOption"
               tableType="data"
               :dateArr="dateArr"
-              source="lz"
+              source="coalWord"
             />
           </div>
         </template>
@@ -82,11 +86,11 @@
         <el-button
           type="primary"
           class="frequency-btn"
-          :plain="select_frequency !== item.key"
+          :plain="select_frequency !== item"
           v-for="item in frequencyList"
-          :key="item.key"
-          @click="changeFrequency(item.key)"
-          >{{ item.label }}</el-button
+          :key="item"
+          @click="changeFrequency(item)"
+          >{{ item }}</el-button
         >
       </div>
     </div>
@@ -95,7 +99,7 @@
 
 <script>
 import lzTable from "@/components/lzTable.vue";
-import { lzDataInterface } from "@/api/api.js";
+import { coalWordInterface } from "@/api/api.js";
 export default {
   name: "coalWord",
   components: { lzTable },
@@ -111,23 +115,15 @@ export default {
     },
   },
   computed: {
-    exportLzapi() {
+    exportApi() {
       // 数据导出接口
       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}`;
+      urlStr += `&Area=${this.select_classify}`;
+      // 指标Id
+      urlStr += `&IndexCode=${this.leftSearchTradeCode}`;
       return this.escapeStr(urlStr);
     },
   },
@@ -143,10 +139,13 @@ 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 + "/entry/export/mtjh", //数据导出接口
       select_classify: "",
       classifyList: [],
       select_frequency: "",
+      PageSize:20,
+      CurrentIndex:1,
+      haveMore:true,
       frequencyType: new Map([
         [1, "日度"],
         [2, "周度"],
@@ -159,100 +158,102 @@ export default {
       tableOption: [],
       dateArr: [], //最长的日期数组
       btnload: false,
-
       leftSearchVal: "", //左侧搜索值
       leftSearchTradeCode: "", //如果是搜索选择的 则有此code
-      select_quota: "", // 选中的指标名称
-      select_Unit: "", // 选中的单位
-      select_ModifyTime: "", //选中的更新时间
-      select_breed: "", // 选中的分类名称
       isAuto: true, // 改变分类时是否自动获取数据
     };
   },
   methods: {
     /* 获取分类 */
     getClassify() {
-      // TODO: 获取分类接口对接
-      lzDataInterface.classifyList().then((res) => {
+      coalWordInterface.classifyList().then((res) => {
         if (res.Ret !== 200) return;
         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].Area;
       });
     },
     /* 获取频度 */
     getFrequency(defaultSelect) {
-      // TODO: 获取频度接口对接
-      lzDataInterface
-        .frequencyList({
-          BreedId: Number(this.select_classify),
-        })
-        .then((res) => {
-          if (res.Ret !== 200) return;
-          this.frequencyList =
-            res.Data &&
-            res.Data.map((item) => {
-              return {
-                label: this.frequencyType.get(item.Frequency),
-                key: item.Frequency,
-              };
-            });
-          //设置当前选中的频度,若传入有默认选项则选中默认频度,否则选中列表第一个
-          this.select_frequency = defaultSelect || this.frequencyList[0].key;
-          //如果有默认频度,结束后恢复watcher
-          this.$nextTick(() => {
-            if (defaultSelect) this.isAuto = true;
-          });
+      coalWordInterface.getFrequencyList({
+        Area: this.select_classify,
+      }).then((res) => {
+        if (res.Ret !== 200) return;
+        this.frequencyList = res.Data || []
+        //设置当前选中的频度,若传入有默认选项则选中默认频度,否则选中列表第一个
+        this.select_frequency = defaultSelect || this.frequencyList[0];
+        //如果有默认频度,结束后恢复watcher
+        this.$nextTick(() => {
+          if (defaultSelect) this.isAuto = true;
         });
+      });
     },
     /* 获取数据 */
     getDataList() {
-      // TODO: 获取数据接口对接
       this.dataloading = true;
-      lzDataInterface
-        .dataList({
-          BreedId: Number(this.select_classify),
-          Frequency: this.select_frequency,
-        })
-        .then((res) => {
-          this.rightShow = true;
-          if (res.Ret !== 200) return;
-          // 设置表格数据
-          this.setDataList(res.Data);
+      coalWordInterface.dataList({
+        Area: this.select_classify,
+        PageSize: this.PageSize,
+        CurrentIndex:this.CurrentIndex,
+        Frequency: this.select_frequency,
+      }).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.CurrentIndex < totalPage ? true : false;
+        // 设置表格数据
+        this.setDataList(res.Data || []);
 
+        this.CurrentIndex == 1 &&
           this.$nextTick(() => {
             this.initWidth();
-            this.dataloading = false;
           });
-        });
+      }).finally(()=>{
+        this.dataloading = false;
+      })
+    },
+    /* 滚动加载 */
+    loadNext() {
+      this.CurrentIndex++;
+      if(this.leftSearchTradeCode){
+        this.getTargetDataList()
+      }else{
+        this.getDataList();
+      }
     },
-    /* 改变品种 */
+    /* 改变分类 */
     changeClassify(item) {
-      this.select_classify = item.BreedId;
-      this.select_breed = item.BreedName;
+      if(this.dataloading) return 
+      this.select_classify = item.Area;
       this.leftSearchVal = "";
       this.leftSearchTradeCode = ""
-      this.select_quota = ""
-      this.select_Unit = ""
-      this.select_ModifyTime = ""
+      this.CurrentIndex=1
     },
     /* 改变频度 */
-    changeFrequency(key) {
-      this.select_frequency = key;
+    changeFrequency(item) {
+      if(this.select_frequency == item) return 
+      this.select_frequency = item;
       this.leftSearchVal = "";
+      this.CurrentIndex=1
     },
     initWidth() {
       $(".right-box")[0].style.width =
-      this.$refs.table && this.$refs.table.$el.clientWidth + 2 + "px";
+      this.$refs.table ? this.$refs.table.$el.clientWidth + 2 + "px":0
       $(".right-box")[0].scrollTop = 0;
       $(".right-box")[0].scrollLeft = 0;
     },
     /* 数据导出 */
     exportClick() {
       this.btnload = true;
+      console.log({
+        Area:this.select_classify,
+        IndexCode:this.leftSearchTradeCode
+      },this.exportApi);
       const link = document.createElement("a");
-      link.href = this.exportLzapi;
+      link.href = this.exportApi;
       link.download = "";
       link.click();
       setTimeout(() => {
@@ -264,7 +265,7 @@ export default {
     async handleLeftSearch(query, cb) {
       cb([]);
       if (!query) return;
-      const res = await lzDataInterface.getTargetListByName({
+      const res = await coalWordInterface.targetListSearch({
         Keyword: query,
       });
       if (res.Ret === 200) {
@@ -278,26 +279,29 @@ export default {
     },
     // 选中左侧搜索值
     handleSelectLeftSearchval(e) {
-      if (!e.LzCode) 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 = "";
+      if (!e.IndexCode || this.dataloading) return;
+      this.leftSearchTradeCode = e.IndexCode;
+      this.leftSearchVal = e.IndexName;
+      this.select_classify = e.Area
       // 关闭watcher
       this.isAuto = false;
       this.getFrequency(e.Frequency);
-      this.setDataList([e]);
+      this.CurrentIndex=1
+      this.getTargetDataList()
       this.$nextTick(() => {
-        this.rightShow = true;
         this.handleScrollLeftWrap();
       });
     },
+    searchvalBlur(){
+      if((!this.leftSearchVal) && this.leftSearchTradeCode){
+        this.searchvalClear()
+      }   
+    },
+    searchvalClear(){
+      this.CurrentIndex=1
+      this.leftSearchTradeCode=''
+      this.getDataList();
+    },
     // 左侧滚动
     handleScrollLeftWrap() {
       let top = $(".act")[0].offsetTop;
@@ -305,19 +309,58 @@ export default {
         scrollTop: top - 200,
       });
     },
+    // 获取单个指标数据
+    getTargetDataList() {
+      if (!this.leftSearchTradeCode) return;
+      this.dataloading = true;
+
+      try {
+        coalWordInterface.getTargetDataList({
+          IndexCode: this.leftSearchTradeCode,
+          Pagesize: this.PageSize,
+          CurrentIndex: this.CurrentIndex
+        }).then(res=>{
+          if (res.Ret !== 200) return;
+
+          this.haveMore = this.CurrentIndex < res.Data.Paging.Pages ? true : false;
+          this.setDataList([res.Data])
+
+          this.CurrentIndex == 1 &&
+            this.$nextTick(() => {
+              this.initWidth();
+            });
+        }).finally(()=>{
+          this.dataloading = false;
+        })
+      } catch (err) {
+        console.error(err);
+        this.dataloading = false;
+      }
+    },
     // 设置表格数据
-    setDataList(tableOption) {
-      this.tableOption = tableOption;
-      /* 不满6个追加6个空的显示一排 别问 问就是为了美观  */
-      if (tableOption.length < 6)
-        for (let i = 0; i < 6; i++) {
-          this.tableOption.push({
-            DataList: [],
-          });
-          if (this.tableOption.length >= 6) break;
+    setDataList(data) {
+      if(this.CurrentIndex ==1){
+        this.tableOption = data;
+        /* 不满6个追加6个空的显示一排 别问 问就是为了美观  */
+        if (data.length < 6){
+          for (let i = 0; i < 6; i++) {
+            this.tableOption.push({
+              DataList: [],
+            });
+            if (this.tableOption.length >= 6) 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));
@@ -325,11 +368,13 @@ export default {
       // 日期去重倒序排序
       this.dateArr = [...new Set(obj)].sort().reverse();
       //数据最大长度小于12个 追加数据满12个 别问 问就是为了美观
-      if (this.dateArr.length < 12)
+      if (this.dateArr.length < 12){
         for (let i = 0; i < 12; i++) {
           this.dateArr.push("");
           if (this.dateArr.length >= 12) break;
         }
+      }
+
     },
     // 对[#,;]转义
     escapeStr(str) {