icpiConsumption.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. import { icpiInterface } from "@/api/api.js";
  87. export default {
  88. name: "icpiConsumption",
  89. components: { lzTable },
  90. data() {
  91. return {
  92. isLeftWrapShow:true,
  93. dataloading: false,
  94. rightShow: false,
  95. exportBase: process.env.VUE_APP_API_ROOT + "/datamanage/export/lzList", //数据导出接口
  96. select_classify: "",
  97. classifyList: [],
  98. frequencyType: new Map([
  99. [1, "日度"],
  100. [2, "周度"],
  101. [3, "月度"],
  102. [4, "季度"],
  103. [5, "年度"],
  104. [99, "无固定频率"],
  105. ]),
  106. tableOption: [],
  107. dateArr: [], //最长的日期数组
  108. btnload: false,
  109. leftSearchVal: "", //左侧搜索值
  110. leftSearchTradeCode: "", //如果是搜索选择的 则有此code
  111. select_quota: "", // 选中的指标名称
  112. select_Unit: "", // 选中的单位
  113. select_ModifyTime: "", //选中的更新时间
  114. select_breed: "", // 选中的分类名称
  115. pageParams:{
  116. PageSize:20,
  117. CurrentIndex:1
  118. }
  119. };
  120. },
  121. computed: {
  122. exportLzapi() {
  123. // 数据导出接口
  124. let urlStr = this.exportBase;
  125. // token
  126. urlStr += `?${localStorage.getItem("auth") || ""}`;
  127. // 指标名称参数
  128. urlStr += `&QuotaName=${this.select_quota}`;
  129. // 指标id
  130. urlStr += `&LzCode=${this.leftSearchTradeCode}`;
  131. // 分类名称
  132. urlStr += `&BreedName=${this.select_breed}`;
  133. // 频度
  134. urlStr += `&Frequency=${this.select_frequency}`;
  135. // 单位
  136. urlStr += `&UnitName=${this.select_Unit}`;
  137. // 修改时间
  138. urlStr += `&ModifyTime=${this.select_ModifyTime}`;
  139. return this.escapeStr(urlStr);
  140. },
  141. },
  142. created() {
  143. this.getClassify();
  144. },
  145. methods: {
  146. /* 获取分类 */
  147. getClassify() {
  148. // icpiInterface
  149. lzDataInterface.classifyList().then((res) => {
  150. if (res.Ret !== 200) return;
  151. console.log(res);
  152. this.classifyList = res.Data || [];
  153. this.select_classify =
  154. this.select_classify || this.classifyList[0].BreedId;
  155. this.select_breed = this.classifyList[0].BreedName;
  156. this.getDataList()
  157. });
  158. },
  159. /* 获取数据 */
  160. getDataList() {
  161. this.dataloading = true;
  162. // icpiInterface.dataList({
  163. // BaseFromIcpiClassifyId: Number(this.select_classify),
  164. // PageSize:this.pageParams.PageSize,
  165. // CurrentIndex:this.pageParams.CurrentIndex
  166. // })
  167. lzDataInterface.dataList({BaseFromIcpiClassifyId: Number(this.select_classify),Frequency:1}).then((res) => {
  168. this.rightShow = true;
  169. if (res.Ret !== 200) return;
  170. // 设置表格数据
  171. this.setDataList(res.Data);
  172. this.$nextTick(() => {
  173. this.initWidth();
  174. });
  175. }).finally(()=>{
  176. this.dataloading = false;
  177. })
  178. },
  179. /* 改变品种 */
  180. changeClassify(item) {
  181. this.select_classify = item.BreedId;
  182. this.select_breed = item.BreedName;
  183. this.leftSearchVal = ""
  184. this.leftSearchTradeCode = ""
  185. this.select_quota = ""
  186. this.select_Unit = ""
  187. this.select_ModifyTime = ""
  188. this.getDataList()
  189. },
  190. initWidth() {
  191. $(".right-box")[0].style.width =
  192. this.$refs.table ? this.$refs.table.$el.clientWidth + 2 + "px":'0';
  193. $(".right-box")[0].scrollTop = 0;
  194. $(".right-box")[0].scrollLeft = 0;
  195. },
  196. /* 导出 */
  197. exportClick() {
  198. this.btnload = true;
  199. // TODO: 导出接口对接
  200. const link = document.createElement("a");
  201. link.href = this.exportLzapi;
  202. link.download = "";
  203. link.click();
  204. setTimeout(() => {
  205. this.btnload = false;
  206. }, 2000);
  207. },
  208. //左侧搜索
  209. async handleLeftSearch(query, cb) {
  210. cb([]);
  211. if (!query) return;
  212. const res = await lzDataInterface.getTargetListByName({
  213. Keyword: query,
  214. });
  215. if (res.Ret === 200) {
  216. let arr = res.Data || [];
  217. if (!arr.length) {
  218. cb([{ nodata: true }]);
  219. } else {
  220. cb(arr);
  221. }
  222. }
  223. },
  224. // 选中左侧搜索值
  225. handleSelectLeftSearchval(e) {
  226. if (!e.LzCode) return;
  227. this.rightShow = false;
  228. this.leftSearchTradeCode = e.LzCode;
  229. this.leftSearchVal = e.QuotaName;
  230. this.select_quota = e.QuotaName;
  231. this.select_Unit = e.UnitName;
  232. this.select_ModifyTime = e.ModifyTime;
  233. this.select_classify = this.classifyList.find(
  234. (item) => item.BreedName === e.BreedName
  235. ).BreedId;
  236. this.select_breed = "";
  237. this.setDataList([e]);
  238. this.getDataList()
  239. this.$nextTick(() => {
  240. this.rightShow = true;
  241. this.handleScrollLeftWrap();
  242. });
  243. },
  244. // 左侧滚动
  245. handleScrollLeftWrap() {
  246. let top = $(".act")[0].offsetTop;
  247. $(".classify-list").animate({
  248. scrollTop: top - 200,
  249. });
  250. },
  251. // 设置表格数据
  252. setDataList(tableOption) {
  253. this.tableOption = tableOption;
  254. /* 不满7个追加7个空的显示一排 别问 问就是为了美观 */
  255. if (tableOption.length < 7)
  256. for (let i = 0; i < 7; i++) {
  257. this.tableOption.push({
  258. DataList: [],
  259. });
  260. if (this.tableOption.length >= 7) break;
  261. }
  262. // 合并所有日期
  263. let arr = tableOption.map((item) => item.DataList);
  264. let obj = [];
  265. arr.forEach((dataList) => {
  266. obj.push(...dataList.map((item) => item.DataTime));
  267. });
  268. // 日期去重倒序排序
  269. this.dateArr = [...new Set(obj)].sort().reverse();
  270. //数据最大长度小于13个 追加数据满13个 别问 问就是为了美观
  271. if (this.dateArr.length < 13)
  272. for (let i = 0; i < 13; i++) {
  273. this.dateArr.push("");
  274. if (this.dateArr.length >= 13) break;
  275. }
  276. },
  277. },
  278. };
  279. </script>
  280. <style lang="scss" scoped>
  281. @import "../css/coalCommon.scss";
  282. </style>