index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="draught-fan-list">
  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-select
  9. v-model="wpId"
  10. clearable
  11. placeholder="请选择"
  12. popper-class="select"
  13. @change="
  14. (wpId) => {
  15. getWt(wpId, true);
  16. }
  17. "
  18. >
  19. <el-option
  20. v-for="item in wpArray"
  21. :key="item.id"
  22. :value="item.id"
  23. :label="item.name"
  24. />
  25. </el-select>
  26. </div>
  27. </div>
  28. <div class="query-item">
  29. <div class="lable">风机:</div>
  30. <div class="search-input">
  31. <el-select
  32. v-model="wtId"
  33. clearable
  34. placeholder="请选择"
  35. popper-class="select"
  36. >
  37. <el-option
  38. v-for="item in wtArray"
  39. :key="item.id"
  40. :value="item.id"
  41. :label="item.nemCode"
  42. />
  43. </el-select>
  44. </div>
  45. </div>
  46. <div class="query-item">
  47. <div class="lable">日期:</div>
  48. <div class="search-input">
  49. <el-date-picker
  50. v-model="recorddate"
  51. type="month"
  52. value-format="YYYY-MM"
  53. placeholder="选择日期"
  54. popper-class="date-select"
  55. >
  56. </el-date-picker>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="query-actions">
  61. <button class="btn green" @click="search">搜索</button>
  62. </div>
  63. </div>
  64. <ScatterLineChart
  65. xTitle="风速(m/s)"
  66. yTitle="功率(kw)"
  67. :showLegend="true"
  68. :height="'calc(100vh - 40px)'"
  69. :lineData="chartLineData"
  70. :data="chartData"
  71. />
  72. </div>
  73. </template>
  74. <script>
  75. import ScatterLineChart from "@com/chart/combination/scatter-line-chart.vue";
  76. import api1 from "@api/economic/index.js";
  77. import api from "@api/wisdomOverhaul/energy/index.js";
  78. export default {
  79. // 名称
  80. name: "cutAnalyse",
  81. // 使用组件
  82. components: {
  83. ScatterLineChart,
  84. },
  85. // 数据
  86. data() {
  87. return {
  88. isAsc: "asc",
  89. wpArray: [],
  90. wtArray: [],
  91. wpId: "",
  92. wtId: "",
  93. recorddate:
  94. "2021-09" ||
  95. new Date(new Date().getTime() - 3600 * 1000 * 24).formatDate("yyyy-MM"),
  96. chartLineData: {
  97. xTitle: "风速",
  98. yTitle: "功率",
  99. legends: [],
  100. data: [],
  101. },
  102. chartData: [
  103. {
  104. title: "",
  105. value: [],
  106. },
  107. ],
  108. };
  109. },
  110. // 函数
  111. methods: {
  112. // 获取风场
  113. getWp(reGetWp) {
  114. api1
  115. .getWpList({
  116. type: "-1",
  117. })
  118. .then((res) => {
  119. if (res.data.code === 200) {
  120. this.wpArray = res.data.data;
  121. this.wpId = res.data.data[0].id;
  122. this.getWt(this.wpId, reGetWp);
  123. }
  124. });
  125. },
  126. // 获取风机
  127. getWt(wpid, reGetWp) {
  128. if (wpid) {
  129. api1
  130. .getWtList({
  131. wpId: wpid,
  132. })
  133. .then((res) => {
  134. if (res.code === 200) {
  135. this.wtArray = res.data;
  136. this.wtId = res.data[0].id;
  137. if (!reGetWp) {
  138. this.getChartData();
  139. }
  140. }
  141. });
  142. }
  143. },
  144. // 获取图表数据
  145. getChartData() {
  146. api
  147. .scatterScatterWtAjax({
  148. wtId: this.wtId,
  149. year: this.recorddate.split("-")[0],
  150. month: this.recorddate.split("-")[1],
  151. })
  152. .then((res) => {
  153. if (res.data.line.length || res.data.scatter.length) {
  154. let chartLineData = {
  155. xTitle: "风速",
  156. yTitle: "功率",
  157. legends: [],
  158. // data: [[], []],
  159. data: [[]],
  160. };
  161. res.data.line.forEach((ele) => {
  162. // chartLineData.data[0].push(ele[0]);
  163. // chartLineData.data[1].push(ele[1]);
  164. chartLineData.data[0].push(ele[1]);
  165. });
  166. let chartData = [
  167. {
  168. title: "功率曲线拟合",
  169. value: res.data.scatter,
  170. },
  171. ];
  172. this.chartLineData = chartLineData;
  173. this.chartData = chartData;
  174. } else {
  175. this.BASE.showMsg({
  176. msg: "所选日期区间暂无数据",
  177. });
  178. }
  179. });
  180. // let that = this;
  181. // that.API.requestData({
  182. // method: "POST",
  183. // subUrl: "scatter/scatterWtAjax",
  184. // showLoading: true,
  185. // data: {
  186. // wtId: that.wtId,
  187. // year: that.recorddate.split("-")[0],
  188. // month: that.recorddate.split("-")[1],
  189. // },
  190. // success(res) {
  191. // if (res.data.line.length || res.data.scatter.length) {
  192. // let chartLineData = {
  193. // xTitle: "风速",
  194. // yTitle: "功率",
  195. // legends: [],
  196. // // data: [[], []],
  197. // data: [[]],
  198. // };
  199. // res.data.line.forEach((ele) => {
  200. // // chartLineData.data[0].push(ele[0]);
  201. // // chartLineData.data[1].push(ele[1]);
  202. // chartLineData.data[0].push(ele[1]);
  203. // });
  204. // let chartData = [
  205. // {
  206. // title: "功率曲线拟合",
  207. // value: res.data.scatter,
  208. // },
  209. // ];
  210. // that.chartLineData = chartLineData;
  211. // that.chartData = chartData;
  212. // } else {
  213. // that.BASE.showMsg({
  214. // msg: "所选日期区间暂无数据",
  215. // });
  216. // }
  217. // },
  218. // });
  219. },
  220. search() {
  221. if (!this.wpId || !this.wtId) {
  222. this.BASE.showMsg({
  223. msg: "场站与风机为必选项",
  224. });
  225. } else {
  226. this.getChartData();
  227. }
  228. },
  229. },
  230. created() {
  231. this.getWp();
  232. },
  233. mounted() {},
  234. unmounted() {},
  235. };
  236. </script>
  237. <style lang="less" scoped>
  238. .draught-fan-list {
  239. width: 100%;
  240. height: 100%;
  241. display: flex;
  242. flex-direction: column;
  243. .btn-group-tabs {
  244. display: flex;
  245. flex-direction: row;
  246. .photovoltaic {
  247. margin-left: 1.481vh;
  248. }
  249. }
  250. .df-table {
  251. border: 0.093vh solid fade(@darkgray, 50%);
  252. position: relative;
  253. overflow: auto;
  254. flex-grow: 1;
  255. margin-top: 1.481vh;
  256. height: 30vh;
  257. &:before {
  258. content: "";
  259. width: 0.37vh;
  260. height: 0.37vh;
  261. background: @write;
  262. position: absolute;
  263. left: 0.278vh;
  264. top: 0.278vh;
  265. }
  266. tbody {
  267. height: calc(100vh - 166px);
  268. }
  269. }
  270. }
  271. </style>