index.vue 13 KB

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