index.vue 12 KB

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