index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:06:09
  4. * @LastEditTime: 2025-02-10 13:58:32
  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-dialog
  50. v-if="isShowDescription"
  51. title="添加评论"
  52. :visible="isShow"
  53. width="30%"
  54. v-dialogDrag
  55. :modal="false"
  56. :lock-scroll="false"
  57. :modal-append-to-body="false"
  58. @close="handleClose"
  59. >
  60. <el-tabs value="first">
  61. <el-tab-pane label="意见描述" name="first">
  62. <TinymceEditor
  63. ref="editor"
  64. v-model="comment"
  65. @input="handleEditorInput($event)"
  66. @onClick="onClick"
  67. >
  68. </TinymceEditor>
  69. </el-tab-pane>
  70. </el-tabs>
  71. <el-row
  72. type="flex"
  73. class="row-bg"
  74. justify="end"
  75. style="margin: 20px 60px 0 0"
  76. >
  77. <el-col :span="2">
  78. <el-button type="primary" size="small" @click="handleComment"
  79. >提交评论</el-button
  80. >
  81. </el-col>
  82. </el-row>
  83. </el-dialog>
  84. </div>
  85. <div class="right">
  86. <DicCard
  87. :batchCode="initBatchCode"
  88. :analysisTypeCode="analysisTypeCode"
  89. :commentDescriptionVos="commentDescriptionVos"
  90. >
  91. </DicCard>
  92. </div>
  93. </div>
  94. </template>
  95. <script>
  96. import DicCard from "@/views/overview/components/dicCard/index.vue";
  97. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  98. import BoxLineCharts from "@/views/performance/components/chartsCom/BoxLineCharts.vue";
  99. import TinymceEditor from "@/components/Tinymce.vue";
  100. import {
  101. analysisDetail,
  102. queryAnalysisedEngine,
  103. analysisCommentEdit,
  104. } from "@/api/performance";
  105. import axios from "axios";
  106. export default {
  107. name: "cpTrend",
  108. components: {
  109. DicCard,
  110. FilterChart,
  111. BoxLineCharts,
  112. TinymceEditor,
  113. },
  114. props: {
  115. initBatchCode: {
  116. default: "",
  117. type: String,
  118. },
  119. analysisTypeCode: {
  120. default: "",
  121. type: String,
  122. },
  123. batchCodeList: {
  124. default: "",
  125. type: Array,
  126. },
  127. isShow: {
  128. default: false,
  129. type: Boolean,
  130. },
  131. },
  132. data() {
  133. return {
  134. form: {
  135. value2: "",
  136. },
  137. isShowDescription: false,
  138. windEngineGroupList: [], //批次风机列表
  139. fieldEngineCodes: [], //选中风机
  140. comment: "",
  141. options: [],
  142. generalFilesDatas: [], //总图
  143. diagramRelationsDatas: [], //分图,
  144. commentDescriptionVos: [], //评论列表
  145. editableTabs: [],
  146. };
  147. },
  148. watch: {
  149. initBatchCode(newVal) {
  150. if (newVal) {
  151. this.fetchData(); // 调用合并后的函数
  152. }
  153. },
  154. analysisTypeCode(newVal) {
  155. if (newVal) {
  156. this.fetchData(); // 调用合并后的函数
  157. }
  158. },
  159. isShow() {
  160. if (this.isShow) {
  161. if (!this.isShowDescription) {
  162. this.$message({
  163. message: "当前分析类型暂无分析,不能进行评论操作",
  164. type: "warning",
  165. });
  166. this.$emit("setIsShow");
  167. }
  168. }
  169. },
  170. },
  171. mounted() {
  172. if (this.initBatchCode && this.analysisTypeCode) {
  173. this.fetchData(); // 调用合并后的函数
  174. }
  175. },
  176. methods: {
  177. handleClose() {
  178. console.log("handleClose", this.isShow);
  179. //关闭评论弹框
  180. this.$emit("setIsShow");
  181. },
  182. async handleComment() {
  183. try {
  184. await analysisCommentEdit({
  185. batchCode: this.initBatchCode,
  186. analysisTypeCode: this.analysisTypeCode,
  187. commentList: this.editableTabs.map((item) => {
  188. return {
  189. commentTypeCode: item.commentTypeCode,
  190. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  191. };
  192. }),
  193. });
  194. this.$message({
  195. type: "success",
  196. message: "保存成功",
  197. });
  198. this.comment = "";
  199. this.getAnalysisDetail();
  200. this.$emit("setIsShow");
  201. } catch (e) {
  202. console.error(e);
  203. this.loading = false;
  204. }
  205. },
  206. onSubmit() {
  207. console.log("submit!");
  208. },
  209. // 合并后的函数,处理数据请求
  210. async fetchData() {
  211. try {
  212. console.log(
  213. this.initBatchCode,
  214. this.analysisTypeCode,
  215. "请求详情 分钟级"
  216. );
  217. // 获取分析详情
  218. await this.getAnalysisDetail();
  219. // 获取风机列表
  220. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  221. } catch (err) {
  222. console.error("Failed to fetch data:", err);
  223. }
  224. },
  225. // 获取分析详情接口
  226. async getAnalysisDetail() {
  227. try {
  228. const result = await analysisDetail({
  229. batchCode: this.initBatchCode,
  230. analysisTypeCode: this.analysisTypeCode,
  231. fieldEngineCodes:
  232. this.fieldEngineCodes.length === 0
  233. ? undefined
  234. : this.fieldEngineCodes.join(","),
  235. });
  236. if (result.data.length > 0) {
  237. this.isShowDescription = true;
  238. }
  239. if (
  240. result.data &&
  241. result.data[0] &&
  242. result.data[0].commentTypeRelations
  243. ) {
  244. this.editableTabs = result.data[0].commentTypeRelations;
  245. }
  246. //当前评论展示获取
  247. if (
  248. result.data &&
  249. result.data[0] &&
  250. result.data[0].commentDescriptionVos
  251. ) {
  252. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  253. }
  254. this.generalFilesDatas =
  255. (result.data &&
  256. result.data[0] &&
  257. result.data[0].generalFiles &&
  258. result.data[0].generalFiles.filter((item) =>
  259. item.fileAddr.endsWith(".json")
  260. )) ||
  261. []; //总图数据
  262. this.diagramRelationsDatas =
  263. (result.data &&
  264. result.data[0] &&
  265. result.data[0].diagramRelations &&
  266. result.data[0].diagramRelations.filter((item) =>
  267. item.fileAddr.endsWith(".json")
  268. )) ||
  269. [];
  270. } catch (err) {
  271. console.error("Failed to fetch analysis details:", err);
  272. }
  273. },
  274. // 请求风机列表
  275. async getWindEnfineList(batchCode, analysisTypeCode) {
  276. // console.log("请求风机列表 分钟级");
  277. const resEngineList = await queryAnalysisedEngine({
  278. batchCode: batchCode,
  279. analysisTypeCode,
  280. });
  281. this.windEngineGroupList = resEngineList.data;
  282. },
  283. handleEditorInput(index, newVal) {
  284. // 更新对应的 comment 值
  285. // 如果该功能没有实现,可以删除这个方法
  286. },
  287. //获取选中风机list
  288. getEnfineList(data) {
  289. this.fieldEngineCodes = data;
  290. this.getAnalysisDetail();
  291. console.log(this.fieldEngineCodes, "this.fieldEngineCodes");
  292. },
  293. //下一条
  294. handleNext() {
  295. const index = this.batchCodeList.findIndex(
  296. (item) => item === this.initBatchCode
  297. );
  298. if (index === this.batchCodeList.length - 1) {
  299. this.$message.warning("已经是最后一个分析结果了");
  300. return;
  301. }
  302. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  303. },
  304. //上一条
  305. handlePrevious() {
  306. const index = this.batchCodeList.findIndex(
  307. (item) => item === this.initBatchCode
  308. );
  309. if (index === 0) {
  310. this.$message.warning("没有上一条了");
  311. return;
  312. }
  313. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  314. },
  315. onClick() {},
  316. },
  317. };
  318. </script>
  319. <style scoped lang="scss">
  320. .type-variable {
  321. display: flex;
  322. height: 90%;
  323. overflow: hidden;
  324. .left {
  325. width: 30%;
  326. height: 100%;
  327. overflow: auto;
  328. padding: 20px;
  329. flex: 1;
  330. &::-webkit-scrollbar {
  331. width: 6px; /* 滚动条宽度 */
  332. }
  333. /* 滚动条轨道 */
  334. &::-webkit-scrollbar-track {
  335. background: #f5f7fa;
  336. border-radius: 3px;
  337. }
  338. /* 滚动条滑块 */
  339. &::-webkit-scrollbar-thumb {
  340. background: #c0c4cc;
  341. border-radius: 3px;
  342. }
  343. /* 滚动条滑块悬停时 */
  344. &::-webkit-scrollbar-thumb:hover {
  345. background: #909399;
  346. }
  347. }
  348. .right {
  349. width: 250px;
  350. height: 100%;
  351. overflow: hidden;
  352. }
  353. }
  354. .el-dialog__wrapper {
  355. position: relative !important;
  356. }
  357. ::v-deep .el-dialog {
  358. position: fixed !important;
  359. z-index: 999 !important;
  360. top: 50%;
  361. left: 50%;
  362. transform: translate(0, -50%);
  363. }
  364. </style>