index.vue 13 KB

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