index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-10 09:09:17
  4. * @LastEditTime: 2025-02-12 17:19:11
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/speed_power/index.vue
  8. -->
  9. <!-- -->
  10. <template>
  11. <div class="type-variable">
  12. <!-- 发电机转速和有功功率分析 -->
  13. <div class="left">
  14. <FilterChart
  15. :windList="windEngineGroupList"
  16. @getEnfineList="getEnfineList"
  17. @handlePrevious="handlePrevious"
  18. @handleNext="handleNext"
  19. ></FilterChart>
  20. <el-alert type="info" :closable="false">
  21. <template v-slot:title>
  22. <div style="display: flex; align-items: center">
  23. <i
  24. class="el-icon-info"
  25. style="font-size: 20px; margin-right: 5px"
  26. ></i>
  27. <h3>分析说明:</h3>
  28. </div>
  29. </template>
  30. <div style="font-size: 12px; margin-top: 10px">
  31. 在风力发电机组中,转速-功率散点图展示了风机发电机转速与风机产生的功率之间的关系。这种散点图能够揭示在不同转速速和操作条件下,发电机转速调整是如何影响风机的功率和转矩输出的。
  32. </div>
  33. </el-alert>
  34. <div class="titleCharts">分析总图 :</div>
  35. <VirtualList
  36. :list="generalFilesDatas"
  37. keyField="batchCode"
  38. :itemSize="600"
  39. v-slot="{ item, index }"
  40. >
  41. <DDrawingChart
  42. :key="item.batchCode + index"
  43. :index="index + 'zong'"
  44. :ref="item.batchCode + index"
  45. :fileAddr="item.fileAddr"
  46. >
  47. </DDrawingChart>
  48. </VirtualList>
  49. <div class="titleCharts">分析分图 :</div>
  50. <VirtualList
  51. :list="diagramRelationsDatas"
  52. keyField="fieldEngineCode"
  53. :itemSize="600"
  54. v-slot="{ item, index }"
  55. >
  56. <TwoDMarkersChart
  57. v-if="getFileTypeFromUrl(item.fileAddr) === 'speed_power'"
  58. :index="index + 'TwoDMarkersChart'"
  59. :key="item.fieldEngineCode + 'TwoDMarkersChart'"
  60. :ref="item.fieldEngineCode"
  61. :fileAddr="item.fileAddr"
  62. >
  63. </TwoDMarkersChart>
  64. <Time3DChart
  65. v-if="getFileTypeFromUrl(item.fileAddr) === '3D'"
  66. :key="item.fieldEngineCode + 'Time3DChart'"
  67. :index="index + 'fen'"
  68. :ref="item.fieldEngineCode + 'Time3DChart'"
  69. :fileAddr="item.fileAddr"
  70. >
  71. </Time3DChart>
  72. </VirtualList>
  73. <el-dialog
  74. v-if="isShowDescription"
  75. title="添加评论"
  76. :visible="isShow"
  77. width="30%"
  78. v-dialogDrag
  79. :modal="false"
  80. :lock-scroll="false"
  81. :modal-append-to-body="false"
  82. @close="handleClose"
  83. >
  84. <el-tabs value="first">
  85. <el-tab-pane label="意见描述" name="first">
  86. <TinymceEditor
  87. ref="editor"
  88. v-model="comment"
  89. @input="handleEditorInput($event)"
  90. @onClick="onClick"
  91. >
  92. </TinymceEditor>
  93. </el-tab-pane>
  94. </el-tabs>
  95. <el-row
  96. type="flex"
  97. class="row-bg"
  98. justify="end"
  99. style="margin: 20px 60px 0 0"
  100. >
  101. <el-col :span="2">
  102. <el-button type="primary" size="small" @click="handleComment"
  103. >提交评论</el-button
  104. >
  105. </el-col>
  106. </el-row>
  107. </el-dialog>
  108. </div>
  109. <div class="right" v-if="isShowTinymceEditorCom">
  110. <DicCard
  111. :batchCode="initBatchCode"
  112. :analysisTypeCode="analysisTypeCode"
  113. :commentDescriptionVos="commentDescriptionVos"
  114. >
  115. </DicCard>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. import DicCard from "@/views/overview/components/dicCard/index.vue";
  121. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  122. import DDrawingChart from "@/views/performance/components/chartsCom/3DDrawingChart.vue";
  123. import TinymceEditor from "@/components/Tinymce.vue";
  124. import Time3DChart from "@/views/performance/components/chartsCom/Time3DChart.vue";
  125. import {
  126. analysisDetail,
  127. queryAnalysisedEngine,
  128. analysisCommentEdit,
  129. } from "@/api/performance";
  130. import TwoDMarkersChart from "@/views/performance/components/chartsCom/TwoDMarkersChart.vue";
  131. export default {
  132. name: "speedPower",
  133. components: {
  134. DicCard,
  135. FilterChart,
  136. DDrawingChart,
  137. TinymceEditor,
  138. Time3DChart,
  139. TwoDMarkersChart,
  140. },
  141. props: {
  142. initBatchCode: {
  143. default: "",
  144. type: String,
  145. },
  146. isShowTinymceEditorCom: {
  147. default: true,
  148. type: Boolean,
  149. },
  150. isShow: {
  151. default: false,
  152. type: Boolean,
  153. },
  154. analysisTypeCode: {
  155. default: "",
  156. type: String,
  157. },
  158. batchCodeList: {
  159. default: "",
  160. type: Array,
  161. },
  162. },
  163. data() {
  164. return {
  165. form: {
  166. value2: "",
  167. },
  168. windEngineGroupList: [], //批次风机列表
  169. fieldEngineCodes: [], //选中风机
  170. comment: "",
  171. options: [],
  172. generalFilesDatas: [], //总图
  173. diagramRelationsDatas: [], //分图,
  174. requestResult: [], // 请求结果
  175. requestRecord: [],
  176. commentDescriptionVos: [], //评论列表
  177. editableTabs: [],
  178. isShowDescription: false,
  179. };
  180. },
  181. watch: {
  182. initBatchCode(newVal) {
  183. if (newVal) {
  184. this.fetchData(); // 调用合并后的函数
  185. }
  186. },
  187. analysisTypeCode(newVal) {
  188. if (newVal) {
  189. this.fetchData(); // 调用合并后的函数
  190. }
  191. },
  192. isShow() {
  193. if (this.isShow) {
  194. if (!this.isShowDescription) {
  195. this.$message({
  196. message: "当前分析类型暂无分析,不能进行评论操作",
  197. type: "warning",
  198. });
  199. this.$emit("setIsShow");
  200. }
  201. }
  202. },
  203. },
  204. mounted() {
  205. if (this.initBatchCode && this.analysisTypeCode) {
  206. this.fetchData(); // 调用合并后的函数
  207. }
  208. },
  209. methods: {
  210. handleClose() {
  211. //关闭评论弹框
  212. this.$emit("setIsShow");
  213. },
  214. async handleComment() {
  215. try {
  216. await analysisCommentEdit({
  217. batchCode: this.initBatchCode,
  218. analysisTypeCode: this.analysisTypeCode,
  219. commentList: this.editableTabs.map((item) => {
  220. return {
  221. commentTypeCode: item.commentTypeCode,
  222. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  223. };
  224. }),
  225. });
  226. this.$message({
  227. type: "success",
  228. message: "保存成功",
  229. });
  230. this.comment = "";
  231. this.getAnalysisDetail();
  232. this.$emit("setIsShow");
  233. } catch (e) {
  234. console.error(e);
  235. this.loading = false;
  236. }
  237. },
  238. getResult({ index, result }) {
  239. console.log(index, result);
  240. this.$set(this.requestResult, index, result);
  241. // this.requestResult[index] = result
  242. this.requestRecord[index] = result;
  243. },
  244. changeRequestNum(index) {
  245. if (index <= 1) {
  246. this.$set(this.requestRecord, index, "start");
  247. return;
  248. }
  249. if (index > 1) {
  250. if (
  251. this.requestRecord.every((item) =>
  252. ["success", "error"].includes(item)
  253. )
  254. ) {
  255. this.$set(this.requestRecord, index, "start");
  256. this.$set(this.requestResult, index, "start");
  257. } else {
  258. this.$set(this.requestRecord, index, "start");
  259. }
  260. }
  261. },
  262. onSubmit() {
  263. console.log("submit!");
  264. },
  265. // 合并后的函数,处理数据请求
  266. async fetchData() {
  267. try {
  268. console.log(
  269. this.initBatchCode,
  270. this.analysisTypeCode,
  271. "请求详情 分钟级"
  272. );
  273. // 获取分析详情
  274. await this.getAnalysisDetail();
  275. // 获取风机列表
  276. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  277. } catch (err) {
  278. console.error("Failed to fetch data:", err);
  279. }
  280. },
  281. // 获取分析详情接口
  282. async getAnalysisDetail() {
  283. try {
  284. const result = await analysisDetail({
  285. batchCode: this.initBatchCode,
  286. analysisTypeCode: this.analysisTypeCode,
  287. fieldEngineCodes:
  288. this.fieldEngineCodes.length === 0
  289. ? undefined
  290. : this.fieldEngineCodes.join(","),
  291. });
  292. if (result.data.length > 0) {
  293. this.isShowDescription = true;
  294. }
  295. if (
  296. result.data &&
  297. result.data[0] &&
  298. result.data[0].commentTypeRelations
  299. ) {
  300. this.editableTabs = result.data[0].commentTypeRelations;
  301. }
  302. //当前评论展示获取
  303. if (
  304. result.data &&
  305. result.data[0] &&
  306. result.data[0].commentDescriptionVos
  307. ) {
  308. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  309. }
  310. this.generalFilesDatas =
  311. (result.data &&
  312. result.data[0] &&
  313. result.data[0].generalFiles &&
  314. result.data[0].generalFiles.filter((item) =>
  315. item.fileAddr.endsWith(".json")
  316. )) ||
  317. []; //总图数据
  318. console.log(this.generalFilesDatas, "总图数据");
  319. if (result.data && result.data[0] && result.data[0].diagramRelations) {
  320. // const diagramRelationsDatas = result.data[0].diagramRelations.filter(
  321. // (item) => item.fileAddr.endsWith(".json")
  322. // );
  323. // this.diagramRelationsDatas2D = diagramRelationsDatas.filter(
  324. // (item) => this.getFileTypeFromUrl(item.fileAddr) === "speed_power"
  325. // );
  326. // this.diagramRelationsDatas3D = diagramRelationsDatas.filter(
  327. // (item) => this.getFileTypeFromUrl(item.fileAddr) === "3D"
  328. // );
  329. }
  330. this.diagramRelationsDatas =
  331. (result.data &&
  332. result.data[0] &&
  333. result.data[0].diagramRelations &&
  334. result.data[0].diagramRelations.filter((item) =>
  335. item.fileAddr.endsWith(".json")
  336. )) ||
  337. [];
  338. } catch (err) {
  339. console.error("Failed to fetch analysis details:", err);
  340. }
  341. },
  342. getFileTypeFromUrl(url) {
  343. // 判断文件名或路径是否包含关键字
  344. if (url.includes("3D")) {
  345. return "3D"; // 如果 URL 中包含 "3D" 字符串,判断为 3D 类型
  346. } else if (url.includes("speed_power")) {
  347. return "speed_power"; // 如果 URL 中包含 "speed_power" 字符串,判断为 speed_power 类型
  348. } else {
  349. return "Unknown"; // 如果都不包含,返回 Unknown 或其他提示
  350. }
  351. },
  352. // 请求风机列表
  353. async getWindEnfineList(batchCode, analysisTypeCode) {
  354. // console.log("请求风机列表 分钟级");
  355. const resEngineList = await queryAnalysisedEngine({
  356. batchCode: batchCode,
  357. analysisTypeCode,
  358. });
  359. this.windEngineGroupList = resEngineList.data;
  360. },
  361. handleEditorInput(index, newVal) {
  362. // 更新对应的 comment 值
  363. // 如果该功能没有实现,可以删除这个方法
  364. },
  365. //获取选中风机list
  366. getEnfineList(data) {
  367. this.fieldEngineCodes = data;
  368. this.getAnalysisDetail();
  369. },
  370. //下一条
  371. handleNext() {
  372. const index = this.batchCodeList.findIndex(
  373. (item) => item === this.initBatchCode
  374. );
  375. if (index === this.batchCodeList.length - 1) {
  376. this.$message.warning("已经是最后一个分析结果了");
  377. return;
  378. }
  379. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  380. },
  381. //上一条
  382. handlePrevious() {
  383. const index = this.batchCodeList.findIndex(
  384. (item) => item === this.initBatchCode
  385. );
  386. if (index === 0) {
  387. this.$message.warning("没有上一条了");
  388. return;
  389. }
  390. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  391. },
  392. onClick() {},
  393. },
  394. };
  395. </script>
  396. <style scoped lang="scss">
  397. .type-variable {
  398. display: flex;
  399. height: 90%;
  400. overflow: hidden;
  401. .left {
  402. width: 30%;
  403. height: 100%;
  404. overflow: auto;
  405. padding: 20px;
  406. flex: 1;
  407. /* 滚动条整体样式 */
  408. &::-webkit-scrollbar {
  409. width: 6px; /* 滚动条宽度 */
  410. }
  411. /* 滚动条轨道 */
  412. &::-webkit-scrollbar-track {
  413. background: #f5f7fa;
  414. border-radius: 3px;
  415. }
  416. /* 滚动条滑块 */
  417. &::-webkit-scrollbar-thumb {
  418. background: #c0c4cc;
  419. border-radius: 3px;
  420. }
  421. /* 滚动条滑块悬停时 */
  422. &::-webkit-scrollbar-thumb:hover {
  423. background: #909399;
  424. }
  425. }
  426. .right {
  427. width: 250px;
  428. height: 100%;
  429. overflow: hidden;
  430. }
  431. }
  432. .el-dialog__wrapper {
  433. position: relative !important;
  434. }
  435. ::v-deep .el-dialog {
  436. position: fixed !important;
  437. z-index: 999 !important;
  438. top: 50%;
  439. left: 50%;
  440. transform: translate(0, -50%);
  441. }
  442. .titleCharts {
  443. font-size: 16px;
  444. font-weight: 500;
  445. margin-top: 20px;
  446. }
  447. </style>