index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:09:41
  4. * @LastEditTime: 2025-07-10 14:57:20
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/pitch_power/index.vue
  8. -->
  9. <template>
  10. <div class="type-variable">
  11. <!-- 变桨和有功功率协调性分析--只有分图不存在总图 -->
  12. <div class="left">
  13. <FilterChart
  14. :setUpimg="['桨距角', '有功功率']"
  15. :windList="windEngineGroupList"
  16. @getEnfineList="getEnfineList"
  17. @handlePrevious="handlePrevious"
  18. @handleNext="handleNext"
  19. ></FilterChart>
  20. <el-alert type="info" :closable="false">
  21. <template v-slot:title>
  22. <div style="display: flex; align-items: center">
  23. <i
  24. class="el-icon-info"
  25. style="font-size: 20px; margin-right: 5px"
  26. ></i>
  27. <h3>分析说明:</h3>
  28. </div>
  29. </template>
  30. <div style="font-size: 12px; margin-top: 10px">
  31. 在风力发电机组中,变桨-功率散点图展示了风机叶片的桨距角(即叶片与风向的角度)与风机产生的功率之间的关系。这种散点图能够揭示在不同风速和操作条件下,叶片角度调整是如何影响风机的功率输出的。
  32. </div>
  33. </el-alert>
  34. <div></div>
  35. <div class="titleCharts">
  36. 分析分图 :
  37. <el-button size="small" type="primary" @click="handleChartsType">{{
  38. chartsType === "2D" ? "查看3D图" : "查看2D图"
  39. }}</el-button>
  40. </div>
  41. <VirtualList
  42. :list="filteredDiagramList"
  43. keyField="fileAddr"
  44. :itemSize="700"
  45. v-slot="{ item, index }"
  46. >
  47. <powerMarkers2DCharts
  48. :setUpImgData="setUpImgData"
  49. v-if="getFileTypeFromUrl(item.fileAddr) === 'pitch_power'"
  50. :index="index + 'powerMarkers2DCharts'"
  51. :key="item.fieldEngineCode + 'powerMarkers2DCharts'"
  52. :ref="item.fieldEngineCode"
  53. :fileAddr="item.fileAddr"
  54. ></powerMarkers2DCharts>
  55. <Time3DChart
  56. :setUpImgData="setUpImgData"
  57. v-if="getFileTypeFromUrl(item.fileAddr) === '3D'"
  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. 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 powerMarkers2DCharts from "@/views/performance/components/chartsCom/powerMarkers2DCharts.vue";
  115. import TinymceEditor from "@/components/Tinymce.vue";
  116. import Time3DChart from "@/views/performance/components/chartsCom/Time3DChart.vue";
  117. import {
  118. analysisDetail,
  119. queryAnalysisedEngine,
  120. analysisCommentEdit,
  121. } from "@/api/performance";
  122. export default {
  123. name: "pitchPower",
  124. components: {
  125. DicCard,
  126. FilterChart,
  127. powerMarkers2DCharts,
  128. Time3DChart,
  129. TinymceEditor,
  130. },
  131. props: {
  132. initBatchCode: {
  133. default: "",
  134. type: String,
  135. },
  136. isShowTinymceEditorCom: {
  137. default: true,
  138. type: Boolean,
  139. },
  140. isShow: {
  141. default: false,
  142. type: Boolean,
  143. },
  144. analysisTypeCode: {
  145. default: "",
  146. type: String,
  147. },
  148. batchCodeList: {
  149. default: "",
  150. type: Array,
  151. },
  152. },
  153. data() {
  154. return {
  155. chartsType: "2D",
  156. form: {
  157. value2: "",
  158. },
  159. setUpImgData: [],
  160. windEngineGroupList: [], //批次风机列表
  161. fieldEngineCodes: [], //选中风机
  162. comment: "",
  163. options: [],
  164. generalFilesDatas: [], //总图
  165. diagramRelationsDatas: [], //分图,
  166. commentDescriptionVos: [], //评论列表
  167. editableTabs: [],
  168. isShowDescription: false,
  169. };
  170. },
  171. watch: {
  172. initBatchCode(newVal) {
  173. if (newVal) {
  174. this.fetchData(); // 调用合并后的函数
  175. }
  176. },
  177. analysisTypeCode(newVal) {
  178. if (newVal) {
  179. this.fetchData(); // 调用合并后的函数
  180. }
  181. },
  182. isShow() {
  183. if (this.isShow) {
  184. if (!this.isShowDescription) {
  185. this.$message({
  186. message: "当前分析模型暂无分析,不能进行评论操作",
  187. type: "warning",
  188. });
  189. this.$emit("setIsShow");
  190. }
  191. }
  192. },
  193. },
  194. mounted() {
  195. if (this.initBatchCode && this.analysisTypeCode) {
  196. this.fetchData(); // 调用合并后的函数
  197. }
  198. },
  199. computed: {
  200. filteredDiagramList() {
  201. return this.diagramRelationsDatas.filter((item) => {
  202. const type = this.getFileTypeFromUrl(item.fileAddr);
  203. return this.chartsType === "2D"
  204. ? type === "pitch_power"
  205. : type === "3D";
  206. });
  207. },
  208. },
  209. methods: {
  210. handleChartsType() {
  211. this.chartsType = this.chartsType === "2D" ? "3D" : "2D";
  212. },
  213. getFileTypeFromUrl(url) {
  214. // 判断文件名或路径是否包含关键字
  215. if (url.includes("3D")) {
  216. return "3D"; // 如果 URL 中包含 "3D" 字符串,判断为 3D 类型
  217. } else if (url.includes("pitch_power")) {
  218. return "pitch_power"; // 如果 URL 中包含 "pitch_power" 字符串,判断为 pitch_power 类型
  219. } else {
  220. return "Unknown"; // 如果都不包含,返回 Unknown 或其他提示
  221. }
  222. },
  223. handleClose() {
  224. //关闭评论弹框
  225. this.$emit("setIsShow");
  226. },
  227. async handleComment() {
  228. try {
  229. await analysisCommentEdit({
  230. batchCode: this.initBatchCode,
  231. analysisTypeCode: this.analysisTypeCode,
  232. commentList: this.editableTabs.map((item) => {
  233. return {
  234. commentTypeCode: item.commentTypeCode,
  235. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  236. };
  237. }),
  238. });
  239. this.$message({
  240. type: "success",
  241. message: "保存成功",
  242. });
  243. this.comment = "";
  244. this.getAnalysisDetail();
  245. this.$emit("setIsShow");
  246. } catch (e) {
  247. console.error(e);
  248. this.loading = false;
  249. }
  250. },
  251. onSubmit() {
  252. console.log("submit!");
  253. },
  254. // 合并后的函数,处理数据请求
  255. async fetchData() {
  256. try {
  257. // 获取分析详情
  258. await this.getAnalysisDetail();
  259. // 获取风机列表
  260. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  261. } catch (err) {
  262. console.error("Failed to fetch data:", err);
  263. }
  264. },
  265. // 获取分析详情接口
  266. async getAnalysisDetail() {
  267. try {
  268. const result = await analysisDetail({
  269. batchCode: this.initBatchCode,
  270. analysisTypeCode: this.analysisTypeCode,
  271. fieldEngineCodes:
  272. this.fieldEngineCodes.length === 0
  273. ? undefined
  274. : this.fieldEngineCodes.join(","),
  275. });
  276. if (result.data.length > 0) {
  277. this.isShowDescription = true;
  278. }
  279. if (
  280. result.data &&
  281. result.data[0] &&
  282. result.data[0].commentTypeRelations
  283. ) {
  284. this.editableTabs = result.data[0].commentTypeRelations;
  285. }
  286. //当前评论展示获取
  287. if (
  288. result.data &&
  289. result.data[0] &&
  290. result.data[0].commentDescriptionVos
  291. ) {
  292. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  293. }
  294. this.generalFilesDatas =
  295. (result.data &&
  296. result.data[0] &&
  297. result.data[0].generalFiles &&
  298. result.data[0].generalFiles.filter((item) =>
  299. item.fileAddr.endsWith(".json")
  300. )) ||
  301. []; //总图数据
  302. this.diagramRelationsDatas =
  303. (result.data &&
  304. result.data[0] &&
  305. result.data[0].diagramRelations &&
  306. result.data[0].diagramRelations.filter((item) =>
  307. item.fileAddr.endsWith(".json")
  308. )) ||
  309. [];
  310. } catch (err) {
  311. console.error("Failed to fetch analysis details:", err);
  312. }
  313. },
  314. // 请求风机列表
  315. async getWindEnfineList(batchCode, analysisTypeCode) {
  316. // console.log("请求风机列表 分钟级");
  317. const resEngineList = await queryAnalysisedEngine({
  318. batchCode: batchCode,
  319. analysisTypeCode,
  320. });
  321. this.windEngineGroupList = resEngineList.data;
  322. },
  323. handleEditorInput(index, newVal) {
  324. // 更新对应的 comment 值
  325. // 如果该功能没有实现,可以删除这个方法
  326. },
  327. //获取选中风机list
  328. getEnfineList(data, setUpImg) {
  329. this.fieldEngineCodes = data;
  330. this.setUpImgData = [...setUpImg];
  331. this.getAnalysisDetail();
  332. },
  333. //下一条
  334. handleNext() {
  335. const index = this.batchCodeList.findIndex(
  336. (item) => item === this.initBatchCode
  337. );
  338. if (index === this.batchCodeList.length - 1) {
  339. this.$message.warning("已经是最后一个分析结果了");
  340. return;
  341. }
  342. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  343. },
  344. //上一条
  345. handlePrevious() {
  346. const index = this.batchCodeList.findIndex(
  347. (item) => item === this.initBatchCode
  348. );
  349. if (index === 0) {
  350. this.$message.warning("没有上一条了");
  351. return;
  352. }
  353. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  354. },
  355. onClick() {},
  356. },
  357. };
  358. </script>
  359. <style scoped lang="scss">
  360. .type-variable {
  361. display: flex;
  362. height: 90%;
  363. overflow: hidden;
  364. .left {
  365. width: 30%;
  366. height: 100%;
  367. overflow: auto;
  368. padding: 20px;
  369. flex: 1;
  370. }
  371. .right {
  372. width: 0px;
  373. height: 100%;
  374. overflow: hidden;
  375. }
  376. }
  377. .el-dialog__wrapper {
  378. position: relative !important;
  379. }
  380. ::v-deep .el-dialog {
  381. position: fixed !important;
  382. z-index: 999 !important;
  383. top: 50%;
  384. left: 50%;
  385. transform: translate(0, -50%);
  386. }
  387. .titleCharts {
  388. font-size: 16px;
  389. font-weight: 500;
  390. margin-top: 20px;
  391. margin-bottom: 20px;
  392. }
  393. </style>