index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:10:22
  4. * @LastEditTime: 2025-01-21 14:56:56
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/power_scatter/index.vue
  8. -->
  9. <template>
  10. <div class="type-variable">
  11. <!-- 逐月有功功率散点3D分析--只有分图不存在总图 -->
  12. <div class="left">
  13. <FilterChart
  14. :windList="windEngineGroupList"
  15. @getEnfineList="getEnfineList"
  16. @handlePrevious="handlePrevious"
  17. @handleNext="handleNext"
  18. ></FilterChart>
  19. <el-alert type="info" :closable="false">
  20. <template v-slot:title>
  21. <div style="display: flex; align-items: center">
  22. <i
  23. class="el-icon-info"
  24. style="font-size: 20px; margin-right: 5px"
  25. ></i>
  26. <h3>分析说明:</h3>
  27. </div>
  28. </template>
  29. <div style="font-size: 12px; margin-top: 10px">
  30. 在风力发电机组中,功率曲线散点图是一种展示在不同风速下风机产生的功率的工具。这种图表通常以风速为横坐标,以发电机的功率输出为纵坐标。在理想情况下,这些散点应当形成一条清晰的曲线,反映出风速与发电机功率之间的关系。功率曲线是风力发电机性能的关键指标,可以用来评估风机在不同风速条件下的表现。
  31. </div>
  32. </el-alert>
  33. <div class="titleCharts">分析分图 :</div>
  34. <VirtualList
  35. :list="diagramRelationsDatas"
  36. keyField="fieldEngineCode"
  37. :itemSize="452"
  38. v-slot="{ item, index }"
  39. >
  40. <DDrawingChart
  41. :key="item.fieldEngineCode"
  42. :index="index + 'fen'"
  43. :ref="item.fieldEngineCode"
  44. :fileAddr="item.fileAddr"
  45. >
  46. </DDrawingChart>
  47. </VirtualList>
  48. <el-tabs value="first">
  49. <el-tab-pane label="意见描述" name="first">
  50. <TinymceEditor
  51. ref="editor"
  52. v-model="comment"
  53. @input="handleEditorInput($event)"
  54. @onClick="onClick"
  55. >
  56. </TinymceEditor>
  57. </el-tab-pane>
  58. </el-tabs>
  59. <el-row type="flex" class="row-bg" justify="end">
  60. <el-col :span="2" style="margin: 20px">
  61. <el-button type="primary" size="small" @click="handleComment"
  62. >提交评论</el-button
  63. >
  64. </el-col>
  65. </el-row>
  66. </div>
  67. <div class="right">
  68. <DicCard
  69. :batchCode="initBatchCode"
  70. :analysisTypeCode="analysisTypeCode"
  71. :commentDescriptionVos="commentDescriptionVos"
  72. >
  73. </DicCard>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import DicCard from "@/views/overview/components/dicCard/index.vue";
  79. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  80. import DDrawingChart from "@/views/performance/components/chartsCom/3DDrawingChart.vue";
  81. import TinymceEditor from "@/components/Tinymce.vue";
  82. import {
  83. analysisDetail,
  84. queryAnalysisedEngine,
  85. analysisCommentEdit,
  86. } from "@/api/performance";
  87. export default {
  88. name: "powerScatter",
  89. components: {
  90. DicCard,
  91. FilterChart,
  92. DDrawingChart,
  93. TinymceEditor,
  94. },
  95. props: {
  96. initBatchCode: {
  97. default: "",
  98. type: String,
  99. },
  100. analysisTypeCode: {
  101. default: "",
  102. type: String,
  103. },
  104. batchCodeList: {
  105. default: "",
  106. type: Array,
  107. },
  108. },
  109. data() {
  110. return {
  111. form: {
  112. value2: "",
  113. },
  114. windEngineGroupList: [], //批次风机列表
  115. fieldEngineCodes: [], //选中风机
  116. comment: "",
  117. options: [],
  118. generalFilesDatas: [], //总图
  119. diagramRelationsDatas: [], //分图,
  120. requestResult: [], // 请求结果
  121. requestRecord: [],
  122. commentDescriptionVos: [], //评论列表
  123. editableTabs: [],
  124. };
  125. },
  126. watch: {
  127. initBatchCode(newVal) {
  128. if (newVal) {
  129. this.fetchData(); // 调用合并后的函数
  130. }
  131. },
  132. analysisTypeCode(newVal) {
  133. if (newVal) {
  134. this.fetchData(); // 调用合并后的函数
  135. }
  136. },
  137. },
  138. mounted() {
  139. if (this.initBatchCode && this.analysisTypeCode) {
  140. this.fetchData(); // 调用合并后的函数
  141. }
  142. },
  143. methods: {
  144. async handleComment() {
  145. try {
  146. await analysisCommentEdit({
  147. batchCode: this.initBatchCode,
  148. analysisTypeCode: this.analysisTypeCode,
  149. commentList: this.editableTabs.map((item) => {
  150. return {
  151. commentTypeCode: item.commentTypeCode,
  152. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  153. };
  154. }),
  155. });
  156. this.$message({
  157. type: "success",
  158. message: "保存成功",
  159. });
  160. this.comment = "";
  161. this.getAnalysisDetail();
  162. } catch (e) {
  163. console.error(e);
  164. this.loading = false;
  165. }
  166. },
  167. getResult({ index, result }) {
  168. console.log(index, result);
  169. this.$set(this.requestResult, index, result);
  170. // this.requestResult[index] = result
  171. this.requestRecord[index] = result;
  172. },
  173. changeRequestNum(index) {
  174. if (index <= 1) {
  175. this.$set(this.requestRecord, index, "start");
  176. return;
  177. }
  178. if (index > 1) {
  179. if (
  180. this.requestRecord.every((item) =>
  181. ["success", "error"].includes(item)
  182. )
  183. ) {
  184. this.$set(this.requestRecord, index, "start");
  185. this.$set(this.requestResult, index, "start");
  186. } else {
  187. this.$set(this.requestRecord, index, "start");
  188. }
  189. }
  190. },
  191. onSubmit() {
  192. console.log("submit!");
  193. },
  194. // 合并后的函数,处理数据请求
  195. async fetchData() {
  196. try {
  197. console.log(
  198. this.initBatchCode,
  199. this.analysisTypeCode,
  200. "请求详情 分钟级"
  201. );
  202. // 获取分析详情
  203. await this.getAnalysisDetail();
  204. // 获取风机列表
  205. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  206. } catch (err) {
  207. console.error("Failed to fetch data:", err);
  208. }
  209. },
  210. // 获取分析详情接口
  211. async getAnalysisDetail() {
  212. try {
  213. const result = await analysisDetail({
  214. batchCode: this.initBatchCode,
  215. analysisTypeCode: this.analysisTypeCode,
  216. fieldEngineCodes:
  217. this.fieldEngineCodes.length === 0
  218. ? undefined
  219. : this.fieldEngineCodes.join(","),
  220. });
  221. if (
  222. result.data &&
  223. result.data[0] &&
  224. result.data[0].commentTypeRelations
  225. ) {
  226. this.editableTabs = result.data[0].commentTypeRelations;
  227. }
  228. //当前评论展示获取
  229. if (
  230. result.data &&
  231. result.data[0] &&
  232. result.data[0].commentDescriptionVos
  233. ) {
  234. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  235. }
  236. this.generalFilesDatas =
  237. (result.data &&
  238. result.data[0] &&
  239. result.data[0].generalFiles &&
  240. result.data[0].generalFiles.filter((item) =>
  241. item.fileAddr.endsWith(".json")
  242. )) ||
  243. []; //总图数据
  244. this.diagramRelationsDatas =
  245. (result.data &&
  246. result.data[0] &&
  247. result.data[0].diagramRelations.filter((item) =>
  248. item.fileAddr.endsWith(".json")
  249. )) ||
  250. [];
  251. } catch (err) {
  252. console.error("Failed to fetch analysis details:", err);
  253. }
  254. },
  255. // 请求风机列表
  256. async getWindEnfineList(batchCode, analysisTypeCode) {
  257. // console.log("请求风机列表 分钟级");
  258. const resEngineList = await queryAnalysisedEngine({
  259. batchCode: batchCode,
  260. analysisTypeCode,
  261. });
  262. this.windEngineGroupList = resEngineList.data;
  263. },
  264. handleEditorInput(index, newVal) {
  265. // 更新对应的 comment 值
  266. // 如果该功能没有实现,可以删除这个方法
  267. },
  268. //获取选中风机list
  269. getEnfineList(data) {
  270. this.fieldEngineCodes = data;
  271. this.getAnalysisDetail();
  272. },
  273. //下一条
  274. handleNext() {
  275. const index = this.batchCodeList.findIndex(
  276. (item) => item === this.initBatchCode
  277. );
  278. if (index === this.batchCodeList.length - 1) {
  279. this.$message.warning("已经是最后一个分析结果了");
  280. return;
  281. }
  282. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  283. },
  284. //上一条
  285. handlePrevious() {
  286. const index = this.batchCodeList.findIndex(
  287. (item) => item === this.initBatchCode
  288. );
  289. if (index === 0) {
  290. this.$message.warning("没有上一条了");
  291. return;
  292. }
  293. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  294. },
  295. onClick() {},
  296. },
  297. };
  298. </script>
  299. <style scoped lang="scss">
  300. .type-variable {
  301. display: flex;
  302. height: 90%;
  303. overflow: hidden;
  304. .left {
  305. width: 30%;
  306. height: 100%;
  307. overflow: auto;
  308. padding: 20px;
  309. flex: 1;
  310. /* 滚动条整体样式 */
  311. &::-webkit-scrollbar {
  312. width: 6px; /* 滚动条宽度 */
  313. }
  314. /* 滚动条轨道 */
  315. &::-webkit-scrollbar-track {
  316. background: #f5f7fa;
  317. border-radius: 3px;
  318. }
  319. /* 滚动条滑块 */
  320. &::-webkit-scrollbar-thumb {
  321. background: #c0c4cc;
  322. border-radius: 3px;
  323. }
  324. /* 滚动条滑块悬停时 */
  325. &::-webkit-scrollbar-thumb:hover {
  326. background: #909399;
  327. }
  328. }
  329. .right {
  330. width: 250px;
  331. height: 100%;
  332. overflow: hidden;
  333. }
  334. }
  335. .titleCharts {
  336. font-size: 16px;
  337. font-weight: 500;
  338. margin-top: 20px;
  339. }
  340. </style>