index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <script setup name="agcAnalysis">
  2. import {
  3. getPrepareExcelShow,
  4. getPrepareTree,
  5. getWindAgcDeviate,
  6. } from "@/api/powerGenerating/index.js";
  7. import searchCop from "./components/search.vue";
  8. import excelCop from "@/components/excel.vue";
  9. import treeCop from "@/components/tree.vue";
  10. import tableCop from "@/views/powerGenerating/components/table.vue";
  11. import { ElMessage } from "element-plus";
  12. import { onMounted, ref, onActivated } from "vue";
  13. import CurrentScatterChart from "./components/current-scatter-chart.vue";
  14. import request from "@/api/axios.js";
  15. import dayjs from "dayjs";
  16. /**excel 开始 */
  17. const excelList = ref([]);
  18. const funExcelChange = async (obj) => {
  19. //点击excel项时
  20. activeTab.value = "1";
  21. tableShowId.value = obj.id;
  22. tableName.value = obj.name;
  23. tableLoading.value = true;
  24. const res = await getPrepareExcelShow({ id: obj.id });
  25. if (res.code === 200) {
  26. tableColumn.value = res.data.title.map((o) => {
  27. return {
  28. prop: o.key,
  29. label: o.des,
  30. width: o.des === "时间" ? 100 : 80,
  31. };
  32. });
  33. tableData.value = res.data.data;
  34. tableLoading.value = false;
  35. } else {
  36. tableLoading.value = false;
  37. }
  38. };
  39. /**tree 开始 */
  40. const treeData = ref([]);
  41. const funRepeatMap = (arr) => {
  42. return arr.map((o) => {
  43. if (o.children) {
  44. const findIndex = o.children.findIndex((p) => !!p.type);
  45. if (findIndex !== -1) {
  46. o.childs = o.children;
  47. o.children = [];
  48. }
  49. }
  50. return {
  51. ...o,
  52. children: o.children?.length ? funRepeatMap(o.children) : [],
  53. };
  54. });
  55. };
  56. const funGetTree = async () => {
  57. const res = await getPrepareTree();
  58. treeData.value = funRepeatMap(res.data);
  59. excelList.value = [];
  60. };
  61. const funCurrentChange = ({ current, currentNode }) => {
  62. if (current.childs) {
  63. excelList.value = current.childs.map((o) => {
  64. return {
  65. id: o.id,
  66. interval: o.interval,
  67. path: o.path,
  68. prepareid: o.prepareid,
  69. station: o.station,
  70. time: o.time,
  71. type: o.type,
  72. windturbine: o.windturbine,
  73. name: o.path.substring(
  74. o.path.indexOf(o.station + "_") + (o.station + "_").length
  75. ),
  76. };
  77. });
  78. } else {
  79. excelList.value = [];
  80. }
  81. };
  82. /**table 开始 */
  83. const tableShowId = ref("");
  84. const tableName = ref("");
  85. const tableColumn = ref([]);
  86. const tableLoading = ref(false);
  87. const tableData = ref([]);
  88. /**tab */
  89. const activeTab = ref("1");
  90. /**chart Data */
  91. const xAxisData = ref([]);
  92. const chartRef = ref(); //chart 的ref
  93. const seriesData = ref([]);
  94. const dataSet = ref("");
  95. const funChartSelect = async (batch) => {
  96. return false;
  97. };
  98. /**submit */
  99. const funSubmit = async (params) => {
  100. activeTab.value = "2";
  101. tableShowId.value = "";
  102. tableName.value = "AGC曲线分析";
  103. tableLoading.value = true;
  104. const res = await getWindAgcDeviate(params);
  105. tableColumn.value = [
  106. {
  107. prop: "ts",
  108. label: "时间",
  109. width: 100,
  110. },
  111. {
  112. prop: "ygsdxz",
  113. label: "有功设定限值",
  114. width: 80,
  115. },
  116. {
  117. prop: "sfyg",
  118. label: "实发有功",
  119. width: 80,
  120. },
  121. {
  122. prop: "llgl",
  123. label: "理论功率",
  124. width: 80,
  125. },
  126. {
  127. prop: "pcsx",
  128. label: "偏差上限",
  129. width: 80,
  130. },
  131. {
  132. prop: "pcxx",
  133. label: "偏差下限",
  134. width: 100,
  135. },
  136. ];
  137. const tableArr = [];
  138. const tsArr = [];
  139. const ygsdxz = [];
  140. const sfyg = [];
  141. const llgl = [];
  142. const pcsx = [];
  143. const pcxx = [];
  144. res["有功设定限值"].values.map((o, index) => {
  145. tsArr.push(dayjs(o.ts).format("YYYY-MM-DD HH:mm:ss"));
  146. ygsdxz.push(Number(o.value).toFixed(2));
  147. sfyg.push(Number(res["实发有功"].values[index].value).toFixed(2));
  148. llgl.push(Number(res["理论功率"].values[index].value).toFixed(2));
  149. pcsx.push(Number(res["偏差上限"].values[index].value).toFixed(2));
  150. pcxx.push(Number(res["偏差下限"].values[index].value).toFixed(2));
  151. tableArr.push({
  152. ts: dayjs(o.ts).format("YYYY-MM-DD HH:mm:ss"),
  153. ygsdxz: Number(o.value).toFixed(2),
  154. sfyg: Number(res["实发有功"].values[index].value).toFixed(2),
  155. llgl: Number(res["理论功率"].values[index].value).toFixed(2),
  156. pcsx: Number(res["偏差上限"].values[index].value).toFixed(2),
  157. pcxx: Number(res["偏差下限"].values[index].value).toFixed(2),
  158. });
  159. });
  160. xAxisData.value = tableArr.map((o) => o.ts);
  161. seriesData.value = [
  162. {
  163. name: "有功设定限值",
  164. type: "line",
  165. symbol: "line", //设定为实心点
  166. symbolSize: 0, //设定实心点的大小
  167. smooth: false, //这个是把线变成曲线
  168. data: ygsdxz,
  169. xAxisIndex: 0,
  170. },
  171. {
  172. name: "实发有功",
  173. type: "line",
  174. symbol: "line", //设定为实心点
  175. symbolSize: 0, //设定实心点的大小
  176. smooth: false, //这个是把线变成曲线
  177. data: sfyg,
  178. xAxisIndex: 0,
  179. },
  180. {
  181. name: "理论功率",
  182. type: "line",
  183. symbol: "line", //设定为实心点
  184. symbolSize: 0, //设定实心点的大小
  185. smooth: false, //这个是把线变成曲线
  186. data: llgl,
  187. xAxisIndex: 0,
  188. },
  189. {
  190. name: "偏差上限",
  191. type: "line",
  192. symbol: "line", //设定为实心点
  193. symbolSize: 0, //设定实心点的大小
  194. smooth: false, //这个是把线变成曲线
  195. data: pcsx,
  196. xAxisIndex: 0,
  197. lineStyle: {
  198. opacity: 0,
  199. },
  200. areaStyle: {
  201. color: "#ccc",
  202. },
  203. symbol: "none",
  204. },
  205. {
  206. name: "偏差下限",
  207. type: "line",
  208. symbol: "line", //设定为实心点
  209. symbolSize: 0, //设定实心点的大小
  210. smooth: false, //这个是把线变成曲线
  211. data: pcxx,
  212. xAxisIndex: 0,
  213. lineStyle: {
  214. opacity: 0,
  215. },
  216. areaStyle: {
  217. color: "#fff",
  218. opacity: 1,
  219. },
  220. symbol: "none",
  221. },
  222. ];
  223. tableData.value = tableArr;
  224. tableLoading.value = false;
  225. tableShowId.value = "1";
  226. // if (res.code === 200) {
  227. // if(res.data.sjgl?.length){
  228. // for(const wtObj of res.data.sjgl){
  229. // seriesData.value.push(
  230. // {
  231. // name: wtObj.obj.windturbine + "\n实际功率",
  232. // type: "line",
  233. // symbol: "line", //设定为实心点
  234. // symbolSize: 0, //设定实心点的大小
  235. // smooth: true, //这个是把线变成曲线
  236. // data: wtObj.sjgl || [],
  237. // xAxisIndex: 0,
  238. // },
  239. // )
  240. // wtData.value.push(wtObj.obj)
  241. // }
  242. // }
  243. // }
  244. };
  245. /**created */
  246. funGetTree();
  247. /**mounted */
  248. /**activated */
  249. onActivated(() => {
  250. // funGetTree()
  251. // funSubmit()
  252. });
  253. </script>
  254. <template>
  255. <div class="container-wrapper">
  256. <search-cop @submit="funSubmit"> </search-cop>
  257. <div class="power-data-wrapper card-shadow wrapper">
  258. <div class="card-title">数据展示</div>
  259. <div class="data-wrapper">
  260. <div class="data-table-wrapper card-shadow">
  261. <el-tabs v-model="activeTab" class="data-table-tabs">
  262. <el-tab-pane label="表格数据" name="1"> </el-tab-pane>
  263. <el-tab-pane label="图表展示" name="2"> </el-tab-pane>
  264. <table-cop
  265. v-show="activeTab === '1'"
  266. :data="tableData"
  267. :loading="tableLoading"
  268. :column="tableColumn"
  269. :showShadow="false"
  270. :tableId="tableShowId"
  271. :tableName="tableName"
  272. ></table-cop>
  273. <div v-show="activeTab === '2'" class="data-chart-wrapper">
  274. <CurrentScatterChart
  275. ref="chartRef"
  276. width="100%"
  277. height="100%"
  278. :chartTitle="''"
  279. :xAxisData="xAxisData"
  280. :yAxisData="{ splitLine: { show: false } }"
  281. :seriesData="seriesData"
  282. :showLegend="true"
  283. :brushSelected="false"
  284. :dataSet="dataSet"
  285. @getSelected="funChartSelect"
  286. />
  287. </div>
  288. </el-tabs>
  289. </div>
  290. </div>
  291. </div>
  292. </div>
  293. </template>
  294. <style lang="less" scoped>
  295. .container-wrapper .power-data-wrapper .data-wrapper .data-table-wrapper {
  296. width: 100%;
  297. }
  298. .el-tabs ::v-deep {
  299. height: 100%;
  300. .el-tabs__item {
  301. color: #b3b3b3;
  302. padding: 0 12px;
  303. }
  304. .el-tabs__nav-wrap::after {
  305. background-color: #14221f;
  306. }
  307. .el-tabs__active-bar {
  308. background-color: #05bb4c;
  309. }
  310. .el-tabs__item.is-active,
  311. .el-tabs__item:hover {
  312. color: #05bb4c;
  313. }
  314. .el-tabs__content {
  315. height: calc(100% - 45px);
  316. .table-wrapper {
  317. width: 100%;
  318. }
  319. .data-chart-wrapper {
  320. width: 100%;
  321. height: 100%;
  322. }
  323. }
  324. }
  325. </style>