index.vue 13 KB

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