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. <!-- <div class="titleCharts">分析总图 :</div> -->
  26. <!-- <div v-for="(item, index) in generalFilesDatas">
  27. <DDrawingChart
  28. :key="item.batchCode + index"
  29. :index="index + 'zong'"
  30. :ref="item.batchCode + index"
  31. :fileAddr="item.fileAddr"
  32. >
  33. </DDrawingChart>
  34. </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_torque'"
  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">
  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 Time3DChart from "@/views/performance/components/chartsCom/Time3DChart.vue";
  124. import TinymceEditor from "@/components/Tinymce.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: "speedTorque",
  133. components: {
  134. DicCard,
  135. FilterChart,
  136. DDrawingChart,
  137. Time3DChart,
  138. TinymceEditor,
  139. TwoDMarkersChart,
  140. },
  141. props: {
  142. initBatchCode: {
  143. default: "",
  144. type: String,
  145. },
  146. isShow: {
  147. default: false,
  148. type: Boolean,
  149. },
  150. analysisTypeCode: {
  151. default: "",
  152. type: String,
  153. },
  154. batchCodeList: {
  155. default: "",
  156. type: Array,
  157. },
  158. },
  159. data() {
  160. return {
  161. form: {
  162. value2: "",
  163. },
  164. windEngineGroupList: [], //批次风机列表
  165. fieldEngineCodes: [], //选中风机
  166. comment: "",
  167. options: [],
  168. generalFilesDatas: [], //总图
  169. diagramRelationsDatas: [], //分图,
  170. requestResult: [], // 请求结果
  171. requestRecord: [],
  172. commentDescriptionVos: [], //评论列表
  173. editableTabs: [],
  174. isShowDescription: false,
  175. diagramRelationsDatas2D: [],
  176. diagramRelationsDatas3D: [],
  177. };
  178. },
  179. watch: {
  180. initBatchCode(newVal) {
  181. if (newVal) {
  182. this.fetchData(); // 调用合并后的函数
  183. }
  184. },
  185. analysisTypeCode(newVal) {
  186. if (newVal) {
  187. this.fetchData(); // 调用合并后的函数
  188. }
  189. },
  190. isShow() {
  191. if (this.isShow) {
  192. if (!this.isShowDescription) {
  193. this.$message({
  194. message: "当前分析类型暂无分析,不能进行评论操作",
  195. type: "warning",
  196. });
  197. this.$emit("setIsShow");
  198. }
  199. }
  200. },
  201. },
  202. mounted() {
  203. if (this.initBatchCode && this.analysisTypeCode) {
  204. this.fetchData(); // 调用合并后的函数
  205. }
  206. },
  207. methods: {
  208. handleClose() {
  209. //关闭评论弹框
  210. this.$emit("setIsShow");
  211. },
  212. async handleComment() {
  213. try {
  214. await analysisCommentEdit({
  215. batchCode: this.initBatchCode,
  216. analysisTypeCode: this.analysisTypeCode,
  217. commentList: this.editableTabs.map((item) => {
  218. return {
  219. commentTypeCode: item.commentTypeCode,
  220. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  221. };
  222. }),
  223. });
  224. this.$message({
  225. type: "success",
  226. message: "保存成功",
  227. });
  228. this.comment = "";
  229. this.getAnalysisDetail();
  230. this.$emit("setIsShow");
  231. } catch (e) {
  232. console.error(e);
  233. this.loading = false;
  234. }
  235. },
  236. getResult({ index, result }) {
  237. console.log(index, result);
  238. this.$set(this.requestResult, index, result);
  239. // this.requestResult[index] = result
  240. this.requestRecord[index] = result;
  241. },
  242. changeRequestNum(index) {
  243. if (index <= 1) {
  244. this.$set(this.requestRecord, index, "start");
  245. return;
  246. }
  247. if (index > 1) {
  248. if (
  249. this.requestRecord.every((item) =>
  250. ["success", "error"].includes(item)
  251. )
  252. ) {
  253. this.$set(this.requestRecord, index, "start");
  254. this.$set(this.requestResult, index, "start");
  255. } else {
  256. this.$set(this.requestRecord, index, "start");
  257. }
  258. }
  259. },
  260. onSubmit() {
  261. console.log("submit!");
  262. },
  263. // 合并后的函数,处理数据请求
  264. async fetchData() {
  265. try {
  266. console.log(
  267. this.initBatchCode,
  268. this.analysisTypeCode,
  269. "请求详情 分钟级"
  270. );
  271. // 获取分析详情
  272. await this.getAnalysisDetail();
  273. // 获取风机列表
  274. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  275. } catch (err) {
  276. console.error("Failed to fetch data:", err);
  277. }
  278. },
  279. // 获取分析详情接口
  280. async getAnalysisDetail() {
  281. try {
  282. const result = await analysisDetail({
  283. batchCode: this.initBatchCode,
  284. analysisTypeCode: this.analysisTypeCode,
  285. fieldEngineCodes:
  286. this.fieldEngineCodes.length === 0
  287. ? undefined
  288. : this.fieldEngineCodes.join(","),
  289. });
  290. if (result.data.length > 0) {
  291. this.isShowDescription = true;
  292. }
  293. if (
  294. result.data &&
  295. result.data[0] &&
  296. result.data[0].commentTypeRelations
  297. ) {
  298. this.editableTabs = result.data[0].commentTypeRelations;
  299. }
  300. //当前评论展示获取
  301. if (
  302. result.data &&
  303. result.data[0] &&
  304. result.data[0].commentDescriptionVos
  305. ) {
  306. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  307. }
  308. this.generalFilesDatas =
  309. (result.data &&
  310. result.data[0] &&
  311. result.data[0].generalFiles &&
  312. result.data[0].generalFiles.filter((item) =>
  313. item.fileAddr.endsWith(".json")
  314. )) ||
  315. []; //总图数据
  316. console.log(this.generalFilesDatas, "总图数据");
  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 =
  322. diagramRelationsDatas.filter(
  323. (item) =>
  324. this.getFileTypeFromUrl(item.fileAddr) === "speed_torque"
  325. ) || [];
  326. this.diagramRelationsDatas3D =
  327. diagramRelationsDatas.filter(
  328. (item) => this.getFileTypeFromUrl(item.fileAddr) === "3D"
  329. ) || [];
  330. }
  331. this.diagramRelationsDatas =
  332. (result.data &&
  333. result.data[0] &&
  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_torque")) {
  347. return "speed_torque"; // 如果 URL 中包含 "speed_torque" 字符串,判断为 speed_torque 类型
  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>