index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <template>
  2. <div class="searchPage1">
  3. <div class="query mg-b-8">
  4. <div class="query-items">
  5. <div class="query-item">
  6. <div class="lable">日期:</div>
  7. <div class="search-input">
  8. <el-date-picker
  9. size="medium"
  10. v-model="form.dateArea"
  11. type="datetimerange"
  12. :picker-options="pickerOptions"
  13. range-separator="至"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期"
  16. align="right"
  17. >
  18. </el-date-picker>
  19. </div>
  20. </div>
  21. <div class="query-item">
  22. <div class="lable">间隔:</div>
  23. <div class="search-input">
  24. <el-input
  25. placeholder="请输入间隔"
  26. clearable
  27. v-model="form.interval"
  28. type="number"
  29. ></el-input>
  30. </div>
  31. </div>
  32. <div class="query-item">
  33. <div class="lable"></div>
  34. <div class="search-input">
  35. <transition name="el-zoom-in-center">
  36. <el-radio-group
  37. v-model="form.type"
  38. size="small"
  39. v-show="form.interval"
  40. >
  41. <el-radio label="0" @click.native.prevent="getRadio('0')"
  42. >最大</el-radio
  43. >
  44. <el-radio label="1" @click.native.prevent="getRadio('1')"
  45. >最小</el-radio
  46. >
  47. <el-radio label="2" @click.native.prevent="getRadio('2')"
  48. >平均</el-radio
  49. >
  50. </el-radio-group>
  51. </transition>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="query-actions">
  56. <button class="btn green" @click="renderCharts">生成曲线</button>
  57. </div>
  58. </div>
  59. <div class="cardBox">
  60. <el-card class="box-card">
  61. <div slot="header" class="clearfix">
  62. <span>类型</span>
  63. <!-- <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button> -->
  64. </div>
  65. <div>
  66. <el-radio-group
  67. v-model="form.fjType"
  68. size="small"
  69. @change="
  70. (fjType) => {
  71. resetForm();
  72. }
  73. "
  74. >
  75. <el-form ref="form" :model="form">
  76. <el-form-item style="margin-bottom: 5px">
  77. <el-radio border size="medium" label="1"
  78. >单风机多参数对比</el-radio
  79. >
  80. </el-form-item>
  81. <el-form-item style="margin-bottom: 5px">
  82. <el-radio border size="medium" label="2"
  83. >多风机单参数对比</el-radio
  84. >
  85. </el-form-item>
  86. </el-form>
  87. </el-radio-group>
  88. </div>
  89. </el-card>
  90. <el-card class="box-card">
  91. <div slot="header" class="clearfix">
  92. <span>设备结构</span>
  93. </div>
  94. <div>
  95. <div class="treeBox">
  96. <el-input
  97. size="small"
  98. placeholder="输入以检索"
  99. :disabled="!treeData.length"
  100. v-model="filterText"
  101. ></el-input>
  102. <el-tree
  103. ref="treeRef"
  104. node-key="id"
  105. :data="treeData"
  106. :props="treeProps"
  107. :show-checkbox="true"
  108. :highlight-current="true"
  109. :filter-node-method="filterNode"
  110. @check-change="getTreeChecked"
  111. ></el-tree>
  112. </div>
  113. </div>
  114. </el-card>
  115. <el-card class="box-card">
  116. <div slot="header" class="clearfix">
  117. <span>关键参数</span>
  118. </div>
  119. <div class="selectBox treeBox">
  120. <el-input
  121. size="small"
  122. placeholder="输入以检索"
  123. :disabled="!gjcsOptions.length"
  124. v-model="filterText1"
  125. ></el-input>
  126. <el-tree
  127. ref="treeRef1"
  128. node-key="code"
  129. :data="gjcsOptions"
  130. :props="{ children: null, label: 'description' }"
  131. :show-checkbox="true"
  132. :highlight-current="true"
  133. :filter-node-method="filterNode1"
  134. @check-change="getTreeChecked1"
  135. ></el-tree>
  136. <!-- <el-select style="width:100%;" v-model="form.gjcs" filterable clearable :multiple="!treeIsMultiple"
  137. placeholder="输入以检索" @change="(res) => { this.$forceUpdate(); }">
  138. <el-option v-for="item in gjcsOptions" :key="item.id" :label="item.description" :value="item.code">
  139. </el-option>
  140. </el-select> -->
  141. </div>
  142. </el-card>
  143. </div>
  144. <div class="chartsBox">
  145. <div id="lineChart" style="width: 100%; height: 100%"></div>
  146. </div>
  147. </div>
  148. </template>
  149. <script>
  150. import * as echarts from "echarts";
  151. import api from "@api/economic/index.js";
  152. export default {
  153. data() {
  154. return {
  155. form: {
  156. pointId: "",
  157. pointName: "",
  158. autoReq: false,
  159. dateArea: [
  160. this.fmtDate(
  161. new Date(
  162. new Date().setTime(new Date().getTime() - 3600 * 1000 * 24)
  163. )
  164. ),
  165. this.fmtDate(new Date()),
  166. ],
  167. interval: "",
  168. type: "",
  169. fjType: "1",
  170. gjcs: "",
  171. },
  172. treeIsMultiple: false,
  173. filterText: "",
  174. filterText1: "",
  175. treeData: [],
  176. gjcsOptions: [],
  177. treeProps: {
  178. children: "children",
  179. label: "label",
  180. },
  181. pickerOptions: {
  182. shortcuts: [
  183. {
  184. text: "最近一天",
  185. onClick(picker) {
  186. const end = new Date();
  187. const start = new Date();
  188. start.setTime(start.getTime() - 3600 * 1000 * 24);
  189. picker.$emit("pick", [start, end]);
  190. },
  191. },
  192. {
  193. text: "最近一周",
  194. onClick(picker) {
  195. const end = new Date();
  196. const start = new Date();
  197. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  198. picker.$emit("pick", [start, end]);
  199. },
  200. },
  201. {
  202. text: "最近一个月",
  203. onClick(picker) {
  204. const end = new Date();
  205. const start = new Date();
  206. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  207. picker.$emit("pick", [start, end]);
  208. },
  209. },
  210. {
  211. text: "最近三个月",
  212. onClick(picker) {
  213. const end = new Date();
  214. const start = new Date();
  215. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  216. picker.$emit("pick", [start, end]);
  217. },
  218. },
  219. ],
  220. },
  221. };
  222. },
  223. created() {},
  224. mounted() {
  225. let that = this;
  226. that.$nextTick(() => {
  227. that.getEquipmentStructure();
  228. that.getEquipmentParams();
  229. });
  230. },
  231. methods: {
  232. // 获取设备结构
  233. getEquipmentStructure() {
  234. api.paramComparisonEquipmentStructure({}).then((res) => {
  235. // 请求成功的回调
  236. let treeData = [];
  237. res.data.forEach((ele) => {
  238. let findRes = treeData.find((findEle) => {
  239. return ele.windpowerstationid === findEle.label;
  240. });
  241. if (!findRes) {
  242. let treeTemp = {
  243. label: ele.windpowerstationid,
  244. children: [],
  245. };
  246. treeTemp.children.push({
  247. label: ele.name,
  248. id: ele.id,
  249. });
  250. treeData.push(treeTemp);
  251. } else {
  252. findRes.children.push({
  253. label: ele.name,
  254. id: ele.id,
  255. });
  256. }
  257. });
  258. this.treeData = treeData;
  259. });
  260. let that = this;
  261. // that.API.requestData({
  262. // baseURL:"http://10.155.32.4:8031/",
  263. // subUrl: "paramComparison/equipmentStructure",
  264. // timeout:30000,
  265. // success (res) {
  266. // // 请求成功的回调
  267. // let treeData = [];
  268. // res.data.forEach(ele => {
  269. // let findRes = treeData.find(findEle => {
  270. // return ele.windpowerstationid === findEle.label;
  271. // });
  272. // if (!findRes) {
  273. // let treeTemp = {
  274. // label: ele.windpowerstationid,
  275. // children: []
  276. // };
  277. // treeTemp.children.push({
  278. // label: ele.name,
  279. // id: ele.id
  280. // });
  281. // treeData.push(treeTemp);
  282. // } else {
  283. // findRes.children.push({
  284. // label: ele.name,
  285. // id: ele.id
  286. // });
  287. // }
  288. // });
  289. // that.treeData = treeData;
  290. // }
  291. // });
  292. },
  293. // 获取关键节点
  294. getEquipmentParams() {
  295. api.paramComparisonEquipmentParams({}).then((res) => {
  296. that.gjcsOptions = res.data;
  297. });
  298. // let that = this;
  299. // that.API.requestData({
  300. // baseURL: "http://10.155.32.4:8031/",
  301. // subUrl: "paramComparison/equipmentParams",
  302. // success(res) {
  303. // that.gjcsOptions = res.data;
  304. // },
  305. // });
  306. },
  307. // 获取单选结果
  308. getRadio(type) {
  309. if (type === this.form.type && this.form.type !== "") {
  310. this.form.type = "";
  311. } else {
  312. this.form.type = type;
  313. }
  314. },
  315. // 渲染图表
  316. renderCharts() {
  317. let that = this;
  318. that.$nextTick(() => {
  319. let begin = that.form.dateArea.length
  320. ? new Date(that.form.dateArea[0]).formatDate("yyyy-MM-dd hh:mm:ss")
  321. : "";
  322. let end = that.form.dateArea.length
  323. ? new Date(that.form.dateArea[1]).formatDate("yyyy-MM-dd hh:mm:ss")
  324. : "";
  325. let interval = that.form.interval;
  326. let type = that.form.type;
  327. let paramtype = that.form.fjType;
  328. let wts = [];
  329. let wtsArray = that.$refs.treeRef.getCheckedNodes();
  330. let params = [];
  331. let paramsArray = that.$refs.treeRef1.getCheckedNodes();
  332. // let params = that.form.gjcs;
  333. wtsArray.forEach((pEle) => {
  334. if (pEle.id) {
  335. wts.push(pEle.id);
  336. } else {
  337. pEle.children.forEach((cEle) => {
  338. wts.push(cEle.id);
  339. });
  340. }
  341. });
  342. paramsArray.forEach((pEle) => {
  343. params.push(pEle.code);
  344. });
  345. let data = {};
  346. data.begin = begin;
  347. data.end = end;
  348. interval && (data.interval = interval);
  349. type && (data.type = type);
  350. data.paramtype = paramtype;
  351. data.wts = wts.toString();
  352. data.params = params.toString();
  353. if (begin && end && paramtype && wts.length && params.length) {
  354. // that.API.requestData({
  355. // baseURL: "http://10.155.32.4:8031/",
  356. // subUrl: "paramComparison/generatingCurve",
  357. // timeout: 10000,
  358. // data,
  359. // success(res) {
  360. // if (res.data.length) {
  361. // let xAxisData = []; // x轴标题
  362. // let seriesData = []; // 折线图数据
  363. // let keyArray = [];
  364. // if (that.form.fjType === "1") {
  365. // params.forEach((ele) => {
  366. // let findRes = that.gjcsOptions.find((findEle) => {
  367. // return ele === findEle.code;
  368. // });
  369. // keyArray.push(findRes.description);
  370. // });
  371. // } else {
  372. // wtsArray.forEach((pEle) => {
  373. // if (pEle.id) {
  374. // keyArray.push(pEle.label);
  375. // } else {
  376. // pEle.children.forEach((cEle) => {
  377. // keyArray.push(cEle.label);
  378. // });
  379. // }
  380. // });
  381. // }
  382. // keyArray.forEach((ele) => {
  383. // seriesData.push({
  384. // data: [],
  385. // type: "line",
  386. // smooth: true,
  387. // name: ele,
  388. // });
  389. // });
  390. // res.data.forEach((pEle) => {
  391. // xAxisData.push(that.fmtDate(new Date(pEle.time)));
  392. // keyArray.forEach((cEle, cIndex) => {
  393. // seriesData[cIndex].data.push(pEle[cEle] || null);
  394. // });
  395. // });
  396. // document
  397. // .getElementById("lineChart")
  398. // .removeAttribute("_echarts_instance_");
  399. // let chartDom = document.getElementById("lineChart");
  400. // let myChart = echarts.init(chartDom);
  401. // let option = {
  402. // xAxis: {
  403. // type: "category",
  404. // data: xAxisData,
  405. // },
  406. // yAxis: {
  407. // type: "value",
  408. // },
  409. // series: seriesData,
  410. // tooltip: {
  411. // trigger: "axis",
  412. // axisPointer: {
  413. // type: "cross",
  414. // label: {
  415. // backgroundColor: "#6a7985",
  416. // },
  417. // },
  418. // },
  419. // };
  420. // option && myChart.setOption(option);
  421. // } else {
  422. // that.BASE.showMsg({
  423. // type: "warning",
  424. // msg: "所选参数暂无数据,请切换参数后再次尝试",
  425. // });
  426. // }
  427. // },
  428. // });
  429. } else {
  430. that.BASE.showMsg({
  431. msg: "无法生成,请检查 日期、设备结构与关键参数是否已选择",
  432. });
  433. }
  434. });
  435. },
  436. // 过滤树形节点
  437. filterNode(value, data) {
  438. if (!value) return true;
  439. return data.label.indexOf(value) !== -1;
  440. },
  441. // 过滤树形节点
  442. filterNode1(value, data) {
  443. if (!value) return true;
  444. return data.description.indexOf(value) !== -1;
  445. },
  446. // 获取树形选中
  447. getTreeChecked(data, checked, node) {
  448. if (!this.treeIsMultiple) {
  449. if (checked === true) {
  450. this.checkedId = data.id;
  451. this.$refs.treeRef.setCheckedKeys([data.id]);
  452. } else {
  453. if (this.checkedId == data.id) {
  454. this.$refs.treeRef.setCheckedKeys([]);
  455. }
  456. }
  457. }
  458. },
  459. // 获取树形选中
  460. getTreeChecked1(data, checked, node) {
  461. if (this.treeIsMultiple) {
  462. if (checked === true) {
  463. this.checkedId = data.code;
  464. this.$refs.treeRef1.setCheckedKeys([data.code]);
  465. } else {
  466. if (this.checkedId == data.code) {
  467. this.$refs.treeRef1.setCheckedKeys([]);
  468. }
  469. }
  470. }
  471. },
  472. // 重置表单
  473. resetForm() {
  474. this.form.fjType === "1"
  475. ? (this.treeIsMultiple = false)
  476. : (this.treeIsMultiple = true);
  477. this.$refs.treeRef.setCheckedKeys([]);
  478. this.$refs.treeRef1.setCheckedKeys([]);
  479. this.form.gjcs = "";
  480. this.$forceUpdate();
  481. document
  482. .getElementById("lineChart")
  483. .removeAttribute("_echarts_instance_");
  484. echarts.init(document.getElementById("lineChart"));
  485. },
  486. // 格式化日期
  487. fmtDate(date) {
  488. let curDate = date || new Date();
  489. let year = curDate.getFullYear();
  490. let mouth = curDate.getUTCMonth() + 1;
  491. let day = curDate.getDate();
  492. let hour = curDate.getHours();
  493. let minutes = curDate.getMinutes();
  494. let seconds = curDate.getSeconds();
  495. return (
  496. year +
  497. "-" +
  498. (mouth < 10 ? "0" + mouth : mouth) +
  499. "-" +
  500. (day < 10 ? "0" + day : day) +
  501. " " +
  502. (hour < 10 ? "0" + hour : hour) +
  503. ":" +
  504. (minutes < 10 ? "0" + minutes : minutes) +
  505. ":" +
  506. (seconds < 10 ? "0" + seconds : seconds)
  507. );
  508. },
  509. },
  510. watch: {
  511. filterText(val) {
  512. this.$refs.treeRef.filter(val);
  513. },
  514. filterText1(val) {
  515. this.$refs.treeRef1.filter(val);
  516. },
  517. },
  518. };
  519. </script>
  520. <style lang="less" scoped>
  521. .searchBox1 {
  522. width: 80%;
  523. display: flex;
  524. justify-content: start;
  525. align-items: center;
  526. position: relative;
  527. .btnBox {
  528. position: absolute;
  529. left: calc(100% + 60px);
  530. top: 0;
  531. display: flex;
  532. justify-content: start;
  533. align-items: center;
  534. }
  535. .el-input {
  536. width: 150px;
  537. }
  538. }
  539. .cardBox {
  540. width: 100%;
  541. display: flex;
  542. justify-content: space-between;
  543. align-items: center;
  544. margin-top: 20px;
  545. .el-card {
  546. width: 32%;
  547. height: 255px;
  548. .treeBox {
  549. width: 100%;
  550. .el-tree {
  551. width: 100%;
  552. height: 160px;
  553. margin-top: 10px;
  554. overflow-y: scroll;
  555. &::-webkit-scrollbar {
  556. width: 6px;
  557. height: 6px;
  558. background: #fff;
  559. }
  560. &::-webkit-scrollbar-track {
  561. border-radius: 5px;
  562. background: #fff;
  563. }
  564. &::-webkit-scrollbar-thumb {
  565. border-radius: 10px;
  566. background: rgba(144, 147, 153, 0.3);
  567. }
  568. }
  569. }
  570. }
  571. }
  572. .selectBox {
  573. .el-select {
  574. max-height: 150px;
  575. overflow-y: scroll;
  576. &::-webkit-scrollbar {
  577. width: 6px;
  578. height: 6px;
  579. background: #fff;
  580. }
  581. &::-webkit-scrollbar-track {
  582. border-radius: 5px;
  583. background: #fff;
  584. }
  585. &::-webkit-scrollbar-thumb {
  586. border-radius: 10px;
  587. background: rgba(144, 147, 153, 0.3);
  588. }
  589. }
  590. }
  591. .chartsBox {
  592. width: 100%;
  593. height: 400px;
  594. }
  595. </style>
  596. <style lang="less">
  597. .cardBox {
  598. .el-card__header {
  599. padding: 5px 20px;
  600. }
  601. .el-card__body {
  602. padding: 10px 20px;
  603. }
  604. }
  605. </style>