icpcConsumption.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="icpc-container coal-similarity-container">
  3. <span
  4. class="slide-btn-icon"
  5. :class="{'slide-left':isLeftWrapShow,'slide-right':!isLeftWrapShow}"
  6. @click="isLeftWrapShow = !isLeftWrapShow"
  7. >
  8. <i :class="{'el-icon-d-arrow-left':isLeftWrapShow,'el-icon-d-arrow-right':!isLeftWrapShow}"></i>
  9. </span>
  10. <div class="left-cont minHeight" v-show="isLeftWrapShow">
  11. <div class="left-top">
  12. <el-button
  13. style="width: 100%;"
  14. type="primary"
  15. plain
  16. size="medium"
  17. @click="exportClick"
  18. :loading="btnload"
  19. >导出Excel</el-button
  20. >
  21. <el-autocomplete
  22. style="margin-top: 20px; width: 100%"
  23. prefix-icon="el-icon-search"
  24. v-model="leftSearchVal"
  25. :fetch-suggestions="handleLeftSearch"
  26. :trigger-on-focus="false"
  27. placeholder="指标名称/指标ID"
  28. @select="handleSelectLeftSearchval"
  29. popper-class="el-autocomplete-suggestion-data-entry"
  30. clearable
  31. >
  32. <template slot-scope="scope">
  33. <div v-if="scope.item.nodata" style="text-align: center">
  34. 暂无数据
  35. </div>
  36. <div v-else>
  37. {{ scope.item.QuotaName }}
  38. {{ frequencyType.get(scope.item.Frequency) }}
  39. </div>
  40. </template>
  41. </el-autocomplete>
  42. </div>
  43. <ul class="classify-list">
  44. <li
  45. :class="['classify-item', { act: select_classify === item.BreedId }]"
  46. v-for="item in classifyList"
  47. :key="item.BreedId"
  48. @click="changeClassify(item)"
  49. >
  50. {{ item.BreedName }}
  51. </li>
  52. </ul>
  53. </div>
  54. <div
  55. class="right-cont minHeight"
  56. v-loading="dataloading"
  57. element-loading-text="获取数据中..."
  58. >
  59. <div class="right-box" v-if="rightShow">
  60. <template v-if="dateArr.length">
  61. <div class="data-header">
  62. <lz-table
  63. :tableOption="tableOption"
  64. tableType="header"
  65. ref="table"
  66. source="lz"
  67. />
  68. </div>
  69. <div class="data-cont">
  70. <lz-table
  71. :tableOption="tableOption"
  72. tableType="data"
  73. :dateArr="dateArr"
  74. source="lz"
  75. />
  76. </div>
  77. </template>
  78. <tableNoData v-else text="暂无数据" class="nodata"></tableNoData>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import lzTable from "@/components/lzTable.vue";
  85. import { lzDataInterface } from "@/api/api.js";
  86. export default {
  87. name: "icpcConsumption",
  88. components: { lzTable },
  89. data() {
  90. return {
  91. isLeftWrapShow:true,
  92. dataloading: false,
  93. rightShow: false,
  94. exportBase: process.env.VUE_APP_API_ROOT + "/datamanage/export/lzList", //数据导出接口
  95. select_classify: "",
  96. classifyList: [],
  97. frequencyType: new Map([
  98. [1, "日度"],
  99. [2, "周度"],
  100. [3, "月度"],
  101. [4, "季度"],
  102. [5, "年度"],
  103. [99, "无固定频率"],
  104. ]),
  105. tableOption: [],
  106. dateArr: [], //最长的日期数组
  107. btnload: false,
  108. leftSearchVal: "", //左侧搜索值
  109. leftSearchTradeCode: "", //如果是搜索选择的 则有此code
  110. select_quota: "", // 选中的指标名称
  111. select_Unit: "", // 选中的单位
  112. select_ModifyTime: "", //选中的更新时间
  113. select_breed: "", // 选中的分类名称
  114. };
  115. },
  116. computed: {
  117. exportLzapi() {
  118. // 数据导出接口
  119. let urlStr = this.exportBase;
  120. // token
  121. urlStr += `?${localStorage.getItem("auth") || ""}`;
  122. // 指标名称参数
  123. urlStr += `&QuotaName=${this.select_quota}`;
  124. // 指标id
  125. urlStr += `&LzCode=${this.leftSearchTradeCode}`;
  126. // 分类名称
  127. urlStr += `&BreedName=${this.select_breed}`;
  128. // 频度
  129. urlStr += `&Frequency=${this.select_frequency}`;
  130. // 单位
  131. urlStr += `&UnitName=${this.select_Unit}`;
  132. // 修改时间
  133. urlStr += `&ModifyTime=${this.select_ModifyTime}`;
  134. return this.escapeStr(urlStr);
  135. },
  136. },
  137. created() {
  138. this.getClassify();
  139. },
  140. methods: {
  141. /* 获取分类 */
  142. getClassify() {
  143. lzDataInterface.classifyList().then((res) => {
  144. if (res.Ret !== 200) return;
  145. this.classifyList = res.Data || [];
  146. this.select_classify =
  147. this.select_classify || this.classifyList[0].BreedId;
  148. this.select_breed = this.classifyList[0].BreedName;
  149. this.getDataList()
  150. });
  151. },
  152. /* 获取数据 */
  153. getDataList() {
  154. this.dataloading = true;
  155. lzDataInterface.dataList({BreedId: Number(this.select_classify),Frequency:1}).then((res) => {
  156. this.rightShow = true;
  157. if (res.Ret !== 200) return;
  158. // 设置表格数据
  159. this.setDataList(res.Data);
  160. this.$nextTick(() => {
  161. this.initWidth();
  162. });
  163. }).finally(()=>{
  164. this.dataloading = false;
  165. })
  166. },
  167. /* 改变品种 */
  168. changeClassify(item) {
  169. this.select_classify = item.BreedId;
  170. this.select_breed = item.BreedName;
  171. this.leftSearchVal = ""
  172. this.leftSearchTradeCode = ""
  173. this.select_quota = ""
  174. this.select_Unit = ""
  175. this.select_ModifyTime = ""
  176. this.getDataList()
  177. },
  178. initWidth() {
  179. $(".right-box")[0].style.width =
  180. this.$refs.table ? this.$refs.table.$el.clientWidth + 2 + "px":'0';
  181. $(".right-box")[0].scrollTop = 0;
  182. $(".right-box")[0].scrollLeft = 0;
  183. },
  184. /* 导出 */
  185. exportClick() {
  186. this.btnload = true;
  187. // TODO: 导出接口对接
  188. const link = document.createElement("a");
  189. link.href = this.exportLzapi;
  190. link.download = "";
  191. link.click();
  192. setTimeout(() => {
  193. this.btnload = false;
  194. }, 2000);
  195. },
  196. //左侧搜索
  197. async handleLeftSearch(query, cb) {
  198. cb([]);
  199. if (!query) return;
  200. const res = await lzDataInterface.getTargetListByName({
  201. Keyword: query,
  202. });
  203. if (res.Ret === 200) {
  204. let arr = res.Data || [];
  205. if (!arr.length) {
  206. cb([{ nodata: true }]);
  207. } else {
  208. cb(arr);
  209. }
  210. }
  211. },
  212. // 选中左侧搜索值
  213. handleSelectLeftSearchval(e) {
  214. if (!e.LzCode) return;
  215. this.rightShow = false;
  216. this.leftSearchTradeCode = e.LzCode;
  217. this.leftSearchVal = e.QuotaName;
  218. this.select_quota = e.QuotaName;
  219. this.select_Unit = e.UnitName;
  220. this.select_ModifyTime = e.ModifyTime;
  221. this.select_classify = this.classifyList.find(
  222. (item) => item.BreedName === e.BreedName
  223. ).BreedId;
  224. this.select_breed = "";
  225. this.setDataList([e]);
  226. this.getDataList()
  227. this.$nextTick(() => {
  228. this.rightShow = true;
  229. this.handleScrollLeftWrap();
  230. });
  231. },
  232. // 左侧滚动
  233. handleScrollLeftWrap() {
  234. let top = $(".act")[0].offsetTop;
  235. $(".classify-list").animate({
  236. scrollTop: top - 200,
  237. });
  238. },
  239. // 设置表格数据
  240. setDataList(tableOption) {
  241. this.tableOption = tableOption;
  242. /* 不满7个追加7个空的显示一排 别问 问就是为了美观 */
  243. if (tableOption.length < 7)
  244. for (let i = 0; i < 7; i++) {
  245. this.tableOption.push({
  246. DataList: [],
  247. });
  248. if (this.tableOption.length >= 7) break;
  249. }
  250. // 合并所有日期
  251. let arr = tableOption.map((item) => item.DataList);
  252. let obj = [];
  253. arr.forEach((dataList) => {
  254. obj.push(...dataList.map((item) => item.DataTime));
  255. });
  256. // 日期去重倒序排序
  257. this.dateArr = [...new Set(obj)].sort().reverse();
  258. //数据最大长度小于13个 追加数据满13个 别问 问就是为了美观
  259. if (this.dateArr.length < 13)
  260. for (let i = 0; i < 13; i++) {
  261. this.dateArr.push("");
  262. if (this.dateArr.length >= 13) break;
  263. }
  264. },
  265. },
  266. };
  267. </script>
  268. <style lang="scss" scoped>
  269. @import "../css/coalCommon.scss";
  270. </style>