index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:06:09
  4. * @LastEditTime: 2025-01-21 14:55:00
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/cp_trend/index.vue
  8. -->
  9. <template>
  10. <div class="type-variable">
  11. <!-- 风能利用系数时序分析--只有分图不存在总图 -->
  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. 分析风力发电机组的Cp值对于优化其性能和增强效率至关重要:通过测量和分析Cp,可以直观了解风机的效率。Cp值越接近贝兹极限,说明风机的设计和运行越高效。
  31. </div>
  32. <div style="font-size: 12px; margin-top: 10px">
  33. Cp的分析也是监测风机性能的重要手段。如果Cp值出现异常下降,可能预示着机械故障、叶片磨损或其他维护需求。
  34. </div>
  35. </el-alert>
  36. <VirtualList
  37. :list="diagramRelationsDatas"
  38. keyField="fieldEngineCode"
  39. :itemSize="452"
  40. v-slot="{ item, index }"
  41. >
  42. <BoxLineCharts
  43. :key="item.fieldEngineCode + index"
  44. :index="index"
  45. :ref="item.fieldEngineCode"
  46. :fileAddr="item.fileAddr"
  47. ></BoxLineCharts>
  48. </VirtualList>
  49. <el-tabs value="first">
  50. <el-tab-pane label="意见描述" name="first">
  51. <TinymceEditor
  52. ref="editor"
  53. v-model="comment"
  54. @input="handleEditorInput($event)"
  55. @onClick="onClick"
  56. >
  57. </TinymceEditor>
  58. </el-tab-pane>
  59. </el-tabs>
  60. <el-row type="flex" class="row-bg" justify="end">
  61. <el-col :span="2" style="margin: 20px">
  62. <el-button type="primary" size="small" @click="handleComment"
  63. >提交评论</el-button
  64. >
  65. </el-col>
  66. </el-row>
  67. </div>
  68. <div class="right">
  69. <DicCard
  70. :batchCode="initBatchCode"
  71. :analysisTypeCode="analysisTypeCode"
  72. :commentDescriptionVos="commentDescriptionVos"
  73. >
  74. </DicCard>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import DicCard from "@/views/overview/components/dicCard/index.vue";
  80. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  81. import BoxLineCharts from "@/views/performance/components/chartsCom/BoxLineCharts.vue";
  82. import TinymceEditor from "@/components/Tinymce.vue";
  83. import {
  84. analysisDetail,
  85. queryAnalysisedEngine,
  86. analysisCommentEdit,
  87. } from "@/api/performance";
  88. import axios from "axios";
  89. export default {
  90. name: "cpTrend",
  91. components: {
  92. DicCard,
  93. FilterChart,
  94. BoxLineCharts,
  95. TinymceEditor,
  96. },
  97. props: {
  98. initBatchCode: {
  99. default: "",
  100. type: String,
  101. },
  102. analysisTypeCode: {
  103. default: "",
  104. type: String,
  105. },
  106. batchCodeList: {
  107. default: "",
  108. type: Array,
  109. },
  110. },
  111. data() {
  112. return {
  113. form: {
  114. value2: "",
  115. },
  116. windEngineGroupList: [], //批次风机列表
  117. fieldEngineCodes: [], //选中风机
  118. comment: "",
  119. options: [],
  120. generalFilesDatas: [], //总图
  121. diagramRelationsDatas: [], //分图,
  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. onSubmit() {
  168. console.log("submit!");
  169. },
  170. // 合并后的函数,处理数据请求
  171. async fetchData() {
  172. try {
  173. console.log(
  174. this.initBatchCode,
  175. this.analysisTypeCode,
  176. "请求详情 分钟级"
  177. );
  178. // 获取分析详情
  179. await this.getAnalysisDetail();
  180. // 获取风机列表
  181. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  182. } catch (err) {
  183. console.error("Failed to fetch data:", err);
  184. }
  185. },
  186. // 获取分析详情接口
  187. async getAnalysisDetail() {
  188. try {
  189. const result = await analysisDetail({
  190. batchCode: this.initBatchCode,
  191. analysisTypeCode: this.analysisTypeCode,
  192. fieldEngineCodes:
  193. this.fieldEngineCodes.length === 0
  194. ? undefined
  195. : this.fieldEngineCodes.join(","),
  196. });
  197. if (
  198. result.data &&
  199. result.data[0] &&
  200. result.data[0].commentTypeRelations
  201. ) {
  202. this.editableTabs = result.data[0].commentTypeRelations;
  203. }
  204. //当前评论展示获取
  205. if (
  206. result.data &&
  207. result.data[0] &&
  208. result.data[0].commentDescriptionVos
  209. ) {
  210. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  211. }
  212. this.generalFilesDatas =
  213. (result.data &&
  214. result.data[0] &&
  215. result.data[0].generalFiles &&
  216. result.data[0].generalFiles.filter((item) =>
  217. item.fileAddr.endsWith(".json")
  218. )) ||
  219. []; //总图数据
  220. this.diagramRelationsDatas =
  221. (result.data &&
  222. result.data[0] &&
  223. result.data[0].diagramRelations.filter((item) =>
  224. item.fileAddr.endsWith(".json")
  225. )) ||
  226. [];
  227. } catch (err) {
  228. console.error("Failed to fetch analysis details:", err);
  229. }
  230. },
  231. // 请求风机列表
  232. async getWindEnfineList(batchCode, analysisTypeCode) {
  233. // console.log("请求风机列表 分钟级");
  234. const resEngineList = await queryAnalysisedEngine({
  235. batchCode: batchCode,
  236. analysisTypeCode,
  237. });
  238. this.windEngineGroupList = resEngineList.data;
  239. },
  240. handleEditorInput(index, newVal) {
  241. // 更新对应的 comment 值
  242. // 如果该功能没有实现,可以删除这个方法
  243. },
  244. //获取选中风机list
  245. getEnfineList(data) {
  246. this.fieldEngineCodes = data;
  247. this.getAnalysisDetail();
  248. console.log(this.fieldEngineCodes, "this.fieldEngineCodes");
  249. },
  250. //下一条
  251. handleNext() {
  252. const index = this.batchCodeList.findIndex(
  253. (item) => item === this.initBatchCode
  254. );
  255. if (index === this.batchCodeList.length - 1) {
  256. this.$message.warning("已经是最后一个分析结果了");
  257. return;
  258. }
  259. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  260. },
  261. //上一条
  262. handlePrevious() {
  263. const index = this.batchCodeList.findIndex(
  264. (item) => item === this.initBatchCode
  265. );
  266. if (index === 0) {
  267. this.$message.warning("没有上一条了");
  268. return;
  269. }
  270. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  271. },
  272. onClick() {},
  273. },
  274. };
  275. </script>
  276. <style scoped lang="scss">
  277. .type-variable {
  278. display: flex;
  279. height: 90%;
  280. overflow: hidden;
  281. .left {
  282. width: 30%;
  283. height: 100%;
  284. overflow: auto;
  285. padding: 20px;
  286. flex: 1;
  287. &::-webkit-scrollbar {
  288. width: 6px; /* 滚动条宽度 */
  289. }
  290. /* 滚动条轨道 */
  291. &::-webkit-scrollbar-track {
  292. background: #f5f7fa;
  293. border-radius: 3px;
  294. }
  295. /* 滚动条滑块 */
  296. &::-webkit-scrollbar-thumb {
  297. background: #c0c4cc;
  298. border-radius: 3px;
  299. }
  300. /* 滚动条滑块悬停时 */
  301. &::-webkit-scrollbar-thumb:hover {
  302. background: #909399;
  303. }
  304. }
  305. .right {
  306. width: 250px;
  307. height: 100%;
  308. overflow: hidden;
  309. }
  310. }
  311. </style>