index.vue 13 KB

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